Skip to content

Commit e2f036c

Browse files
committed
fix(policies): add schema validation for finding_type and document proto mapping
- Add buf.validate string.in constraint on finding_type field - Document the mapping between finding_type values and their proto messages Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>
1 parent c54103c commit e2f036c

5 files changed

Lines changed: 38 additions & 12 deletions

File tree

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

Lines changed: 0 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.Metadata.jsonschema.json

Lines changed: 12 additions & 2 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.Metadata.schema.json

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

app/controlplane/api/workflowcontract/v1/crafting_schema.pb.go

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

app/controlplane/api/workflowcontract/v1/crafting_schema.proto

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,17 @@ message Metadata {
282282

283283
// Declares the structured output schema for policy violations.
284284
// When set, the policy engine validates that violations conform to the
285-
// corresponding proto message (e.g., PolicyVulnerabilityFinding).
286-
// Valid values: "VULNERABILITY", "SAST", "LICENSE_VIOLATION"
287-
optional string finding_type = 7;
285+
// corresponding proto message:
286+
// VULNERABILITY -> attestation.v1.PolicyVulnerabilityFinding
287+
// SAST -> attestation.v1.PolicySASTFinding
288+
// LICENSE_VIOLATION -> attestation.v1.PolicyLicenseViolationFinding
289+
optional string finding_type = 7 [(buf.validate.field).string = {
290+
in: [
291+
"VULNERABILITY",
292+
"SAST",
293+
"LICENSE_VIOLATION"
294+
]
295+
}];
288296
}
289297

290298
message PolicySpec {

0 commit comments

Comments
 (0)