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

Add test for config per policy source #1153

Merged
merged 1 commit into from
Nov 8, 2023
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
87 changes: 87 additions & 0 deletions features/__snapshots__/validate_image.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3245,3 +3245,90 @@ Error: 1 error occurred:
[fetch OCI blob:stderr - 1]

---

[policy rule filtering per source:stdout - 1]
{
"success": true,
"components": [
{
"name": "Unnamed",
"containerImage": "${REGISTRY}/acceptance/ec-happy-day@sha256:${REGISTRY_acceptance/ec-happy-day:latest_DIGEST}",
"source": {},
"successes": [
{
"msg": "Pass",
"metadata": {
"code": "builtin.attestation.signature_check"
}
},
{
"msg": "Pass",
"metadata": {
"code": "builtin.attestation.syntax_check"
}
},
{
"msg": "Pass",
"metadata": {
"code": "builtin.image.signature_check"
}
},
{
"msg": "Pass",
"metadata": {
"code": "filtering.always_pass"
}
}
],
"success": true,
"signatures": [
{
"keyid": "",
"sig": "${IMAGE_SIGNATURE_acceptance/ec-happy-day}"
}
],
"attestations": [
{
"type": "https://in-toto.io/Statement/v0.1",
"predicateType": "https://slsa.dev/provenance/v0.2",
"predicateBuildType": "https://tekton.dev/attestations/chains/pipelinerun@v2",
"signatures": [
{
"keyid": "",
"sig": "${ATTESTATION_SIGNATURE_acceptance/ec-happy-day}"
}
]
}
]
}
],
"key": "${known_PUBLIC_KEY_JSON}",
"policy": {
"sources": [
{
"policy": [
"git::https://${GITHOST}/git/happy-day-policy.git"
],
"config": {
"exclude": [
"filtering.always_pass_with_collection",
"filtering.always_fail_with_collection"
],
"include": [
"@stamps",
"filtering.always_pass"
]
}
}
],
"rekorUrl": "${REKOR}",
"publicKey": "${known_PUBLIC_KEY}"
},
"ec-version": "${EC_VERSION}",
"effective-time": "${TIMESTAMP}"
}
---

[policy rule filtering per source:stderr - 1]

---
29 changes: 29 additions & 0 deletions features/validate_image.feature
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,35 @@ Feature: evaluate enterprise contract
Then the exit status should be 0
Then the output should match the snapshot

Scenario: policy rule filtering per source
Given a key pair named "known"
Given an image named "acceptance/ec-happy-day"
Given a valid image signature of "acceptance/ec-happy-day" image signed by the "known" key
Given a valid Rekor entry for image signature of "acceptance/ec-happy-day"
Given a valid attestation of "acceptance/ec-happy-day" signed by the "known" key
Given a valid Rekor entry for attestation of "acceptance/ec-happy-day"
Given a git repository named "happy-day-policy" with
| filtering.rego | examples/filtering.rego |
Given policy configuration named "ec-policy" with specification
"""
{
"sources": [
{
"policy": [
"git::https://${GITHOST}/git/happy-day-policy.git"
],
"config": {
"include": ["@stamps", "filtering.always_pass"],
"exclude": ["filtering.always_pass_with_collection", "filtering.always_fail_with_collection"]
}
}
]
}
"""
When ec command is run with "validate image --image ${REGISTRY}/acceptance/ec-happy-day --policy acceptance/ec-policy --rekor-url ${REKOR} --public-key ${known_PUBLIC_KEY} --show-successes"
Then the exit status should be 0
Then the output should match the snapshot

Scenario: inline application snapshot
Given a key pair named "known"
Given an image named "acceptance/ec-happy-day"
Expand Down