Trivy and Semgrep put the Dockerfile root user in different classes

Đang mở
#167 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@anushkasingh-commits đang làm issue này rồi.

Từ ngày 1/12/2026.

  • #169 của @anushkasingh-commits — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
docker, go
Lĩnh vực
security, tooling

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Go
Star
0
Fork
1
Merge trung bình
8 giờ 14 phút
Pull request đã merge (30 ngày)
3

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của TMHSDigital/Spackle

Tất cả issue của TMHSDigital/Spackle

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.