Skip to content

Commit 7a21421

Browse files
authored
feat: add policyEvaluationsCount and policyViolationsCount to attestation predicate (#2976)
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>
1 parent 797862b commit 7a21421

13 files changed

Lines changed: 288 additions & 30 deletions

app/controlplane/api/controlplane/v1/response_messages.pb.go

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

app/controlplane/api/controlplane/v1/response_messages.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ message AttestationItem {
117117
bool blocked = 3;
118118
bool has_violations = 4;
119119
bool has_gated_violations = 5;
120+
// Total number of policy evaluations
121+
int32 evaluations_count = 6;
122+
// Total number of policy violations across all evaluations
123+
int32 violations_count = 7;
120124
}
121125

122126
message EnvVariable {

app/controlplane/api/gen/frontend/controlplane/v1/response_messages.ts

Lines changed: 39 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/controlplane.v1.AttestationItem.PolicyEvaluationStatus.jsonschema.json

Lines changed: 24 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/controlplane.v1.AttestationItem.PolicyEvaluationStatus.schema.json

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

app/controlplane/internal/service/attestation.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,8 @@ func bizAttestationToPb(att *biz.Attestation, predicate chainloop.NormalizablePr
563563
Blocked: policyEvaluationStatus.Blocked,
564564
HasViolations: policyEvaluationStatus.HasViolations,
565565
HasGatedViolations: policyEvaluationStatus.HasGatedViolations,
566+
EvaluationsCount: int32(policyEvaluationStatus.EvaluationsCount),
567+
ViolationsCount: int32(policyEvaluationStatus.ViolationsCount),
566568
},
567569
Bundle: att.Bundle,
568570
}, nil

pkg/attestation/renderer/chainloop/chainloop.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ type PolicyEvaluationStatus struct {
5757
HasViolations bool
5858
// Whether the attestation has gated policy violations
5959
HasGatedViolations bool
60+
// Total number of policy evaluations
61+
EvaluationsCount int
62+
// Total number of policy violations across all evaluations
63+
ViolationsCount int
6064
}
6165

6266
type NormalizedMaterial struct {

pkg/attestation/renderer/chainloop/testdata/attestation.output-2.v0.2.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@
121121
"policyAttBlocked": false,
122122
"policyBlockBypassEnabled": false,
123123
"policyCheckBlockingStrategy": "ADVISORY",
124+
"policyEvaluationsCount": 0,
124125
"policyHasViolations": false,
126+
"policyViolationsCount": 0,
125127
"runnerType": "RUNNER_TYPE_UNSPECIFIED"
126128
}
127129
}

pkg/attestation/renderer/chainloop/testdata/attestation.output-2.v2.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@
121121
"policyAttBlocked": false,
122122
"policyBlockBypassEnabled": false,
123123
"policyCheckBlockingStrategy": "ADVISORY",
124+
"policyEvaluationsCount": 0,
124125
"policyHasViolations": false,
126+
"policyViolationsCount": 0,
125127
"runnerType": "RUNNER_TYPE_UNSPECIFIED"
126128
}
127129
}

pkg/attestation/renderer/chainloop/testdata/attestation.output.v0.2.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@
117117
}
118118
]
119119
},
120+
"policyEvaluationsCount": 1,
120121
"policyHasViolations": true,
122+
"policyViolationsCount": 1,
121123
"runnerType": "GITHUB_ACTION"
122124
}
123125
}

0 commit comments

Comments
 (0)