Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(misconf): init frameworks before updating them #7376

Merged
merged 1 commit into from
Aug 23, 2024

Conversation

nikpivkin
Copy link
Contributor

@nikpivkin nikpivkin commented Aug 23, 2024

Description

Fixes:

2024-08-23T04:50:26Z    DEBUG   [misconf] 50:26.747428627 terraform.scanner.rego           Error occurred while parsing: root/.cache/trivy/policy/content/policies/cloud/policies/aws/ec2/no_public_ingress_sgr.rego, root/.cache/trivy/policy/content/policies/cloud/policies/aws/ec2/no_public_ingress_sgr.rego:44: rego_type_error: undefined function cidr.is_public. Trying to fallback to embedded check.
panic: assignment to entry in nil map

goroutine 1 [running]:
github.com/aquasecurity/trivy/pkg/iac/rego.(*StaticMetadata).updateFrameworks(0xc004228500, 0xc0014cb5c0?)
        /Users/nikita/projects/trivy/pkg/iac/rego/metadata.go:138 +0x1f3
github.com/aquasecurity/trivy/pkg/iac/rego.(*StaticMetadata).Update(0xc004228500, 0xc0014cb5c0)
        /Users/nikita/projects/trivy/pkg/iac/rego/metadata.go:107 +0x8ff
github.com/aquasecurity/trivy/pkg/iac/rego.(*StaticMetadata).FromAnnotations(0xc004228500, 0xc0025a7260)
        /Users/nikita/projects/trivy/pkg/iac/rego/metadata.go:166 +0x1b9
github.com/aquasecurity/trivy/pkg/iac/rego.metadataFromRegoModule(0xc003192870)
        /Users/nikita/projects/trivy/pkg/iac/rego/metadata.go:428 +0x6f
github.com/aquasecurity/trivy/pkg/iac/rego.(*Scanner).findMatchedEmbeddedCheck(0xc003102000, 0xc003192870)
        /Users/nikita/projects/trivy/pkg/iac/rego/load.go:198 +0xff
github.com/aquasecurity/trivy/pkg/iac/rego.(*Scanner).fallbackChecks(0xc003102000, 0xc00308cc60)
        /Users/nikita/projects/trivy/pkg/iac/rego/load.go:173 +0x352
github.com/aquasecurity/trivy/pkg/iac/rego.(*Scanner).compilePolicies(0xc003102000, {0x533bc00, 0xc000212510}, {0xc002ff5970, 0x1, 0x1})
        /Users/nikita/projects/trivy/pkg/iac/rego/load.go:248 +0x151
github.com/aquasecurity/trivy/pkg/iac/rego.(*Scanner).LoadPolicies(0xc003102000, 0x0, 0x0, {0x533bc00?, 0xc002e6e2a0?}, {0xc002ff5970, 0x1, 0x1}, {0x0, 0x0, ...})
        /Users/nikita/projects/trivy/pkg/iac/rego/load.go:144 +0x8f6
github.com/aquasecurity/trivy/pkg/iac/scanners/terraform.(*Scanner).initRegoScanner(0xc0035b9900, {0x533bc00, 0xc002e6e2a0})
        /Users/nikita/projects/trivy/pkg/iac/scanners/terraform/scanner.go:138 +0x166
github.com/aquasecurity/trivy/pkg/iac/scanners/terraform.(*Scanner).ScanFS(0xc0035b9900, {0x53796a0, 0xc0010a1e30}, {0x533bc00, 0xc002e6e2a0}, {0x5320a88, 0x1})
        /Users/nikita/projects/trivy/pkg/iac/scanners/terraform/scanner.go:165 +0x190
github.com/aquasecurity/trivy/pkg/misconf.(*Scanner).Scan(0xc0017971d0, {0x53796a0, 0xc0010a1e30}, {0x533bc00?, 0xc002e6e288?})
        /Users/nikita/projects/trivy/pkg/misconf/scanner.go:158 +0x223
github.com/aquasecurity/trivy/pkg/fanal/analyzer/config.(*Analyzer).PostAnalyze(0xc002a2a7e0, {0x53796a0?, 0xc0010a1e30?}, {{0x533bc00?, 0xc002e6e288?}, {0x9?, 0x0?}})
        /Users/nikita/projects/trivy/pkg/fanal/analyzer/config/config.go:45 +0x46
github.com/aquasecurity/trivy/pkg/fanal/analyzer.AnalyzerGroup.PostAnalyze({0xc000d0e7e0, {0xc003690140, 0x3, 0x4}, {0xc0018c2280, 0x8, 0x8}, 0xc0012dee40, {0x0, 0x0}}, ...)
        /Users/nikita/projects/trivy/pkg/fanal/analyzer/analyzer.go:501 +0x2e2
github.com/aquasecurity/trivy/pkg/fanal/artifact/local.Artifact.Inspect({{0x7fffffffff74, 0x9}, {0x7ffeb86dc3b8, 0xc003690100}, {0x533bb40, 0x7abbb00}, {0xc000d0e7e0, {0xc003690140, 0x3, 0x4}, ...}, ...}, ...)
        /Users/nikita/projects/trivy/pkg/fanal/artifact/local/fs.go:120 +0x429
github.com/aquasecurity/trivy/pkg/scanner.Scanner.ScanArtifact({{_, _}, {_, _}}, {_, _}, {{0x0, 0x0, 0x0}, {0x0, ...}, ...})
        /Users/nikita/projects/trivy/pkg/scanner/scan.go:156 +0x103
github.com/aquasecurity/trivy/pkg/commands/artifact.(*runner).scan(_, {_, _}, {{{0x44a4d8a, 0xa}, 0x0, 0x0, 0x1, 0x0, 0x45d964b800, ...}, ...}, ...)
        /Users/nikita/projects/trivy/pkg/commands/artifact/run.go:647 +0x2cb
github.com/aquasecurity/trivy/pkg/commands/artifact.(*runner).scanArtifact(_, {_, _}, {{{0x44a4d8a, 0xa}, 0x0, 0x0, 0x1, 0x0, 0x45d964b800, ...}, ...}, ...)
        /Users/nikita/projects/trivy/pkg/commands/artifact/run.go:258 +0xa5
github.com/aquasecurity/trivy/pkg/commands/artifact.(*runner).scanFS(_, {_, _}, {{{0x44a4d8a, 0xa}, 0x0, 0x0, 0x1, 0x0, 0x45d964b800, ...}, ...})
        /Users/nikita/projects/trivy/pkg/commands/artifact/run.go:203 +0xb4
github.com/aquasecurity/trivy/pkg/commands/artifact.(*runner).ScanFilesystem(_, {_, _}, {{{0x44a4d8a, 0xa}, 0x0, 0x0, 0x1, 0x0, 0x45d964b800, ...}, ...})
        /Users/nikita/projects/trivy/pkg/commands/artifact/run.go:183 +0x205
github.com/aquasecurity/trivy/pkg/commands/artifact.Run({_, _}, {{{0x44a4d8a, 0xa}, 0x0, 0x0, 0x1, 0x0, 0x45d964b800, {0xc0027f1b60, ...}, ...}, ...}, ...)
        /Users/nikita/projects/trivy/pkg/commands/artifact/run.go:384 +0x87d
github.com/aquasecurity/trivy/pkg/commands.NewConfigCommand.func2(0xc000295508, {0xc00328f470, 0x1, 0x3})
        /Users/nikita/projects/trivy/pkg/commands/app.go:717 +0x2a5
github.com/spf13/cobra.(*Command).execute(0xc000295508, {0xc00328f410, 0x3, 0x3})
        /Users/nikita/go/pkg/mod/github.com/spf13/[email protected]/command.go:985 +0xaaa
github.com/spf13/cobra.(*Command).ExecuteC(0xc0009ef508)
        /Users/nikita/go/pkg/mod/github.com/spf13/[email protected]/command.go:1117 +0x3ff
github.com/spf13/cobra.(*Command).Execute(0x44f9552?)
        /Users/nikita/go/pkg/mod/github.com/spf13/[email protected]/command.go:1041 +0x13
main.run()
        /Users/nikita/projects/trivy/cmd/trivy/main.go:39 +0x113
main.main()
        /Users/nikita/projects/trivy/cmd/trivy/main.go:19 +0x1f

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

@simar7 simar7 added this pull request to the merge queue Aug 23, 2024
Merged via the queue into aquasecurity:main with commit b65b32d Aug 23, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants