Trivy and Semgrep put the Dockerfile root user in different classes

未關閉
#167 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

@anushkasingh-commits 已經在處理了。

開始於 2026年12月1日。

  • #169 來自 @anushkasingh-commits —— 未關閉

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
45/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
停滯
技術堆疊
docker, go
領域
security, tooling

研究方向

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.

由索引模型根據 Issue 內容生成。

描述

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

主要語言
Go
星號
0
分支
1
平均合併
8 小時 14 分鐘
30 天內合併 PR
3

環境準備

在 Codespaces 中開啟

在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

TMHSDigital/Spackle 的其他 Issue

查看 TMHSDigital/Spackle 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。