Skip to content

Commit 9364b39

Browse files
committed
fix: cosign keyless attestations
Signed-off-by: Vishal Choudhary <[email protected]>
1 parent 5ec3406 commit 9364b39

File tree

20 files changed

+159
-26
lines changed

20 files changed

+159
-26
lines changed

.crds/nirmata.io_imageverificationpolicies.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,9 @@ spec:
569569
ImageReferences is a list of matching image reference patterns. At least one pattern in the
570570
list must match the image for the rule to apply. Each image reference consists of a registry
571571
address, repository, image, and tag (defaults to latest). Wildcards ('*' and '?') are allowed.
572-
type: string
572+
items:
573+
type: string
574+
type: array
573575
notary:
574576
description: Notary is an array of attributes used to
575577
verify notary signatures

.schemas/openapi/v2/schema.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

.schemas/openapi/v3/apis/nirmata.io/v1alpha1.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

cmd/e2e_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ func Test_Verify(t *testing.T) {
4343
resourcePath: "./examples/cosign-keyless/bad-payload.json",
4444
outputPath: "./examples/cosign-keyless/bad-out.txt",
4545
},
46+
{
47+
name: "cosign keyless attestation pass",
48+
policyPath: "./examples/cosign-keyless-attestations/policy.yaml",
49+
resourcePath: "./examples/cosign-keyless-attestations/payload.json",
50+
outputPath: "./examples/cosign-keyless-attestations/out.txt",
51+
},
4652
{
4753
name: "notary attestation pass",
4854
policyPath: "./examples/notary-attestation-verification/policy.yaml",

cmd/examples/aws-signer-image-verification/policy.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ spec:
1818
- name: test
1919
path: /containerDefinitions/*/image/
2020
verify:
21-
- imageReferences: "*"
21+
- imageReferences:
22+
- "*"
2223
externalService:
2324
- apiCall:
2425
method: POST
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Verification Result:
2+
Results for policy: test
3+
Results for rule: cosign-keyless
4+
Verifying image: ghcr.io/chipzoller/zulu:v0.0.14, result: PASS
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"containerDefinitions": [
3+
{
4+
"command": [
5+
"/bin/sh -c \"echo '<html> <head> <title>Amazon ECS Sample App</title> <style>body {margin-top: 40px; background-color: #333;} </style> </head><body> <div style=color:white;text-align:center> <h1>Amazon ECS Sample App</h1> <h2>Congratulations!</h2> <p>Your application is now running on a container in Amazon ECS.</p> </div></body></html>' > /usr/local/apache2/htdocs/index.html && httpd-foreground\""
6+
],
7+
"entryPoint": [
8+
"sh",
9+
"-c"
10+
],
11+
"essential": true,
12+
"image": "ghcr.io/chipzoller/zulu:v0.0.14",
13+
"logConfiguration": {
14+
"logDriver": "awslogs",
15+
"options": {
16+
"awslogs-group" : "/ecs/fargate-task-definition",
17+
"awslogs-region": "us-east-1",
18+
"awslogs-stream-prefix": "ecs"
19+
}
20+
},
21+
"name": "sample-fargate-app",
22+
"portMappings": [
23+
{
24+
"containerPort": 80,
25+
"hostPort": 80,
26+
"protocol": "tcp"
27+
}
28+
]
29+
}
30+
],
31+
"cpu": "256",
32+
"executionRoleArn": "arn:aws:iam::012345678910:role/ecsTaskExecutionRole",
33+
"family": "fargate-task-definition",
34+
"memory": "512",
35+
"networkMode": "awsvpc",
36+
"runtimePlatform": {
37+
"operatingSystemFamily": "LINUX"
38+
},
39+
"requiresCompatibilities": [
40+
"FARGATE"
41+
]
42+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
apiVersion: nirmata.io/v1alpha1
2+
kind: ImageVerificationPolicy
3+
metadata:
4+
name: test
5+
spec:
6+
rules:
7+
- name: cosign-keyless
8+
match:
9+
any:
10+
- (length(containerDefinitions) > `0`): true
11+
imageExtractors:
12+
- name: test
13+
path: /containerDefinitions/*/image/
14+
verify:
15+
- imageReferences:
16+
- ghcr.io/*
17+
cosign:
18+
- keyless:
19+
issuer: https://token.actions.githubusercontent.com
20+
subject: https://github.com/slsa-framework/slsa-github-generator/.github/workflows/generator_container_slsa3.yml@refs/heads/main
21+
rekor:
22+
url: https://rekor.sigstore.dev
23+
ignoreSCT: true
24+
intotoAttestations:
25+
- type: https://slsa.dev/provenance/v0.2
26+
conditions:
27+
- all:
28+
- key: '{{ regex_match(''^https://github.com/slsa-framework/slsa-github-generator/.github/workflows/generator_container_slsa3.yml@refs/heads/main'',''{{
29+
builder.id}}'') }}'
30+
operator: Equals
31+
value: true

cmd/examples/cosign-keyless/policy.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ spec:
1212
- name: test
1313
path: /containerDefinitions/*/image/
1414
verify:
15-
- imageReferences: ghcr.io/*
15+
- imageReferences:
16+
- ghcr.io/*
1617
cosign:
1718
- keyless:
1819
issuer: https://accounts.google.com

cmd/examples/external-api-image-verification/fail-policy.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ spec:
1212
- name: test
1313
path: /containerDefinitions/*/image/
1414
verify:
15-
- imageReferences: ghcr.io/kyverno/test-verify-image*
15+
- imageReferences:
16+
- ghcr.io/kyverno/test-verify-image*
1617
externalService:
1718
- apiCall:
1819
method: POST

0 commit comments

Comments
 (0)