Skip to content

Commit

Permalink
fix: ecosystems validate external references urls (#97)
Browse files Browse the repository at this point in the history
* fix: ecosystems validate urls

* fix: rename arg to ref and use url pkg name
  • Loading branch information
acidghost authored Jan 6, 2025
1 parent bc55e4d commit 7d69dae
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/ecosystems/enrich_cyclonedx.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package ecosystems

import (
"net/url"
"strings"
"time"

Expand Down Expand Up @@ -65,12 +66,15 @@ func enrichCDXLicense(comp *cdx.Component, data *packages.Version) {
}
}

func enrichExternalReference(comp *cdx.Component, url *string, refType cdx.ExternalReferenceType) {
if url == nil {
func enrichExternalReference(comp *cdx.Component, ref *string, refType cdx.ExternalReferenceType) {
if ref == nil {
return
}
if _, err := url.Parse(*ref); err != nil {
return
}
ext := cdx.ExternalReference{
URL: *url,
URL: *ref,
Type: refType,
}
if comp.ExternalReferences == nil {
Expand Down

0 comments on commit 7d69dae

Please sign in to comment.