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

feat(cyclonedx): add file checksums to CycloneDX reports #7507

Merged
merged 3 commits into from
Oct 18, 2024

Conversation

Churro
Copy link
Contributor

@Churro Churro commented Sep 13, 2024

Description

When creating SBOMs from JAR archives, the CycloneDX currently doesn't include file checksums, although they're available internally. For SPDX, checksums are included since #3888. This PR supplements file checksums for CycloneDX SBOMs.

I'm not aware how this could be tested but I have verified that there are marshalling tests for CycloneDX that ensure hashes are correctly encoded.

To provide a before / after example setup:

$ wget https://repo1.maven.org/maven2/com/google/guava/guava/33.3.0-jre/guava-33.3.0-jre.jar
$ trivy rootfs guava-33.3.0-jre.jar --format cyclonedx

Before this PR, the components section of this SBOM looked like this:

  "components": [
    {
      "bom-ref": "pkg:maven/com.google.guava/guava@33.3.0-jre",
      "type": "library",
      "group": "com.google.guava",
      "name": "guava",
      "version": "33.3.0-jre",
      "purl": "pkg:maven/com.google.guava/guava@33.3.0-jre",
      "properties": [
        {
          "name": "aquasecurity:trivy:FilePath",
          "value": "guava-33.3.0-jre.jar"
        },
        {
          "name": "aquasecurity:trivy:PkgType",
          "value": "jar"
        }
      ]
    }
  ]

After this PR, the output also includes a hashes section with the SHA-1 digest of the guava JAR:

  "components": [
    {
      "bom-ref": "pkg:maven/com.google.guava/guava@33.3.0-jre",
      "type": "library",
      "group": "com.google.guava",
      "name": "guava",
      "version": "33.3.0-jre",
      "hashes": [
        {
          "alg": "SHA-1",
          "content": "13b4d0924e6023eda04b4c7aa83b32dfedf735a7"
        }
      ],
      "purl": "pkg:maven/com.google.guava/guava@33.3.0-jre",
      "properties": [
        {
          "name": "aquasecurity:trivy:FilePath",
          "value": "guava-33.3.0-jre.jar"
        },
        {
          "name": "aquasecurity:trivy:PkgType",
          "value": "jar"
        }
      ]
    }
  ]

Related issues

None

Related PRs

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).

@Churro Churro requested a review from knqyf263 as a code owner September 13, 2024 23:22
@Churro
Copy link
Contributor Author

Churro commented Oct 10, 2024

@knqyf263 or @DmitriyLewen, I understand that this PR came unrequested but it would be highly appreciated if you could dedicate some time to review it 😊

@knqyf263
Copy link
Collaborator

Thanks for your contribution. I've merged the main branch to resolve flaky tests due to GHCR rate limits. The test is failing now.

@knqyf263 knqyf263 enabled auto-merge October 18, 2024 06:52
@knqyf263 knqyf263 added this pull request to the merge queue Oct 18, 2024
Merged via the queue into aquasecurity:main with commit c225883 Oct 18, 2024
12 checks passed
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.

2 participants