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(image): disable AVD-DS-0007 for history scanning #8366

Merged
merged 1 commit into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 9 additions & 1 deletion docs/docs/target/container_image.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,15 @@ See https://avd.aquasec.com/misconfig/ds026
!!! tip
You can see how each layer is created with `docker history`.

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.
#### Disabled checks

The following checks are disabled for this scan type due to known issues. See the linked issues for more details.

| Check ID | Reason | Issue |
|----------|------------|--------|
| [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) |
| [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) |


### Secrets
Trivy detects secrets on the configuration of container images.
Expand Down
14 changes: 10 additions & 4 deletions pkg/fanal/analyzer/imgconf/dockerfile/dockerfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ import (
"github.com/aquasecurity/trivy/pkg/iac/detection"
"github.com/aquasecurity/trivy/pkg/mapfs"
"github.com/aquasecurity/trivy/pkg/misconf"
"github.com/aquasecurity/trivy/pkg/version/doc"
)

var disabledChecks = []misconf.DisabledCheck{
{
ID: "DS007", Scanner: string(analyzer.TypeHistoryDockerfile),
Reason: "See " + doc.URL("docs/target/container_image", "disabled-checks"),
},
{
ID: "DS016", Scanner: string(analyzer.TypeHistoryDockerfile),
Reason: "See https://github.com/aquasecurity/trivy/issues/7368",
Reason: "See " + doc.URL("docs/target/container_image", "disabled-checks"),
},
}

Expand Down Expand Up @@ -101,9 +106,10 @@ func imageConfigToDockerfile(cfg *v1.ConfigFile) []byte {
createdBy = buildHealthcheckInstruction(cfg.Config.Healthcheck)
default:
for _, prefix := range []string{"ARG", "ENV", "ENTRYPOINT"} {
strings.HasPrefix(h.CreatedBy, prefix)
createdBy = h.CreatedBy
break
if strings.HasPrefix(h.CreatedBy, prefix) {
createdBy = h.CreatedBy
break
}
}
}
dockerfile.WriteString(strings.TrimSpace(createdBy) + "\n")
Expand Down