Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use container as cause in KSV104 check #304

Merged
merged 1 commit into from
Jan 9, 2025

Conversation

nikpivkin
Copy link
Contributor

We should only use objects as causes in kubernetes checks , since only they contain the locations used to display the findings.

Config:

---
apiVersion: v1
kind: Pod
metadata:
  name: hello-sysctls
spec:
  containers:
  - name: hello
    image: busybox
    command:
    - sh
    - "-c"
    - echo 'Hello' && sleep 1h
    securityContext:
      seccompProfile:
        type: Unconfined

Before:

AVD-KSV-0104 (MEDIUM): container "hello" of pod "hello-sysctls" in "default" namespace should specify a seccomp profile
════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
A program inside the container can bypass Seccomp protection policies.

See https://avd.aquasec.com/misconfig/ksv104
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 test.yaml:1
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1 [ ---
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

After:

AVD-KSV-0104 (MEDIUM): container "hello" of pod "hello-sysctls" in "default" namespace should specify a seccomp profile
════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
A program inside the container can bypass Seccomp protection policies.

See https://avd.aquasec.com/misconfig/ksv104
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 test.yaml:8-16
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   8 ┌   - name: hello
   9 │     image: busybox
  10 │     command:
  11 │     - sh
  12 │     - "-c"
  13 │     - echo 'Hello' && sleep 1h
  14 │     securityContext:
  15 │       seccompProfile:
  16 └         type: Unconfined
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

@nikpivkin nikpivkin marked this pull request as ready for review December 19, 2024 12:00
@nikpivkin nikpivkin requested a review from simar7 as a code owner December 19, 2024 12:00
@simar7
Copy link
Member

simar7 commented Jan 3, 2025

In our tests, do we not assert the cause? Should we do so or would that make the tests too brittle?

Copy link
Member

@simar7 simar7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a comment but we can merge this in for now.

@simar7 simar7 added this pull request to the merge queue Jan 9, 2025
Merged via the queue into aquasecurity:main with commit a1d01c3 Jan 9, 2025
6 checks passed
@nikpivkin nikpivkin deleted the ksv104-loc branch January 9, 2025 05:51
@nikpivkin
Copy link
Contributor Author

nikpivkin commented Jan 9, 2025

We do not check the cause in Rego tests because the test data is simplified. We can add such a check to the example tests.

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.

2 participants