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

Add support for Pod Security Admission scanning #379

Open
spiarh opened this issue Jan 10, 2023 · 0 comments
Open

Add support for Pod Security Admission scanning #379

spiarh opened this issue Jan 10, 2023 · 0 comments
Assignees

Comments

@spiarh
Copy link
Contributor

spiarh commented Jan 10, 2023

Describe the solution you'd like

@vicenteherrera wrote a nice tool to statically check for Pod Security Standards levels. The tool uses the Pod Security Admission library from Kubernetes repository. https://github.com/vicenteherrera/psa-checker

Having this feature integrated into kubesec as a subcommand (something like kubesec psa-check) would be helpful for users as they could (e.g; in CI):

  • first scan for security risk
  • then validate in a second stage if the resource is compliant with the target PSA level

We could also consider adding some extra flags to kubesec scan with a new field in the output to do the previously mentioned in one stage:

Considering:

kubesec scan deploy.yaml --enable-psa-check --psa-level restricted

==> This would not break any existing usage as it is opt-in.

This could yield a result look like this

[
  {
    "object": "Deployment/nginx",
    "valid": true,
    "fileName": "deploy.yaml",
    "message": "Passed with a score of 0 points",
    "score": 0,
    "scoring": {
      "advise": [...]
    },
    "podSecurityAdmission": {
      "level": "restricted",
      "valid": false,
      "message": "Deployment nginx-deployment\n  PSS level restricted\n    Check 8 failed: allowPrivilegeEscalation != false\n      container \"nginx\" must set securityContext.allowPrivilegeEscalation=false\n    Check 9 failed: unrestricted capabilities\n      container \"nginx\" must set securityContext.capabilities.drop=[\"ALL\"]\n    Check 11 failed: runAsNonRoot != true\n      pod or container \"nginx\" must set securityContext.runAsNonRoot=true\n    Check 13 failed: seccompProfile\n      pod or container \"nginx\" must set securityContext.seccompProfile.type to \"RuntimeDefault\" or \"Localhost\"\n"
    }
  }
]
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

No branches or pull requests

4 participants