Skip to content

Commit

Permalink
add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sluetze committed Oct 29, 2024
1 parent add9b1b commit 55e3a8b
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 0 deletions.
11 changes: 11 additions & 0 deletions BSI/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM registry.fedoraproject.org/fedora-minimal:38 as builder
WORKDIR /content
COPY . .
RUN microdnf -y install cmake make git /usr/bin/python3 python3-pyyaml python3-jinja2 openscap-utils
RUN ./build_product --datastream-only --debug ocp4 rhcos4


FROM registry.access.redhat.com/ubi8/ubi-minimal
WORKDIR /
COPY --from=builder /content/build/ssg-ocp4-ds.xml .
COPY --from=builder /content/build/ssg-rhcos4-ds.xml .
17 changes: 17 additions & 0 deletions BSI/ProfileBundles.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: compliance.openshift.io/v1alpha1
kind: ProfileBundle
metadata:
name: upstream-rhcos4
namespace: openshift-compliance
spec:
contentFile: ssg-rhcos4-ds.xml
contentImage: quay.io/sluetzen/sig-bsi-grundschutz-content@sha256:c69db5c430b46f102a0bdea1f22ff66dd74c8fc7b921ed9d0039c6dba4a831be
---
apiVersion: compliance.openshift.io/v1alpha1
kind: ProfileBundle
metadata:
name: upstream-ocp4
namespace: openshift-compliance
spec:
contentFile: ssg-ocp4-ds.xml
contentImage: quay.io/sluetzen/sig-bsi-grundschutz-content@sha256:c69db5c430b46f102a0bdea1f22ff66dd74c8fc7b921ed9d0039c6dba4a831be
38 changes: 38 additions & 0 deletions BSI/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Summary
The following is intended for people who want to use this UPSTREAM content in the context of OpenShift, and do not need to understand the details of the buildprocess. It combines the Red Hat packaged Compliance Operator from Red Hat with the upstream content

# Install Compliance Operator
Follow the guidance in the official docs
https://docs.openshift.com/container-platform/4.16/security/compliance_operator/co-management/compliance-operator-installation.html#compliance-operator-installation

# Build
You can get the content in different ways. First possibility is a build from source in your own infrastructure.
The other possibility is a prebuild-content image, which provides the build content for you

## ALTERNATIVE A: BUILD FROM SOURCE
This Process builds the content only for one cluster in the internal registry. if you need it in different clusters, you need to build it and output it to a image-repository. You can do this in an openshift cluster using the `outputs` in the `BuildConfig` or just manually build with `podman build --tag $IMAGEREGISTRY:$TAG --file BSI/Containerfile .` from the `content` directory

### Clone git Repository
`git clone --depth 1 https://github.com/sig-bsi-grundschutz/content.git --branch bsi-profile-complete-2024-10-31`

### Build content in the cluster using the build scripts
`./utils/build_ds_container.py --create-profile-bundles --build-in-cluster`

IMPORTANT!
This creates additional upstream-rules and Profiles (prefixed with upstream) in the OpenShift Cluster due to the current functionality in RHACS the Compliance Dashboard in RHACS will show DUPLICATE RULES and throw ERRORS for the duplicate rules and not show the additional content

This can currently be worked around with the following command, which REPLACES THE SUPPORTED CONTENT with the upstream content
`./utils/build_ds_container.py --create-profile-bundles --build-in-cluster --no-upstream-prefix`

## ALTERNATIVE B: Use PreBuild Image
in disconnected / airgapped environments you might want to mirror the image first and either change the contentImage or create a `ImageDigestMirrorSet`.

This follows https://docs.openshift.com/container-platform/4.17/security/compliance_operator/co-management/compliance-operator-manage.html

`oc apply -f BSI/ProfileBundles.yaml`

# Schedule
The profiles are prefixed with upstream in this case. If you do not use a prefix, please change accordingly
This follows https://docs.openshift.com/container-platform/4.17/security/compliance_operator/co-scans/compliance-scans.html

`oc apply -f BSI/ScanSettings.yaml`
41 changes: 41 additions & 0 deletions BSI/ScanSettings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
apiVersion: compliance.openshift.io/v1alpha1
kind: ScanSettingBinding
metadata:
name: upstream-bsi-ocp
namespace: openshift-compliance
profiles:
- apiGroup: compliance.openshift.io/v1alpha1
kind: Profile
name: upstream-ocp4-bsi
- apiGroup: compliance.openshift.io/v1alpha1
kind: Profile
name: upstream-ocp4-bsi-node
settingsRef:
apiGroup: compliance.openshift.io/v1alpha1
kind: ScanSetting
name: bsi-schedule
---
apiVersion: compliance.openshift.io/v1alpha1
kind: ScanSettingBinding
metadata:
name: upstream-bsi-rhcos
namespace: openshift-compliance
profiles:
- apiGroup: compliance.openshift.io/v1alpha1
kind: Profile
name: upstream-rhcos4-bsi
settingsRef:
apiGroup: compliance.openshift.io/v1alpha1
kind: ScanSetting
name: bsi-schedule
---
apiVersion: compliance.openshift.io/v1alpha1
kind: ScanSetting
maxRetryOnTimeout: 3
metadata:
name: bsi-schedule
namespace: openshift-compliance
roles:
- master
- worker
schedule: 0 1 * * 1
9 changes: 9 additions & 0 deletions products/ocp4/profiles/test.profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
documentation_complete: true

title: 'Test Profile for sandboxed_containers_operator_configured'

platform: ocp4

description: Test Profile
selections:
- sandboxed_containers_operator_configured

0 comments on commit 55e3a8b

Please sign in to comment.