@cyclonedx/cdxgen 10.9.4 → 10.9.6
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 +1 -13
- package/data/README.md +1 -0
- package/data/glibc-stdlib.json +117 -0
- package/index.js +157 -19
- package/package.json +4 -3
- package/postgen.js +0 -1
- package/types/index.d.ts +12 -0
- package/types/index.d.ts.map +1 -1
- package/types/postgen.d.ts.map +1 -1
- package/types/utils.d.ts +33 -0
- package/types/utils.d.ts.map +1 -1
- package/utils.js +312 -7
- package/utils.test.js +12 -3
package/README.md
CHANGED
|
@@ -232,19 +232,7 @@ Use curl or your favorite tool to pass arguments to the `/sbom` route.
|
|
|
232
232
|
|
|
233
233
|
### Server arguments
|
|
234
234
|
|
|
235
|
-
Arguments can be passed either via the query string or as a JSON body.
|
|
236
|
-
|
|
237
|
-
| Argument | Description |
|
|
238
|
-
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
239
|
-
| type | Project type. Please refer to [Supported Project Types][docs-project-types]. |
|
|
240
|
-
| multiProject | [boolean] |
|
|
241
|
-
| requiredOnly | Include only the packages with required scope on the SBOM. [boolean] |
|
|
242
|
-
| noBabel | Do not use babel to perform usage analysis for JavaScript/TypeScript projects. [boolean] |
|
|
243
|
-
| installDeps | Install dependencies automatically for some projects. Defaults to true but disabled for containers and oci scans. [boolean] [default: true] |
|
|
244
|
-
| project | |
|
|
245
|
-
| projectName | Dependency track project name. Default use the directory name |
|
|
246
|
-
| projectGroup | Dependency track project group |
|
|
247
|
-
| projectVersion | Dependency track project version [default: ""] |
|
|
235
|
+
Arguments can be passed either via the query string or as a JSON body. Please refer to [Server Usage][docs-server]
|
|
248
236
|
|
|
249
237
|
### Health endpoint
|
|
250
238
|
|
package/data/README.md
CHANGED
|
@@ -22,3 +22,4 @@ Contents of data directory and their purpose.
|
|
|
22
22
|
| wrapdb-releases.json | Database of all available meson wraps. Generated using contrib/wrapdb.py. |
|
|
23
23
|
| frameworks-list.json | List of string fragments to categorize components into frameworks |
|
|
24
24
|
| crypto-oid.json | Peter Gutmann's crypto oid [mapping](https://www.cs.auckland.ac.nz/~pgut001). GPL, BSD, or CC BY license |
|
|
25
|
+
| glibc-stdlib.json | Standard libraries that can be filtered out in C++ |
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
[
|
|
2
|
+
"algorithm",
|
|
3
|
+
"iomanip",
|
|
4
|
+
"list",
|
|
5
|
+
"ostream",
|
|
6
|
+
"streambuf",
|
|
7
|
+
"bitset",
|
|
8
|
+
"ios",
|
|
9
|
+
"locale",
|
|
10
|
+
"queue",
|
|
11
|
+
"string",
|
|
12
|
+
"complex",
|
|
13
|
+
"iosfwd",
|
|
14
|
+
"map",
|
|
15
|
+
"set",
|
|
16
|
+
"typeinfo",
|
|
17
|
+
"deque",
|
|
18
|
+
"iostream",
|
|
19
|
+
"memory",
|
|
20
|
+
"sstream",
|
|
21
|
+
"utility",
|
|
22
|
+
"exception",
|
|
23
|
+
"istream",
|
|
24
|
+
"new",
|
|
25
|
+
"stack",
|
|
26
|
+
"valarray",
|
|
27
|
+
"fstream",
|
|
28
|
+
"iterator",
|
|
29
|
+
"numeric",
|
|
30
|
+
"stdexcept",
|
|
31
|
+
"vector",
|
|
32
|
+
"functional",
|
|
33
|
+
"limits",
|
|
34
|
+
"debugging",
|
|
35
|
+
"inplace_vector",
|
|
36
|
+
"linalg",
|
|
37
|
+
"rcu",
|
|
38
|
+
"text_encoding",
|
|
39
|
+
"hazard_pointer",
|
|
40
|
+
"expected",
|
|
41
|
+
"flat_set",
|
|
42
|
+
"mdspan",
|
|
43
|
+
"spanstream",
|
|
44
|
+
"stdfloat",
|
|
45
|
+
"flat_map",
|
|
46
|
+
"generator",
|
|
47
|
+
"print",
|
|
48
|
+
"stacktrace",
|
|
49
|
+
"barrier",
|
|
50
|
+
"concepts",
|
|
51
|
+
"latch",
|
|
52
|
+
"semaphore",
|
|
53
|
+
"stop_token",
|
|
54
|
+
"bit",
|
|
55
|
+
"coroutine",
|
|
56
|
+
"numbers",
|
|
57
|
+
"source_location",
|
|
58
|
+
"syncstream",
|
|
59
|
+
"compare",
|
|
60
|
+
"format",
|
|
61
|
+
"ranges",
|
|
62
|
+
"span",
|
|
63
|
+
"version",
|
|
64
|
+
"any",
|
|
65
|
+
"execution",
|
|
66
|
+
"memory_resource",
|
|
67
|
+
"string_view",
|
|
68
|
+
"variant",
|
|
69
|
+
"charconv",
|
|
70
|
+
"filesystem",
|
|
71
|
+
"optional",
|
|
72
|
+
"shared_mutex",
|
|
73
|
+
"array",
|
|
74
|
+
"condition_variable",
|
|
75
|
+
"mutex",
|
|
76
|
+
"scoped_allocator",
|
|
77
|
+
"type_traits",
|
|
78
|
+
"atomic",
|
|
79
|
+
"forward_list",
|
|
80
|
+
"random",
|
|
81
|
+
"system_error",
|
|
82
|
+
"typeindex",
|
|
83
|
+
"chrono",
|
|
84
|
+
"future",
|
|
85
|
+
"ratio",
|
|
86
|
+
"thread",
|
|
87
|
+
"unordered_map",
|
|
88
|
+
"codecvt",
|
|
89
|
+
"initializer_list",
|
|
90
|
+
"regex",
|
|
91
|
+
"tuple",
|
|
92
|
+
"unordered_set",
|
|
93
|
+
"cassert",
|
|
94
|
+
"cctype",
|
|
95
|
+
"cerrno",
|
|
96
|
+
"cfenv",
|
|
97
|
+
"cfloat",
|
|
98
|
+
"cinttypes",
|
|
99
|
+
"ciso646",
|
|
100
|
+
"climits",
|
|
101
|
+
"clocale",
|
|
102
|
+
"cmath",
|
|
103
|
+
"csetjmp",
|
|
104
|
+
"csignal",
|
|
105
|
+
"cstdarg",
|
|
106
|
+
"cstdbool",
|
|
107
|
+
"cstddef",
|
|
108
|
+
"cstdint",
|
|
109
|
+
"cstdio",
|
|
110
|
+
"cstdlib",
|
|
111
|
+
"cstring",
|
|
112
|
+
"ctgmath",
|
|
113
|
+
"ctime",
|
|
114
|
+
"cuchar",
|
|
115
|
+
"cwchar",
|
|
116
|
+
"cwctype"
|
|
117
|
+
]
|
package/index.js
CHANGED
|
@@ -119,6 +119,8 @@ import {
|
|
|
119
119
|
parsePackageJsonName,
|
|
120
120
|
parsePaketLockData,
|
|
121
121
|
parsePiplockData,
|
|
122
|
+
parsePixiLockFile,
|
|
123
|
+
parsePixiTomlFile,
|
|
122
124
|
parsePkgJson,
|
|
123
125
|
parsePkgLock,
|
|
124
126
|
parsePnpmLock,
|
|
@@ -1686,11 +1688,11 @@ export async function createJavaBom(path, options) {
|
|
|
1686
1688
|
null,
|
|
1687
1689
|
).toString();
|
|
1688
1690
|
rootSubProjectObj["purl"] = rootSubProjectPurl;
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
+
const rootSubProjectBomRef = decodeURIComponent(rootSubProjectPurl);
|
|
1692
|
+
rootSubProjectObj["bom-ref"] = rootSubProjectBomRef;
|
|
1691
1693
|
if (!allProjectsAddedPurls.includes(rootSubProjectPurl)) {
|
|
1692
1694
|
allProjects.push(rootSubProjectObj);
|
|
1693
|
-
rootDependsOn.push(
|
|
1695
|
+
rootDependsOn.push(rootSubProjectBomRef);
|
|
1694
1696
|
allProjectsAddedPurls.push(rootSubProjectPurl);
|
|
1695
1697
|
}
|
|
1696
1698
|
}
|
|
@@ -1720,11 +1722,11 @@ export async function createJavaBom(path, options) {
|
|
|
1720
1722
|
null,
|
|
1721
1723
|
).toString();
|
|
1722
1724
|
rootSubProjectObj["purl"] = rootSubProjectPurl;
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
+
const rootSubProjectBomRef = decodeURIComponent(rootSubProjectPurl);
|
|
1726
|
+
rootSubProjectObj["bom-ref"] = rootSubProjectBomRef;
|
|
1725
1727
|
if (!allProjectsAddedPurls.includes(rootSubProjectPurl)) {
|
|
1726
1728
|
allProjects.push(rootSubProjectObj);
|
|
1727
|
-
rootDependsOn.push(
|
|
1729
|
+
rootDependsOn.push(rootSubProjectBomRef);
|
|
1728
1730
|
allProjectsAddedPurls.push(rootSubProjectPurl);
|
|
1729
1731
|
}
|
|
1730
1732
|
}
|
|
@@ -2703,6 +2705,92 @@ export async function createNodejsBom(path, options) {
|
|
|
2703
2705
|
});
|
|
2704
2706
|
}
|
|
2705
2707
|
|
|
2708
|
+
/**
|
|
2709
|
+
* Function to create bom string for Projects that use Pixi package manager.
|
|
2710
|
+
* createPixiBom is based on createPythonBom.
|
|
2711
|
+
* Pixi package manager utilizes many languages like python, rust, C/C++, ruby, etc.
|
|
2712
|
+
* It produces a Lockfile which help produce reproducible envs across operating systems.
|
|
2713
|
+
* This code will look at the operating system of our machine and create a BOM specific to that machine.
|
|
2714
|
+
*
|
|
2715
|
+
*
|
|
2716
|
+
* @param {String} path
|
|
2717
|
+
* @param {Object} options
|
|
2718
|
+
*/
|
|
2719
|
+
export async function createPixiBom(path, options) {
|
|
2720
|
+
const allImports = {};
|
|
2721
|
+
let metadataFilename = "";
|
|
2722
|
+
let dependencies = [];
|
|
2723
|
+
let pkgList = [];
|
|
2724
|
+
let formulationList = [];
|
|
2725
|
+
let frozen = true;
|
|
2726
|
+
let parentComponent = createDefaultParentComponent(path, "pypi", options);
|
|
2727
|
+
let PixiLockData = {};
|
|
2728
|
+
|
|
2729
|
+
const pixiToml = join(path, "pixi.toml");
|
|
2730
|
+
|
|
2731
|
+
// if pixi.toml file found then we
|
|
2732
|
+
// Add parentComponent Details
|
|
2733
|
+
const pixiTomlMode = existsSync(pixiToml);
|
|
2734
|
+
if (pixiTomlMode) {
|
|
2735
|
+
const tmpParentComponent = parsePixiTomlFile(pixiToml);
|
|
2736
|
+
parentComponent = tmpParentComponent;
|
|
2737
|
+
parentComponent.type = "application";
|
|
2738
|
+
const ppurl = new PackageURL(
|
|
2739
|
+
"pixi",
|
|
2740
|
+
parentComponent.group || "",
|
|
2741
|
+
parentComponent.name,
|
|
2742
|
+
parentComponent.version || "latest",
|
|
2743
|
+
null,
|
|
2744
|
+
null,
|
|
2745
|
+
).toString();
|
|
2746
|
+
parentComponent["bom-ref"] = decodeURIComponent(ppurl);
|
|
2747
|
+
parentComponent["purl"] = ppurl;
|
|
2748
|
+
}
|
|
2749
|
+
|
|
2750
|
+
const pixiLockFile = join(path, "pixi.lock");
|
|
2751
|
+
const pixiFilesMode = existsSync(pixiLockFile);
|
|
2752
|
+
if (pixiFilesMode) {
|
|
2753
|
+
// Instead of what we do in createPythonBOM
|
|
2754
|
+
// where we install packages and run `getPipFrozenTree`
|
|
2755
|
+
// here I assume `pixi.lock` file to contain the accuracte version information
|
|
2756
|
+
// across all platforms
|
|
2757
|
+
PixiLockData = parsePixiLockFile(pixiLockFile, path);
|
|
2758
|
+
metadataFilename = "pixi.lock";
|
|
2759
|
+
} else {
|
|
2760
|
+
if (options.installDeps) {
|
|
2761
|
+
generatePixiLockFile(path);
|
|
2762
|
+
|
|
2763
|
+
const pixiLockFile = join(path, "pixi.lock");
|
|
2764
|
+
if (!existsSync(pixiLockFile) && DEBUG_MODE) {
|
|
2765
|
+
console.log(
|
|
2766
|
+
"Unexpected Error tried to generate pixi.lock file but failed.",
|
|
2767
|
+
);
|
|
2768
|
+
console.log("This will result in creations of empty BOM.");
|
|
2769
|
+
}
|
|
2770
|
+
PixiLockData = parsePixiLockFile(pixiLockFile);
|
|
2771
|
+
metadataFilename = "pixi.lock";
|
|
2772
|
+
} else {
|
|
2773
|
+
// If no pixi.lock and installDeps is false
|
|
2774
|
+
// then return None and let `createPythonBOM()` handle generation of BOM.
|
|
2775
|
+
return null;
|
|
2776
|
+
}
|
|
2777
|
+
}
|
|
2778
|
+
|
|
2779
|
+
pkgList = PixiLockData.pkgList;
|
|
2780
|
+
frozen = PixiLockData.frozen;
|
|
2781
|
+
formulationList = PixiLockData.formulationList;
|
|
2782
|
+
dependencies = PixiLockData.dependencies;
|
|
2783
|
+
|
|
2784
|
+
return buildBomNSData(options, pkgList, "pypi", {
|
|
2785
|
+
allImports,
|
|
2786
|
+
src: path,
|
|
2787
|
+
filename: metadataFilename,
|
|
2788
|
+
dependencies,
|
|
2789
|
+
parentComponent,
|
|
2790
|
+
formulationList,
|
|
2791
|
+
});
|
|
2792
|
+
}
|
|
2793
|
+
|
|
2706
2794
|
/**
|
|
2707
2795
|
* Function to create bom string for Python projects
|
|
2708
2796
|
*
|
|
@@ -2718,6 +2806,19 @@ export async function createPythonBom(path, options) {
|
|
|
2718
2806
|
const tempDir = mkdtempSync(join(tmpdir(), "cdxgen-venv-"));
|
|
2719
2807
|
let parentComponent = createDefaultParentComponent(path, "pypi", options);
|
|
2720
2808
|
const pipenvMode = existsSync(join(path, "Pipfile"));
|
|
2809
|
+
|
|
2810
|
+
// If pixi is used then just return that as output instead
|
|
2811
|
+
const pixiLockFile = join(path, "pixi.lock");
|
|
2812
|
+
const pixiFilesMode = existsSync(pixiLockFile);
|
|
2813
|
+
const pixiToml = join(path, "pixi.toml");
|
|
2814
|
+
const pixiTomlMode = existsSync(pixiToml);
|
|
2815
|
+
if (pixiTomlMode || pixiFilesMode) {
|
|
2816
|
+
const BomNSData = createPixiBom(path, options);
|
|
2817
|
+
if (BomNSData) {
|
|
2818
|
+
return BomNSData;
|
|
2819
|
+
}
|
|
2820
|
+
}
|
|
2821
|
+
|
|
2721
2822
|
let poetryFiles = getAllFiles(
|
|
2722
2823
|
path,
|
|
2723
2824
|
`${options.multiProject ? "**/" : ""}poetry.lock`,
|
|
@@ -2759,7 +2860,7 @@ export async function createPythonBom(path, options) {
|
|
|
2759
2860
|
`${options.multiProject ? "**/" : ""}*.egg-info`,
|
|
2760
2861
|
options,
|
|
2761
2862
|
);
|
|
2762
|
-
|
|
2863
|
+
|
|
2763
2864
|
const pyProjectFile = join(path, "pyproject.toml");
|
|
2764
2865
|
const pyProjectMode = existsSync(pyProjectFile);
|
|
2765
2866
|
if (pyProjectMode) {
|
|
@@ -2787,6 +2888,7 @@ export async function createPythonBom(path, options) {
|
|
|
2787
2888
|
}
|
|
2788
2889
|
const requirementsMode = reqFiles?.length || reqDirFiles?.length;
|
|
2789
2890
|
const poetryMode = poetryFiles?.length;
|
|
2891
|
+
const setupPy = join(path, "setup.py");
|
|
2790
2892
|
const setupPyMode = existsSync(setupPy);
|
|
2791
2893
|
// Poetry sets up its own virtual env containing site-packages so
|
|
2792
2894
|
// we give preference to poetry lock file. Issue# 129
|
|
@@ -3069,6 +3171,7 @@ export async function createPythonBom(path, options) {
|
|
|
3069
3171
|
}
|
|
3070
3172
|
}
|
|
3071
3173
|
}
|
|
3174
|
+
|
|
3072
3175
|
// Final fallback is to manually parse setup.py if we still
|
|
3073
3176
|
// have an empty list
|
|
3074
3177
|
if (!pkgList.length && setupPyMode) {
|
|
@@ -3319,6 +3422,8 @@ export async function createGoBom(path, options) {
|
|
|
3319
3422
|
},
|
|
3320
3423
|
);
|
|
3321
3424
|
if (result.status !== 0 || result.error) {
|
|
3425
|
+
// go list -deps command may not work when private packages are involved
|
|
3426
|
+
// So we support a fallback to only operate with go mod graph command output in such instances
|
|
3322
3427
|
console.log("go list -deps command has failed.");
|
|
3323
3428
|
shouldManuallyParse = true;
|
|
3324
3429
|
if (DEBUG_MODE && result.stdout) {
|
|
@@ -3392,17 +3497,50 @@ export async function createGoBom(path, options) {
|
|
|
3392
3497
|
}
|
|
3393
3498
|
}
|
|
3394
3499
|
} else {
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
);
|
|
3405
|
-
|
|
3500
|
+
if (DEBUG_MODE) {
|
|
3501
|
+
console.log("Executing go mod graph in", basePath);
|
|
3502
|
+
}
|
|
3503
|
+
// Next we use the go mod graph command to construct the dependency tree
|
|
3504
|
+
result = spawnSync("go", ["mod", "graph"], {
|
|
3505
|
+
cwd: basePath,
|
|
3506
|
+
encoding: "utf-8",
|
|
3507
|
+
timeout: TIMEOUT_MS,
|
|
3508
|
+
maxBuffer: MAX_BUFFER,
|
|
3509
|
+
});
|
|
3510
|
+
if (result.stdout) {
|
|
3511
|
+
const cmdOutput = Buffer.from(result.stdout).toString();
|
|
3512
|
+
// The arguments to parseGoModGraph are slightly different to force inclusion of all packages
|
|
3513
|
+
const retMap = await parseGoModGraph(
|
|
3514
|
+
cmdOutput,
|
|
3515
|
+
f,
|
|
3516
|
+
gosumMap,
|
|
3517
|
+
[],
|
|
3518
|
+
{},
|
|
3519
|
+
);
|
|
3520
|
+
if (retMap.pkgList?.length) {
|
|
3521
|
+
pkgList = pkgList.concat(retMap.pkgList);
|
|
3522
|
+
pkgList = trimComponents(pkgList);
|
|
3523
|
+
}
|
|
3524
|
+
if (retMap.dependenciesList?.length) {
|
|
3525
|
+
dependencies = mergeDependencies(
|
|
3526
|
+
dependencies,
|
|
3527
|
+
retMap.dependenciesList,
|
|
3528
|
+
parentComponent,
|
|
3529
|
+
);
|
|
3530
|
+
}
|
|
3531
|
+
} else {
|
|
3532
|
+
shouldManuallyParse = true;
|
|
3533
|
+
console.log(
|
|
3534
|
+
"1. Check if the correct version of golang is installed. Try building the application using go build or make command to troubleshoot.",
|
|
3535
|
+
);
|
|
3536
|
+
console.log(
|
|
3537
|
+
"2. If the application uses private go modules, ensure the environment variable GOPRIVATE is set with the comma-separated repo names.\nEnsure $HOME/.netrc file contains a valid username and password for the private repos.",
|
|
3538
|
+
);
|
|
3539
|
+
console.log(
|
|
3540
|
+
"3. Alternatively, consider generating a post-build SBOM from the built binary using blint. Use the official container image and invoke cdxgen with the arguments `-t binary --lifecycle post-build`.",
|
|
3541
|
+
);
|
|
3542
|
+
options.failOnError && process.exit(1);
|
|
3543
|
+
}
|
|
3406
3544
|
}
|
|
3407
3545
|
}
|
|
3408
3546
|
if (pkgList.length && !shouldManuallyParse) {
|
|
@@ -5843,7 +5981,7 @@ export async function createMultiXBom(pathList, options) {
|
|
|
5843
5981
|
}
|
|
5844
5982
|
// Jar scanning is enabled by default
|
|
5845
5983
|
// See #330
|
|
5846
|
-
bomData = createJarBom(path, options);
|
|
5984
|
+
bomData = await createJarBom(path, options);
|
|
5847
5985
|
if (bomData?.bomJson?.components?.length) {
|
|
5848
5986
|
if (DEBUG_MODE) {
|
|
5849
5987
|
console.log(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cyclonedx/cdxgen",
|
|
3
|
-
"version": "10.9.
|
|
3
|
+
"version": "10.9.6",
|
|
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>",
|
|
@@ -83,10 +83,11 @@
|
|
|
83
83
|
"ssri": "^10.0.6",
|
|
84
84
|
"table": "^6.8.2",
|
|
85
85
|
"tar": "^6.2.1",
|
|
86
|
+
"toml": "^3.0.0",
|
|
86
87
|
"uuid": "^10.0.0",
|
|
88
|
+
"validate-iri": "^1.0.1",
|
|
87
89
|
"xml-js": "^1.6.11",
|
|
88
|
-
"yargs": "^17.7.2"
|
|
89
|
-
"validate-iri": "^1.0.1"
|
|
90
|
+
"yargs": "^17.7.2"
|
|
90
91
|
},
|
|
91
92
|
"optionalDependencies": {
|
|
92
93
|
"@appthreat/atom": "2.0.17",
|
package/postgen.js
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -53,6 +53,18 @@ export function createJavaBom(path: string, options: any): Promise<any>;
|
|
|
53
53
|
* @param {Object} options Parse options from the cli
|
|
54
54
|
*/
|
|
55
55
|
export function createNodejsBom(path: string, options: any): Promise<any>;
|
|
56
|
+
/**
|
|
57
|
+
* Function to create bom string for Projects that use Pixi package manager.
|
|
58
|
+
* createPixiBom is based on createPythonBom.
|
|
59
|
+
* Pixi package manager utilizes many languages like python, rust, C/C++, ruby, etc.
|
|
60
|
+
* It produces a Lockfile which help produce reproducible envs across operating systems.
|
|
61
|
+
* This code will look at the operating system of our machine and create a BOM specific to that machine.
|
|
62
|
+
*
|
|
63
|
+
*
|
|
64
|
+
* @param {String} path
|
|
65
|
+
* @param {Object} options
|
|
66
|
+
*/
|
|
67
|
+
export function createPixiBom(path: string, options: any): Promise<any>;
|
|
56
68
|
/**
|
|
57
69
|
* Function to create bom string for Python projects
|
|
58
70
|
*
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.js"],"names":[],"mappings":"AA6vBA;;;;;;;;GAQG;AACH,gFAFW,MAAM,SAchB;AAyUD;;;;;;;GAOG;AACH,mCALW,MAAM,qBAiEhB;AAED;;;;;GAKG;AACH,uCAHW,MAAM;;;;EAKhB;AAED;;;;;GAKG;AACH,sCAHW,MAAM;;;;EAkBhB;AAED;;;;;GAKG;AACH,oCAHW,MAAM,8BA4/BhB;AAED;;;;;GAKG;AACH,sCAHW,MAAM,8BA2chB;AAED;;;;;;;;;;GAUG;AACH,wEAyEC;AAED;;;;;GAKG;AACH,sCAHW,MAAM,8BA2bhB;AAED;;;;;GAKG;AACH,kCAHW,MAAM,8BAqWhB;AAED;;;;;GAKG;AACH,oCAHW,MAAM,8BAqIhB;AAED;;;;;GAKG;AACH,oCAHW,MAAM,8BAiDhB;AAED;;;;;GAKG;AACH,mCAHW,MAAM,qBA+KhB;AAED;;;;;GAKG;AACH,uCAHW,MAAM,qBAsHhB;AAED;;;;;GAKG;AACH,uCAHW,MAAM,qBA2BhB;AAED;;;;;GAKG;AACH,sCAHW,MAAM,qBA2BhB;AAED;;;;;GAKG;AACH,sCAHW,MAAM,qBA2BhB;AAED;;;;;GAKG;AACH,0CAHW,MAAM,qBAuBhB;AAED;;;;;GAKG;AACH,kCAHW,MAAM,8BAqDhB;AAED;;;;;GAKG;AACH,uCAHW,MAAM,8BA4ChB;AAED;;;;;GAKG;AACH,oCAHW,MAAM,qBA2BhB;AAED;;;;;GAKG;AACH,qCAHW,MAAM,8BAwFhB;AAED;;;;;GAKG;AACH,iDAHW,MAAM,qBAiUhB;AAED;;;;;GAKG;AACH,mCAHW,MAAM,qBAwJhB;AAED;;;;;GAKG;AACH,oCAHW,MAAM,8BAmFhB;AAED;;;;;GAKG;AACH,sCAHW,MAAM,8BA6XhB;AAED;;;;;GAKG;AACH,2CAHW,MAAM;;;;;;;;;;;;;;;;;;;;GAoChB;AAED;;;;;;;;KA+DC;AAED;;;;;;GAMG;AACH,yDA2CC;AAED;;;;;;;;;GASG;AACH,2GA6BC;AAED;;;;;GAKG;AACH,0CAHW,MAAM,EAAE,8BAmclB;AAED;;;;;GAKG;AACH,iCAHW,MAAM,8BAiUhB;AAED;;;;;GAKG;AACH,gCAHW,MAAM,qBAsOhB;AAED;;;;;;GAMG;AACH,wDAFY,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG,SAAS,CAAC,CAwHxE"}
|
package/types/postgen.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgen.d.ts","sourceRoot":"","sources":["../postgen.js"],"names":[],"mappings":"AAOA;;;;;;;GAOG;AACH,+DAcC;AAED;;;;;;;GAOG;AACH,+DAqCC;AAED;;;;;;;GAOG;AACH,gEA+BC;AAED;;;;;;;GAOG;AACH,
|
|
1
|
+
{"version":3,"file":"postgen.d.ts","sourceRoot":"","sources":["../postgen.js"],"names":[],"mappings":"AAOA;;;;;;;GAOG;AACH,+DAcC;AAED;;;;;;;GAOG;AACH,+DAqCC;AAED;;;;;;;GAOG;AACH,gEA+BC;AAED;;;;;;;GAOG;AACH,2DAuIC;AAED;;GAEG;AACH,+CAIC"}
|
package/types/utils.d.ts
CHANGED
|
@@ -455,12 +455,45 @@ export function getPyModules(src: string, epkgList: any[], options: any): Promis
|
|
|
455
455
|
* @param {Object} setupPyData Contents of setup.py
|
|
456
456
|
*/
|
|
457
457
|
export function parseSetupPyFile(setupPyData: any): Promise<any[]>;
|
|
458
|
+
/**
|
|
459
|
+
* Method to parse pixi.lock data
|
|
460
|
+
*
|
|
461
|
+
* @param {Object} pixiData Contents of pixi.lock file
|
|
462
|
+
*/
|
|
463
|
+
export function parsePixiLockFile(pixiLockFileName: any, path: any): {
|
|
464
|
+
pkgList: any;
|
|
465
|
+
formulationList: any[];
|
|
466
|
+
rootList: any[];
|
|
467
|
+
dependenciesList: {
|
|
468
|
+
ref: string;
|
|
469
|
+
dependsOn: string[];
|
|
470
|
+
}[];
|
|
471
|
+
frozen: boolean;
|
|
472
|
+
};
|
|
473
|
+
/**
|
|
474
|
+
* Method to parse pixi.toml file
|
|
475
|
+
*
|
|
476
|
+
* @param {String} pixiToml
|
|
477
|
+
*/
|
|
478
|
+
export function parsePixiTomlFile(pixiToml: string): {
|
|
479
|
+
description: any;
|
|
480
|
+
name: any;
|
|
481
|
+
version: any;
|
|
482
|
+
homepage: any;
|
|
483
|
+
repository: any;
|
|
484
|
+
};
|
|
458
485
|
/**
|
|
459
486
|
* Method to construct a GitHub API url for the given repo metadata
|
|
460
487
|
* @param {Object} repoMetadata Repo metadata with group and name
|
|
461
488
|
* @return {String|undefined} github api url (or undefined - if not enough data)
|
|
462
489
|
*/
|
|
463
490
|
export function repoMetadataToGitHubApiUrl(repoMetadata: any): string | undefined;
|
|
491
|
+
/**
|
|
492
|
+
* Method to run cli command `pixi install`
|
|
493
|
+
*
|
|
494
|
+
*
|
|
495
|
+
*/
|
|
496
|
+
export function generatePixiLockFile(path: any): void;
|
|
464
497
|
/**
|
|
465
498
|
* Method to split GitHub url into its parts
|
|
466
499
|
* @param {String} repoUrl Repository url
|
package/types/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../utils.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../utils.js"],"names":[],"mappings":"AA2JA,yCAYC;AAED,2CAQC;A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AA+B;AAM/B,kDAWE;AAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8FE;;;;AAwHF,8BAQG;AAqiJH,8CAUE"}
|
package/utils.js
CHANGED
|
@@ -46,6 +46,7 @@ import {
|
|
|
46
46
|
satisfies,
|
|
47
47
|
valid,
|
|
48
48
|
} from "semver";
|
|
49
|
+
import toml from "toml";
|
|
49
50
|
import { IriValidationStrategy, validateIri } from "validate-iri";
|
|
50
51
|
import { xml2js } from "xml-js";
|
|
51
52
|
import { getTreeWithPlugin } from "./piptree.js";
|
|
@@ -85,6 +86,10 @@ export const frameworksList = JSON.parse(
|
|
|
85
86
|
const selfPJson = JSON.parse(
|
|
86
87
|
readFileSync(join(dirNameStr, "package.json"), "utf-8"),
|
|
87
88
|
);
|
|
89
|
+
|
|
90
|
+
const CPP_STD_MODULES = JSON.parse(
|
|
91
|
+
readFileSync(join(dirNameStr, "data", "glibc-stdlib.json"), "utf-8"),
|
|
92
|
+
);
|
|
88
93
|
const _version = selfPJson.version;
|
|
89
94
|
|
|
90
95
|
// Refer to contrib/py-modules.py for a script to generate this list
|
|
@@ -280,6 +285,7 @@ export const PROJECT_TYPE_ALIASES = {
|
|
|
280
285
|
"python310",
|
|
281
286
|
"python311",
|
|
282
287
|
"python312",
|
|
288
|
+
"pixi",
|
|
283
289
|
],
|
|
284
290
|
go: ["go", "golang", "gomod", "gopkg"],
|
|
285
291
|
rust: ["rust", "rust-lang", "cargo"],
|
|
@@ -2604,7 +2610,7 @@ export function parseGradleDep(
|
|
|
2604
2610
|
version = undefined;
|
|
2605
2611
|
}
|
|
2606
2612
|
}
|
|
2607
|
-
|
|
2613
|
+
const purl = new PackageURL(
|
|
2608
2614
|
"maven",
|
|
2609
2615
|
group !== "project" ? group : rootProjectGroup,
|
|
2610
2616
|
name,
|
|
@@ -2612,7 +2618,7 @@ export function parseGradleDep(
|
|
|
2612
2618
|
{ type: "jar" },
|
|
2613
2619
|
null,
|
|
2614
2620
|
).toString();
|
|
2615
|
-
purlString = decodeURIComponent(
|
|
2621
|
+
const purlString = decodeURIComponent(purl);
|
|
2616
2622
|
keys_cache[`${purlString}_${last_purl}`] = true;
|
|
2617
2623
|
// Filter duplicates
|
|
2618
2624
|
if (!deps_keys_cache[purlString]) {
|
|
@@ -2623,8 +2629,8 @@ export function parseGradleDep(
|
|
|
2623
2629
|
version: version !== undefined ? version : rootProjectVersion,
|
|
2624
2630
|
qualifiers: { type: "jar" },
|
|
2625
2631
|
};
|
|
2626
|
-
adep["purl"] =
|
|
2627
|
-
adep["bom-ref"] =
|
|
2632
|
+
adep["purl"] = purl;
|
|
2633
|
+
adep["bom-ref"] = purlString;
|
|
2628
2634
|
if (scope) {
|
|
2629
2635
|
adep["scope"] = scope;
|
|
2630
2636
|
}
|
|
@@ -4251,6 +4257,222 @@ export async function parseSetupPyFile(setupPyData) {
|
|
|
4251
4257
|
return await parseReqFile(lines.join("\n"), false);
|
|
4252
4258
|
}
|
|
4253
4259
|
|
|
4260
|
+
/**
|
|
4261
|
+
* Method to create purl using information in pixi.lock file.
|
|
4262
|
+
* According to pixi lock file satisfiability (https://pixi.sh/latest/features/lockfile/#lockfile-satisfiability)
|
|
4263
|
+
*
|
|
4264
|
+
*
|
|
4265
|
+
*
|
|
4266
|
+
* @param {*} packageData
|
|
4267
|
+
* @returns
|
|
4268
|
+
*/
|
|
4269
|
+
function createPurlTemplate(packageData) {
|
|
4270
|
+
const purlTemplate = `pkg:${packageData["kind"]}/${packageData["name"]}@${packageData["version"]}-${packageData["build"]}?os=${packageData["subdir"]}`;
|
|
4271
|
+
return purlTemplate;
|
|
4272
|
+
}
|
|
4273
|
+
|
|
4274
|
+
/**
|
|
4275
|
+
* Method to parse pixi.lock data
|
|
4276
|
+
*
|
|
4277
|
+
* @param {Object} pixiData Contents of pixi.lock file
|
|
4278
|
+
*/
|
|
4279
|
+
export function parsePixiLockFile(pixiLockFileName, path) {
|
|
4280
|
+
const pixiFileData = readFileSync(pixiLockFileName, { encoding: "utf-8" });
|
|
4281
|
+
const pixiLockData = _load(pixiFileData);
|
|
4282
|
+
|
|
4283
|
+
// this function returns
|
|
4284
|
+
let pkgList = [];
|
|
4285
|
+
const formulationList = [];
|
|
4286
|
+
const rootList = [];
|
|
4287
|
+
let dependenciesList = [];
|
|
4288
|
+
// we do not set false because we have assumed that pixi lock is accurate
|
|
4289
|
+
const frozen = true;
|
|
4290
|
+
|
|
4291
|
+
/**
|
|
4292
|
+
* pixiMapper used with a map on pixi packages list.
|
|
4293
|
+
* the pixi list contains the following information e.g.
|
|
4294
|
+
* {kind: conda
|
|
4295
|
+
* name: alsa-lib
|
|
4296
|
+
* version: 1.2.11
|
|
4297
|
+
* build: h31becfc_1
|
|
4298
|
+
* build_number: 1
|
|
4299
|
+
* subdir: linux-aarch64
|
|
4300
|
+
* url: https://conda.anaconda.org/conda-forge/linux-aarch64/alsa-lib-1.2.11-h31becfc_1.conda
|
|
4301
|
+
* sha256: d062bc712dd307714dfdb0f7da095a510c138c5db76321494a516ac127f9e5cf
|
|
4302
|
+
* md5: 76bf292a85a0556cef4f500420cabe6c
|
|
4303
|
+
* depends:
|
|
4304
|
+
* - libgcc-ng >=12
|
|
4305
|
+
* license: LGPL-2.1-or-later
|
|
4306
|
+
* license_family: GPL
|
|
4307
|
+
* size: 584152
|
|
4308
|
+
* timestamp: 1709396718705
|
|
4309
|
+
* }
|
|
4310
|
+
* We create the purl using the following logic:
|
|
4311
|
+
* "purl": "pkg:{kind}/{name}@{version}-{build}?os={os}"
|
|
4312
|
+
* type would be "library" and evidence would be
|
|
4313
|
+
* {
|
|
4314
|
+
* "identity": {
|
|
4315
|
+
* "field": "purl",
|
|
4316
|
+
* "confidence": 1,
|
|
4317
|
+
* "methods": [
|
|
4318
|
+
* {
|
|
4319
|
+
* "technique": "instrumentation",
|
|
4320
|
+
* "confidence": 1,
|
|
4321
|
+
* "value": "pixi.lock"
|
|
4322
|
+
* }
|
|
4323
|
+
* ]
|
|
4324
|
+
* }
|
|
4325
|
+
* }
|
|
4326
|
+
*
|
|
4327
|
+
*/
|
|
4328
|
+
function pixiMapper(packageData) {
|
|
4329
|
+
// return pkgList
|
|
4330
|
+
/** E.g. of what a pkgList element looks like
|
|
4331
|
+
* {
|
|
4332
|
+
* name: "conda-content-trust",
|
|
4333
|
+
* version: "latest",
|
|
4334
|
+
* purl: "pkg:pypi/conda-content-trust@latest",
|
|
4335
|
+
* type: "library",
|
|
4336
|
+
* "bom-ref": "pkg:pypi/conda-content-trust@latest",
|
|
4337
|
+
* scope: "excluded",
|
|
4338
|
+
* evidence: {
|
|
4339
|
+
* identity: {
|
|
4340
|
+
* field: "purl",
|
|
4341
|
+
* confidence: 1,
|
|
4342
|
+
* methods: [
|
|
4343
|
+
* {
|
|
4344
|
+
* technique: "instrumentation",
|
|
4345
|
+
* confidence: 1,
|
|
4346
|
+
* value: "/home/greatsage/miniconda3",
|
|
4347
|
+
* },
|
|
4348
|
+
* ],
|
|
4349
|
+
* },
|
|
4350
|
+
* },
|
|
4351
|
+
* properties: [
|
|
4352
|
+
* {
|
|
4353
|
+
* name: "SrcFile",
|
|
4354
|
+
* value: "/home/greatsage/projects/supplyChain/trials/pythonprojs/fastapi/requirements.txt",
|
|
4355
|
+
* },
|
|
4356
|
+
* ],
|
|
4357
|
+
* }
|
|
4358
|
+
*
|
|
4359
|
+
*/
|
|
4360
|
+
const purlTemplate = createPurlTemplate(packageData);
|
|
4361
|
+
return {
|
|
4362
|
+
name: packageData["name"],
|
|
4363
|
+
version: packageData["version"],
|
|
4364
|
+
purl: purlTemplate,
|
|
4365
|
+
type: "library",
|
|
4366
|
+
"bom-ref": purlTemplate,
|
|
4367
|
+
// "licenses": [
|
|
4368
|
+
// [{
|
|
4369
|
+
// "id": packageData["license"]
|
|
4370
|
+
// }]
|
|
4371
|
+
// ],
|
|
4372
|
+
supplier: {
|
|
4373
|
+
name: packageData["build"],
|
|
4374
|
+
url: packageData["url"],
|
|
4375
|
+
},
|
|
4376
|
+
// "hashes": [
|
|
4377
|
+
// {"md5": packageData["md5"]},
|
|
4378
|
+
// {"sha256": packageData["sha256"]}
|
|
4379
|
+
// ],
|
|
4380
|
+
evidence: {
|
|
4381
|
+
identity: {
|
|
4382
|
+
field: "purl",
|
|
4383
|
+
confidence: 1,
|
|
4384
|
+
methods: [
|
|
4385
|
+
{
|
|
4386
|
+
technique: "instrumentation",
|
|
4387
|
+
confidence: 1,
|
|
4388
|
+
// "value": `${path}/.pixi/envs/default`
|
|
4389
|
+
},
|
|
4390
|
+
],
|
|
4391
|
+
},
|
|
4392
|
+
},
|
|
4393
|
+
properties: [
|
|
4394
|
+
{ operatingSystem: packageData["subdir"] },
|
|
4395
|
+
{ build_number: packageData["build_number"] },
|
|
4396
|
+
{ build: packageData["build"] },
|
|
4397
|
+
],
|
|
4398
|
+
};
|
|
4399
|
+
}
|
|
4400
|
+
|
|
4401
|
+
function mapAddEvidenceValue(p) {
|
|
4402
|
+
// TODO: get pixi environment variable (PR #1343)
|
|
4403
|
+
p["evidence"]["identity"]["methods"]["value"] =
|
|
4404
|
+
`${path}/.pixi/envs/default`;
|
|
4405
|
+
return p;
|
|
4406
|
+
}
|
|
4407
|
+
// create the pkgList
|
|
4408
|
+
pkgList = pixiLockData["packages"].map(pixiMapper);
|
|
4409
|
+
pkgList = pkgList.map(mapAddEvidenceValue);
|
|
4410
|
+
|
|
4411
|
+
// create dependencies
|
|
4412
|
+
const dictionary_packages = pixiLockData["packages"].reduce(
|
|
4413
|
+
(accumulator, currentObject) => {
|
|
4414
|
+
accumulator[currentObject["name"]] = currentObject;
|
|
4415
|
+
return accumulator;
|
|
4416
|
+
},
|
|
4417
|
+
{},
|
|
4418
|
+
);
|
|
4419
|
+
|
|
4420
|
+
dependenciesList = [];
|
|
4421
|
+
for (const package_iter of pixiLockData["packages"]) {
|
|
4422
|
+
const depends = package_iter["depends"];
|
|
4423
|
+
if (!depends) {
|
|
4424
|
+
continue;
|
|
4425
|
+
}
|
|
4426
|
+
|
|
4427
|
+
const purltemplate = createPurlTemplate(package_iter);
|
|
4428
|
+
const subdir = package_iter["subdir"];
|
|
4429
|
+
const dependsOn = [];
|
|
4430
|
+
for (const depends_package of depends) {
|
|
4431
|
+
const depends_package_name = depends_package.split(" ");
|
|
4432
|
+
const depends_package_information =
|
|
4433
|
+
dictionary_packages[depends_package_name[0] + subdir];
|
|
4434
|
+
if (!depends_package_information) {
|
|
4435
|
+
continue;
|
|
4436
|
+
}
|
|
4437
|
+
dependsOn.push(createPurlTemplate(depends_package_information));
|
|
4438
|
+
}
|
|
4439
|
+
|
|
4440
|
+
dependenciesList.push({
|
|
4441
|
+
ref: purltemplate,
|
|
4442
|
+
dependsOn: dependsOn,
|
|
4443
|
+
});
|
|
4444
|
+
}
|
|
4445
|
+
|
|
4446
|
+
return {
|
|
4447
|
+
pkgList,
|
|
4448
|
+
formulationList,
|
|
4449
|
+
rootList,
|
|
4450
|
+
dependenciesList,
|
|
4451
|
+
frozen,
|
|
4452
|
+
};
|
|
4453
|
+
}
|
|
4454
|
+
|
|
4455
|
+
/**
|
|
4456
|
+
* Method to parse pixi.toml file
|
|
4457
|
+
*
|
|
4458
|
+
* @param {String} pixiToml
|
|
4459
|
+
*/
|
|
4460
|
+
export function parsePixiTomlFile(pixiToml) {
|
|
4461
|
+
const pixiTomlFile = readFileSync(pixiToml, { encoding: "utf-8" });
|
|
4462
|
+
const tomlData = toml.parse(pixiTomlFile);
|
|
4463
|
+
const pkg = {};
|
|
4464
|
+
if (!tomlData) {
|
|
4465
|
+
return pkg;
|
|
4466
|
+
}
|
|
4467
|
+
pkg.description = tomlData["project"]["description"];
|
|
4468
|
+
pkg.name = tomlData["project"]["name"];
|
|
4469
|
+
pkg.version = tomlData["project"]["version"];
|
|
4470
|
+
// pkg.authors = tomlData['project']['authors'];
|
|
4471
|
+
pkg.homepage = tomlData["project"]["homepage"];
|
|
4472
|
+
pkg.repository = tomlData["project"]["repository"];
|
|
4473
|
+
return pkg;
|
|
4474
|
+
}
|
|
4475
|
+
|
|
4254
4476
|
/**
|
|
4255
4477
|
* Method to construct a GitHub API url for the given repo metadata
|
|
4256
4478
|
* @param {Object} repoMetadata Repo metadata with group and name
|
|
@@ -4270,6 +4492,33 @@ export function repoMetadataToGitHubApiUrl(repoMetadata) {
|
|
|
4270
4492
|
return undefined;
|
|
4271
4493
|
}
|
|
4272
4494
|
|
|
4495
|
+
/**
|
|
4496
|
+
* Method to run cli command `pixi install`
|
|
4497
|
+
*
|
|
4498
|
+
*
|
|
4499
|
+
*/
|
|
4500
|
+
export function generatePixiLockFile(path) {
|
|
4501
|
+
const result = spawnSync("pixi", ["install"], {
|
|
4502
|
+
encoding: "utf-8",
|
|
4503
|
+
});
|
|
4504
|
+
|
|
4505
|
+
if (result.status !== 0) {
|
|
4506
|
+
// Handle errors
|
|
4507
|
+
if (result.error && result.error.code === "ENOENT") {
|
|
4508
|
+
console.error(
|
|
4509
|
+
"Error: pixi command not found. Make sure pixi.js is installed globally.",
|
|
4510
|
+
);
|
|
4511
|
+
} else {
|
|
4512
|
+
console.error(
|
|
4513
|
+
`Error executing pixi install: ${result.error || result.stderr.toString()}`,
|
|
4514
|
+
);
|
|
4515
|
+
}
|
|
4516
|
+
process.exit(1);
|
|
4517
|
+
} else {
|
|
4518
|
+
console.log("Dependencies installed successfully.");
|
|
4519
|
+
}
|
|
4520
|
+
}
|
|
4521
|
+
|
|
4273
4522
|
/**
|
|
4274
4523
|
* Method to split GitHub url into its parts
|
|
4275
4524
|
* @param {String} repoUrl Repository url
|
|
@@ -6136,7 +6385,29 @@ export function recurseImageNameLookup(keyValueObj, pkgList, imgList) {
|
|
|
6136
6385
|
return imgList;
|
|
6137
6386
|
}
|
|
6138
6387
|
|
|
6388
|
+
function substituteBuildArgs(statement, buildArgs) {
|
|
6389
|
+
for (const argMatch of [
|
|
6390
|
+
...statement.matchAll(/\${?([^:\/\\}]+)}?/g),
|
|
6391
|
+
].reverse()) {
|
|
6392
|
+
const fullArgName = argMatch[0];
|
|
6393
|
+
const argName = argMatch[1];
|
|
6394
|
+
const argIndex = argMatch.index;
|
|
6395
|
+
if (buildArgs.has(argName)) {
|
|
6396
|
+
statement =
|
|
6397
|
+
statement.slice(0, argIndex) +
|
|
6398
|
+
buildArgs.get(argName) +
|
|
6399
|
+
statement.slice(argIndex + fullArgName.length);
|
|
6400
|
+
} else {
|
|
6401
|
+
console.warn(
|
|
6402
|
+
`Unable to substitute build argument '${fullArgName}' in '${statement}'.`,
|
|
6403
|
+
);
|
|
6404
|
+
}
|
|
6405
|
+
}
|
|
6406
|
+
return statement;
|
|
6407
|
+
}
|
|
6408
|
+
|
|
6139
6409
|
export function parseContainerFile(fileContents) {
|
|
6410
|
+
const buildArgs = new Map();
|
|
6140
6411
|
const imagesSet = new Set();
|
|
6141
6412
|
const buildStageNames = [];
|
|
6142
6413
|
for (let line of fileContents.split("\n")) {
|
|
@@ -6146,11 +6417,26 @@ export function parseContainerFile(fileContents) {
|
|
|
6146
6417
|
continue; // skip commented out lines
|
|
6147
6418
|
}
|
|
6148
6419
|
|
|
6420
|
+
if (line.startsWith("ARG")) {
|
|
6421
|
+
const argStatement = line.split("ARG ")[1].split("=");
|
|
6422
|
+
|
|
6423
|
+
if (argStatement.length < 2) {
|
|
6424
|
+
continue; // skip ARG statements without default value
|
|
6425
|
+
}
|
|
6426
|
+
|
|
6427
|
+
const argName = argStatement[0].trim();
|
|
6428
|
+
let argValue = argStatement[1].trim().replace(/['"]+/g, "");
|
|
6429
|
+
if (argValue.includes("$")) {
|
|
6430
|
+
argValue = substituteBuildArgs(argValue, buildArgs);
|
|
6431
|
+
}
|
|
6432
|
+
buildArgs.set(argName, argValue);
|
|
6433
|
+
}
|
|
6434
|
+
|
|
6149
6435
|
if (line.startsWith("FROM")) {
|
|
6150
6436
|
// The alias could be called AS or as
|
|
6151
6437
|
const fromStatement = line.split("FROM ")[1].split(/\s(as|AS)\s/);
|
|
6152
6438
|
|
|
6153
|
-
|
|
6439
|
+
let imageStatement = fromStatement[0].trim();
|
|
6154
6440
|
const buildStageName =
|
|
6155
6441
|
fromStatement.length > 1
|
|
6156
6442
|
? fromStatement[fromStatement.length - 1].trim()
|
|
@@ -6163,6 +6449,15 @@ export function parseContainerFile(fileContents) {
|
|
|
6163
6449
|
}
|
|
6164
6450
|
continue;
|
|
6165
6451
|
}
|
|
6452
|
+
if (imageStatement.includes("$")) {
|
|
6453
|
+
imageStatement = substituteBuildArgs(imageStatement, buildArgs);
|
|
6454
|
+
if (imageStatement.includes("$")) {
|
|
6455
|
+
console.warn(
|
|
6456
|
+
`Unable to substitute build arguments in '${line}' statement.`,
|
|
6457
|
+
);
|
|
6458
|
+
continue;
|
|
6459
|
+
}
|
|
6460
|
+
}
|
|
6166
6461
|
imagesSet.add(imageStatement);
|
|
6167
6462
|
|
|
6168
6463
|
if (buildStageName) {
|
|
@@ -7329,6 +7624,9 @@ export function parseCsProjAssetsData(csProjData, assetsJsonFile) {
|
|
|
7329
7624
|
// extract name, operator, version from .NET package representation
|
|
7330
7625
|
// like "NLog >= 4.5.0"
|
|
7331
7626
|
function extractNameOperatorVersion(inputStr) {
|
|
7627
|
+
if (!inputStr) {
|
|
7628
|
+
return null;
|
|
7629
|
+
}
|
|
7332
7630
|
const extractNameOperatorVersion = /([\w.-]+)\s*([><=!]+)\s*([\d.]+)/;
|
|
7333
7631
|
const match = inputStr.match(extractNameOperatorVersion);
|
|
7334
7632
|
|
|
@@ -7821,7 +8119,7 @@ export function parseComposerLock(pkgLockFile, rootRequires) {
|
|
|
7821
8119
|
"composer",
|
|
7822
8120
|
group,
|
|
7823
8121
|
name,
|
|
7824
|
-
pkg.version,
|
|
8122
|
+
pkg.version?.toString(),
|
|
7825
8123
|
null,
|
|
7826
8124
|
null,
|
|
7827
8125
|
).toString();
|
|
@@ -7830,7 +8128,7 @@ export function parseComposerLock(pkgLockFile, rootRequires) {
|
|
|
7830
8128
|
name: name,
|
|
7831
8129
|
purl,
|
|
7832
8130
|
"bom-ref": decodeURIComponent(purl),
|
|
7833
|
-
version: pkg.version,
|
|
8131
|
+
version: pkg.version?.toString(),
|
|
7834
8132
|
repository: pkg.source,
|
|
7835
8133
|
license: pkg.license,
|
|
7836
8134
|
description: pkg.description,
|
|
@@ -11045,6 +11343,7 @@ export function getCppModules(src, options, osPkgsList, epkgList) {
|
|
|
11045
11343
|
const epkgMap = {};
|
|
11046
11344
|
let parentComponent = undefined;
|
|
11047
11345
|
const dependsOn = [];
|
|
11346
|
+
|
|
11048
11347
|
(epkgList || []).forEach((p) => {
|
|
11049
11348
|
epkgMap[`${p.group}/${p.name}`] = p;
|
|
11050
11349
|
});
|
|
@@ -11193,6 +11492,12 @@ export function getCppModules(src, options, osPkgsList, epkgList) {
|
|
|
11193
11492
|
const version = "";
|
|
11194
11493
|
// We need to resolve the name to an os package here
|
|
11195
11494
|
const name = fileName.replace(extn, "");
|
|
11495
|
+
// Logic here if name matches the standard library of cpp
|
|
11496
|
+
// we skip it
|
|
11497
|
+
// Load the glibc-stdlib.json file, which contains std lib for cpp
|
|
11498
|
+
if (CPP_STD_MODULES.includes(name)) {
|
|
11499
|
+
continue;
|
|
11500
|
+
}
|
|
11196
11501
|
let apkg = getOSPackageForFile(afile, osPkgsList) ||
|
|
11197
11502
|
epkgMap[`${group}/${name}`] || {
|
|
11198
11503
|
name,
|
package/utils.test.js
CHANGED
|
@@ -3033,8 +3033,8 @@ test("parsePnpmLock", async () => {
|
|
|
3033
3033
|
expect(parsedList.dependenciesList).toHaveLength(462);
|
|
3034
3034
|
expect(parsedList.pkgList.filter((pkg) => !pkg.scope)).toHaveLength(3);
|
|
3035
3035
|
parsedList = await parsePnpmLock("./pnpm-lock.yaml");
|
|
3036
|
-
expect(parsedList.pkgList.length).toEqual(
|
|
3037
|
-
expect(parsedList.dependenciesList.length).toEqual(
|
|
3036
|
+
expect(parsedList.pkgList.length).toEqual(653);
|
|
3037
|
+
expect(parsedList.dependenciesList.length).toEqual(653);
|
|
3038
3038
|
expect(parsedList.pkgList[0]).toEqual({
|
|
3039
3039
|
group: "@ampproject",
|
|
3040
3040
|
name: "remapping",
|
|
@@ -4047,7 +4047,7 @@ test("parse containerfiles / dockerfiles", () => {
|
|
|
4047
4047
|
const dep_list = parseContainerFile(
|
|
4048
4048
|
readFileSync("./test/data/Dockerfile", { encoding: "utf-8" }),
|
|
4049
4049
|
);
|
|
4050
|
-
expect(dep_list.length).toEqual(
|
|
4050
|
+
expect(dep_list.length).toEqual(7);
|
|
4051
4051
|
expect(dep_list[0]).toEqual({
|
|
4052
4052
|
image: "hello-world",
|
|
4053
4053
|
});
|
|
@@ -4060,6 +4060,15 @@ test("parse containerfiles / dockerfiles", () => {
|
|
|
4060
4060
|
expect(dep_list[3]).toEqual({
|
|
4061
4061
|
image: "hello-world:latest@sha256:1234567890abcdef",
|
|
4062
4062
|
});
|
|
4063
|
+
expect(dep_list[4]).toEqual({
|
|
4064
|
+
image: "docker.io/hello-world@sha256:1234567890abcdef",
|
|
4065
|
+
});
|
|
4066
|
+
expect(dep_list[5]).toEqual({
|
|
4067
|
+
image: "docker.io/hello-world:latest@sha256:1234567890abcdef",
|
|
4068
|
+
});
|
|
4069
|
+
expect(dep_list[6]).toEqual({
|
|
4070
|
+
image: "docker.io/hello-world:latest",
|
|
4071
|
+
});
|
|
4063
4072
|
});
|
|
4064
4073
|
|
|
4065
4074
|
test("parse bitbucket-pipelines", () => {
|