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

BOM downloads default to "SNAPSHOT" version when project version is unassigned #4112

Closed
2 tasks done
lukas-braune opened this issue Sep 2, 2024 · 4 comments · Fixed by #4142
Closed
2 tasks done
Labels
defect Something isn't working good first issue Good for newcomers p3 Nice-to-have features size/S Small effort
Milestone

Comments

@lukas-braune
Copy link
Contributor

Current Behavior

When downloading BOMs via Dependency-Track's frontend (Components > Download BOM) and no version is assigned to the project (Project Details > Version), the generated CycloneDX document defaults to the version SNAPSHOT in metadata.component.version, e.g.:

{
  "bomFormat" : "CycloneDX",
  "specVersion" : "1.5",
  "serialNumber" : "urn:uuid:c60df495-ab6a-4677-b825-5940811a7c3b",
  "version" : 1,
  "metadata" : {
    "timestamp" : "2024-09-02T08:10:01Z",
    "tools" : [
      {
        "vendor" : "OWASP",
        "name" : "Dependency-Track",
        "version" : "4.11.7"
      }
    ],
    "component" : {
      "type" : "application",
      "bom-ref" : "f6b74dfe-e8aa-41c9-ab8b-03e285165273",
      "name" : "Test BOM",
      "version" : "SNAPSHOT"
    }
  },

Steps to Reproduce

  1. Create a new project and leave the version field blank.
  2. In the newly created project, go to Components tab, click on Download BOM, and select one of the available options.
  3. Check the generated BOM for metadata.component.version to confirm that the version is set to SNAPSHOT.

Expected Behavior

If no version is assigned to a project in Dependency-Track, the metadata.component.version field in the downloaded BOMs should be left empty. This field is optional in the CycloneDX specification.

Dependency-Track Version

4.11.7

Dependency-Track Distribution

Container Image

Database Server

PostgreSQL

Database Server Version

15.8

Browser

Google Chrome

Checklist

@lukas-braune lukas-braune added defect Something isn't working in triage labels Sep 2, 2024
@nscuro nscuro added p3 Nice-to-have features good first issue Good for newcomers size/S Small effort and removed in triage labels Sep 2, 2024
@nscuro
Copy link
Member

nscuro commented Sep 2, 2024

The version is set here:

if (StringUtils.trimToNull(project.getVersion()) == null) {
cycloneComponent.setVersion("SNAPSHOT"); // Version is required per CycloneDX spec
} else {
cycloneComponent.setVersion(StringUtils.trimToNull(project.getVersion()));
}

It seems like component.version was a required field in earlier versions of the CycloneDX spec.

component.version is a required field in CycloneDX v1.3 and earlier: https://cyclonedx.org/docs/1.3/json/#components_items_version

@nscuro
Copy link
Member

nscuro commented Sep 2, 2024

We could technically exploit an oversight in the spec by setting it to an empty string instead: CycloneDX/specification#461

@Gepardgame
Copy link
Contributor

@nscuro I added a fix for that #4142

@nscuro nscuro added this to the 4.12 milestone Sep 12, 2024
Copy link
Contributor

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
defect Something isn't working good first issue Good for newcomers p3 Nice-to-have features size/S Small effort
Projects
None yet
3 participants