mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-12 07:40:48 -08:00
feat(template) Add misconfigurations to gitlab codequality report (#1756)
This commit is contained in:
@@ -13,8 +13,8 @@
|
||||
"type": "issue",
|
||||
"check_name": "container_scanning",
|
||||
"categories": [ "Security" ],
|
||||
"description": {{ list .VulnerabilityID .Title | join ": " | printf "%q" }},
|
||||
"fingerprint": "{{ .VulnerabilityID | sha1sum }}",
|
||||
"description": {{ list .VulnerabilityID .PkgName .InstalledVersion .Title | join " - " | printf "%q" }},
|
||||
"fingerprint": "{{ list .VulnerabilityID .PkgName .InstalledVersion $target | join "" | sha1sum }}",
|
||||
"content": {{ .Description | printf "%q" }},
|
||||
"severity": {{ if eq .Severity "LOW" -}}
|
||||
"info"
|
||||
@@ -28,9 +28,41 @@
|
||||
"info"
|
||||
{{- end }},
|
||||
"location": {
|
||||
"path": "{{ .PkgName }}-{{ .InstalledVersion }}",
|
||||
"path": "{{ $target }}",
|
||||
"lines": {
|
||||
"begin": 1
|
||||
"begin": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
{{- end -}}
|
||||
{{- range .Misconfigurations -}}
|
||||
{{- if $t_first -}}
|
||||
{{- $t_first = false -}}
|
||||
{{ else -}}
|
||||
,
|
||||
{{- end }}
|
||||
{
|
||||
"type": "issue",
|
||||
"check_name": "container_scanning",
|
||||
"categories": [ "Security" ],
|
||||
"description": {{ list .ID .Title | join ": " | printf "%q" }},
|
||||
"fingerprint": "{{ list .ID .Title $target | join "" | sha1sum }}",
|
||||
"content": {{ .Description | printf "%q" }},
|
||||
"severity": {{ if eq .Severity "LOW" -}}
|
||||
"info"
|
||||
{{- else if eq .Severity "MEDIUM" -}}
|
||||
"minor"
|
||||
{{- else if eq .Severity "HIGH" -}}
|
||||
"major"
|
||||
{{- else if eq .Severity "CRITICAL" -}}
|
||||
"critical"
|
||||
{{- else -}}
|
||||
"info"
|
||||
{{- end }},
|
||||
"location": {
|
||||
"path": "{{ $target }}",
|
||||
"lines": {
|
||||
"begin": {{ .IacMetadata.StartLine }}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,8 +140,13 @@ trivy:
|
||||
script:
|
||||
# Build image
|
||||
- docker build -t $IMAGE .
|
||||
# Build report
|
||||
- ./trivy image --exit-code 0 --format template --template "@contrib/gitlab-codequality.tpl" -o gl-codeclimate.json $IMAGE
|
||||
# Image report
|
||||
- ./trivy image --exit-code 0 --format template --template "@contrib/gitlab-codequality.tpl" -o gl-codeclimate-image.json $IMAGE
|
||||
# Filesystem report
|
||||
- ./trivy filesystem --security-checks config,vuln --exit-code 0 --format template --template "@contrib/gitlab-codequality.tpl" -o gl-codeclimate-fs.json .
|
||||
# Combine report
|
||||
- apk update && apk add jq
|
||||
- jq -s 'add' gl-codeclimate-image.json gl-codeclimate-fs.json > gl-codeclimate.json
|
||||
cache:
|
||||
paths:
|
||||
- .trivycache/
|
||||
@@ -161,3 +166,11 @@ already have a code quality report in your pipeline, you can use
|
||||
be necessary to rename the artifact if you want to reuse the name. To then
|
||||
combine the previous artifact with the output of trivy, the following `jq`
|
||||
command can be used, `jq -s 'add' prev-codeclimate.json trivy-codeclimate.json > gl-codeclimate.json`.
|
||||
|
||||
### Gitlab CI alternative template example report
|
||||
|
||||
You'll be able to see a full report in the Gitlab pipeline code quality UI, where filesystem vulnerabilities and misconfigurations include links to the flagged files and image vulnerabilities report the image/os or runtime/library that the vulnerability originates from instead.
|
||||
|
||||
<p align="left">
|
||||
<img src="../../../imgs/gitlab-codequality.png" width="900">
|
||||
</p>
|
||||
|
||||
BIN
docs/imgs/gitlab-codequality.png
Normal file
BIN
docs/imgs/gitlab-codequality.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 87 KiB |
@@ -3,14 +3,14 @@
|
||||
"type": "issue",
|
||||
"check_name": "container_scanning",
|
||||
"categories": [ "Security" ],
|
||||
"description": "CVE-2019-1549: openssl: information disclosure in fork()",
|
||||
"fingerprint": "4fd5aebc601a7127e0a012b91569675cd8566e15",
|
||||
"description": "CVE-2019-1549 - libcrypto1.1 - 1.1.1c-r0 - openssl: information disclosure in fork()",
|
||||
"fingerprint": "aeda1fbbe0e7f685887445359f8078c98eafd6de",
|
||||
"content": "OpenSSL 1.1.1 introduced a rewritten random number generator (RNG). This was intended to include protection in the event of a fork() system call in order to ensure that the parent and child processes did not share the same RNG state. However this protection was not being used in the default case. A partial mitigation for this issue is that the output from a high precision timer is mixed into the RNG state so the likelihood of a parent and child process sharing state is significantly reduced. If an application already calls OPENSSL_init_crypto() explicitly using OPENSSL_INIT_ATFORK then this problem does not occur at all. Fixed in OpenSSL 1.1.1d (Affected 1.1.1-1.1.1c).",
|
||||
"severity": "minor",
|
||||
"location": {
|
||||
"path": "libcrypto1.1-1.1.1c-r0",
|
||||
"path": "testdata/fixtures/images/alpine-310.tar.gz (alpine 3.10.2)",
|
||||
"lines": {
|
||||
"begin": 1
|
||||
"begin": 0
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -18,14 +18,14 @@
|
||||
"type": "issue",
|
||||
"check_name": "container_scanning",
|
||||
"categories": [ "Security" ],
|
||||
"description": "CVE-2019-1551: openssl: Integer overflow in RSAZ modular exponentiation on x86_64",
|
||||
"fingerprint": "7a6f161c388588da3cca874c3aba98a296a1ebf4",
|
||||
"description": "CVE-2019-1551 - libcrypto1.1 - 1.1.1c-r0 - openssl: Integer overflow in RSAZ modular exponentiation on x86_64",
|
||||
"fingerprint": "473af5b2ba6b728fa3f356551c4b07a3b64d4f2a",
|
||||
"content": "There is an overflow bug in the x64_64 Montgomery squaring procedure used in exponentiation with 512-bit moduli. No EC algorithms are affected. Analysis suggests that attacks against 2-prime RSA1024, 3-prime RSA1536, and DSA1024 as a result of this defect would be very difficult to perform and are not believed likely. Attacks against DH512 are considered just feasible. However, for an attack the target would have to re-use the DH512 private key, which is not recommended anyway. Also applications directly using the low level API BN_mod_exp may be affected if they use BN_FLG_CONSTTIME. Fixed in OpenSSL 1.1.1e (Affected 1.1.1-1.1.1d). Fixed in OpenSSL 1.0.2u (Affected 1.0.2-1.0.2t).",
|
||||
"severity": "minor",
|
||||
"location": {
|
||||
"path": "libcrypto1.1-1.1.1c-r0",
|
||||
"path": "testdata/fixtures/images/alpine-310.tar.gz (alpine 3.10.2)",
|
||||
"lines": {
|
||||
"begin": 1
|
||||
"begin": 0
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -33,14 +33,14 @@
|
||||
"type": "issue",
|
||||
"check_name": "container_scanning",
|
||||
"categories": [ "Security" ],
|
||||
"description": "CVE-2019-1549: openssl: information disclosure in fork()",
|
||||
"fingerprint": "4fd5aebc601a7127e0a012b91569675cd8566e15",
|
||||
"description": "CVE-2019-1549 - libssl1.1 - 1.1.1c-r0 - openssl: information disclosure in fork()",
|
||||
"fingerprint": "45d39f7ecf688270aeab0da7fcad5c0cf5a57886",
|
||||
"content": "OpenSSL 1.1.1 introduced a rewritten random number generator (RNG). This was intended to include protection in the event of a fork() system call in order to ensure that the parent and child processes did not share the same RNG state. However this protection was not being used in the default case. A partial mitigation for this issue is that the output from a high precision timer is mixed into the RNG state so the likelihood of a parent and child process sharing state is significantly reduced. If an application already calls OPENSSL_init_crypto() explicitly using OPENSSL_INIT_ATFORK then this problem does not occur at all. Fixed in OpenSSL 1.1.1d (Affected 1.1.1-1.1.1c).",
|
||||
"severity": "minor",
|
||||
"location": {
|
||||
"path": "libssl1.1-1.1.1c-r0",
|
||||
"path": "testdata/fixtures/images/alpine-310.tar.gz (alpine 3.10.2)",
|
||||
"lines": {
|
||||
"begin": 1
|
||||
"begin": 0
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -48,14 +48,14 @@
|
||||
"type": "issue",
|
||||
"check_name": "container_scanning",
|
||||
"categories": [ "Security" ],
|
||||
"description": "CVE-2019-1551: openssl: Integer overflow in RSAZ modular exponentiation on x86_64",
|
||||
"fingerprint": "7a6f161c388588da3cca874c3aba98a296a1ebf4",
|
||||
"description": "CVE-2019-1551 - libssl1.1 - 1.1.1c-r0 - openssl: Integer overflow in RSAZ modular exponentiation on x86_64",
|
||||
"fingerprint": "28d484eb3b3439c4991f14b3b1b26cc339eee128",
|
||||
"content": "There is an overflow bug in the x64_64 Montgomery squaring procedure used in exponentiation with 512-bit moduli. No EC algorithms are affected. Analysis suggests that attacks against 2-prime RSA1024, 3-prime RSA1536, and DSA1024 as a result of this defect would be very difficult to perform and are not believed likely. Attacks against DH512 are considered just feasible. However, for an attack the target would have to re-use the DH512 private key, which is not recommended anyway. Also applications directly using the low level API BN_mod_exp may be affected if they use BN_FLG_CONSTTIME. Fixed in OpenSSL 1.1.1e (Affected 1.1.1-1.1.1d). Fixed in OpenSSL 1.0.2u (Affected 1.0.2-1.0.2t).",
|
||||
"severity": "minor",
|
||||
"location": {
|
||||
"path": "libssl1.1-1.1.1c-r0",
|
||||
"path": "testdata/fixtures/images/alpine-310.tar.gz (alpine 3.10.2)",
|
||||
"lines": {
|
||||
"begin": 1
|
||||
"begin": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user