@@ -10,7 +10,6 @@ import (
1010 "slices"
1111 "strings"
1212
13- "github.com/aquasecurity/trivy/pkg/iac/scanners/terraformplan/tfjson/parser"
1413 "github.com/aquasecurity/trivy/pkg/iac/terraform"
1514 tfcontext "github.com/aquasecurity/trivy/pkg/iac/terraform/context"
1615 tfjson "github.com/hashicorp/terraform-json"
@@ -20,7 +19,7 @@ import (
2019 "github.com/coder/preview/hclext"
2120)
2221
23- func PlanJSONHook (dfs fs.FS , input Input ) (func (ctx * tfcontext.Context , blocks terraform.Blocks , inputVars map [string ]cty.Value ), error ) {
22+ func planJSONHook (dfs fs.FS , input Input ) (func (ctx * tfcontext.Context , blocks terraform.Blocks , inputVars map [string ]cty.Value ), error ) {
2423 var contents io.Reader = bytes .NewReader (input .PlanJSON )
2524 // Also accept `{}` as an empty plan. If this is stored in postgres or another json
2625 // type, then `{}` is the "empty" value.
@@ -36,7 +35,7 @@ func PlanJSONHook(dfs fs.FS, input Input) (func(ctx *tfcontext.Context, blocks t
3635 }
3736 }
3837
39- plan , err := ParsePlanJSON (contents )
38+ plan , err := parsePlanJSON (contents )
4039 if err != nil {
4140 return nil , fmt .Errorf ("unable to parse plan JSON: %w" , err )
4241 }
@@ -216,28 +215,15 @@ func toCtyValue(a any) (cty.Value, error) {
216215 }
217216}
218217
219- // ParsePlanJSON can parse the JSON output of a Terraform plan.
218+ // parsePlanJSON can parse the JSON output of a Terraform plan.
220219// terraform plan out.plan
221220// terraform show -json out.plan
222- func ParsePlanJSON (reader io.Reader ) (* tfjson.Plan , error ) {
221+ func parsePlanJSON (reader io.Reader ) (* tfjson.Plan , error ) {
223222 plan := new (tfjson.Plan )
224223 plan .FormatVersion = tfjson .PlanFormatVersionConstraints
225224 return plan , json .NewDecoder (reader ).Decode (plan )
226225}
227226
228- // ParsePlanJSON can parse the JSON output of a Terraform plan.
229- // terraform plan out.plan
230- // terraform show -json out.plan
231- func TrivyParsePlanJSON (reader io.Reader ) (* tfjson.Plan , error ) {
232- p := parser .New ()
233- plan , err := p .Parse (reader )
234- var _ = plan
235-
236- plan .ToFS ()
237-
238- return nil , err
239- }
240-
241227func keyMatcher (key cty.Value ) func (to any ) bool {
242228 switch {
243229 case key .Type ().Equals (cty .Number ):
0 commit comments