cdxgen: [validation] Invalid externalReferences URLs may be present in the SBOM
With DependencyTrack 4.11 validating SBOM with schema validation at upload, I’ve discovered that some SBOM may have invalid externalReferences. For example:
"externalReferences": [
{
"type": "vcs",
"url": "git@gitlab.com:behat-chrome/chrome-mink-driver.git"
}
],
coming from composer dmore/chrome-mink-driver package.
Indeed, an externalReference should be a iri-reference or a #/definitions/bomLink according to the JsonSchema.
The problem is that git@gitlab.com:behat-chrome/chrome-mink-driver.git is neither a #/definitions/bomLink nor an iri-reference (that should be of the form scheme://... according to the RFC).
If we can “convert” git@gitlab.com:behat-chrome/chrome-mink-driver.git to https://gitlab.com/behat-chrome/chrome-mink-driver.git it would be nice, but if not, we’d better drop the reference than write an invalid one.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 3
- Comments: 38 (16 by maintainers)
This is not the only issues. I have seen BOMs that contain whitespace around the URL inside the reference, like
Or failed replacements like
I’m re-closing this issue
It’s fixed in json-schema-validator@1.4.2 that is used in cyclonedx-core-java@9.0.4 that is used in dependency-track@4.11.4
I’ve started to work on it by enabling strict JSON Schema validation on this PR: https://github.com/CycloneDX/cdxgen/pull/1128
Hey in my case as well it is no longer getting stuck Thanks @prabhu
Look good, thanks! @prabhu
cdxgen generates SBOMs by analyzing files. During that analysis, it extracts information from files such as package.json, pom.xml, composer.json, … In those information, there is an external reference URLs corresponding to the URL of the corresponding dependency. CycloneDX format (the specification for SBOM) forces those external references to be an “iri-reference” (to simplify, an URL). The problem is that the external reference extracted from package.json, pom.xml, composer.json, … is sometimes NOT an iri-reference (such as git@…). Before this PR, the generated SBOM was sometimes invalid according to the CycloneDX specification. Now, it logs a warning message for every external reference URL that is not a valid iri-reference and excludes that external reference from the generated SBOM to prevent it to be invalid.
So, I see 3 “solutions”:
git@github.com:micrometer-metrics/micrometer.gitto something likehttps://github.com/micrometer-metrics/micrometer, but it requires some contribution to the micrometer-metrics/micrometer source codegit@github.com:micrometer-metrics/micrometer.git, but how would you convert${repository.url}or any other incorrect value?I’ve created an issue on json-schema-validator that is used by DependencyTrack. In my opinion, “http://” should be considered as valid as it is allowed by the RFC (if I understand it well), event though it’s not a very useful value. So the fix should be on DependencyTrack/json-schema-validator side and not on cdxgen/validate-iri.
I had this issue a well and had it in Java – unfortunately not Maven but Gradle. Seems to work perfectly though!
@prabhu sorry no java over here.
@prabhu, thanks a lot for the fix. It works perfectly.
https://github.com/DependencyTrack/dependency-track/discussions/3775#discussioncomment-9604636
@setchy and all, @timmyteo has kindly volunteered to look into this. Please work with him to get this tested and released.
I think we may need to trim the url, and then ideally use the same regex DTrack is using to validate [IRI RFC 3987](https://datatracker.ietf.org/doc/html/rfc3987
We’ve had instances like the following being rejected
UNKNOWNgit@github.com:follow-redirects/follow-redirects.git