feat(crafter): Extract evidence information from input #2503
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR extends the Evidence crafter to automatically parse JSON evidence files and extract structured metadata as material annotations. This matches with the custom policies documentation which recommends JSON format for evidence materials.
Changes
evidence.go: Extended theCraftmethod to intelligently parse evidence files and extract metadata when they follow a specific JSON structuretryExtractAnnotationshelper: Attempts to parse evidence as JSON and extractsidandschemafields as annotationscustomEvidencestruct: Represents the expected structure withid,schema(optional), anddatafieldschainloop.material.evidence.id- Evidence identifierchainloop.material.evidence.schema- Schema reference URLExample from an attestation
{ "annotations": { "chainloop.material.cas": true, "chainloop.material.evidence.id": "my-awesome-report-id", "chainloop.material.name": "material-1761835944639691000", "chainloop.material.type": "EVIDENCE" }, "digest": { "sha256": "337199c3efb1cf6a579b6f035597ad9a16a178a42a962eb1c32f5f28ce6f770e" }, "name": "report.json" }