Trivy and Semgrep put the Dockerfile root user in different classes

Open
#167 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@anushkasingh-commits is already working on this.

Since Dec 1, 2026.

  • #169 by @anushkasingh-commits — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
docker, go
Domain
security, tooling

Research direction

Read internal/seed/external.go, especially trivyPrivRe and trivyMisconfigClass, then inspect the scanner fixtures in internal/seed/testdata/real/. Update the classification so Trivy DS-0002 matches Semgrep last-user-is-root, and add or adjust TestParseRealScannerOutput in internal/seed/external_test.go. Run go test ./internal/seed; the change is complete when both scanner outputs produce the same class.

Written by the indexing model from the issue text.

Description

bug good first issue severity: low

Summary

The same root-user flaw in a Dockerfile lands in two different classes depending on which scanner found it. Trivy's DS-0002 ("Image user should not be 'root'") becomes container-hardening, while Semgrep's last-user-is-root becomes container-privilege. Leads from the two scanners on the same line are then not merged as one finding, and the class (and its remediation text) depends on which tools are installed.

Where

  • internal/seed/external.go:1004 (trivyPrivRe)
  • internal/seed/external.go:1015 (trivyMisconfigClass)
  • internal/seed/testdata/real/trivy-0.76.2.json and semgrep-1.187.0.json (real outputs showing both)

Details

trivyPrivRe = regexp.MustCompile(`(?i)privileged|host ?(?:network|pid|ipc|path)|capabilit|docker\.sock`)
...
case trivyPrivRe.MatchString(text):
	return "container-privilege", "CWE-250"
...
return "container-hardening", "CWE-250"

DS-0002's title and message do not contain any of those words, so it falls through to container-hardening.

Impact

Duplicate findings for one flaw when both scanners run, and an inconsistent class across runs with different scanners installed.

Suggested fix

Map DS-0002 (by ID, which is more stable than the text) or text matching user should not be .?root|runs? as root to container-privilege, matching the Semgrep rule. Add a case to TestParseRealScannerOutput asserting both scanners give the same class for the Dockerfile root user.

Acceptance criteria

  • Trivy DS-0002 and Semgrep last-user-is-root produce the same class.
  • The real-output test pins it.

Getting started

  • Relevant files: internal/seed/external.go, internal/seed/external_test.go
  • How to run tests: go test ./internal/seed

Filed by repo-audit/fix-issues at b041273. Severity: low. Effort: S. audit-key: bug|internal/seed/external.go|trivyMisconfigClass

Dominant language
Go
Stars
0
Forks
1
Avg merge
8h 14m
Merged PRs (30d)
3

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from TMHSDigital/Spackle

All issues in TMHSDigital/Spackle

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.