Skip to content

Commit 73b205c

Browse files
committed
regex builderid match
1 parent 86c7868 commit 73b205c

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

policy/policy_pull_request.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ sources:
99
format: "semver"
1010
max: "1.31.0"
1111
allowed_builder_ids:
12-
- https://github.com/st3penta/fosdem-2026-build-sample/.github/workflows/pull_request.yml@refs/pull/
12+
- ^https://github\.com/st3penta/fosdem-2026-build-sample/\.github/workflows/pull_request\.yml@refs/pull/\d+/merge$

policy/rules/main.rego

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ deny contains result if {
4141
att.statement.predicateType == "https://slsa.dev/provenance/v1"
4242
builder_id := att.statement.predicate.runDetails.builder.id
4343

44-
not builder_id in allowed_builder_ids
44+
not is_builder_id_allowed(builder_id, allowed_builder_ids)
4545
result := lib.result_helper(rego.metadata.chain(), [builder_id])
4646
}
47+
48+
# Check if builder_id matches any allowed pattern (exact or regex)
49+
is_builder_id_allowed(builder_id, allowed_ids) if {
50+
some allowed_id in allowed_ids
51+
builder_id == allowed_id
52+
} else if {
53+
some allowed_id in allowed_ids
54+
startswith(allowed_id, "^")
55+
regex.match(allowed_id, builder_id)
56+
}

0 commit comments

Comments
 (0)