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): Improve filtering of terraform JSON #7393

Closed
1 of 2 tasks
simar7 opened this issue Aug 26, 2024 Discussed in #7363 · 0 comments · Fixed by #7406
Closed
1 of 2 tasks

fix(misconf): Improve filtering of terraform JSON #7393

simar7 opened this issue Aug 26, 2024 Discussed in #7363 · 0 comments · Fixed by #7406
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. scan/misconfiguration Issues relating to misconfiguration scanning
Milestone

Comments

@simar7
Copy link
Member

simar7 commented Aug 26, 2024

Currently we detect by content but later on filter by name. We shouldn't double filter if the content is already valid.

Discussed in #7363

Originally posted by Molaire August 20, 2024

Description

Hello I planned a dummy terraform project using our boilerplate, turned it in a json and trivy does not seem to be able to scan it. I have no problem with Regula and Checkov.

I'm wondering what part of the plan is tripping up Trivy.

It shows no successful check using --include-non-failures, so it seems it's simply not able to scan it.

(venv) ➜  uswest1-devc git:(main) ✗ trivy clean -a
2024-08-20T09:31:17-07:00	INFO	Removing all caches...
(venv) ➜  uswest1-devc git:(main) ✗ trivy conf ./tf_plan.json  --include-non-failures -v
2024-08-20T09:31:20-07:00	INFO	Misconfiguration scanning is enabled
2024-08-20T09:31:20-07:00	INFO	Need to update the built-in policies
2024-08-20T09:31:20-07:00	INFO	Downloading the built-in policies...
74.86 KiB / 74.86 KiB [---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 100.00% ? p/s 0s
2024-08-20T09:31:20-07:00	INFO	Detected config files	num=0

pastebin of json plan: https://pastebin.com/zjb0xgti

Desired Behavior

It should trigger the IMDSv2 check

Actual Behavior

It scans no resource at all

Reproduction Steps

1. Use shared plan
2. Run `trivy conf ./tf_plan.json  --include-non-failures -v`
3. Be sad
...

Target

None

Scanner

None

Output Format

None

Mode

None

Debug Output

(venv) ➜  uswest1-devc git:(main) ✗ trivy conf ./tf_plan.json  --include-non-failures -d
2024-08-20T09:37:24-07:00	DEBUG	Cache dir	dir="/nail/home/vit/.cache/trivy"
2024-08-20T09:37:24-07:00	DEBUG	Parsed severities	severities=[UNKNOWN LOW MEDIUM HIGH CRITICAL]
2024-08-20T09:37:24-07:00	INFO	[misconfig] Misconfiguration scanning is enabled
2024-08-20T09:37:24-07:00	DEBUG	[misconfig] Policies successfully loaded from disk
2024-08-20T09:37:24-07:00	DEBUG	Enabling misconfiguration scanners	scanners=[azure-arm cloudformation dockerfile helm kubernetes terraform terraformplan-json terraformplan-snapshot]
2024-08-20T09:37:24-07:00	DEBUG	Initializing scan cache...	type="memory"
2024-08-20T09:37:24-07:00	DEBUG	Scanning files for misconfigurations...	scanner="Terraform Plan JSON"
2024-08-20T09:37:24-07:00	DEBUG	OS is not detected.
2024-08-20T09:37:24-07:00	INFO	Detected config files	num=0
2024-08-20T09:37:24-07:00	DEBUG	[vex] VEX filtering is disabled

Operating System

Ubuntu Jammy

Version

Version: 0.54.1
Check Bundle:
  Digest: sha256:ef2d9ad4fce0f933b20a662004d7e55bf200987c180e7f2cd531af631f408bb3
  DownloadedAt: 2024-08-20 16:31:20.785372254 +0000 UTC

Checklist

@simar7 simar7 added kind/bug Categorizes issue or PR as related to a bug. scan/misconfiguration Issues relating to misconfiguration scanning labels Aug 26, 2024
@simar7 simar7 added this to the v0.55.0 milestone Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. scan/misconfiguration Issues relating to misconfiguration scanning
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants