Skip to content

Commit a3cd693

Browse files
authored
fix(image): disable AVD-DS-0007 for history scanning (#8366)
Signed-off-by: nikpivkin <[email protected]>
1 parent a1c4bd7 commit a3cd693

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

docs/docs/target/container_image.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,15 @@ See https://avd.aquasec.com/misconfig/ds026
154154
!!! tip
155155
You can see how each layer is created with `docker history`.
156156

157-
The [AVD-DS-0016](https://avd.aquasec.com/misconfig/dockerfile/general/avd-ds-0016/) check is disabled for this scan type, see [issue](https://github.com/aquasecurity/trivy/issues/7368) for details.
157+
#### Disabled checks
158+
159+
The following checks are disabled for this scan type due to known issues. See the linked issues for more details.
160+
161+
| Check ID | Reason | Issue |
162+
|----------|------------|--------|
163+
| [AVD-DS-0007](https://avd.aquasec.com/misconfig/dockerfile/general/avd-ds-0007/) | This check detects multiple `ENTRYPOINT` instructions in a stage, but since image history analysis does not identify stages, this check is not relevant for this scan type. | [#8364](https://github.com/aquasecurity/trivy/issues/8364) |
164+
| [AVD-DS-0016](https://avd.aquasec.com/misconfig/dockerfile/general/avd-ds-0016/) | This check detects multiple `CMD` instructions in a stage, but since image history analysis does not identify stages, this check is not relevant for this scan type. | [#7368](https://github.com/aquasecurity/trivy/issues/7368) |
165+
158166

159167
### Secrets
160168
Trivy detects secrets on the configuration of container images.

pkg/fanal/analyzer/imgconf/dockerfile/dockerfile.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,17 @@ import (
1515
"github.com/aquasecurity/trivy/pkg/iac/detection"
1616
"github.com/aquasecurity/trivy/pkg/mapfs"
1717
"github.com/aquasecurity/trivy/pkg/misconf"
18+
"github.com/aquasecurity/trivy/pkg/version/doc"
1819
)
1920

2021
var disabledChecks = []misconf.DisabledCheck{
22+
{
23+
ID: "DS007", Scanner: string(analyzer.TypeHistoryDockerfile),
24+
Reason: "See " + doc.URL("docs/target/container_image", "disabled-checks"),
25+
},
2126
{
2227
ID: "DS016", Scanner: string(analyzer.TypeHistoryDockerfile),
23-
Reason: "See https://github.com/aquasecurity/trivy/issues/7368",
28+
Reason: "See " + doc.URL("docs/target/container_image", "disabled-checks"),
2429
},
2530
}
2631

@@ -101,9 +106,10 @@ func imageConfigToDockerfile(cfg *v1.ConfigFile) []byte {
101106
createdBy = buildHealthcheckInstruction(cfg.Config.Healthcheck)
102107
default:
103108
for _, prefix := range []string{"ARG", "ENV", "ENTRYPOINT"} {
104-
strings.HasPrefix(h.CreatedBy, prefix)
105-
createdBy = h.CreatedBy
106-
break
109+
if strings.HasPrefix(h.CreatedBy, prefix) {
110+
createdBy = h.CreatedBy
111+
break
112+
}
107113
}
108114
}
109115
dockerfile.WriteString(strings.TrimSpace(createdBy) + "\n")

0 commit comments

Comments
 (0)