Skip to content

run-as-non-root: flag explicit root group#1178

Open
Zakharden wants to merge 1 commit into
stackrox:mainfrom
Zakharden:fix/run-as-group-non-root
Open

run-as-non-root: flag explicit root group#1178
Zakharden wants to merge 1 commit into
stackrox:mainfrom
Zakharden:fix/run-as-group-non-root

Conversation

@Zakharden
Copy link
Copy Markdown

Summary

Extend the run-as-non-root template so it also reports containers that explicitly resolve to runAsGroup: 0.

The check now resolves runAsGroup from container and pod security contexts using the same precedence as Kubernetes: container-level settings override pod-level settings. It only reports an explicit root group value, so workloads that omit runAsGroup keep the existing behavior.

Fixes #748.

Validation

  • gofmt -w pkg/templates/runasnonroot/template.go pkg/templates/runasnonroot/template_test.go
  • GOCACHE=/private/tmp/kube-linter-gocache GOMODCACHE=/private/tmp/kube-linter-gomodcache go test ./pkg/templates/runasnonroot
  • GOCACHE=/private/tmp/kube-linter-gocache GOMODCACHE=/private/tmp/kube-linter-gomodcache go test ./pkg/templates/...
  • GOCACHE=/private/tmp/kube-linter-gocache GOMODCACHE=/private/tmp/kube-linter-gomodcache go test ./pkg/builtinchecks/...
  • GOCACHE=/private/tmp/kube-linter-gocache GOMODCACHE=/private/tmp/kube-linter-gomodcache go run ./cmd/kube-linter templates list --format markdown | diff - docs/generated/templates.md
  • GOCACHE=/private/tmp/kube-linter-gocache GOMODCACHE=/private/tmp/kube-linter-gomodcache go run ./cmd/kube-linter checks list --format markdown | diff - docs/generated/checks.md
  • git diff --check

@Zakharden Zakharden requested a review from rhybrillou as a code owner May 11, 2026 21:28
@codecov
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 31.16%. Comparing base (dbd7529) to head (c0a40c7).
⚠️ Report is 307 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1178       +/-   ##
===========================================
- Coverage   62.36%   31.16%   -31.20%     
===========================================
  Files         197      239       +42     
  Lines        4854     6545     +1691     
===========================================
- Hits         3027     2040      -987     
- Misses       1439     4328     +2889     
+ Partials      388      177      -211     
Flag Coverage Δ
unit 31.16% <100.00%> (-31.20%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Zakharden Zakharden force-pushed the fix/run-as-group-non-root branch 2 times, most recently from 62c37fc to 46f9011 Compare May 14, 2026 06:48
@Zakharden
Copy link
Copy Markdown
Author

@rhybrillou pls check

@Zakharden Zakharden force-pushed the fix/run-as-group-non-root branch from 46f9011 to 61f1c66 Compare May 15, 2026 12:12
@Zakharden Zakharden force-pushed the fix/run-as-group-non-root branch from 61f1c66 to c0a40c7 Compare May 19, 2026 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE_REQUEST] Expand run-as-non-root template to verify runAsGroup field is nonzero.

1 participant