Giter Site home page Giter Site logo

khaledemaradev / kubewarden-policy-psp-seccomp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kubewarden/seccomp-psp-policy

0.0 0.0 0.0 77 KB

A Kubewarden Pod Security Policy that controls usage of Seccomp profiles

Home Page: https://kubewarden.io

License: Apache License 2.0

Rust 98.57% Makefile 1.43%

kubewarden-policy-psp-seccomp's Introduction

This policy provides a replacement for the Pod Security Policy that deals with seccomp profiles.

Prior to Kubernetes 1.19, seccomp profiles could be defined only via Pod annotations. Starting from Kubernetes 1.19 the seccomp profiles can be managed via the securityContext field of Pods and Containers.

Note well: the seccomp annotations are deprecated and will be dropped starting from Kubernetes 1.25.

Settings

This policy has some configurations:

  • allowed_profiles: Define the accecpted profile values for the annotations container.seccomp.security.alpha.kubernetes.io/<container> and seccomp.security.alpha.kubernetes.io/pod.
  • profile_types: Define the allowed values to be set in the seccomp type in the security context of a container or of the Pod.
  • localhost_profiles: Define the allowed localhost profiles. This is used only when the "Localhost" type is allowed inside of the security context.

This policy can handle both seccomp policies expressed via annotations and via securityContext. In later Kubernetes version, it will populate the securityContext when the user define only the annotations. For this reason, if the user does not define the profile_types and localhost_profiles settings, the policy will fall-back to the allowed_profiles. Validating the containers securityContext against it. The following two settings are equivalent:

apiVersion: policies.kubewarden.io/v1alpha2
kind: ClusterAdmissionPolicy
metadata:
  name: psp-seccomp
spec:
  policyServer: default
  module: registry://ghcr.io/kubewarden/policies/seccomp-psp:v0.1.0
  rules:
  - apiGroups: [""]
    apiVersions: ["v1"]
    resources: ["pods"]
    operations:
    - CREATE
    - UPDATE
  mutating: false
  settings:
    allowed_profiles:
      - runtime/default
      - docker/default
      - localhost/test
    profile_types:
      - RuntimeDefault
      - Localhost
    localhost_profiles:
      - test
apiVersion: policies.kubewarden.io/v1alpha2
kind: ClusterAdmissionPolicy
metadata:
  name: psp-seccomp
spec:
  policyServer: default
  module: registry://ghcr.io/kubewarden/policies/seccomp-psp:v0.1.0
  rules:
  - apiGroups: [""]
    apiVersions: ["v1"]
    resources: ["pods"]
    operations:
    - CREATE
    - UPDATE
  mutating: false
  settings:
    allowed_profiles:
      - runtime/default
      - docker/default
      - localhost/test

As said before, you do not need to declare the profile_types and localhost_profiles. If you decided to use only the allowed_profiles settings you can get the same results.

Examples

With the yaml settings described in the settings section the following pods will be accepted:

apiVersion: v1
kind: Pod
metadata:
  name: nginx-seccomp-allowed
  annotations:
    container.seccomp.security.alpha.kubernetes.io/nginx: runtime/default
  labels:
    app: nginx-seccomp
spec:
  containers:
  - name: nginx
    image: nginx
----
apiVersion: v1
kind: Pod
metadata:
  name: nginx-seccomp-allowed2
  labels:
    app: nginx-seccomp
spec:
  securityContext:
    seccompProfile:
      type: RuntimeDefault
  containers:
  - name: nginx
    image: nginx
----
apiVersion: v1
kind: Pod
metadata:
  name: nginx-seccomp-allowed3
  labels:
    app: nginx-seccomp
spec:
  securityContext:
    seccompProfile:
      type: Localhost
      localhostProfile: test
  containers:
  - name: nginx
    image: nginx
----
apiVersion: v1
kind: Pod
metadata:
  name: nginx-seccomp-allowed4
  annotations:
    container.seccomp.security.alpha.kubernetes.io/nginx: localhost/test
  labels:
    app: nginx-seccomp
spec:
  containers:
  - name: nginx
    image: nginx
----
apiVersion: v1
kind: Pod
metadata:
  name: nginx-seccomp-allowed5
  annotations:
    container.seccomp.security.alpha.kubernetes.io/nginx: docker/default
  labels:
    app: nginx-seccomp
spec:
  containers:
  - name: nginx
    image: nginx

While the following pods will be rejected:

apiVersion: v1
kind: Pod
metadata:
  name: nginx-seccomp-disallowed
  labels:
    app: nginx-seccomp
spec:
  securityContext:
    seccompProfile:
      type: Unconfined
  containers:
  - name: nginx
    image: nginx
  - name: nginx2
    image: nginx
----
apiVersion: v1
kind: Pod
metadata:
  name: nginx-seccomp-disallowed2
  annotations:
    container.seccomp.security.alpha.kubernetes.io/nginx: localhost/test2
  labels:
    app: nginx-seccomp
spec:
  containers:
  - name: nginx
    image: nginx
  - name: nginx2
    image: nginx
----
apiVersion: v1
kind: Pod
metadata:
  name: nginx-seccomp-disallowed3
  annotations:
    seccomp.security.alpha.kubernetes.io/pod: unconfined
  labels:
    app: nginx-seccomp
spec:
  containers:
  - name: nginx
    image: nginx
----
apiVersion: v1
kind: Pod
metadata:
  name: nginx-seccomp-disallowed4
  annotations:
    container.seccomp.security.alpha.kubernetes.io/nginx: unconfined
  labels:
    app: nginx-seccomp
spec:
  containers:
  - name: nginx
    image: nginx
  - name: nginx2
    image: nginx
----
apiVersion: v1
kind: Pod
metadata:
  name: nginx-seccomp-disallowed5
  labels:
    app: nginx-seccomp
spec:
  securityContext:
    seccompProfile:
      type: Localhost
      localhostProfile: test2
  containers:
  - name: nginx
    image: nginx
  - name: nginx2
    image: nginx

kubewarden-policy-psp-seccomp's People

Contributors

chrisns avatar ereslibre avatar flavio avatar jvanz avatar olblak avatar renovate-bot avatar renovate[bot] avatar viccuad avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.