Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.1.0 #38

Merged
merged 16 commits into from
Jun 6, 2024
4 changes: 2 additions & 2 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set Node.js 16.x
- name: Set Node.js 20.x
uses: actions/[email protected]
with:
node-version: 16.x
node-version: 20.x

- name: Install dependencies
run: npm ci
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
name: "Test"

on:
pull_request:
workflow_dispatch:
push:
branches:
- main
- 'releases/*'
workflow_dispatch:

permissions:
id-token: write
contents: write

jobs:
test-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
npm ci
# npm run test

# test action works running from the graph
test:
test-action:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ inputs:
required: false
default: '*.spdx.json'
runs:
using: 'node16'
using: 'node20'
main: 'dist/index.js'
branding:
icon: 'upload-cloud'
Expand Down
47,750 changes: 29,717 additions & 18,033 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

174 changes: 69 additions & 105 deletions dist/licenses.txt

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

23 changes: 9 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,12 @@
const fs = require('fs');
const glob = require('glob');

import {
PackageCache,
BuildTarget,
Package,
Snapshot,
Manifest,
submitSnapshot
} from '@github/dependency-submission-toolkit'
const toolkit = require('@github/dependency-submission-toolkit');

async function run() {
let manifests = getManifestsFromSpdxFiles(searchFiles());

let snapshot = new Snapshot({
let snapshot = new toolkit.Snapshot({
name: "spdx-to-dependency-graph-action",
version: "0.0.1",
url: "https://github.com/advanced-security/spdx-dependency-submission-action",
Expand All @@ -30,13 +23,13 @@
snapshot.addManifest(manifest);
});

submitSnapshot(snapshot);
toolkit.submitSnapshot(snapshot);
}

function getManifestFromSpdxFile(document, fileName) {
core.debug(`getManifestFromSpdxFile processing ${fileName}`);

let manifest = new Manifest(document.name, fileName);
let manifest = new toolkit.Manifest(document.name, fileName);

core.debug(`Processing ${document.packages?.length} packages`);

Expand All @@ -61,9 +54,9 @@

let relationships = document.relationships?.find(rel => rel.relatedSpdxElement == pkg.SPDXID && rel.relationshipType == "DEPENDS_ON" && rel.spdxElementId != "SPDXRef-RootPackage");
if (relationships != null && relationships.length > 0) {
manifest.addIndirectDependency(new Package(purl));
manifest.addIndirectDependency(new toolkit.Package(purl));
} else {
manifest.addDirectDependency(new Package(purl));
manifest.addDirectDependency(new toolkit.Package(purl));
}
});
return manifest;
Expand All @@ -89,7 +82,9 @@
// Fixes issues with an escaped version string
function replaceVersionEscape(purl) {
// Some tools are failing to escape the namespace, so we will escape it to work around that
purl = purl.replace("/@", "/%40");
// @ -> %40
// ^ -> %5E
purl = purl.replace("/@", "/%40").replace("^", "%5E");
Fixed Show fixed Hide fixed

//If there's an "@" in the purl, then we don't need to do anything.
if (purl != null && purl != undefined && !purl?.includes("@")) {
Expand Down
Loading
Loading