diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 397c853..8c120c5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,14 +35,6 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - # Install the cosign tool except on PR - # https://github.com/sigstore/cosign-installer - - name: Install cosign - if: github.event_name != 'pull_request' - uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1 - with: - cosign-release: 'v2.1.1' - # Workaround: https://github.com/docker/build-push-action/issues/461 - name: Setup Docker buildx uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf @@ -78,22 +70,6 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max - - # Sign the resulting Docker image digest except on PRs. - # This will only write to the public Rekor transparency log when the Docker - # repository is public to avoid leaking data. If you would like to publish - # transparency data even for private images, pass --force to cosign below. - # https://github.com/sigstore/cosign - - name: Sign the published Docker image - if: ${{ github.event_name != 'pull_request' }} - env: - # https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable - TAGS: ${{ steps.meta.outputs.tags }} - DIGEST: ${{ steps.build-and-push.outputs.digest }} - # This step uses the identity token to provision an ephemeral certificate - # against the sigstore community Fulcio instance. - run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST} - releasechart: runs-on: ubuntu-latest steps: diff --git a/Dockerfile b/Dockerfile index 8d7c135..1dcbdf3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,10 +15,10 @@ COPY . . RUN CGO_ENABLED=0 go build -o webhook -ldflags '-w -extldflags "-static"' . -FROM alpine:3.19 - -RUN apk add --no-cache ca-certificates +FROM scratch COPY --from=build /workspace/webhook /usr/local/bin/webhook +COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt + ENTRYPOINT ["webhook"] diff --git a/deploy/rcodezero-webhook/templates/deployment.yaml b/deploy/rcodezero-webhook/templates/deployment.yaml index 057cc42..265d9c7 100644 --- a/deploy/rcodezero-webhook/templates/deployment.yaml +++ b/deploy/rcodezero-webhook/templates/deployment.yaml @@ -10,6 +10,9 @@ metadata: heritage: {{ .Release.Service }} spec: replicas: {{ .Values.replicaCount }} + {{- if .Values.podSecurityContext.enabled }} + securityContext: {{- omit .Values.podSecurityContext "enabled" | toYaml | nindent 8 }} + {{- end }} selector: matchLabels: app: {{ include "example-webhook.name" . }} @@ -24,8 +27,12 @@ spec: containers: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + {{- if .Values.containerSecurityContext.enabled }} + securityContext: {{- omit .Values.containerSecurityContext "enabled" | toYaml | nindent 12 }} + {{- end }} imagePullPolicy: {{ .Values.image.pullPolicy }} args: + - --secure-port={{ .Values.service.port }} - --tls-cert-file=/tls/tls.crt - --tls-private-key-file=/tls/tls.key env: @@ -33,7 +40,7 @@ spec: value: {{ .Values.groupName | quote }} ports: - name: https - containerPort: 443 + containerPort: {{ .Values.service.port }} protocol: TCP livenessProbe: httpGet: diff --git a/deploy/rcodezero-webhook/values.yaml b/deploy/rcodezero-webhook/values.yaml index fb895ad..3ed1a45 100644 --- a/deploy/rcodezero-webhook/values.yaml +++ b/deploy/rcodezero-webhook/values.yaml @@ -41,3 +41,48 @@ nodeSelector: {} tolerations: [] affinity: {} + +## @section Security Contexts + +containerSecurityContext: + ## @param containerSecurityContext.enabled Whether to enable the container security context + ## + enabled: true + ## @param containerSecurityContext.runAsNonRoot Whether to run the container as a non-root user + ## + runAsNonRoot: true + ## @param containerSecurityContext.privileged Whether the container is privileged + ## + privileged: false + ## @param containerSecurityContext.readOnlyRootFilesystem Whether the root filesystem is read-only + ## + readOnlyRootFilesystem: false + ## @param containerSecurityContext.allowPrivilegeEscalation Whether to allow privilege escalation + ## + allowPrivilegeEscalation: false + ## @extra containerSecurityContext.capabilities Capabilities to add/drop for the container + ## @skip containerSecurityContext.capabilities.drop + ## + capabilities: + drop: ["ALL"] + ## @extra containerSecurityContext.seccompProfile Seccomp profile for the container + ## @skip containerSecurityContext.seccompProfile.type + ## + seccompProfile: + type: "RuntimeDefault" + + +podSecurityContext: + ## @param podSecurityContext.enabled Whether to enable the pod security context + ## + enabled: true + ## @param podSecurityContext.fsGroupChangePolicy Policy for changing the fsGroup + ## + fsGroupChangePolicy: OnRootMismatch + ## @param podSecurityContext.sysctls Sysctls for the pod + ## + sysctls: [] + ## @param podSecurityContext.supplementalGroups Supplemental groups for the pod + ## + supplementalGroups: [] +