cyclonedx-dotnet: "Unable to locate valid bom ref" when AssemblyName is != project name in referenced project

We are facing an issue where the the cyclonedx-dotnet app exits with the message Unable to locate valid bom ref and code 7.

The problem can be triggered by the following setup:

  • Project1 references Project2
  • Project2 has the AssemblyName Test.Project2
  • Project2 references Project3

@mtsfoni I have once again created a test project for you to reproduce the problem. https://github.com/ag-lls/RefTest

The problem does not trigger if Project2 does not reference Project3 or if Project2’s AssemblyName is equal to the project name exactly.

We think the issue maybe has something to do with how a referenced project is getting read out as a project reference and as a dependency.
As a project reference, the name of the project is used (in this case Project2), while as a dependency the AssemblyName is used (in this case Test.Project2). This results in the two entries not getting caught by the UnionWith in line 254 in ProjectFileService.cs.

image

image

This seems to be the case because for a dependency (getDotnetDependencys), the tool reads out the projects project.assets.json file, in which the “projectName” field has the AssemblyName as a value.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

Just tested the new release, works like a charm! 👍

Well, if you would just use the name as fallback, we would miss something in our case. Since its “ABC.Project” and it would then be just “Project”, which in turn wouldnt be correct sbom-wise, or would it? So if we replace that part we would still have “ABC.Project” in the end.

Got it, I built it your way. I might add a few more tests, but I intend to release it as it is now, if everything works out.

Thanks for your support.

I am quite swamped currently but looking ahead at a week of vacation before the holidays

Expect another release in a week or so