Skip to content

Commit

Permalink
Merge pull request #45 from github/image-glob-support
Browse files Browse the repository at this point in the history
Add ability to pass glob patterns to match image, and add "exempt" policy
  • Loading branch information
codysoyland authored Jul 3, 2024
2 parents bace4ee + cdb96af commit e34dbee
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Next, install the GitHub `TrustRoot` and our default `ClusterImagePolicy`:
helm install trust-policies --atomic \
--namespace artifact-attestations \
oci://ghcr.io/github/artifact-attestations-helm-charts/trust-policies \
--version v0.4.0 \
--version v0.5.0 \
--set policy.enabled=true \
--set policy.organization=MY-ORGANIZATION
```
Expand Down
4 changes: 2 additions & 2 deletions charts/trust-policies/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ sources:
type: application

name: trust-policies
version: "v0.4.0"
appVersion: "v0.4.0"
version: "v0.5.0"
appVersion: "v0.5.0"

maintainers:
- name: codysoyland
Expand Down
12 changes: 11 additions & 1 deletion charts/trust-policies/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@ Generate subjectRegExp value
*/}}
{{- define "clusterimagepolicy.subjectRegExp" -}}
{{- if .Values.policy.subjectRegExp -}}
subjectRegExp: {{ .Values.policy.subjectRegExp }}
subjectRegExp: "{{ .Values.policy.subjectRegExp }}"
{{- else -}}
subjectRegExp: https://github.com/{{ .Values.policy.organization | required "One of policy.organization/policy.subjectRegExp is required" }}/{{ .Values.policy.repository }}/\.github/workflows/.*
{{- end -}}
{{- end -}}
{{- define "clusterimagepolicy.images" -}}
{{- range .Values.policy.images -}}
- glob: "{{ . }}"
{{ end -}}
{{- end -}}
{{- define "clusterimagepolicy.exemptImages" -}}
{{- range .Values.policy.exemptImages -}}
- glob: "{{ . }}"
{{ end -}}
{{- end -}}
11 changes: 11 additions & 0 deletions charts/trust-policies/templates/clusterimagepolicy-exempt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{ if and .Values.policy.enabled .Values.policy.exemptImages }}
apiVersion: policy.sigstore.dev/v1alpha1
kind: ClusterImagePolicy
metadata:
name: github-exempt-policy
spec:
images: {{ include "clusterimagepolicy.exemptImages" . | nindent 4 }}
authorities:
- static:
action: pass
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ kind: ClusterImagePolicy
metadata:
name: github-policy
spec:
images:
- glob: "**"
images: {{ include "clusterimagepolicy.images" . | nindent 4 }}
authorities:
{{ if .Values.policy.trust.github }}
- name: github
Expand Down
5 changes: 5 additions & 0 deletions charts/trust-policies/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ policy:
subjectRegExp:
# policy.predicateType defines the type of predicate that the default policy expects
predicateType: https://slsa.dev/provenance/v1
# images is a list of image glob patterns that the policy applies to
images:
- "**"
# exemptImages is a list of image glob patterns that will be allowed to run without verification
exemptImages: []
# policy.enabled enables the default policy
enabled: false
# policy.trust identifies which signing authorities should be trusted as part of the policy
Expand Down

0 comments on commit e34dbee

Please sign in to comment.