-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathstatic.ts
More file actions
35 lines (30 loc) · 931 Bytes
/
static.ts
File metadata and controls
35 lines (30 loc) · 931 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { normalize as normalizePath } from "path";
import { ExtractAction, ExtractedLayers } from "../../extractor/types";
import { streamToString } from "../../stream-utils";
export const getSpdxFileContentAction: ExtractAction = {
actionName: "spdx-files",
filePathMatches: (filePath) => {
const normalized = normalizePath(filePath);
return (
normalized.includes("/docker/sbom/") &&
normalized.includes("spdx.") &&
normalized.endsWith(".json")
);
},
callback: streamToString,
};
export function getSpdxFileContents(
extractedLayers: ExtractedLayers,
): string[] {
const files: string[] = [];
for (const fileName of Object.keys(extractedLayers)) {
if (!("spdx-files" in extractedLayers[fileName])) {
continue;
}
const content = extractedLayers[fileName]["spdx-files"];
if (typeof content === "string") {
files.push(content);
}
}
return files;
}