Skip to content

Commit

Permalink
Add purl to SBOM output
Browse files Browse the repository at this point in the history
  • Loading branch information
eoftedal committed Aug 15, 2024
1 parent 5e34e91 commit 8d17f2a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.4.0

* Add purl to SBOM output

## 1.3.0

* Add support for color output via --color
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"author": "Erlend Oftedal <[email protected]>",
"name": "retire-site-scanner",
"version": "1.3.0",
"version": "1.4.0",
"license": "Apache-2.0",
"description": "A scanner for checking a web site using retire.js",
"main": "dist/index.js",
Expand Down
7 changes: 7 additions & 0 deletions src/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ type CycloneDXComponent = {
name: string;
version: string;
"bom-ref": string;
purl?: string;
properties: Array<{
name: string;
value: string;
Expand Down Expand Up @@ -164,6 +165,11 @@ function formatContentTypes(
.join(" ");
}

function generatePURL(component: Component): string {
if (component.basePurl) return component.basePurl + "@" + component.version;
return `pkg:npm/${component.npmname ?? component.component}@${component.version}`;
}

export function convertToCycloneDX(resultToConvert: typeof collectedResults) {
const components = new Map<string, CycloneDXComponent>();
const vulnerabilities: Array<CycloneDXVulnerability> = [];
Expand All @@ -188,6 +194,7 @@ export function convertToCycloneDX(resultToConvert: typeof collectedResults) {
"bom-ref": randomUUID(),
name: c.component,
version: c.version,
purl: generatePURL(c),
properties: [],
};
components.set(key, comp);
Expand Down

0 comments on commit 8d17f2a

Please sign in to comment.