40 lines
1.3 KiB
YAML
40 lines
1.3 KiB
YAML
apiVersion: kyverno.io/v1
|
|
kind: ClusterPolicy
|
|
metadata:
|
|
name: restrict-image-registries
|
|
annotations:
|
|
policies.kyverno.io/title: Restrict image registries
|
|
policies.kyverno.io/category: Supply chain
|
|
policies.kyverno.io/severity: high
|
|
# CIS 5.5.1: image provenance. This is a concrete admission control that
|
|
# supports the broader provenance objective but is not the full CIS test.
|
|
policies.kyverno.io/cis-control: "5.5.1 supplemental"
|
|
spec:
|
|
validationFailureAction: Enforce
|
|
background: false
|
|
failurePolicy: Fail
|
|
rules:
|
|
- name: images-from-approved-registries
|
|
match:
|
|
any:
|
|
- resources:
|
|
kinds:
|
|
- Pod
|
|
namespaceSelector:
|
|
matchLabels:
|
|
security-baseline/open: "true"
|
|
validate:
|
|
message: Images must come from ghcr.io, quay.io, or docker.io/library.
|
|
foreach:
|
|
- list: request.object.spec.containers[]
|
|
anyPattern:
|
|
- image: ghcr.io/*
|
|
- image: quay.io/*
|
|
- image: docker.io/library/*
|
|
- list: request.object.spec.initContainers[]
|
|
anyPattern:
|
|
- image: ghcr.io/*
|
|
- image: quay.io/*
|
|
- image: docker.io/library/*
|
|
|