Skip to content

fix(schema): require project unless project-si-source is set - #236

Open
cvas22 wants to merge 2 commits into
ossf:mainfrom
cvas22:schema/119-project-or-source
Open

cvas22 wants to merge 2 commits into
ossf:mainfrom
cvas22:schema/119-project-or-source

Conversation

@cvas22

@cvas22 cvas22 commented Nov 21, 2026

Copy link
Copy Markdown

Fixes #119

The descriptions of project and repository already say when each one is required, but the schema left both optional, so a file with neither passed cue vet. I added two conditional fields to #SecurityInsights: without header.project-si-source the file needs project, and with it the file needs repository. A parent file can still ship just header and project. I didn't forbid project in child files since the description only says to omit it.

Notes

All the examples and .github/security-insights.yml still validate. I added tests to tests/schema/required-fields.test.js, and the two rejection cases fail without the schema change.

The editor's cue-parser.js didn't know about if blocks, so I made it skip them. make check-schema-fallback passes with no change to the fallback. cue2openapi ignores the conditionals for now, so the OpenAPI output doesn't change. I can add that in a follow-up if you want it there too.

@cvas22
cvas22 requested a review from a team as a code owner November 21, 2026 17:09

@jmeridth jmeridth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 (summary) Thanks for picking up #119. The schema now enforces what the project and repository descriptions already promised, and the conditionals hold in both directions. Two things to sort out before merge: the LLM prompt checksum and a question about generated Go types, both inline.

Comment thread spec/schema.cue Resolved
Comment thread spec/schema.cue

// A file without `header.project-si-source` must carry its own project information.
if header["project-si-source"] == _|_ {
project!: #Project

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 (medium) Heads-up: cue exp gengotypes reads this conditional project! as always required, so the generated Go field loses omitempty. ossf/si-tooling generates its types that way, so a regenerate there would start writing a project key into child files. As far as I can tell the @go optional attributes don't fix it, and splitting the rules into a separate definition does but needs parser changes. Is that worth handling here, or better as a follow-up with si-tooling?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx for the heads-up, I haven't run gengotypes against this. I'd rather leave the Go types to a follow-up with si-tooling than add parser changes here, unless you want it in this PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 A follow-up works for me. Could you open an issue on ossf/si-tooling describing the omitempty change, so it's tracked before the next type regeneration there?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened ossf/si-tooling#80 for it. thx

Comment thread docs/editor/js/cue-parser.js Resolved
A file without header.project-si-source now has to include project, and a
child file that sets it has to include repository, which is what the field
descriptions already say. The editor's CUE parser skips the conditional
blocks so the fallback schema stays the same.

Fixes ossf#119

Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
Points SCHEMA_URL at the schema commit and updates SCHEMA_SHA256.

Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
@cvas22

cvas22 commented Nov 24, 2026

Copy link
Copy Markdown
Author

Opened ossf/si-tooling#80 to track it.

This branch has not been deployed

No deployments
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.

Schema improvement - possibly implemented using cue's struct disjunction

2 participants