Trivy and Semgrep put the Dockerfile root user in different classes

Aberta
#167 1 comentário 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

@anushkasingh-commits já está trabalhando nisso.

Desde 1/12/2026.

  • #169 de @anushkasingh-commits — aberto

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
45/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Estagnada
Stack de tecnologia
docker, go
Domínio
security, tooling

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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

Linguagem predominante
Go
Estrelas
0
Forks
1
Merge médio
8h 14min
PRs com merge (30d)
3

Preparar o ambiente

Abrir no Codespaces

Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de TMHSDigital/Spackle

Todas as issues de TMHSDigital/Spackle

Issues semelhantes

Mais issues de Go

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.