Skip to content

Commit c67c887

Browse files
committed
Update testing, fix SPDX 2.3
1 parent c354d2e commit c67c887

File tree

5 files changed

+26
-17
lines changed

5 files changed

+26
-17
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ jobs:
1414
steps:
1515
- uses: actions/checkout@v3
1616
- uses: ./
17+
with:
18+
filePath: "test"
19+

dist/index.js

Lines changed: 11 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,18 @@ function getManifestFromSpdxFile(document, fileName) {
4343
document.packages?.forEach(pkg => {
4444
let packageName = pkg.name;
4545
let packageVersion = pkg.packageVersion;
46-
let purl = pkg.externalRefs?.find(ref => ref.referenceCategory === "PACKAGE-MANAGER" && ref.referenceType === "purl")?.referenceLocator;
46+
// SPDX 2.3 defines a purl field
47+
let purl = pkg.purl;
48+
4749
if (purl == null || purl == undefined) {
50+
purl = pkg.externalRefs?.find(ref => ref.referenceCategory === "PACKAGE-MANAGER" && ref.referenceType === "purl")?.referenceLocator;
51+
} else if (purl == null || purl == undefined) {
4852
purl = `pkg:generic/${packageName}@${packageVersion}`;
49-
} else {
50-
// Working around weird encoding issues from an SBOM generator
51-
// Find the last instance of %40 and replace it with @
52-
purl = replaceVersionEscape(purl);
53-
}
54-
55-
53+
}
54+
55+
// Working around weird encoding issues from an SBOM generator
56+
// Find the last instance of %40 and replace it with @
57+
purl = replaceVersionEscape(purl);
5658

5759
let relationships = document.relationships?.find(rel => rel.relatedSpdxElement == pkg.SPDXID && rel.relationshipType == "DEPENDS_ON" && rel.spdxElementId != "SPDXRef-RootPackage");
5860
if (relationships != null && relationships.length > 0) {
@@ -83,6 +85,7 @@ function searchFiles() {
8385

8486
// Fixes issues with an escaped version string
8587
function replaceVersionEscape(purl) {
88+
//If there's an "@" in the purl, then we don't need to do anything.
8689
if (!purl.includes("@")) {
8790
let index = purl.lastIndexOf("%40");
8891
if (index > 0) {
File renamed without changes.

0 commit comments

Comments
 (0)