Trivy and Semgrep put the Dockerfile root user in different classes

Abierto
#167 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@anushkasingh-commits ya está trabajando en esto.

Desde el 1/12/2026.

  • #169 de @anushkasingh-commits — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
docker, go
Área
security, tooling

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
Go
Estrellas
0
Forks
1
Merge medio
8 h 14 min
PR fusionados (30 d)
3

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de TMHSDigital/Spackle

Todos los issues de TMHSDigital/Spackle

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.