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

Added tests to tests/gh-actions to enable baseline and restricted PSS #2819

Merged
merged 6 commits into from
Aug 12, 2024
Merged
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
35 changes: 35 additions & 0 deletions .github/workflows/pss_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Appy PSS labels to namespaces
on:

Check warning on line 2 in .github/workflows/pss_test.yaml

View workflow job for this annotation

GitHub Actions / format_YAML_files

2:1 [truthy] truthy value should be one of [false, true]
pull_request:
paths:
- .github/workflows/*
- tests/gh-actions/kind-cluster.yaml
- apps/profiles/upstream/**
- common/dex/**
- common/cert-manager/**
- common/oidc-client/oauth2-proxy/**
- common/istio*/**
- tests/gh-actions/install_istio_with_ext_auth.sh
- tests/gh-actions/install_multitenancy.sh

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install KinD
run: ./tests/gh-actions/install_kind.sh

- name: Create KinD Cluster
run: kind create cluster --config tests/gh-actions/kind-cluster.yaml

- name: Install kustomize
run: ./tests/gh-actions/install_kustomize.sh

- name: Install kubectl
run: ./tests/gh-actions/install_kubectl.sh

- name: Applying Pod Security Standards baseline levels for static namespaces
run: ./tests/gh-actions/enable_baseline_PSS.sh
6 changes: 3 additions & 3 deletions contrib/security/PSS/static/baseline/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Component

patches:
- path: patches/kubeflow-labels.yaml
- path: patches/istio-labels.yaml
- path: patches/istio-system-labels.yaml
- path: patches/cert-manager-labels.yaml
- path: patches/dex-labels.yaml
- path: patches/oauth2-proxy-labels.yaml
- path: patches/auth-labels.yaml
- path: patches/oauth2-proxy-labels.yaml
5 changes: 2 additions & 3 deletions contrib/security/PSS/static/restricted/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ kind: Component

patches:
- path: patches/kubeflow-labels.yaml
- path: patches/istio-labels.yaml
- path: patches/istio-system-labels.yaml
- path: patches/cert-manager-labels.yaml
- path: patches/dex-labels.yaml
- path: patches/auth-labels.yaml
- path: patches/oauth2-proxy-labels.yaml
- path: patches/istio-labels.yaml
10 changes: 10 additions & 0 deletions tests/gh-actions/enable_baseline_PSS.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

NAMESPACES=("istio-system" "auth" "cert-manager" "oauth2-proxy" "kubeflow")

for NAMESPACE in "${NAMESPACES[@]}"; do
if kubectl get namespace "$NAMESPACE" >/dev/null 2>&1; then
echo "Patching the PSS-baseline labels for namespace $NAMESPACE..."
kubectl patch namespace $NAMESPACE --patch-file ./contrib/security/PSS/static/baseline/patches/${NAMESPACE}-labels.yaml
fi
done
10 changes: 10 additions & 0 deletions tests/gh-actions/enable_restricted_PSS.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

NAMESPACES=("istio-system" "auth" "cert-manager" "oauth2-proxy" "kubeflow")

for NAMESPACE in "${NAMESPACES[@]}"; do
if kubectl get namespace "$NAMESPACE" >/dev/null 2>&1; then
echo "Patching the PSS-restricted labels for namespace $NAMESPACE..."
kubectl patch namespace $NAMESPACE --patch-file ./contrib/security/PSS/static/restricted/patches/${NAMESPACE}-labels.yaml
fi
done
Loading