Skip to content

Commit 5034a6d

Browse files
Add validate-sbom action (#48)
1 parent 5f095b4 commit 5034a6d

12 files changed

Lines changed: 39538 additions & 1 deletion

File tree

common/src/path-utils.test.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { filterPaths } from "./path-utils";
1+
import { filterPaths, splitPaths } from "./path-utils";
22

33
describe('path utils', () => {
44

@@ -89,4 +89,31 @@ describe('path utils', () => {
8989
expect(filterPaths(paths, patterns)).toEqual(expected);
9090
});
9191
});
92+
93+
describe('splitPaths', () => {
94+
test.each([
95+
{
96+
paths: '',
97+
expected: []
98+
},
99+
{
100+
paths: 'a.cdx.json',
101+
expected: ['a.cdx.json']
102+
},
103+
{
104+
paths: 'a.cdx.json,b.cdx.json',
105+
expected: ['a.cdx.json', 'b.cdx.json']
106+
},
107+
{
108+
paths: 'a.cdx.json;b.cdx.json',
109+
expected: ['a.cdx.json', 'b.cdx.json']
110+
},
111+
{
112+
paths: 'a.cdx.json\r\nb.cdx.json\n c.cdx.json ',
113+
expected: ['a.cdx.json', 'b.cdx.json', 'c.cdx.json']
114+
},
115+
])('basic cases [%#]', ({ paths, expected }) => {
116+
expect(splitPaths(paths)).toEqual(expected);
117+
});
118+
});
92119
});

common/src/path-utils.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,10 @@ function filterPathsImpl(
3232
}, false);
3333
});
3434
}
35+
36+
export function splitPaths(paths: string): string[] {
37+
return paths
38+
.split(/[\r\n,;]+/)
39+
.map(path => path.trim())
40+
.filter(path => path.length > 0);
41+
}

get-changed-files/dist/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ var __importStar = (this && this.__importStar) || (function () {
124124
})();
125125
Object.defineProperty(exports, "__esModule", ({ value: true }));
126126
exports.filterPaths = filterPaths;
127+
exports.splitPaths = splitPaths;
127128
const core = __importStar(__nccwpck_require__(1751));
128129
const minimatch_1 = __nccwpck_require__(4804);
129130
const NEGATION = '!';
@@ -148,6 +149,12 @@ function filterPathsImpl(paths, patterns) {
148149
}, false);
149150
});
150151
}
152+
function splitPaths(paths) {
153+
return paths
154+
.split(/[\r\n,;]+/)
155+
.map(path => path.trim())
156+
.filter(path => path.length > 0);
157+
}
151158

152159

153160
/***/ }),

pnpm-lock.yaml

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

pnpm-workspace.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ packages:
33
- get-changed-files
44
- pr-filter
55
- send-teams-notification
6+
- validate-sbom
67
- verify-version-change
78

89
catalog:

pr-filter/dist/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ var __importStar = (this && this.__importStar) || (function () {
124124
})();
125125
Object.defineProperty(exports, "__esModule", ({ value: true }));
126126
exports.filterPaths = filterPaths;
127+
exports.splitPaths = splitPaths;
127128
const core = __importStar(__nccwpck_require__(1751));
128129
const minimatch_1 = __nccwpck_require__(4804);
129130
const NEGATION = '!';
@@ -148,6 +149,12 @@ function filterPathsImpl(paths, patterns) {
148149
}, false);
149150
});
150151
}
152+
function splitPaths(paths) {
153+
return paths
154+
.split(/[\r\n,;]+/)
155+
.map(path => path.trim())
156+
.filter(path => path.length > 0);
157+
}
151158

152159

153160
/***/ }),

validate-sbom/action.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: validate-sbom
2+
description: Install CycloneDX CLI and validate SBOM file(s)
3+
4+
inputs:
5+
input-format:
6+
description: SBOM file format
7+
required: false
8+
default: json
9+
input-file:
10+
description: Path to SBOM file to validate
11+
required: false
12+
input-files:
13+
description: Newline, comma, or semicolon separated paths to SBOM files to validate
14+
required: false
15+
16+
runs:
17+
using: node24
18+
main: dist/index.js

0 commit comments

Comments
 (0)