Skip to content

Commit 544be66

Browse files
committed
feat(policies): add attestation phase lifecycle control to policy evaluation
Add an AttestationPhase enum (INIT, STATUS, PUSH) and an attestation_phases field on PolicySpecV2 so policy authors can control at which attestation lifecycle phase their policy is evaluated. When no phases are specified the policy runs at all phases, preserving backwards compatibility. Closes #2764 Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
1 parent bcf7331 commit 544be66

14 files changed

Lines changed: 651 additions & 93 deletions

app/cli/pkg/action/attestation_push.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2024-2025 The Chainloop Authors.
2+
// Copyright 2024-2026 The Chainloop Authors.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@ import (
2727
"github.com/chainloop-dev/chainloop/pkg/attestation/crafter"
2828
"github.com/chainloop-dev/chainloop/pkg/attestation/renderer"
2929
"github.com/chainloop-dev/chainloop/pkg/attestation/signer"
30+
"github.com/chainloop-dev/chainloop/pkg/policies"
3031
"github.com/secure-systems-lab/go-securesystemslib/dsse"
3132
protobundle "github.com/sigstore/protobuf-specs/gen/pb-go/bundle/v1"
3233
"google.golang.org/grpc"
@@ -196,7 +197,7 @@ func (action *AttestationPush) Run(ctx context.Context, attestationID string, ru
196197
}
197198

198199
// Add attestation-level policy evaluations
199-
if err := crafter.EvaluateAttestationPolicies(ctx, attestationID, statement); err != nil {
200+
if err := crafter.EvaluateAttestationPolicies(ctx, attestationID, statement, policies.EvalPhasePush); err != nil {
200201
return nil, fmt.Errorf("evaluating attestation policies: %w", err)
201202
}
202203

app/cli/pkg/action/attestation_status.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2024-2025 The Chainloop Authors.
2+
// Copyright 2024-2026 The Chainloop Authors.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@ import (
2626
v1 "github.com/chainloop-dev/chainloop/pkg/attestation/crafter/api/attestation/v1"
2727
"github.com/chainloop-dev/chainloop/pkg/attestation/renderer"
2828
"github.com/chainloop-dev/chainloop/pkg/attestation/renderer/chainloop"
29+
"github.com/chainloop-dev/chainloop/pkg/policies"
2930
)
3031

3132
type AttestationStatusOpts struct {
@@ -156,7 +157,7 @@ func (action *AttestationStatus) Run(ctx context.Context, attestationID string,
156157
}
157158

158159
// Add attestation-level policy evaluations
159-
if err := c.EvaluateAttestationPolicies(ctx, attestationID, statement); err != nil {
160+
if err := c.EvaluateAttestationPolicies(ctx, attestationID, statement, policies.EvalPhaseStatus); err != nil {
160161
return nil, fmt.Errorf("evaluating attestation policies: %w", err)
161162
}
162163

app/controlplane/api/gen/frontend/workflowcontract/v1/crafting_schema.ts

Lines changed: 87 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/api/gen/jsonschema/workflowcontract.v1.PolicySpecV2.jsonschema.json

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/api/gen/jsonschema/workflowcontract.v1.PolicySpecV2.schema.json

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)