Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add structured data attestor #408

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

feat: add structured data attestor #408

wants to merge 5 commits into from

Conversation

colek42
Copy link
Member

@colek42 colek42 commented Jan 12, 2025

What this PR does / why we need it
This PR introduces a new structured data attestor that handles JSON/YAML files by:

Parsing and canonicalizing their content (Vendored a JSON Canonicalization Scheme).
Storing a digest of the original file.
Optionally running user-defined jq queries (subject queries) to extract and store additional subject digests.
Adding a console logger for debugging tests

This helps us:
Ensure a reliable canonical form for any structured data,
Provide flexible per-field or per-expression queries for advanced pipelines.

image image

@ChaosInTheCRD
Copy link
Collaborator

Hi @colek42! What happens in the event that I am using some other attestors that parse json (e.g., sbom, vex attestors)? We probably want to make sure that we can call the json attestor in conjunction with those other attestors.

@colek42
Copy link
Member Author

colek42 commented Jan 13, 2025

Hi @colek42! What happens in the event that I am using some other attestors that parse json (e.g., sbom, vex attestors)? We probably want to make sure that we can call the json attestor in conjunction with those other attestors.

I think it should just work -- It probably makes sense to add a test for that.

@mikhailswift
Copy link
Member

How does this handle the case where there are multiple json files in the products?

attestation/jsonattestor/json.go Outdated Show resolved Hide resolved
attestation/jsonattestor/json.go Outdated Show resolved Hide resolved
attestation/jsonattestor/json.go Outdated Show resolved Hide resolved
attestation/jsonattestor/json_test.go Outdated Show resolved Hide resolved
@mikhailswift
Copy link
Member

Played around with this locally a bit and can confirm it works.

It does need an import added to imports.go

The directory should probably be json instead of jsonattestor to match the attestor's name being registered

@colek42
Copy link
Member Author

colek42 commented Jan 17, 2025

Thanks for the great code review. I'll incorporate this feedback into the k8smanifest attestor as well.

internal/jsoncanonicalizer/jsoncanonicalizer.go Dismissed Show dismissed Hide dismissed
internal/jsoncanonicalizer/jsoncanonicalizer.go Dismissed Show dismissed Hide dismissed
@colek42 colek42 force-pushed the json_attestor branch 2 times, most recently from 23704ac to 47818a5 Compare January 17, 2025 18:41
@colek42 colek42 changed the title feat/add json attestor feat: add structured data attestor Jan 17, 2025
Cole Kennedy added 3 commits January 21, 2025 09:46
-supports attestations on json/multi doc yaml
-canancolizes data
-adds canacolization library to internal
-adds a console logger used to debig tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants