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

feat(misconf): Show misconfig ID in output #7762

Merged
merged 3 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pkg/report/table/misconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,18 @@ func (r *misconfigRenderer) renderSummary(misconf types.DetectedMisconfiguration
}
}

// severity
// ID & severity
switch misconf.Severity {
case severityCritical:
r.printf("<red><bold>%s: ", misconf.Severity)
r.printf("%s <red><bold>(%s): ", misconf.ID, misconf.Severity)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to use the AVDID field instead of ID because ID can contain aliases https://github.com/aquasecurity/trivy/blob/main/pkg/misconf/scanner.go#L452-L454

s3-bucket-logging (LOW): Bucket has logging disabled
══════════════════════════════════════════════════════════════════════════════════════════════════════════════════
Ensures S3 bucket logging is enabled for S3 buckets

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! good catch, updated.

case severityHigh:
r.printf("<red>%s: ", misconf.Severity)
r.printf("%s <red>(%s): ", misconf.ID, misconf.Severity)
case severityMedium:
r.printf("<yellow>%s: ", misconf.Severity)
r.printf("%s <yellow>(%s): ", misconf.ID, misconf.Severity)
case severityLow:
r.printf("%s: ", misconf.Severity)
r.printf("%s (%s): ", misconf.ID, misconf.Severity)
default:
r.printf("<blue>%s: ", misconf.Severity)
r.printf("%s <blue>(%s): ", misconf.ID, misconf.Severity)
}

// heading
Expand Down
10 changes: 5 additions & 5 deletions pkg/report/table/misconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ my-file ()
Tests: 1 (SUCCESSES: 0, FAILURES: 1, EXCEPTIONS: 0)
Failures: 1 (LOW: 0, MEDIUM: 0, HIGH: 1, CRITICAL: 0)

HIGH: Oh no, a bad config.
AVD-XYZ-0123 (HIGH): Oh no, a bad config.
════════════════════════════════════════
Your config file is not good.

Expand Down Expand Up @@ -103,7 +103,7 @@ my-file ()
Tests: 1 (SUCCESSES: 0, FAILURES: 1, EXCEPTIONS: 0)
Failures: 1 (LOW: 0, MEDIUM: 0, HIGH: 1, CRITICAL: 0)

HIGH: Oh no, a bad config.
AVD-XYZ-0123 (HIGH): Oh no, a bad config.
════════════════════════════════════════
Your config file is not good.

Expand Down Expand Up @@ -174,7 +174,7 @@ my-file ()
Tests: 2 (SUCCESSES: 1, FAILURES: 1, EXCEPTIONS: 0)
Failures: 1 (LOW: 0, MEDIUM: 0, HIGH: 1, CRITICAL: 0)

FAIL: HIGH: Oh no, a bad config.
FAIL: AVD-XYZ-0123 (HIGH): Oh no, a bad config.
════════════════════════════════════════
Your config file is not good.

Expand All @@ -188,7 +188,7 @@ See https://google.com/search?q=bad%20config
────────────────────────────────────────


PASS: MEDIUM: Oh no, a bad config AGAIN.
PASS: AVD-XYZ-0456 (MEDIUM): Oh no, a bad config AGAIN.
════════════════════════════════════════
Your config file is still not good.

Expand Down Expand Up @@ -312,7 +312,7 @@ terraform-aws-modules/security-group/aws/main.tf (terraform)
Tests: 6 (SUCCESSES: 5, FAILURES: 1, EXCEPTIONS: 0)
Failures: 1 (LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 1)

CRITICAL: Security group rule allows ingress from public internet.
AVD-AWS-0107 (CRITICAL): Security group rule allows ingress from public internet.
════════════════════════════════════════
Opening up ports to the public internet is generally to be avoided. You should restrict access to IP addresses or ranges that explicitly require it where possible.

Expand Down