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

fix: cyclonedx depends-on relationship inverted #1816

Merged

Conversation

shanealv
Copy link
Contributor

@shanealv shanealv commented May 15, 2023

When reading CycloneDX boms, the relationships defined in the "dependencies" sections are translated into "artifact.Relationship" objects. Previously, relationships were inverted by this process. That is, a CycloneDx dependency "a depends on b" was being read as "a dependency of b". This caused downstream processing to write out the dependency relationship incorrectly. This commit fixes the issue by inverting the relationship during decoding and adding a regression test.

Fixes #1815

When reading CycloneDX boms, the relationships defined in the
"dependencies" sections are translated into "artifact.Relationship"
objects. Previously, relationships were inverted by this process. That
is, a CyloneDx dependency "a depends on b" was being read as "a
dependency of b". This caused downstream processing to write out the
dependency relationship incorrectly. This commit fixes the issue by
inverting the relationship during decoding and adding a regression test.

See anchore#1815

Signed-off-by: Shane Alvarez <shane.alv@gmail.com>
Copy link
Contributor

@kzantow kzantow left a comment

Choose a reason for hiding this comment

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

Good catch @shanealv !

Signed-off-by: Keith Zantow <kzantow@gmail.com>
@kzantow
Copy link
Contributor

kzantow commented May 15, 2023

@shanealv I went ahead and ran make lint-fix to fix the imports/static analysis error and pushed. Apologies if that's an issue, happy to back this out if you want.

@kzantow kzantow merged commit 8046f09 into anchore:main May 15, 2023
spiffcs added a commit that referenced this pull request May 15, 2023
* main:
  fix: cyclonedx depends-on relationship inverted (#1816)
  fix: retain sbom cataloger relationships (#1509)
spiffcs added a commit that referenced this pull request May 18, 2023
* main: (32 commits)
  chore(deps): bump github.com/google/go-containerregistry (#1823)
  chore(deps): bump github.com/sirupsen/logrus from 1.9.0 to 1.9.1 (#1822)
  chore(deps): bump github.com/docker/docker (#1824)
  fix: update field plurality of 8.0.0 schema before release (#1820)
  fix: update cataloger to check for expressions before split (#1819)
  feat: update syft license concept to complex struct (#1743)
  fix: cyclonedx depends-on relationship inverted (#1816)
  fix: retain sbom cataloger relationships (#1509)
  feat: warn if parsing newer SBOM (#1810)
  feat: Add R cataloger (#1790)
  update cosign to v2 release (different go module) (#1805)
  fix: Reduce log spam on unknown relationship type (#1797)
  chore(deps): update bootstrap tools to latest versions (#1807)
  chore(deps): bump golang.org/x/net from 0.9.0 to 0.10.0 (#1802)
  chore(deps): bump github.com/docker/docker (#1795)
  chore(deps): bump github.com/google/go-containerregistry (#1796)
  chore(deps): update bootstrap tools to latest versions (#1792)
  Print package list when extra packages found (#1791)
  chore(deps): update bootstrap tools to latest versions (#1786)
  chore(deps): bump golang.org/x/term from 0.7.0 to 0.8.0 (#1787)
  ...

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
GijsCalis pushed a commit to GijsCalis/syft that referenced this pull request Feb 19, 2024
Signed-off-by: Shane Alvarez <shane.alv@gmail.com>
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.

CycloneDX Dependencies Relationships Inverted
2 participants