Skip to content

fix: bound the component descriptor name, so a license source cannot outgrow its own contract - #42

Merged
bomly-guy merged 2 commits into
mainfrom
fix/bound-component-name
Sep 5, 2026
Merged

bomly-guy merged 2 commits into
mainfrom
fix/bound-component-name

Conversation

@bomly-guy

Copy link
Copy Markdown
Contributor

Closes #32.

What was wrong

PackageLicense.Source is documented as a component name and bounded at its gate. validateComponentDescriptor asked only that a name be non-blank. So a matcher named with 257 bytes was a valid component, and passing that name to the license set normalizer had its source silently erased one layer down from where the name was accepted.

The fix

The shape the issue asked for:

  • A shared bound, stated once. maxComponentNameLength lives in component.go next to ComponentDescriptor, with the contract documented on the type.
  • Enforced at the descriptor gate. validateComponentDescriptor refuses a name over the bound, one that is not valid UTF-8, or one carrying a control character. The name is measured trimmed, the way the source gate measures it, so the two agree on every value. All four kinds go through it.
  • The license source references it by name. maxLicenseSourceLength = maxComponentNameLength, replacing the coincidental tie to the contact-name allowance. The decline note recorded in package.go is replaced with the reason the two are now tied.

Control characters are rejected because the issue asked whether they should be, and the answer is the same one the source gate already gives: the name reaches published documents, and a newline corrupts SPDX's line-oriented tag form.

The new test pins both halves: the descriptor gate's accept and reject sets across all four validators, and the actual contract, that every name descriptor validation accepts survives as a license source.

Release note

⚠️ Minor release, not patch. Descriptor names over 256 bytes, or containing control characters or invalid UTF-8, now fail Validate*Descriptor. Plugins with such names validated before this change. No wire change: the JSON schema is untouched, and the bound is enforced in-process at validation.

The conformance suite stays green and the change is API-additive, so the CLI's example-plugin compile check is unaffected.

Verification

go test ./...
go vet ./...
gofmt -l .
go mod tidy -diff

🤖 Generated with Claude Code

PackageLicense.Source is a component name and is bounded at the gate;
descriptor validation asked only that a name be non-blank. So a matcher
with a 257-byte name was a valid component whose provenance the source
gate silently erased -- the shape of the bug #31 fixed, one layer down.

A shared maxComponentNameLength now lives with ComponentDescriptor,
validateComponentDescriptor enforces it (bounded, valid UTF-8, no
control characters, measured trimmed the way the source gate measures),
and maxLicenseSourceLength references it by name so the two domains
cannot drift again. Control characters are refused for the reason the
source gate refuses them: the name reaches published documents, and a
newline corrupts SPDX's tag form.

This rejects descriptors that validated before, so it ships in a minor
release with a release-notes callout.

Closes #32

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 45 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Team

Run ID: b60a1c16-7843-4fe8-b199-4a1aeb1c5a9d

📥 Commits

Reviewing files that changed from the base of the PR and between 1624880 and db457a4.

📒 Files selected for processing (5)
  • component.go
  • component_name_test.go
  • license_source_test.go
  • package.go
  • validate.go

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 78a7cc2351

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread validate.go
Trimming before the new checks let a control character at an edge
through ("\nmatcher") and let unbounded padding ride past a bound that
exists to be a resource limit, while the descriptor kept the untrimmed
value. Validation does not rewrite the name, so what passes must be
what gets marshaled. The source gate trims before measuring, which only
shrinks, so every name accepted here still survives there.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@bomly-guy
bomly-guy merged commit 1f4eed3 into main Sep 5, 2026
3 checks passed
@bomly-guy
bomly-guy deleted the fix/bound-component-name branch September 5, 2026 06:21
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.

Bound the component descriptor name, so a license source cannot outgrow its own contract

1 participant