Skip to content

Conversation

@thomasschafer
Copy link
Contributor

@thomasschafer thomasschafer commented Nov 21, 2025

  • Tests written and linted ℹ︎
  • Documentation written ℹ︎ - n/a
  • Commit history is tidy ℹ︎

What this does

If a uv project has no dependencies then the SBOM will have no components with a pip PURL, e.g.:

{
  "bomFormat": "CycloneDX",
  "specVersion": "1.5",
  "version": 1,
  "serialNumber": "urn:uuid:ac3b8db9-2725-4a70-b080-86bec40fe7db",
  "metadata": {
    "timestamp": "2025-11-24T15:20:24.447458000Z",
    "tools": [ { "vendor": "Astral Software Inc.", "name": "uv", "version": "0.9.11" } ],
    "component": {
      "type": "library",
      "bom-ref": "[email protected]",
      "name": "no-deps",
      "version": "0.1.0"
    }
  },
  "components": [],
  "dependencies": [
    {
      "ref": "[email protected]",
      "dependsOn": []
    }
  ]
}

This means that, when the SBOM is converted to dep-graphs, no dep-graphs are returned as the conversion endpoint cannot determine the ecosystem.

To work around this, we decided to manually add an empty dep-graph in this case, which this PR implements. To achieve this I've added a new Metadata field to the Findings struct which contains enough information to construct an empty dep-graph. I'm not sure if this is the best approach so happy to hear alternative ideas here.

@snyk-io
Copy link

snyk-io bot commented Nov 21, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@thomasschafer thomasschafer changed the base branch from main to chore/pass-target-file-out-of-plugin November 21, 2025 15:11
@thomasschafer thomasschafer force-pushed the chore/add-empty-dep-graph-when-no-deps branch from 2931a01 to baf1368 Compare November 21, 2025 15:33
@thomasschafer thomasschafer force-pushed the chore/pass-target-file-out-of-plugin branch 2 times, most recently from c0d5ab3 to 5b5372d Compare November 21, 2025 15:35
@thomasschafer thomasschafer force-pushed the chore/add-empty-dep-graph-when-no-deps branch 3 times, most recently from 1009858 to 171bf6c Compare November 21, 2025 16:45
@thomasschafer thomasschafer force-pushed the chore/pass-target-file-out-of-plugin branch from 6af74c1 to 3178baf Compare November 21, 2025 16:47
@thomasschafer thomasschafer force-pushed the chore/add-empty-dep-graph-when-no-deps branch 3 times, most recently from 3efc404 to 03a1e8e Compare November 21, 2025 16:51
@thomasschafer thomasschafer force-pushed the chore/pass-target-file-out-of-plugin branch from 3178baf to 88d4414 Compare November 21, 2025 16:55
@thomasschafer thomasschafer force-pushed the chore/add-empty-dep-graph-when-no-deps branch 3 times, most recently from ed74368 to d0516fc Compare November 21, 2025 17:02
@thomasschafer thomasschafer force-pushed the chore/pass-target-file-out-of-plugin branch from 88d4414 to c46066c Compare November 21, 2025 17:03
@thomasschafer thomasschafer force-pushed the chore/add-empty-dep-graph-when-no-deps branch 2 times, most recently from b8b3e7c to 0797713 Compare November 24, 2025 11:39
Base automatically changed from chore/pass-target-file-out-of-plugin to main November 24, 2025 11:52
@github-actions github-actions bot added the chore label Nov 24, 2025
@thomasschafer thomasschafer force-pushed the chore/add-empty-dep-graph-when-no-deps branch 3 times, most recently from 135c2d5 to e0d894c Compare November 24, 2025 15:07
@thomasschafer thomasschafer changed the title chore: add empty dep graph when there are no dependencies chore: add empty dep-graph when there are no dependencies Nov 24, 2025
@thomasschafer thomasschafer force-pushed the chore/add-empty-dep-graph-when-no-deps branch from e0d894c to a6187de Compare November 24, 2025 15:32
@thomasschafer thomasschafer marked this pull request as ready for review November 24, 2025 15:50
@thomasschafer thomasschafer requested review from a team as code owners November 24, 2025 15:50
@thomasschafer thomasschafer force-pushed the chore/add-empty-dep-graph-when-no-deps branch from a6187de to 47444b9 Compare November 24, 2025 15:52
Sbom: []byte(`{"mock":"sbom"}`),
Sbom: []byte(`{"mock":"sbom"}`),
Metadata: scaplugin.Metadata{
PackageManager: "pip",
Copy link
Collaborator

Choose a reason for hiding this comment

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

The pip package manager confuses me. Why are we impersonating a different package manager which we already support?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is to be changed. We have an RCR pending second Jedi's review to add a new package manager to Registry. Once Registry understands uv, we can use it. Before then, not sure if we can use it and why risk it if we can easily adjust once all bits are in place.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks, I was missing this context.


// Verifies that the SBOM is valid JSON and has a root component.
func validateSBOM(sbomData []byte) error {
func validateSBOM(sbomData []byte) (*scaplugin.Metadata, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: maybe i'm getting hung up on the name too much, but this function does not seem to only validate, but also parse the input and now also return some metadata? should we name it differently to reflect this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, updated the name

return depGraphList, nil
}

func workflowDataFromDepGraph(depGraph any, normalisedTargetFile, targetFileFromPlugin string) (workflow.Data, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

is the any type intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was as the dep-graph from the conversion endpoint was just being unmarshalled into an any, but after you mentioned it I thought it might be worth exploring unmarshalling into a proper DepGraph type. I had to implement a custom UnmarshalJSON method to achieve this as we only want to unmarshall the data to a DepGraph if it has type "depGraph", but it seems to work. Have a look at the latest commit and let me know what you think!

Copy link
Collaborator

Choose a reason for hiding this comment

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

nice! ok i didn't see that this was coming from this polymorphic "facts" array.

@thomasschafer thomasschafer force-pushed the chore/add-empty-dep-graph-when-no-deps branch from a13142e to d2ed715 Compare November 25, 2025 16:49
@thomasschafer thomasschafer force-pushed the chore/add-empty-dep-graph-when-no-deps branch from d2ed715 to 6f764e2 Compare November 26, 2025 08:55
@thomasschafer thomasschafer force-pushed the chore/add-empty-dep-graph-when-no-deps branch from 6f764e2 to 4d6f028 Compare November 26, 2025 09:04
@thomasschafer thomasschafer merged commit c1b0670 into main Nov 26, 2025
15 checks passed
@thomasschafer thomasschafer deleted the chore/add-empty-dep-graph-when-no-deps branch November 26, 2025 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants