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(sbom): fix error when parent of SPDX Relationships is not a package. #6399

Merged

Conversation

DmitriyLewen
Copy link
Contributor

@DmitriyLewen DmitriyLewen commented Mar 27, 2024

Description

When parent from Relationship is not package (e.g. File) - Trivy returns error. (see #6391)
e.g.:

    {
      "relationshipType": "DESCRIBED_BY",
      "relatedSpdxElement": "SPDXRef-DOCUMENT",
      "spdxElementId": "SPDXRef-File--Modules-Microsoft.PowerShell.PSResourceGet--manifest-spdx-2.2-manifest.spdx.json-2B9FB98F5CA97DC84FD382A8F8E68F663C003362"
    }

We only need to add to BOM Relationships relationships between packages

Related issues

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

@DmitriyLewen DmitriyLewen self-assigned this Mar 27, 2024
@DmitriyLewen DmitriyLewen marked this pull request as ready for review March 27, 2024 03:31
@knqyf263
Copy link
Collaborator

@DmitriyLewen Could you add a test? I'd like to fully understand the case.

Comment on lines +241 to +244
// Check the wrong parent to avoid `panic`
if parent == nil {
return
}
Copy link
Contributor Author

@DmitriyLewen DmitriyLewen Mar 27, 2024

Choose a reason for hiding this comment

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

I added parent check in SPDX package (like we do for CycloneDX). But I added 1 more check here so that we don't panic if we use this function later somewhere else.

This may be additional change or we may want to add a log message here.
@knqyf263 wdyt?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks good

@DmitriyLewen
Copy link
Contributor Author

@knqyf263 added test in 4b74dcd

@knqyf263 knqyf263 added this pull request to the merge queue Mar 27, 2024
Merged via the queue into aquasecurity:main with commit 5f69937 Mar 27, 2024
14 checks passed
0intro pushed a commit to DataDog/trivy that referenced this pull request Apr 29, 2024
0intro pushed a commit to DataDog/trivy that referenced this pull request Aug 8, 2024
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.

Segmentation violation running trivy image with trivy v0.50.0
2 participants