Skip to content

Commit a99498c

Browse files
authored
feat(misconf): render causes for Terraform (#8360)
Signed-off-by: nikpivkin <nikita.pivkin@smartforce.io>
1 parent a994453 commit a99498c

File tree

29 files changed

+782
-259
lines changed

29 files changed

+782
-259
lines changed

docs/docs/references/configuration/cli/trivy_config.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ trivy config [flags] DIR
4545
--redis-key string redis key file location, if using redis as cache backend
4646
--redis-tls enable redis TLS with public certificates, if using redis as cache backend
4747
--registry-token string registry token
48+
--render-cause strings specify configuration types for which the rendered causes will be shown in the table report (terraform)
4849
--report string specify a compliance report format for the output (all,summary) (default "all")
4950
-s, --severity strings severities of security issues to be displayed (UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL) (default [UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL])
5051
--skip-check-update skip fetching rego check updates

docs/docs/references/configuration/cli/trivy_filesystem.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ trivy filesystem [flags] PATH
7878
--redis-tls enable redis TLS with public certificates, if using redis as cache backend
7979
--registry-token string registry token
8080
--rekor-url string [EXPERIMENTAL] address of rekor STL server (default "https://rekor.sigstore.dev")
81+
--render-cause strings specify configuration types for which the rendered causes will be shown in the table report (terraform)
8182
--report string specify a compliance report format for the output (all,summary) (default "all")
8283
--sbom-sources strings [EXPERIMENTAL] try to retrieve SBOM from the specified sources (oci,rekor)
8384
--scanners strings comma-separated list of what security issues to detect (vuln,misconfig,secret,license) (default [vuln,secret])

docs/docs/references/configuration/cli/trivy_image.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ trivy image [flags] IMAGE_NAME
100100
--registry-token string registry token
101101
--rekor-url string [EXPERIMENTAL] address of rekor STL server (default "https://rekor.sigstore.dev")
102102
--removed-pkgs detect vulnerabilities of removed packages (only for Alpine)
103+
--render-cause strings specify configuration types for which the rendered causes will be shown in the table report (terraform)
103104
--report string specify a format for the compliance report. (all,summary) (default "summary")
104105
--sbom-sources strings [EXPERIMENTAL] try to retrieve SBOM from the specified sources (oci,rekor)
105106
--scanners strings comma-separated list of what security issues to detect (vuln,misconfig,secret,license) (default [vuln,secret])

docs/docs/references/configuration/cli/trivy_kubernetes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ trivy kubernetes [flags] [CONTEXT]
9494
--redis-tls enable redis TLS with public certificates, if using redis as cache backend
9595
--registry-token string registry token
9696
--rekor-url string [EXPERIMENTAL] address of rekor STL server (default "https://rekor.sigstore.dev")
97+
--render-cause strings specify configuration types for which the rendered causes will be shown in the table report (terraform)
9798
--report string specify a report format for the output (all,summary) (default "all")
9899
--sbom-sources strings [EXPERIMENTAL] try to retrieve SBOM from the specified sources (oci,rekor)
99100
--scanners strings comma-separated list of what security issues to detect (vuln,misconfig,secret,rbac) (default [vuln,misconfig,secret,rbac])

docs/docs/references/configuration/cli/trivy_repository.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ trivy repository [flags] (REPO_PATH | REPO_URL)
7777
--redis-tls enable redis TLS with public certificates, if using redis as cache backend
7878
--registry-token string registry token
7979
--rekor-url string [EXPERIMENTAL] address of rekor STL server (default "https://rekor.sigstore.dev")
80+
--render-cause strings specify configuration types for which the rendered causes will be shown in the table report (terraform)
8081
--sbom-sources strings [EXPERIMENTAL] try to retrieve SBOM from the specified sources (oci,rekor)
8182
--scanners strings comma-separated list of what security issues to detect (vuln,misconfig,secret,license) (default [vuln,secret])
8283
--secret-config string specify a path to config file for secret scanning (default "trivy-secret.yaml")

docs/docs/references/configuration/cli/trivy_rootfs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ trivy rootfs [flags] ROOTDIR
8080
--redis-tls enable redis TLS with public certificates, if using redis as cache backend
8181
--registry-token string registry token
8282
--rekor-url string [EXPERIMENTAL] address of rekor STL server (default "https://rekor.sigstore.dev")
83+
--render-cause strings specify configuration types for which the rendered causes will be shown in the table report (terraform)
8384
--sbom-sources strings [EXPERIMENTAL] try to retrieve SBOM from the specified sources (oci,rekor)
8485
--scanners strings comma-separated list of what security issues to detect (vuln,misconfig,secret,license) (default [vuln,secret])
8586
--secret-config string specify a path to config file for secret scanning (default "trivy-secret.yaml")

docs/docs/references/configuration/cli/trivy_vm.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ trivy vm [flags] VM_IMAGE
6969
--redis-key string redis key file location, if using redis as cache backend
7070
--redis-tls enable redis TLS with public certificates, if using redis as cache backend
7171
--rekor-url string [EXPERIMENTAL] address of rekor STL server (default "https://rekor.sigstore.dev")
72+
--render-cause strings specify configuration types for which the rendered causes will be shown in the table report (terraform)
7273
--sbom-sources strings [EXPERIMENTAL] try to retrieve SBOM from the specified sources (oci,rekor)
7374
--scanners strings comma-separated list of what security issues to detect (vuln,misconfig,secret,license) (default [vuln,secret])
7475
--secret-config string specify a path to config file for secret scanning (default "trivy-secret.yaml")

docs/docs/references/configuration/config-file.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,9 @@ misconfiguration:
409409
# Same as '--include-non-failures'
410410
include-non-failures: false
411411

412+
# Same as '--render-cause'
413+
render-cause: []
414+
412415
# Same as '--misconfig-scanners'
413416
scanners:
414417
- azure-arm

pkg/compliance/report/testdata/all.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"CauseMetadata": {
2424
"Code": {
2525
"Lines": null
26-
}
26+
},
27+
"RenderedCause": {}
2728
}
2829
}
2930
]
@@ -46,7 +47,8 @@
4647
"CauseMetadata": {
4748
"Code": {
4849
"Lines": null
49-
}
50+
},
51+
"RenderedCause": {}
5052
}
5153
}
5254
]

pkg/fanal/types/misconf.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ type MisconfResult struct {
3030
type MisconfResults []MisconfResult
3131

3232
type CauseMetadata struct {
33-
Resource string `json:",omitempty"`
34-
Provider string `json:",omitempty"`
35-
Service string `json:",omitempty"`
36-
StartLine int `json:",omitempty"`
37-
EndLine int `json:",omitempty"`
38-
Code Code `json:",omitempty"`
39-
Occurrences []Occurrence `json:",omitempty"`
33+
Resource string `json:",omitempty"`
34+
Provider string `json:",omitempty"`
35+
Service string `json:",omitempty"`
36+
StartLine int `json:",omitempty"`
37+
EndLine int `json:",omitempty"`
38+
Code Code `json:",omitempty"`
39+
Occurrences []Occurrence `json:",omitempty"`
40+
RenderedCause RenderedCause `json:",omitempty"`
4041
}
4142

4243
type Occurrence struct {
@@ -45,6 +46,11 @@ type Occurrence struct {
4546
Location Location
4647
}
4748

49+
type RenderedCause struct {
50+
Raw string `json:",omitempty"`
51+
Highlighted string `json:",omitempty"`
52+
}
53+
4854
type Code struct {
4955
Lines []Line
5056
}

0 commit comments

Comments
 (0)