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

Report Yarn v3/v4 patches as pedigree rather than components #784

Merged
merged 4 commits into from
Jan 27, 2025

Conversation

taylormadore
Copy link
Contributor

Yarn has a patch protocol for the package patching feature. Patches should not be reported as independent Components in the SBOM, but should instead be reported as pedigree for the patched "regular" package Component.

Maintainers will complete the following section

  • Commit messages are descriptive enough
  • Code coverage from testing does not decrease and new code is covered
  • Docs updated (if applicable)
  • Docs links in the code are still valid (if docs were updated)

Note: if the contribution is external (not from an organization member), the CI
pipeline will not run automatically. After verifying that the CI is safe to run:

Copy link
Member

@eskultety eskultety left a comment

Choose a reason for hiding this comment

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

Since this is a WIP, I approached this as a first round of reviews, so not very thorough. That said, it is pretty straight forward and makes sense, so you should flip the Draft switch :) .

cachi2/core/package_managers/yarn/locators.py Outdated Show resolved Hide resolved
cachi2/core/models/sbom.py Show resolved Hide resolved
cachi2/core/models/sbom.py Show resolved Hide resolved
cachi2/core/package_managers/yarn/resolver.py Show resolved Hide resolved
cachi2/core/package_managers/yarn/resolver.py Outdated Show resolved Hide resolved
Copy link
Contributor

@brunoapimentel brunoapimentel left a comment

Choose a reason for hiding this comment

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

Overall, this LGTM. I think we can mark it as ready to review, I just need to take a better look at tests before giving the final ack.

@taylormadore taylormadore force-pushed the yarn-patches branch 2 times, most recently from 011244f to d277261 Compare January 20, 2025 22:02
@taylormadore taylormadore marked this pull request as ready for review January 20, 2025 23:00
In yarn v4, optional, builtin patches are now denoted with the prefix
`optional!`. Handle this in addition to the yarn v3 prefix for the same

Signed-off-by: Taylor Madore <[email protected]>
Adds an optional Pedigree for the Component model according to:
https://cyclonedx.org/docs/1.6/json/#components_items_pedigree_patches

For the PatchDiff model, provide a URL but not a text diff in the SBOM
since it is not required by the schema.

Signed-off-by: Taylor Madore <[email protected]>
Instead of reporting yarn patches as independent Components in the SBOM,
report them instead as Pedigree for the parent, non-patch Component.

This uses the Pedigree model of SBOM Components, which was implemented
in accordance with:
https://cyclonedx.org/docs/1.6/json/#components_items_pedigree_patches

Yarn has the concept of "builtin" patches that are applied by yarn
itself to make certain features of yarn work. These are reported out of
the Yarn source repository for currently known patches from the compat
plugin.

Signed-off-by: Taylor Madore <[email protected]>
@taylormadore taylormadore added this pull request to the merge queue Jan 27, 2025
Merged via the queue into hermetoproject:main with commit db6e6d9 Jan 27, 2025
15 checks passed
@taylormadore taylormadore deleted the yarn-patches branch January 27, 2025 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants