@cyclonedx/cdxgen 10.1.1 → 10.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/analyzer.js +21 -18
- package/bin/cdxgen.js +4 -4
- package/bin/evinse.js +2 -2
- package/bin/repl.js +4 -4
- package/bin/verify.js +1 -1
- package/binary.js +3 -3
- package/db.js +1 -1
- package/docker.js +8 -8
- package/docker.test.js +5 -5
- package/envcontext.js +6 -6
- package/envcontext.test.js +7 -7
- package/evinser.js +25 -25
- package/index.js +170 -148
- package/package.json +16 -12
- package/protobom.test.js +2 -2
- package/server.js +2 -2
- package/types/analyzer.d.ts +5 -0
- package/types/analyzer.d.ts.map +1 -0
- package/types/binary.d.ts +13 -0
- package/types/binary.d.ts.map +1 -0
- package/types/cbomutils.d.ts +2 -0
- package/types/cbomutils.d.ts.map +1 -0
- package/types/db.d.ts +19 -0
- package/types/db.d.ts.map +1 -0
- package/types/display.d.ts +8 -0
- package/types/display.d.ts.map +1 -0
- package/types/docker.d.ts +44 -0
- package/types/docker.d.ts.map +1 -0
- package/types/envcontext.d.ts +61 -0
- package/types/envcontext.d.ts.map +1 -0
- package/types/evinser.d.ts +728 -0
- package/types/evinser.d.ts.map +1 -0
- package/types/index.d.ts +48 -0
- package/types/index.d.ts.map +1 -0
- package/types/jest.config.d.ts +10 -0
- package/types/jest.config.d.ts.map +1 -0
- package/types/piptree.d.ts +2 -0
- package/types/piptree.d.ts.map +1 -0
- package/types/postgen.d.ts +3 -0
- package/types/postgen.d.ts.map +1 -0
- package/types/protobom.d.ts +3 -0
- package/types/protobom.d.ts.map +1 -0
- package/types/server.d.ts +3 -0
- package/types/server.d.ts.map +1 -0
- package/types/utils.d.ts +517 -0
- package/types/utils.d.ts.map +1 -0
- package/types/validator.d.ts +5 -0
- package/types/validator.d.ts.map +1 -0
- package/utils.js +182 -36
- package/utils.test.js +83 -71
- package/validator.js +2 -2
package/index.js
CHANGED
|
@@ -1,119 +1,119 @@
|
|
|
1
1
|
import { platform as _platform, homedir, tmpdir } from "node:os";
|
|
2
2
|
import process from "node:process";
|
|
3
3
|
import { Buffer } from "node:buffer";
|
|
4
|
-
import { basename, join,
|
|
4
|
+
import { basename, dirname, join, resolve, sep } from "node:path";
|
|
5
5
|
import { parse } from "ssri";
|
|
6
6
|
import {
|
|
7
|
+
accessSync,
|
|
8
|
+
constants,
|
|
9
|
+
existsSync,
|
|
7
10
|
lstatSync,
|
|
11
|
+
mkdirSync,
|
|
8
12
|
mkdtempSync,
|
|
9
|
-
rmSync,
|
|
10
|
-
existsSync,
|
|
11
13
|
readFileSync,
|
|
12
|
-
|
|
13
|
-
mkdirSync,
|
|
14
|
-
writeFileSync,
|
|
14
|
+
rmSync,
|
|
15
15
|
statSync,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
unlinkSync,
|
|
17
|
+
writeFileSync
|
|
18
18
|
} from "node:fs";
|
|
19
19
|
import got from "got";
|
|
20
20
|
import { v4 as uuidv4 } from "uuid";
|
|
21
21
|
import { PackageURL } from "packageurl-js";
|
|
22
22
|
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
CLJ_CMD,
|
|
24
|
+
DEBUG_MODE,
|
|
25
|
+
FETCH_LICENSE,
|
|
26
|
+
LEIN_CMD,
|
|
27
|
+
MAX_BUFFER,
|
|
28
|
+
SWIFT_CMD,
|
|
29
|
+
TIMEOUT_MS,
|
|
30
|
+
addEvidenceForDotnet,
|
|
31
|
+
addEvidenceForImports,
|
|
32
|
+
addPlugin,
|
|
33
|
+
cleanupPlugin,
|
|
32
34
|
collectGradleDependencies,
|
|
35
|
+
collectJarNS,
|
|
33
36
|
collectMvnDependencies,
|
|
34
|
-
parsePom,
|
|
35
|
-
parseMavenTree,
|
|
36
|
-
executeGradleProperties,
|
|
37
|
-
getGradleCommand,
|
|
38
37
|
convertJarNSToPackages,
|
|
39
|
-
|
|
40
|
-
parseBazelSkyframe,
|
|
41
|
-
parseBazelActionGraph,
|
|
42
|
-
parseSbtLock,
|
|
38
|
+
convertOSQueryResults,
|
|
43
39
|
determineSbtVersion,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
readZipEntry,
|
|
56
|
-
parsePiplockData,
|
|
40
|
+
encodeForPurl,
|
|
41
|
+
executeGradleProperties,
|
|
42
|
+
extractJarArchive,
|
|
43
|
+
frameworksList,
|
|
44
|
+
getAllFiles,
|
|
45
|
+
getCppModules,
|
|
46
|
+
getGradleCommand,
|
|
47
|
+
getLicenses,
|
|
48
|
+
getMavenCommand,
|
|
49
|
+
getMvnMetadata,
|
|
50
|
+
getNugetMetadata,
|
|
57
51
|
getPipFrozenTree,
|
|
58
|
-
|
|
52
|
+
getPyMetadata,
|
|
59
53
|
getPyModules,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
54
|
+
getSwiftPackageMetadata,
|
|
55
|
+
includeMavenTestScope,
|
|
56
|
+
parseBazelActionGraph,
|
|
57
|
+
parseBazelSkyframe,
|
|
58
|
+
parseBdistMetadata,
|
|
59
|
+
parseBitbucketPipelinesFile,
|
|
60
|
+
parseBowerJson,
|
|
61
|
+
parseCabalData,
|
|
68
62
|
parseCargoAuditableData,
|
|
69
|
-
parseCargoTomlData,
|
|
70
63
|
parseCargoData,
|
|
71
|
-
|
|
72
|
-
parsePubYamlData,
|
|
73
|
-
parseConanLockData,
|
|
74
|
-
parseConanData,
|
|
75
|
-
parseLeiningenData,
|
|
76
|
-
parseLeinDep,
|
|
77
|
-
parseEdnData,
|
|
64
|
+
parseCargoTomlData,
|
|
78
65
|
parseCljDep,
|
|
79
|
-
parseCabalData,
|
|
80
|
-
parseMixLockData,
|
|
81
|
-
parseGitHubWorkflowData,
|
|
82
66
|
parseCloudBuildData,
|
|
83
|
-
|
|
84
|
-
parseHelmYamlData,
|
|
85
|
-
parseSwiftResolved,
|
|
86
|
-
parseSwiftJsonTree,
|
|
87
|
-
parseContainerSpecData,
|
|
88
|
-
parseOpenapiSpecData,
|
|
89
|
-
parsePrivadoFile,
|
|
67
|
+
parseCmakeLikeFile,
|
|
90
68
|
parseComposerLock,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
69
|
+
parseConanData,
|
|
70
|
+
parseConanLockData,
|
|
71
|
+
parseContainerFile,
|
|
72
|
+
parseContainerSpecData,
|
|
95
73
|
parseCsPkgData,
|
|
74
|
+
parseCsPkgLockData,
|
|
75
|
+
parseCsProjAssetsData,
|
|
96
76
|
parseCsProjData,
|
|
77
|
+
parseEdnData,
|
|
78
|
+
parseGemfileLockData,
|
|
79
|
+
parseGitHubWorkflowData,
|
|
80
|
+
parseGoListDep,
|
|
81
|
+
parseGoModData,
|
|
82
|
+
parseGoModGraph,
|
|
83
|
+
parseGoModWhy,
|
|
84
|
+
parseGoVersionData,
|
|
85
|
+
parseGopkgData,
|
|
86
|
+
parseGosumData,
|
|
87
|
+
parseGradleDep,
|
|
88
|
+
parseHelmYamlData,
|
|
89
|
+
parseLeinDep,
|
|
90
|
+
parseLeiningenData,
|
|
91
|
+
parseMavenTree,
|
|
92
|
+
parseMinJs,
|
|
93
|
+
parseMixLockData,
|
|
94
|
+
parseNodeShrinkwrap,
|
|
95
|
+
parseNupkg,
|
|
96
|
+
parseOpenapiSpecData,
|
|
97
|
+
parsePackageJsonName,
|
|
97
98
|
parsePaketLockData,
|
|
98
|
-
|
|
99
|
+
parsePiplockData,
|
|
100
|
+
parsePkgJson,
|
|
101
|
+
parsePkgLock,
|
|
102
|
+
parsePnpmLock,
|
|
103
|
+
parsePoetrylockData,
|
|
104
|
+
parsePom,
|
|
105
|
+
parsePrivadoFile,
|
|
106
|
+
parsePubLockData,
|
|
107
|
+
parsePubYamlData,
|
|
99
108
|
parsePyProjectToml,
|
|
100
|
-
|
|
109
|
+
parseReqFile,
|
|
110
|
+
parseSbtLock,
|
|
101
111
|
parseSbtTree,
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
getNugetMetadata,
|
|
108
|
-
frameworksList,
|
|
109
|
-
parseContainerFile,
|
|
110
|
-
parseBitbucketPipelinesFile,
|
|
111
|
-
getPyMetadata,
|
|
112
|
-
addEvidenceForDotnet,
|
|
113
|
-
getSwiftPackageMetadata,
|
|
114
|
-
CLJ_CMD,
|
|
115
|
-
LEIN_CMD,
|
|
116
|
-
SWIFT_CMD
|
|
112
|
+
parseSetupPyFile,
|
|
113
|
+
parseSwiftJsonTree,
|
|
114
|
+
parseSwiftResolved,
|
|
115
|
+
parseYarnLock,
|
|
116
|
+
readZipEntry
|
|
117
117
|
} from "./utils.js";
|
|
118
118
|
import {
|
|
119
119
|
collectEnvInfo,
|
|
@@ -122,7 +122,7 @@ import {
|
|
|
122
122
|
listFiles
|
|
123
123
|
} from "./envcontext.js";
|
|
124
124
|
import { spawnSync } from "node:child_process";
|
|
125
|
-
import {
|
|
125
|
+
import { URL, fileURLToPath } from "node:url";
|
|
126
126
|
let url = import.meta.url;
|
|
127
127
|
if (!url.startsWith("file://")) {
|
|
128
128
|
url = new URL(`file://${import.meta.url}`).toString();
|
|
@@ -136,18 +136,18 @@ const _version = selfPJson.version;
|
|
|
136
136
|
import { findJSImportsExports } from "./analyzer.js";
|
|
137
137
|
import { gte, lte } from "semver";
|
|
138
138
|
import {
|
|
139
|
-
|
|
140
|
-
parseImageName,
|
|
139
|
+
addSkippedSrcFiles,
|
|
141
140
|
exportArchive,
|
|
142
141
|
exportImage,
|
|
143
|
-
|
|
142
|
+
getPkgPathList,
|
|
143
|
+
parseImageName
|
|
144
144
|
} from "./docker.js";
|
|
145
145
|
import {
|
|
146
|
-
getGoBuildInfo,
|
|
147
|
-
getCargoAuditableInfo,
|
|
148
146
|
executeOsQuery,
|
|
149
|
-
|
|
150
|
-
getDotnetSlices
|
|
147
|
+
getCargoAuditableInfo,
|
|
148
|
+
getDotnetSlices,
|
|
149
|
+
getGoBuildInfo,
|
|
150
|
+
getOSPackages
|
|
151
151
|
} from "./binary.js";
|
|
152
152
|
import { collectOSCryptoLibs } from "./cbomutils.js";
|
|
153
153
|
|
|
@@ -603,7 +603,7 @@ function addMetadata(parentComponent = {}, options = {}) {
|
|
|
603
603
|
/**
|
|
604
604
|
* Method to create external references
|
|
605
605
|
*
|
|
606
|
-
* @param
|
|
606
|
+
* @param {Array | Object} opkg
|
|
607
607
|
* @returns {Array}
|
|
608
608
|
*/
|
|
609
609
|
function addExternalReferences(opkg) {
|
|
@@ -644,6 +644,11 @@ function addExternalReferences(opkg) {
|
|
|
644
644
|
/**
|
|
645
645
|
* For all modules in the specified package, creates a list of
|
|
646
646
|
* component objects from each one.
|
|
647
|
+
*
|
|
648
|
+
* @param {Object} options CLI options
|
|
649
|
+
* @param {Object} allImports All imports
|
|
650
|
+
* @param {Object} pkg Package object
|
|
651
|
+
* @param {string} ptype Package type
|
|
647
652
|
*/
|
|
648
653
|
export function listComponents(options, allImports, pkg, ptype = "npm") {
|
|
649
654
|
const compMap = {};
|
|
@@ -891,6 +896,13 @@ function addComponentHash(alg, digest, component) {
|
|
|
891
896
|
|
|
892
897
|
/**
|
|
893
898
|
* Return the BOM in json format including any namespace mapping
|
|
899
|
+
*
|
|
900
|
+
* @param {Object} options Options
|
|
901
|
+
* @param {Object} pkgInfo Package information
|
|
902
|
+
* @param {string} ptype Package type
|
|
903
|
+
* @param {Object} context Context
|
|
904
|
+
*
|
|
905
|
+
* @returns {Object} BOM with namespace mapping
|
|
894
906
|
*/
|
|
895
907
|
const buildBomNSData = (options, pkgInfo, ptype, context) => {
|
|
896
908
|
const bomNSData = {
|
|
@@ -940,8 +952,10 @@ const buildBomNSData = (options, pkgInfo, ptype, context) => {
|
|
|
940
952
|
/**
|
|
941
953
|
* Function to create bom string for Java jars
|
|
942
954
|
*
|
|
943
|
-
* @param path to the project
|
|
944
|
-
* @param options Parse options from the cli
|
|
955
|
+
* @param {string} path to the project
|
|
956
|
+
* @param {Object} options Parse options from the cli
|
|
957
|
+
*
|
|
958
|
+
* @returns {Object} BOM with namespace mapping
|
|
945
959
|
*/
|
|
946
960
|
export const createJarBom = async (path, options) => {
|
|
947
961
|
let pkgList = [];
|
|
@@ -1008,8 +1022,8 @@ export const createJarBom = async (path, options) => {
|
|
|
1008
1022
|
/**
|
|
1009
1023
|
* Function to create bom string for Java projects
|
|
1010
1024
|
*
|
|
1011
|
-
* @param path to the project
|
|
1012
|
-
* @param options Parse options from the cli
|
|
1025
|
+
* @param {string} path to the project
|
|
1026
|
+
* @param {Object} options Parse options from the cli
|
|
1013
1027
|
*/
|
|
1014
1028
|
export const createJavaBom = async (path, options) => {
|
|
1015
1029
|
let jarNSMapping = {};
|
|
@@ -1772,8 +1786,8 @@ export const createJavaBom = async (path, options) => {
|
|
|
1772
1786
|
/**
|
|
1773
1787
|
* Function to create bom string for Node.js projects
|
|
1774
1788
|
*
|
|
1775
|
-
* @param path to the project
|
|
1776
|
-
* @param options Parse options from the cli
|
|
1789
|
+
* @param {string} path to the project
|
|
1790
|
+
* @param {Object} options Parse options from the cli
|
|
1777
1791
|
*/
|
|
1778
1792
|
export const createNodejsBom = async (path, options) => {
|
|
1779
1793
|
let pkgList = [];
|
|
@@ -2179,8 +2193,8 @@ export const createNodejsBom = async (path, options) => {
|
|
|
2179
2193
|
/**
|
|
2180
2194
|
* Function to create bom string for Python projects
|
|
2181
2195
|
*
|
|
2182
|
-
* @param path to the project
|
|
2183
|
-
* @param options Parse options from the cli
|
|
2196
|
+
* @param {string} path to the project
|
|
2197
|
+
* @param {Object} options Parse options from the cli
|
|
2184
2198
|
*/
|
|
2185
2199
|
export const createPythonBom = async (path, options) => {
|
|
2186
2200
|
let allImports = {};
|
|
@@ -2531,8 +2545,8 @@ export const createPythonBom = async (path, options) => {
|
|
|
2531
2545
|
/**
|
|
2532
2546
|
* Function to create bom string for Go projects
|
|
2533
2547
|
*
|
|
2534
|
-
* @param path to the project
|
|
2535
|
-
* @param options Parse options from the cli
|
|
2548
|
+
* @param {string} path to the project
|
|
2549
|
+
* @param {Object} options Parse options from the cli
|
|
2536
2550
|
*/
|
|
2537
2551
|
export const createGoBom = async (path, options) => {
|
|
2538
2552
|
let pkgList = [];
|
|
@@ -2857,8 +2871,8 @@ export const createGoBom = async (path, options) => {
|
|
|
2857
2871
|
/**
|
|
2858
2872
|
* Function to create bom string for Rust projects
|
|
2859
2873
|
*
|
|
2860
|
-
* @param path to the project
|
|
2861
|
-
* @param options Parse options from the cli
|
|
2874
|
+
* @param {string} path to the project
|
|
2875
|
+
* @param {Object} options Parse options from the cli
|
|
2862
2876
|
*/
|
|
2863
2877
|
export const createRustBom = async (path, options) => {
|
|
2864
2878
|
let pkgList = [];
|
|
@@ -2943,8 +2957,8 @@ export const createRustBom = async (path, options) => {
|
|
|
2943
2957
|
/**
|
|
2944
2958
|
* Function to create bom string for Dart projects
|
|
2945
2959
|
*
|
|
2946
|
-
* @param path to the project
|
|
2947
|
-
* @param options Parse options from the cli
|
|
2960
|
+
* @param {string} path to the project
|
|
2961
|
+
* @param {Object} options Parse options from the cli
|
|
2948
2962
|
*/
|
|
2949
2963
|
export const createDartBom = async (path, options) => {
|
|
2950
2964
|
const pubFiles = getAllFiles(
|
|
@@ -2996,8 +3010,8 @@ export const createDartBom = async (path, options) => {
|
|
|
2996
3010
|
/**
|
|
2997
3011
|
* Function to create bom string for cpp projects
|
|
2998
3012
|
*
|
|
2999
|
-
* @param path to the project
|
|
3000
|
-
* @param options Parse options from the cli
|
|
3013
|
+
* @param {string} path to the project
|
|
3014
|
+
* @param {Object} options Parse options from the cli
|
|
3001
3015
|
*/
|
|
3002
3016
|
export const createCppBom = (path, options) => {
|
|
3003
3017
|
let parentComponent = undefined;
|
|
@@ -3176,8 +3190,8 @@ export const createCppBom = (path, options) => {
|
|
|
3176
3190
|
/**
|
|
3177
3191
|
* Function to create bom string for clojure projects
|
|
3178
3192
|
*
|
|
3179
|
-
* @param path to the project
|
|
3180
|
-
* @param options Parse options from the cli
|
|
3193
|
+
* @param {string} path to the project
|
|
3194
|
+
* @param {Object} options Parse options from the cli
|
|
3181
3195
|
*/
|
|
3182
3196
|
export const createClojureBom = (path, options) => {
|
|
3183
3197
|
const ednFiles = getAllFiles(
|
|
@@ -3298,8 +3312,8 @@ export const createClojureBom = (path, options) => {
|
|
|
3298
3312
|
/**
|
|
3299
3313
|
* Function to create bom string for Haskell projects
|
|
3300
3314
|
*
|
|
3301
|
-
* @param path to the project
|
|
3302
|
-
* @param options Parse options from the cli
|
|
3315
|
+
* @param {string} path to the project
|
|
3316
|
+
* @param {Object} options Parse options from the cli
|
|
3303
3317
|
*/
|
|
3304
3318
|
export const createHaskellBom = (path, options) => {
|
|
3305
3319
|
const cabalFiles = getAllFiles(
|
|
@@ -3330,8 +3344,8 @@ export const createHaskellBom = (path, options) => {
|
|
|
3330
3344
|
/**
|
|
3331
3345
|
* Function to create bom string for Elixir projects
|
|
3332
3346
|
*
|
|
3333
|
-
* @param path to the project
|
|
3334
|
-
* @param options Parse options from the cli
|
|
3347
|
+
* @param {string} path to the project
|
|
3348
|
+
* @param {Object} options Parse options from the cli
|
|
3335
3349
|
*/
|
|
3336
3350
|
export const createElixirBom = (path, options) => {
|
|
3337
3351
|
const mixFiles = getAllFiles(
|
|
@@ -3362,8 +3376,8 @@ export const createElixirBom = (path, options) => {
|
|
|
3362
3376
|
/**
|
|
3363
3377
|
* Function to create bom string for GitHub action workflows
|
|
3364
3378
|
*
|
|
3365
|
-
* @param path to the project
|
|
3366
|
-
* @param options Parse options from the cli
|
|
3379
|
+
* @param {string} path to the project
|
|
3380
|
+
* @param {Object} options Parse options from the cli
|
|
3367
3381
|
*/
|
|
3368
3382
|
export const createGitHubBom = (path, options) => {
|
|
3369
3383
|
const ghactionFiles = getAllFiles(
|
|
@@ -3394,8 +3408,8 @@ export const createGitHubBom = (path, options) => {
|
|
|
3394
3408
|
/**
|
|
3395
3409
|
* Function to create bom string for cloudbuild yaml
|
|
3396
3410
|
*
|
|
3397
|
-
* @param path to the project
|
|
3398
|
-
* @param options Parse options from the cli
|
|
3411
|
+
* @param {string} path to the project
|
|
3412
|
+
* @param {Object} options Parse options from the cli
|
|
3399
3413
|
*/
|
|
3400
3414
|
export const createCloudBuildBom = (path, options) => {
|
|
3401
3415
|
const cbFiles = getAllFiles(path, "cloudbuild.yml", options);
|
|
@@ -3422,8 +3436,8 @@ export const createCloudBuildBom = (path, options) => {
|
|
|
3422
3436
|
/**
|
|
3423
3437
|
* Function to create obom string for the current OS using osquery
|
|
3424
3438
|
*
|
|
3425
|
-
* @param path to the project
|
|
3426
|
-
* @param options Parse options from the cli
|
|
3439
|
+
* @param {string} path to the project
|
|
3440
|
+
* @param {Object} options Parse options from the cli
|
|
3427
3441
|
*/
|
|
3428
3442
|
export const createOSBom = (path, options) => {
|
|
3429
3443
|
console.warn(
|
|
@@ -3446,9 +3460,7 @@ export const createOSBom = (path, options) => {
|
|
|
3446
3460
|
parentComponent = dlist.splice(0, 1)[0];
|
|
3447
3461
|
}
|
|
3448
3462
|
pkgList = pkgList.concat(
|
|
3449
|
-
dlist.sort(
|
|
3450
|
-
return a.name.localeCompare(b.name);
|
|
3451
|
-
})
|
|
3463
|
+
dlist.sort((a, b) => a.name.localeCompare(b.name))
|
|
3452
3464
|
);
|
|
3453
3465
|
}
|
|
3454
3466
|
} // for
|
|
@@ -3482,8 +3494,8 @@ export const createOSBom = (path, options) => {
|
|
|
3482
3494
|
/**
|
|
3483
3495
|
* Function to create bom string for Jenkins plugins
|
|
3484
3496
|
*
|
|
3485
|
-
* @param path to the project
|
|
3486
|
-
* @param options Parse options from the cli
|
|
3497
|
+
* @param {string} path to the project
|
|
3498
|
+
* @param {Object} options Parse options from the cli
|
|
3487
3499
|
*/
|
|
3488
3500
|
export const createJenkinsBom = async (path, options) => {
|
|
3489
3501
|
let pkgList = [];
|
|
@@ -3531,8 +3543,8 @@ export const createJenkinsBom = async (path, options) => {
|
|
|
3531
3543
|
/**
|
|
3532
3544
|
* Function to create bom string for Helm charts
|
|
3533
3545
|
*
|
|
3534
|
-
* @param path to the project
|
|
3535
|
-
* @param options Parse options from the cli
|
|
3546
|
+
* @param {string} path to the project
|
|
3547
|
+
* @param {Object} options Parse options from the cli
|
|
3536
3548
|
*/
|
|
3537
3549
|
export const createHelmBom = (path, options) => {
|
|
3538
3550
|
let pkgList = [];
|
|
@@ -3563,8 +3575,8 @@ export const createHelmBom = (path, options) => {
|
|
|
3563
3575
|
/**
|
|
3564
3576
|
* Function to create bom string for swift projects
|
|
3565
3577
|
*
|
|
3566
|
-
* @param path to the project
|
|
3567
|
-
* @param options Parse options from the cli
|
|
3578
|
+
* @param {string} path to the project
|
|
3579
|
+
* @param {Object} options Parse options from the cli
|
|
3568
3580
|
*/
|
|
3569
3581
|
export const createSwiftBom = async (path, options) => {
|
|
3570
3582
|
const swiftFiles = getAllFiles(
|
|
@@ -3656,8 +3668,8 @@ export const createSwiftBom = async (path, options) => {
|
|
|
3656
3668
|
/**
|
|
3657
3669
|
* Function to create bom string for docker compose
|
|
3658
3670
|
*
|
|
3659
|
-
* @param path to the project
|
|
3660
|
-
* @param options Parse options from the cli
|
|
3671
|
+
* @param {string} path to the project
|
|
3672
|
+
* @param {Object} options Parse options from the cli
|
|
3661
3673
|
*/
|
|
3662
3674
|
export const createContainerSpecLikeBom = async (path, options) => {
|
|
3663
3675
|
let services = [];
|
|
@@ -3983,8 +3995,8 @@ export const createContainerSpecLikeBom = async (path, options) => {
|
|
|
3983
3995
|
/**
|
|
3984
3996
|
* Function to create bom string for php projects
|
|
3985
3997
|
*
|
|
3986
|
-
* @param path to the project
|
|
3987
|
-
* @param options Parse options from the cli
|
|
3998
|
+
* @param {string} path to the project
|
|
3999
|
+
* @param {Object} options Parse options from the cli
|
|
3988
4000
|
*/
|
|
3989
4001
|
export const createPHPBom = (path, options) => {
|
|
3990
4002
|
let dependencies = [];
|
|
@@ -4140,8 +4152,8 @@ export const createPHPBom = (path, options) => {
|
|
|
4140
4152
|
/**
|
|
4141
4153
|
* Function to create bom string for ruby projects
|
|
4142
4154
|
*
|
|
4143
|
-
* @param path to the project
|
|
4144
|
-
* @param options Parse options from the cli
|
|
4155
|
+
* @param {string} path to the project
|
|
4156
|
+
* @param {Object} options Parse options from the cli
|
|
4145
4157
|
*/
|
|
4146
4158
|
export const createRubyBom = async (path, options) => {
|
|
4147
4159
|
const gemFiles = getAllFiles(
|
|
@@ -4228,8 +4240,8 @@ export const createRubyBom = async (path, options) => {
|
|
|
4228
4240
|
/**
|
|
4229
4241
|
* Function to create bom string for csharp projects
|
|
4230
4242
|
*
|
|
4231
|
-
* @param path to the project
|
|
4232
|
-
* @param options Parse options from the cli
|
|
4243
|
+
* @param {string} path to the project
|
|
4244
|
+
* @param {Object} options Parse options from the cli
|
|
4233
4245
|
*/
|
|
4234
4246
|
export const createCsharpBom = async (path, options) => {
|
|
4235
4247
|
let manifestFiles = [];
|
|
@@ -4475,6 +4487,16 @@ export const trimComponents = (components) => {
|
|
|
4475
4487
|
return filteredComponents;
|
|
4476
4488
|
};
|
|
4477
4489
|
|
|
4490
|
+
/**
|
|
4491
|
+
* Dedupe components
|
|
4492
|
+
*
|
|
4493
|
+
* @param {Object} options Options
|
|
4494
|
+
* @param {Array} components Components
|
|
4495
|
+
* @param {Object} parentComponent Parent component
|
|
4496
|
+
* @param {Array} dependencies Dependencies
|
|
4497
|
+
*
|
|
4498
|
+
* @returns {Object} Object including BOM Json
|
|
4499
|
+
*/
|
|
4478
4500
|
export const dedupeBom = (
|
|
4479
4501
|
options,
|
|
4480
4502
|
components,
|
|
@@ -4514,8 +4536,8 @@ export const dedupeBom = (
|
|
|
4514
4536
|
/**
|
|
4515
4537
|
* Function to create bom string for all languages
|
|
4516
4538
|
*
|
|
4517
|
-
* @param pathList list of to the project
|
|
4518
|
-
* @param options Parse options from the cli
|
|
4539
|
+
* @param {string} pathList list of to the project
|
|
4540
|
+
* @param {Object} options Parse options from the cli
|
|
4519
4541
|
*/
|
|
4520
4542
|
export const createMultiXBom = async (pathList, options) => {
|
|
4521
4543
|
let components = [];
|
|
@@ -4951,8 +4973,8 @@ export const createMultiXBom = async (pathList, options) => {
|
|
|
4951
4973
|
/**
|
|
4952
4974
|
* Function to create bom string for various languages
|
|
4953
4975
|
*
|
|
4954
|
-
* @param path to the project
|
|
4955
|
-
* @param options Parse options from the cli
|
|
4976
|
+
* @param {string} path to the project
|
|
4977
|
+
* @param {Object} options Parse options from the cli
|
|
4956
4978
|
*/
|
|
4957
4979
|
export const createXBom = async (path, options) => {
|
|
4958
4980
|
try {
|
|
@@ -5279,8 +5301,8 @@ export const createXBom = async (path, options) => {
|
|
|
5279
5301
|
/**
|
|
5280
5302
|
* Function to create bom string for various languages
|
|
5281
5303
|
*
|
|
5282
|
-
* @param path to the project
|
|
5283
|
-
* @param options Parse options from the cli
|
|
5304
|
+
* @param {string} path to the project
|
|
5305
|
+
* @param {Object} options Parse options from the cli
|
|
5284
5306
|
*/
|
|
5285
5307
|
export const createBom = async (path, options) => {
|
|
5286
5308
|
let { projectType } = options;
|
|
@@ -5543,8 +5565,8 @@ export const createBom = async (path, options) => {
|
|
|
5543
5565
|
/**
|
|
5544
5566
|
* Method to submit the generated bom to dependency-track or cyclonedx server
|
|
5545
5567
|
*
|
|
5546
|
-
* @param args CLI args
|
|
5547
|
-
* @param bomContents BOM Json
|
|
5568
|
+
* @param {Object} args CLI args
|
|
5569
|
+
* @param {Object} bomContents BOM Json
|
|
5548
5570
|
*/
|
|
5549
5571
|
export async function submitBom(args, bomContents) {
|
|
5550
5572
|
const serverUrl = args.serverUrl.replace(/\/$/, "") + "/api/v1/bom";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cyclonedx/cdxgen",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.3",
|
|
4
4
|
"description": "Creates CycloneDX Software Bill of Materials (SBOM) from source or container image",
|
|
5
5
|
"homepage": "http://github.com/cyclonedx/cdxgen",
|
|
6
6
|
"author": "Prabhu Subramanian <prabhu@appthreat.com>",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
],
|
|
31
31
|
"type": "module",
|
|
32
32
|
"exports": "./index.js",
|
|
33
|
+
"types": "./types/index.d.ts",
|
|
33
34
|
"bin": {
|
|
34
35
|
"cdxgen": "bin/cdxgen.js",
|
|
35
36
|
"obom": "bin/cdxgen.js",
|
|
@@ -41,8 +42,9 @@
|
|
|
41
42
|
"docs": "docsify serve docs",
|
|
42
43
|
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --inject-globals false docker.test.js utils.test.js display.test.js postgen.test.js",
|
|
43
44
|
"watch": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watch --inject-globals false",
|
|
44
|
-
"lint": "eslint *.js *.test.js bin/*.js",
|
|
45
|
-
"pretty": "prettier --write *.js data/*.json bin/*.js *.md docs/*.md data/*.md"
|
|
45
|
+
"lint": "eslint *.js *.test.js bin/*.js --fix",
|
|
46
|
+
"pretty": "prettier --write *.js data/*.json bin/*.js *.md docs/*.md data/*.md",
|
|
47
|
+
"gen-types": "npx -p typescript tsc"
|
|
46
48
|
},
|
|
47
49
|
"engines": {
|
|
48
50
|
"node": ">=20"
|
|
@@ -65,7 +67,7 @@
|
|
|
65
67
|
"find-up": "7.0.0",
|
|
66
68
|
"glob": "^10.3.10",
|
|
67
69
|
"global-agent": "^3.0.0",
|
|
68
|
-
"got": "14.
|
|
70
|
+
"got": "14.2.0",
|
|
69
71
|
"iconv-lite": "^0.6.3",
|
|
70
72
|
"js-yaml": "^4.1.0",
|
|
71
73
|
"jws": "^4.0.0",
|
|
@@ -73,7 +75,7 @@
|
|
|
73
75
|
"packageurl-js": "1.0.2",
|
|
74
76
|
"prettify-xml": "^1.2.0",
|
|
75
77
|
"properties-reader": "^2.3.0",
|
|
76
|
-
"semver": "^7.
|
|
78
|
+
"semver": "^7.6.0",
|
|
77
79
|
"ssri": "^10.0.4",
|
|
78
80
|
"table": "^6.8.1",
|
|
79
81
|
"tar": "^6.2.0",
|
|
@@ -82,26 +84,27 @@
|
|
|
82
84
|
"yargs": "^17.7.2"
|
|
83
85
|
},
|
|
84
86
|
"optionalDependencies": {
|
|
85
|
-
"@appthreat/atom": "2.0.
|
|
87
|
+
"@appthreat/atom": "2.0.8",
|
|
86
88
|
"@appthreat/cdx-proto": "^0.0.4",
|
|
87
89
|
"@cyclonedx/cdxgen-plugins-bin": "^1.5.8",
|
|
88
|
-
"@cyclonedx/cdxgen-plugins-bin-windows-amd64": "^1.5.8",
|
|
89
90
|
"@cyclonedx/cdxgen-plugins-bin-arm64": "^1.5.8",
|
|
90
|
-
"@cyclonedx/cdxgen-plugins-bin-windows-arm64": "^1.5.8",
|
|
91
|
-
"@cyclonedx/cdxgen-plugins-bin-darwin-arm64": "^1.5.8",
|
|
92
91
|
"@cyclonedx/cdxgen-plugins-bin-darwin-amd64": "^1.5.8",
|
|
92
|
+
"@cyclonedx/cdxgen-plugins-bin-darwin-arm64": "^1.5.8",
|
|
93
93
|
"@cyclonedx/cdxgen-plugins-bin-ppc64": "^1.5.8",
|
|
94
|
+
"@cyclonedx/cdxgen-plugins-bin-windows-amd64": "^1.5.8",
|
|
95
|
+
"@cyclonedx/cdxgen-plugins-bin-windows-arm64": "^1.5.8",
|
|
94
96
|
"body-parser": "^1.20.2",
|
|
95
97
|
"compression": "^1.7.4",
|
|
96
98
|
"connect": "^3.7.0",
|
|
97
99
|
"jsonata": "^2.0.3",
|
|
98
|
-
"sequelize": "^6.
|
|
100
|
+
"sequelize": "^6.37.0",
|
|
99
101
|
"sqlite3": "^5.1.7"
|
|
100
102
|
},
|
|
101
103
|
"files": [
|
|
102
104
|
"*.js",
|
|
103
105
|
"bin/",
|
|
104
|
-
"data/"
|
|
106
|
+
"data/",
|
|
107
|
+
"types/"
|
|
105
108
|
],
|
|
106
109
|
"devDependencies": {
|
|
107
110
|
"caxa": "^3.0.1",
|
|
@@ -110,6 +113,7 @@
|
|
|
110
113
|
"eslint-config-prettier": "^9.1.0",
|
|
111
114
|
"eslint-plugin-prettier": "^5.1.3",
|
|
112
115
|
"jest": "^29.7.0",
|
|
113
|
-
"prettier": "3.2.
|
|
116
|
+
"prettier": "3.2.5",
|
|
117
|
+
"typescript": "^5.3.3"
|
|
114
118
|
}
|
|
115
119
|
}
|
package/protobom.test.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { expect, test } from "@jest/globals";
|
|
2
2
|
import { tmpdir } from "node:os";
|
|
3
|
-
import { existsSync,
|
|
3
|
+
import { existsSync, mkdtempSync, readFileSync, rmSync } from "node:fs";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { readBinary, writeBinary } from "./protobom.js";
|
|
7
7
|
|
|
8
8
|
const tempDir = mkdtempSync(join(tmpdir(), "bin-tests-"));
|
|
9
9
|
const testBom = JSON.parse(
|
package/server.js
CHANGED
|
@@ -114,12 +114,12 @@ const start = (options) => {
|
|
|
114
114
|
.listen(options.serverPort, options.serverHost);
|
|
115
115
|
configureServer(cdxgenServer);
|
|
116
116
|
|
|
117
|
-
app.use("/health",
|
|
117
|
+
app.use("/health", (_req, res) => {
|
|
118
118
|
res.setHeader("Content-Type", "application/json");
|
|
119
119
|
res.end(JSON.stringify({ status: "OK" }, null, 2));
|
|
120
120
|
});
|
|
121
121
|
|
|
122
|
-
app.use("/sbom", async
|
|
122
|
+
app.use("/sbom", async (req, res) => {
|
|
123
123
|
const q = url.parse(req.url, true).query;
|
|
124
124
|
let cleanup = false;
|
|
125
125
|
const reqOptions = parseQueryString(
|