Replace privileged:true with minimal capabilities in integration tests#3447
Replace privileged:true with minimal capabilities in integration tests#3447robbycochran wants to merge 4 commits into
Conversation
Deploy collector with CAP_BPF, CAP_PERFMON, CAP_SYS_PTRACE, and CAP_SYS_RESOURCE instead of privileged:true across all three container runtime paths (Docker, CRI, K8s). Changes: - Add CapAdd field to ContainerStartConfig - Wire CapAdd to Docker HostConfig - Wire CapAdd to CRI LinuxContainerSecurityContext with drop ALL - Set K8s SecurityContext with explicit capabilities and allowPrivilegeEscalation:false - Set Docker collector manager to Privileged:false with CapAdd
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3447 +/- ##
=======================================
Coverage 27.34% 27.34%
=======================================
Files 95 95
Lines 5420 5420
Branches 2545 2545
=======================================
Hits 1482 1482
Misses 3211 3211
Partials 727 727
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
RHCOS 4.12-4.19 and RHEL 8 run kernel 4.18.0 where CAP_BPF is not functional as a discrete capability — libbpf_probe_bpf_map_type() returns EPERM. Add NeedsPrivileged() helper that detects these platforms via VM_CONFIG and falls back to privileged: true, while modern kernels (RHEL 9+, Ubuntu, COS, Flatcar) use the reduced capability set.
RHEL-SAP kernel builds (even on 5.14+) restrict BPF capability probing, causing libbpf_probe_bpf_map_type() to return EPERM with discrete CAP_BPF. Fall back to privileged mode on rhel-sap and rhel-s390x VMs.
Summary
This is Phase 2 of the collector privilege reduction effort. Phase 1 (stackrox/stackrox#21065) updated the production Helm templates. This PR validates that BPF collection works correctly under the reduced privilege model by running the existing integration test suite without privileged: true.
Files changed
Capabilities justification
Known considerations
Test plan