Repository navigation
fix(policies): evaluate a non-JSON ARTIFACT material instead of failing - #3843
Conversation
A generic ARTIFACT holds arbitrary bytes, and a policy with no kind, such as upstream-check, applies to it while reading only chainloop_metadata. Decoding a ZIP as JSON failed the material with "failed to parse input", even with gate: false. When an ARTIFACT's content is not JSON, policies now get an empty object plus chainloop_metadata. JSON artifacts keep their content, and typed materials still fail on content that does not match their format. Records the choice as ATT-005 in the Attestation Process decisions. Fixes PFM-8294 Assisted-by: Claude Code Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev> Chainloop-Trace-Sessions: 0e3b127c-259e-426a-bf46-54e6f073f9c3
Assisted-by: Claude Code Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev> Chainloop-Trace-Sessions: 0e3b127c-259e-426a-bf46-54e6f073f9c3
PR validation — ✅ 3 passing
AI Session Checks — 🟡 82% · ✅ 0 failing
|
| Status | Attribution | File | Lines |
|---|---|---|---|
| modified | ai | pkg/attestation/crafter/api/attestation/v1/crafting_state_test.go |
+109 / -0 |
| modified | ai | pkg/policies/policies_test.go |
+35 / -0 |
| created | ai | pkg/policies/testdata/metadata_only.yaml |
+22 / -0 |
| modified | ai | pkg/attestation/crafter/api/attestation/v1/crafting_state.go |
+15 / -1 |
| modified | ai | docs/decisions/attestation-process.md |
+9 / -1 |
Policies (4)
| Status | Policy | Material | Messages |
|---|---|---|---|
| ✅ Passed | ai-config-ai-agents-allowed |
ai-coding-session-0e3b12 |
- |
| ✅ Passed | ai-config-no-dangerous-commands |
ai-coding-session-0e3b12 |
- |
| ✅ Passed | ai-config-no-secrets |
ai-coding-session-0e3b12 |
- |
| ✅ Passed | ai-config-mcp-servers-allowed |
ai-coding-session-0e3b12 |
- |
Security Checks — ✅ 7 passing
✅ AI Security Analysis
Reviewed this change against the project's security context (5 concerns hunted) — no introduced risk found.
View in Chainloop ↗ · How this works ↗
✅ secret-scan
| Status | Policy | Messages |
|---|---|---|
| ✅ Passed | secrets-detection |
- |
✅ sast-scan
| Status | Policy | Messages |
|---|---|---|
| ✅ Passed | owasp-top10-2025 |
- |
| ✅ Passed | sast |
- |
| ✅ Passed | cwe-top25 |
- |
| ✅ Passed | cwe-top26-40-cusp |
- |
✅ iac-scan
| Status | Policy | Messages |
|---|---|---|
| ✅ Passed | iac-misconfiguration |
- |
Scans not applied (2)
| Scan | Reason |
|---|---|
vulnerability-scan |
no manifest/lockfile changed |
github-actions-scan |
no workflow files changed |
Powered by Chainloop and Chainloop Trace
There was a problem hiding this comment.
All reported issues were addressed
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 5 files
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
A policy with no kind can read the content, not only chainloop_metadata. On a non-JSON ARTIFACT such a policy now sees an empty object. Correct the code comment and ATT-005 to say so. Assisted-by: Claude Code Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev> Chainloop-Trace-Sessions: 0e3b127c-259e-426a-bf46-54e6f073f9c3
Fixes PFM-8294.
chainloop att addfailed withfailed to parse inputwhen a policy was attached to anARTIFACTmaterial with non-JSON content, such as a ZIP file. It failed even withgate: false, and the material was not added. Before evaluating policies, the CLI decoded every material's content as JSON, andARTIFACThas no conversion step. A policy with no kind, such asupstream-check, applies to any material and reads onlychainloop_metadata, so the file's content never mattered to it.With this change:
ARTIFACTwhose content does not decode as JSON is evaluated as an empty object pluschainloop_metadata. It does not fail.ARTIFACTwith JSON content behaves as before, including the existing rule that only the first JSON value is read.Trade-off: a policy that reads the content of a non-JSON
ARTIFACTnow sees an empty object. A policy with avalid_inputrule reports it as skipped; one without can pass with no message. This includes a damaged JSON file, which used to fail the material. Before this change, a content-reading policy on a binary or textARTIFACTcould never run.The choice is recorded as ATT-005 on the Attestation Process Current Decisions page (
docs/decisions/attestation-process.md).This PR was written with the help of Claude Code.
🤖 Posted by Maximus bot (Claude Code) on behalf of @migmartri