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

check-compliance-policy and check-imagie-FIPS added #188

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions tetrate/check-compliance-policy/check-compliance-policy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: enforce-istiod-fips-compliance
annotations:
policies.kyverno.io/title: "Ensure Istiod Compliance Policy"
policies.kyverno.io/category: "Security"
policies.kyverno.io/severity: "high"
policies.kyverno.io/subject: "Deployment"
policies.kyverno.io/description: "Ensures that Istiod deployments have COMPLIANCE_POLICY=fips-140-2 set in the environment variables."
spec:
validationFailureAction: Enforce
background: true
rules:
- name: check-compliance-policy
match:
any:
- resources:
kinds:
- Deployment
namespaces:
- istio-system
Copy link
Collaborator

Choose a reason for hiding this comment

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

You should also add the match for istiod Deployment

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also maybe a good idea to write the check for Pod instead

validate:
message: "Istiod containers must have COMPLIANCE_POLICY=fips-140-2 set in their environment variables."
pattern:
spec:
template:
spec:
containers:
- name: discovery
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the container name guaranteed to be discovery?

env:
- name: COMPLIANCE_POLICY
value: fips-140-2
19 changes: 19 additions & 0 deletions tetrate/check-compliance-policy/e2e/bad-resouces.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: istiod
namespace: istio-system
spec:
selector:
matchLabels:
app: istiod
template:
metadata:
labels:
app: istiod
spec:
containers:
- name: discovery
env:
- name: COMPLIANCE_POLICY
value: some-other-value
19 changes: 19 additions & 0 deletions tetrate/check-compliance-policy/e2e/good-resouce.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: istiod
namespace: istio-system
spec:
selector:
matchLabels:
app: istiod
template:
metadata:
labels:
app: istiod
spec:
containers:
- name: discovery
env:
- name: COMPLIANCE_POLICY
value: fips-140-2
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: enforce-fips-compliant-images
annotations:
policies.kyverno.io/title: "Enforce FIPS Compliant Images"
policies.kyverno.io/category: "Security"
policies.kyverno.io/severity: "high"
policies.kyverno.io/subject: "Pod, Deployment, StatefulSet, DaemonSet"
policies.kyverno.io/description: "Ensures that container images are pulled from the FIPS-compliant registry fips-containers.istio.tetratelabs.com."
spec:
validationFailureAction: Enforce
background: true
rules:
- name: check-fips-registry
match:
any:
- resources:
kinds:
- Pod
- Deployment
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should probably write the check only for Pod. Other controllers will be handled by auto-gen rules.

- StatefulSet
- DaemonSet
validate:
message: "Container images must be pulled from fips-containers.istio.tetratelabs.com"
pattern:
spec:
template:
spec:
containers:
- image: "fips-containers.istio.tetratelabs.com/*"
17 changes: 17 additions & 0 deletions tetrate/check-image-FIPS-compliant copy/e2e/bad-resouces.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: non-fips-deployment
namespace: default
spec:
selector:
matchLabels:
app: non-fips
template:
metadata:
labels:
app: non-fips
spec:
containers:
- name: app-container
image: docker.io/istio/proxyv2:1.20.0
17 changes: 17 additions & 0 deletions tetrate/check-image-FIPS-compliant copy/e2e/good-resouce.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: non-fips-deployment
namespace: default
spec:
selector:
matchLabels:
app: non-fips
template:
metadata:
labels:
app: non-fips
spec:
containers:
- name: app-container
image: fips-containers.istio.tetratelabs.com/istio/proxyv2:1.20.0