@trustify-da/trustify-da-javascript-client 0.3.0-ea.de12f6a → 0.3.0-ea.e5bb86c
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 +56 -2
- package/dist/package.json +1 -1
- package/dist/src/analysis.js +3 -2
- package/dist/src/cyclone_dx_sbom.d.ts +7 -0
- package/dist/src/cyclone_dx_sbom.js +14 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/provider.js +4 -0
- package/dist/src/providers/base_javascript.js +34 -3
- package/dist/src/providers/base_pyproject.d.ts +147 -0
- package/dist/src/providers/base_pyproject.js +279 -0
- package/dist/src/providers/manifest.d.ts +2 -0
- package/dist/src/providers/manifest.js +22 -4
- package/dist/src/providers/processors/yarn_berry_processor.js +82 -3
- package/dist/src/providers/python_poetry.d.ts +42 -0
- package/dist/src/providers/python_poetry.js +146 -0
- package/dist/src/providers/python_uv.d.ts +26 -0
- package/dist/src/providers/python_uv.js +118 -0
- package/dist/src/sbom.d.ts +7 -0
- package/dist/src/sbom.js +9 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -224,7 +224,8 @@ $ trustify-da-javascript-client license /path/to/package.json
|
|
|
224
224
|
<li><a href="https://www.javascript.com/">JavaScript</a> - <a href="https://pnpm.io/">pnpm</a></li>
|
|
225
225
|
<li><a href="https://www.javascript.com/">JavaScript</a> - <a href="https://classic.yarnpkg.com/">Yarn Classic</a> / <a href="https://yarnpkg.com/">Yarn Berry</a></li>
|
|
226
226
|
<li><a href="https://go.dev/">Golang</a> - <a href="https://go.dev/blog/using-go-modules/">Go Modules</a></li>
|
|
227
|
-
<li><a href="https://www.python.org/">Python</a> - <a href="https://pypi.org/project/pip/">pip Installer</a
|
|
227
|
+
<li><a href="https://www.python.org/">Python</a> - <a href="https://pypi.org/project/pip/">pip Installer</a> (<code>requirements.txt</code>)</li>
|
|
228
|
+
<li><a href="https://www.python.org/">Python</a> - <a href="https://python-poetry.org/">Poetry</a> / <a href="https://docs.astral.sh/uv/">uv</a> (<code>pyproject.toml</code>)</li>
|
|
228
229
|
<li><a href="https://gradle.org/">Gradle (Groovy and Kotlin DSL)</a> - <a href="https://gradle.org/install/">Gradle Installation</a></li>
|
|
229
230
|
<li><a href="https://www.rust-lang.org/">Rust</a> - <a href="https://doc.rust-lang.org/cargo/">Cargo</a></li>
|
|
230
231
|
</ul>
|
|
@@ -391,7 +392,30 @@ version = "1.10"
|
|
|
391
392
|
log = "0.4" # trustify-da-ignore
|
|
392
393
|
```
|
|
393
394
|
|
|
394
|
-
|
|
395
|
+
|
|
396
|
+
<em>Python pyproject.toml</em> users can add a comment with <code>#exhortignore</code> (or <code># trustify-da-ignore</code>) next to the dependency in <code>pyproject.toml</code>.
|
|
397
|
+
|
|
398
|
+
PEP 621 style (<code>[project]</code> dependencies):
|
|
399
|
+
```toml
|
|
400
|
+
[project]
|
|
401
|
+
dependencies = [
|
|
402
|
+
"flask>=2.0.3",
|
|
403
|
+
"requests>=2.25.1",
|
|
404
|
+
"uvicorn>=0.17.0", #exhortignore
|
|
405
|
+
"click>=8.0.4", # trustify-da-ignore
|
|
406
|
+
]
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
Poetry style (<code>[tool.poetry.dependencies]</code>):
|
|
410
|
+
```toml
|
|
411
|
+
[tool.poetry.dependencies]
|
|
412
|
+
flask = "^2.0.3"
|
|
413
|
+
requests = "^2.25.1"
|
|
414
|
+
uvicorn = "^0.17.0" #exhortignore
|
|
415
|
+
click = "^8.0.4" # trustify-da-ignore
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
All of the above examples are valid for marking a package to be ignored
|
|
395
419
|
</li>
|
|
396
420
|
</ul>
|
|
397
421
|
|
|
@@ -421,6 +445,8 @@ let options = {
|
|
|
421
445
|
'TRUSTIFY_DA_PIP3_PATH' : '/path/to/pip3',
|
|
422
446
|
'TRUSTIFY_DA_PYTHON_PATH' : '/path/to/python',
|
|
423
447
|
'TRUSTIFY_DA_PIP_PATH' : '/path/to/pip',
|
|
448
|
+
'TRUSTIFY_DA_UV_PATH' : '/path/to/uv',
|
|
449
|
+
'TRUSTIFY_DA_POETRY_PATH' : '/path/to/poetry',
|
|
424
450
|
'TRUSTIFY_DA_GRADLE_PATH' : '/path/to/gradle',
|
|
425
451
|
'TRUSTIFY_DA_CARGO_PATH' : '/path/to/cargo',
|
|
426
452
|
// Workspace root for monorepos (Cargo, npm/pnpm/yarn); lock file expected here
|
|
@@ -567,6 +593,16 @@ following keys for setting custom paths for the said executables.
|
|
|
567
593
|
<td>TRUSTIFY_DA_CARGO_PATH</td>
|
|
568
594
|
</tr>
|
|
569
595
|
<tr>
|
|
596
|
+
<td><a href="https://docs.astral.sh/uv/">uv</a></td>
|
|
597
|
+
<td><em>uv</em></td>
|
|
598
|
+
<td>TRUSTIFY_DA_UV_PATH</td>
|
|
599
|
+
</tr>
|
|
600
|
+
<tr>
|
|
601
|
+
<td><a href="https://python-poetry.org/">Poetry</a></td>
|
|
602
|
+
<td><em>poetry</em></td>
|
|
603
|
+
<td>TRUSTIFY_DA_POETRY_PATH</td>
|
|
604
|
+
</tr>
|
|
605
|
+
<tr>
|
|
570
606
|
<td>Workspace root (monorepos)</td>
|
|
571
607
|
<td>—</td>
|
|
572
608
|
<td>workspaceDir / TRUSTIFY_DA_WORKSPACE_DIR</td>
|
|
@@ -619,6 +655,24 @@ TRUSTIFY_DA_GO_MVS_LOGIC_ENABLED=false
|
|
|
619
655
|
|
|
620
656
|
#### Python Support
|
|
621
657
|
|
|
658
|
+
The client supports two Python manifest formats:
|
|
659
|
+
|
|
660
|
+
- **`requirements.txt`** — uses pip/pip3 to resolve dependencies
|
|
661
|
+
- **`pyproject.toml`** — uses [uv](https://docs.astral.sh/uv/) or [Poetry](https://python-poetry.org/) to resolve dependencies
|
|
662
|
+
|
|
663
|
+
##### pyproject.toml
|
|
664
|
+
|
|
665
|
+
For `pyproject.toml` projects, the client detects which tool manages the project by checking for lock files:
|
|
666
|
+
- If `poetry.lock` is present and `[tool.poetry]` is defined, **Poetry** is used (`poetry show --tree` and `poetry show --all`)
|
|
667
|
+
- If `uv.lock` is present, **uv** is used (`uv export --format requirements.txt --frozen --no-hashes`)
|
|
668
|
+
- If neither lock file is found, an error is thrown
|
|
669
|
+
|
|
670
|
+
Both PEP 621 (`[project]` dependencies) and Poetry-style (`[tool.poetry.dependencies]`) are supported.
|
|
671
|
+
|
|
672
|
+
Custom executable paths can be set via `TRUSTIFY_DA_UV_PATH` and `TRUSTIFY_DA_POETRY_PATH`.
|
|
673
|
+
|
|
674
|
+
##### requirements.txt
|
|
675
|
+
|
|
622
676
|
By default, For python support, the api assumes that the package is installed using the pip/pip3 binary on the system PATH, or using the customized
|
|
623
677
|
Binaries passed to environment variables. In any case, If the package is not installed , then an error will be thrown.
|
|
624
678
|
|
package/dist/package.json
CHANGED
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"lint": "eslint src test --ext js",
|
|
39
39
|
"lint:fix": "eslint src test --ext js --fix",
|
|
40
40
|
"test": "c8 npm run tests",
|
|
41
|
-
"tests": "mocha --config .mocharc.json
|
|
41
|
+
"tests": "mocha --config .mocharc.json",
|
|
42
42
|
"tests:rep": "mocha --reporter-option maxDiffSize=0 --reporter json > unit-tests-result.json",
|
|
43
43
|
"pretest": "cp node_modules/tree-sitter-requirements/tree-sitter-requirements.wasm src/providers/tree-sitter-requirements.wasm && cp node_modules/tree-sitter-gomod/tree-sitter-gomod.wasm src/providers/tree-sitter-gomod.wasm",
|
|
44
44
|
"precompile": "rm -rf dist",
|
package/dist/src/analysis.js
CHANGED
|
@@ -189,7 +189,7 @@ async function requestImages(imageRefs, url, html = false, opts = {}) {
|
|
|
189
189
|
if (opts['TRUSTIFY_DA_RECOMMENDATIONS_ENABLED'] === 'false') {
|
|
190
190
|
finalUrl.searchParams.append('recommend', 'false');
|
|
191
191
|
}
|
|
192
|
-
const
|
|
192
|
+
const fetchOptions = addProxyAgent({
|
|
193
193
|
method: 'POST',
|
|
194
194
|
headers: {
|
|
195
195
|
'Accept': html ? 'text/html' : 'application/json',
|
|
@@ -197,7 +197,8 @@ async function requestImages(imageRefs, url, html = false, opts = {}) {
|
|
|
197
197
|
...getTokenHeaders(opts)
|
|
198
198
|
},
|
|
199
199
|
body: JSON.stringify(imageSboms),
|
|
200
|
-
});
|
|
200
|
+
}, opts);
|
|
201
|
+
const resp = await fetch(finalUrl, fetchOptions);
|
|
201
202
|
if (resp.status === 200) {
|
|
202
203
|
let result;
|
|
203
204
|
if (!html) {
|
|
@@ -70,6 +70,13 @@ export default class CycloneDxSbom {
|
|
|
70
70
|
* @return {boolean}
|
|
71
71
|
*/
|
|
72
72
|
checkIfPackageInsideDependsOnList(component: any, name: string): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Checks if any entry in the dependsOn list of sourceRef starts with the given purl prefix.
|
|
75
|
+
* @param {PackageURL} sourceRef - The source component
|
|
76
|
+
* @param {string} purlPrefix - The purl prefix to match (e.g. "pkg:npm/minimist@")
|
|
77
|
+
* @return {boolean}
|
|
78
|
+
*/
|
|
79
|
+
checkDependsOnByPurlPrefix(sourceRef: PackageURL, purlPrefix: string): boolean;
|
|
73
80
|
/** Removes the root component from the sbom
|
|
74
81
|
*/
|
|
75
82
|
removeRootComponent(): void;
|
|
@@ -242,6 +242,20 @@ export default class CycloneDxSbom {
|
|
|
242
242
|
return false;
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
|
+
/**
|
|
246
|
+
* Checks if any entry in the dependsOn list of sourceRef starts with the given purl prefix.
|
|
247
|
+
* @param {PackageURL} sourceRef - The source component
|
|
248
|
+
* @param {string} purlPrefix - The purl prefix to match (e.g. "pkg:npm/minimist@")
|
|
249
|
+
* @return {boolean}
|
|
250
|
+
*/
|
|
251
|
+
checkDependsOnByPurlPrefix(sourceRef, purlPrefix) {
|
|
252
|
+
const sourcePurl = sourceRef.toString();
|
|
253
|
+
const depIndex = this.getDependencyIndex(sourcePurl);
|
|
254
|
+
if (depIndex < 0) {
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
|
+
return this.dependencies[depIndex].dependsOn.some(dep => dep.startsWith(purlPrefix));
|
|
258
|
+
}
|
|
245
259
|
/** Removes the root component from the sbom
|
|
246
260
|
*/
|
|
247
261
|
removeRootComponent() {
|
package/dist/src/index.d.ts
CHANGED
|
@@ -64,6 +64,8 @@ export type Options = {
|
|
|
64
64
|
TRUSTIFY_DA_CONTINUE_ON_ERROR?: string | undefined;
|
|
65
65
|
batchMetadata?: boolean | undefined;
|
|
66
66
|
TRUSTIFY_DA_BATCH_METADATA?: string | undefined;
|
|
67
|
+
TRUSTIFY_DA_UV_PATH?: string | undefined;
|
|
68
|
+
TRUSTIFY_DA_POETRY_PATH?: string | undefined;
|
|
67
69
|
[key: string]: string | number | boolean | string[] | undefined;
|
|
68
70
|
};
|
|
69
71
|
export type BatchAnalysisMetadata = {
|
package/dist/src/index.js
CHANGED
|
@@ -56,6 +56,8 @@ export { discoverWorkspacePackages, discoverWorkspaceCrates, validatePackageJson
|
|
|
56
56
|
* TRUSTIFY_DA_CONTINUE_ON_ERROR?: string | undefined,
|
|
57
57
|
* batchMetadata?: boolean | undefined,
|
|
58
58
|
* TRUSTIFY_DA_BATCH_METADATA?: string | undefined,
|
|
59
|
+
* TRUSTIFY_DA_UV_PATH?: string | undefined,
|
|
60
|
+
* TRUSTIFY_DA_POETRY_PATH?: string | undefined,
|
|
59
61
|
* [key: string]: string | number | boolean | string[] | undefined,
|
|
60
62
|
* }} Options
|
|
61
63
|
*/
|
package/dist/src/provider.js
CHANGED
|
@@ -7,6 +7,8 @@ import Javascript_npm from './providers/javascript_npm.js';
|
|
|
7
7
|
import Javascript_pnpm from './providers/javascript_pnpm.js';
|
|
8
8
|
import Javascript_yarn from './providers/javascript_yarn.js';
|
|
9
9
|
import pythonPipProvider from './providers/python_pip.js';
|
|
10
|
+
import Python_poetry from './providers/python_poetry.js';
|
|
11
|
+
import Python_uv from './providers/python_uv.js';
|
|
10
12
|
import rustCargoProvider from './providers/rust_cargo.js';
|
|
11
13
|
/** @typedef {{ecosystem: string, contentType: string, content: string}} Provided */
|
|
12
14
|
/** @typedef {{isSupported: function(string): boolean, validateLockFile: function(string, Object): void, provideComponent: function(string, {}): Provided | Promise<Provided>, provideStack: function(string, {}): Provided | Promise<Provided>, readLicenseFromManifest: function(string): string | null}} Provider */
|
|
@@ -23,6 +25,8 @@ export const availableProviders = [
|
|
|
23
25
|
new Javascript_npm(),
|
|
24
26
|
golangGomodulesProvider,
|
|
25
27
|
pythonPipProvider,
|
|
28
|
+
new Python_poetry(),
|
|
29
|
+
new Python_uv(),
|
|
26
30
|
rustCargoProvider
|
|
27
31
|
];
|
|
28
32
|
/**
|
|
@@ -235,9 +235,32 @@ export default class Base_javascript {
|
|
|
235
235
|
let sbom = new Sbom();
|
|
236
236
|
sbom.addRoot(mainComponent, license);
|
|
237
237
|
this._addDependenciesToSbom(sbom, depsObject);
|
|
238
|
+
this.#ensurePeerAndOptionalDeps(sbom);
|
|
238
239
|
sbom.filterIgnoredDeps(this.#manifest.ignored);
|
|
239
240
|
return sbom.getAsJsonString(opts);
|
|
240
241
|
}
|
|
242
|
+
/**
|
|
243
|
+
* Ensures peer and optional dependencies declared in the manifest are
|
|
244
|
+
* present in the SBOM, even when the package manager does not resolve them
|
|
245
|
+
* (e.g. yarn does not include peer deps in its dependency listing).
|
|
246
|
+
* @param {Sbom} sbom - The SBOM to supplement
|
|
247
|
+
* @private
|
|
248
|
+
*/
|
|
249
|
+
#ensurePeerAndOptionalDeps(sbom) {
|
|
250
|
+
const rootPurl = toPurl(purlType, this.#manifest.name, this.#manifest.version);
|
|
251
|
+
const depSources = [this.#manifest.peerDependencies, this.#manifest.optionalDependencies];
|
|
252
|
+
for (const source of depSources) {
|
|
253
|
+
for (const [name, version] of Object.entries(source)) {
|
|
254
|
+
// Build the purl prefix for exact matching (e.g. "pkg:npm/minimist@"
|
|
255
|
+
// or "pkg:npm/%40hapi/joi@") to avoid substring false positives
|
|
256
|
+
const probe = toPurl(purlType, name, version);
|
|
257
|
+
const purlPrefix = probe.toString().replace(/@[^@]*$/, '@');
|
|
258
|
+
if (!sbom.checkDependsOnByPurlPrefix(rootPurl, purlPrefix)) {
|
|
259
|
+
sbom.addDependency(rootPurl, probe);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
241
264
|
/**
|
|
242
265
|
* Recursively builds the Sbom from the JSON that npm listing returns
|
|
243
266
|
* @param {Sbom} sbom - The SBOM object to add dependencies to
|
|
@@ -245,7 +268,10 @@ export default class Base_javascript {
|
|
|
245
268
|
* @protected
|
|
246
269
|
*/
|
|
247
270
|
_addDependenciesToSbom(sbom, depTree) {
|
|
248
|
-
const dependencies =
|
|
271
|
+
const dependencies = {
|
|
272
|
+
...depTree["dependencies"],
|
|
273
|
+
...depTree["optionalDependencies"],
|
|
274
|
+
};
|
|
249
275
|
Object.entries(dependencies)
|
|
250
276
|
.forEach(entry => {
|
|
251
277
|
const [name, artifact] = entry;
|
|
@@ -295,6 +321,7 @@ export default class Base_javascript {
|
|
|
295
321
|
const rootPurl = toPurlFromString(sbom.getRoot().purl);
|
|
296
322
|
sbom.addDependency(rootPurl, rootDeps.get(key));
|
|
297
323
|
}
|
|
324
|
+
this.#ensurePeerAndOptionalDeps(sbom);
|
|
298
325
|
sbom.filterIgnoredDeps(this.#manifest.ignored);
|
|
299
326
|
return sbom.getAsJsonString(opts);
|
|
300
327
|
}
|
|
@@ -305,10 +332,14 @@ export default class Base_javascript {
|
|
|
305
332
|
* @protected
|
|
306
333
|
*/
|
|
307
334
|
_getRootDependencies(depTree) {
|
|
308
|
-
|
|
335
|
+
const allDeps = {
|
|
336
|
+
...depTree.dependencies,
|
|
337
|
+
...depTree.optionalDependencies,
|
|
338
|
+
};
|
|
339
|
+
if (Object.keys(allDeps).length === 0) {
|
|
309
340
|
return new Map();
|
|
310
341
|
}
|
|
311
|
-
return new Map(Object.entries(
|
|
342
|
+
return new Map(Object.entries(allDeps).map(([key, value]) => [key, toPurl(purlType, key, value.version)]));
|
|
312
343
|
}
|
|
313
344
|
/**
|
|
314
345
|
* Executes the list command to get dependencies
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/** @typedef {{name: string, version: string, children: string[]}} GraphEntry */
|
|
2
|
+
/** @typedef {{name: string, version: string, dependencies: DepTreeEntry[]}} DepTreeEntry */
|
|
3
|
+
/** @typedef {{directDeps: string[], graph: Map<string, GraphEntry>}} DependencyData */
|
|
4
|
+
/** @typedef {{ecosystem: string, content: string, contentType: string}} Provided */
|
|
5
|
+
export default class Base_pyproject {
|
|
6
|
+
/**
|
|
7
|
+
* @param {string} manifestName
|
|
8
|
+
* @returns {boolean}
|
|
9
|
+
*/
|
|
10
|
+
isSupported(manifestName: string): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* @param {string} manifestDir
|
|
13
|
+
* @returns {boolean}
|
|
14
|
+
*/
|
|
15
|
+
validateLockFile(manifestDir: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Read project license from pyproject.toml, with fallback to LICENSE file.
|
|
18
|
+
* @param {string} manifestPath
|
|
19
|
+
* @returns {string|null}
|
|
20
|
+
*/
|
|
21
|
+
readLicenseFromManifest(manifestPath: string): string | null;
|
|
22
|
+
/**
|
|
23
|
+
* @param {string} manifest - path to pyproject.toml
|
|
24
|
+
* @param {Object} [opts={}]
|
|
25
|
+
* @returns {Promise<Provided>}
|
|
26
|
+
*/
|
|
27
|
+
provideStack(manifest: string, opts?: any): Promise<Provided>;
|
|
28
|
+
/**
|
|
29
|
+
* @param {string} manifest - path to pyproject.toml
|
|
30
|
+
* @param {Object} [opts={}]
|
|
31
|
+
* @returns {Promise<Provided>}
|
|
32
|
+
*/
|
|
33
|
+
provideComponent(manifest: string, opts?: any): Promise<Provided>;
|
|
34
|
+
/**
|
|
35
|
+
* @returns {string}
|
|
36
|
+
* @protected
|
|
37
|
+
*/
|
|
38
|
+
protected _lockFileName(): string;
|
|
39
|
+
/**
|
|
40
|
+
* @returns {string}
|
|
41
|
+
* @protected
|
|
42
|
+
*/
|
|
43
|
+
protected _cmdName(): string;
|
|
44
|
+
/**
|
|
45
|
+
* Resolve dependencies using the tool-specific command and parser.
|
|
46
|
+
* @param {string} manifestDir
|
|
47
|
+
* @param {object} parsed - parsed pyproject.toml
|
|
48
|
+
* @param {Object} opts
|
|
49
|
+
* @returns {Promise<DependencyData>}
|
|
50
|
+
* @protected
|
|
51
|
+
*/
|
|
52
|
+
protected _getDependencyData(manifestDir: string, parsed: object, opts: any): Promise<DependencyData>;
|
|
53
|
+
/**
|
|
54
|
+
* Canonicalize a Python package name per PEP 503.
|
|
55
|
+
* @param {string} name
|
|
56
|
+
* @returns {string}
|
|
57
|
+
* @protected
|
|
58
|
+
*/
|
|
59
|
+
protected _canonicalize(name: string): string;
|
|
60
|
+
/**
|
|
61
|
+
* Get the project name from pyproject.toml.
|
|
62
|
+
* @param {object} parsed
|
|
63
|
+
* @returns {string|null}
|
|
64
|
+
* @protected
|
|
65
|
+
*/
|
|
66
|
+
protected _getProjectName(parsed: object): string | null;
|
|
67
|
+
/**
|
|
68
|
+
* Get the project version from pyproject.toml.
|
|
69
|
+
* @param {object} parsed
|
|
70
|
+
* @returns {string|null}
|
|
71
|
+
* @protected
|
|
72
|
+
*/
|
|
73
|
+
protected _getProjectVersion(parsed: object): string | null;
|
|
74
|
+
/**
|
|
75
|
+
* Scan raw pyproject.toml text for dependencies with ignore markers.
|
|
76
|
+
* @param {string} manifestPath
|
|
77
|
+
* @returns {Set<string>}
|
|
78
|
+
* @protected
|
|
79
|
+
*/
|
|
80
|
+
protected _getIgnoredDeps(manifestPath: string): Set<string>;
|
|
81
|
+
/**
|
|
82
|
+
* Build dependency tree from graph, starting from direct deps.
|
|
83
|
+
* @param {Map<string, GraphEntry>} graph
|
|
84
|
+
* @param {string[]} directDeps - canonical names of direct deps
|
|
85
|
+
* @param {Set<string>} ignoredDeps
|
|
86
|
+
* @param {boolean} includeTransitive
|
|
87
|
+
* @returns {DepTreeEntry[]}
|
|
88
|
+
* @protected
|
|
89
|
+
*/
|
|
90
|
+
protected _buildDependencyTree(graph: Map<string, GraphEntry>, directDeps: string[], ignoredDeps: Set<string>, includeTransitive: boolean): DepTreeEntry[];
|
|
91
|
+
/**
|
|
92
|
+
* Recursively collect transitive dependencies.
|
|
93
|
+
* @param {Map<string, GraphEntry>} graph
|
|
94
|
+
* @param {string[]} childKeys
|
|
95
|
+
* @param {DepTreeEntry[]} result - mutated in place
|
|
96
|
+
* @param {Set<string>} ignoredDeps
|
|
97
|
+
* @param {Set<string>} visited
|
|
98
|
+
* @returns {void}
|
|
99
|
+
* @protected
|
|
100
|
+
*/
|
|
101
|
+
protected _collectTransitive(graph: Map<string, GraphEntry>, childKeys: string[], result: DepTreeEntry[], ignoredDeps: Set<string>, visited: Set<string>): void;
|
|
102
|
+
/**
|
|
103
|
+
* @param {string} name
|
|
104
|
+
* @param {string} version
|
|
105
|
+
* @returns {PackageURL}
|
|
106
|
+
* @protected
|
|
107
|
+
*/
|
|
108
|
+
protected _toPurl(name: string, version: string): PackageURL;
|
|
109
|
+
/**
|
|
110
|
+
* Recursively add a dependency and its transitive deps to the SBOM.
|
|
111
|
+
* @param {PackageURL} source
|
|
112
|
+
* @param {DepTreeEntry} dep
|
|
113
|
+
* @param {Sbom} sbom
|
|
114
|
+
* @returns {void}
|
|
115
|
+
* @private
|
|
116
|
+
*/
|
|
117
|
+
private _addAllDependencies;
|
|
118
|
+
/**
|
|
119
|
+
* Create SBOM json string for a pyproject.toml project.
|
|
120
|
+
* @param {string} manifest - path to pyproject.toml
|
|
121
|
+
* @param {Object} opts
|
|
122
|
+
* @param {boolean} includeTransitive
|
|
123
|
+
* @returns {Promise<string>}
|
|
124
|
+
* @private
|
|
125
|
+
*/
|
|
126
|
+
private _createSbom;
|
|
127
|
+
}
|
|
128
|
+
export type GraphEntry = {
|
|
129
|
+
name: string;
|
|
130
|
+
version: string;
|
|
131
|
+
children: string[];
|
|
132
|
+
};
|
|
133
|
+
export type DepTreeEntry = {
|
|
134
|
+
name: string;
|
|
135
|
+
version: string;
|
|
136
|
+
dependencies: DepTreeEntry[];
|
|
137
|
+
};
|
|
138
|
+
export type DependencyData = {
|
|
139
|
+
directDeps: string[];
|
|
140
|
+
graph: Map<string, GraphEntry>;
|
|
141
|
+
};
|
|
142
|
+
export type Provided = {
|
|
143
|
+
ecosystem: string;
|
|
144
|
+
content: string;
|
|
145
|
+
contentType: string;
|
|
146
|
+
};
|
|
147
|
+
import { PackageURL } from 'packageurl-js';
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { PackageURL } from 'packageurl-js';
|
|
4
|
+
import { parse as parseToml } from 'smol-toml';
|
|
5
|
+
import { getLicense } from '../license/license_utils.js';
|
|
6
|
+
import Sbom from '../sbom.js';
|
|
7
|
+
const ecosystem = 'pip';
|
|
8
|
+
const IGNORE_MARKERS = ['exhortignore', 'trustify-da-ignore'];
|
|
9
|
+
const DEFAULT_ROOT_NAME = 'default-pip-root';
|
|
10
|
+
const DEFAULT_ROOT_VERSION = '0.0.0';
|
|
11
|
+
/** @typedef {{name: string, version: string, children: string[]}} GraphEntry */
|
|
12
|
+
/** @typedef {{name: string, version: string, dependencies: DepTreeEntry[]}} DepTreeEntry */
|
|
13
|
+
/** @typedef {{directDeps: string[], graph: Map<string, GraphEntry>}} DependencyData */
|
|
14
|
+
/** @typedef {{ecosystem: string, content: string, contentType: string}} Provided */
|
|
15
|
+
export default class Base_pyproject {
|
|
16
|
+
/**
|
|
17
|
+
* @param {string} manifestName
|
|
18
|
+
* @returns {boolean}
|
|
19
|
+
*/
|
|
20
|
+
isSupported(manifestName) {
|
|
21
|
+
return 'pyproject.toml' === manifestName;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @param {string} manifestDir
|
|
25
|
+
* @returns {boolean}
|
|
26
|
+
*/
|
|
27
|
+
validateLockFile(manifestDir) {
|
|
28
|
+
return fs.existsSync(path.join(manifestDir, this._lockFileName()));
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Read project license from pyproject.toml, with fallback to LICENSE file.
|
|
32
|
+
* @param {string} manifestPath
|
|
33
|
+
* @returns {string|null}
|
|
34
|
+
*/
|
|
35
|
+
readLicenseFromManifest(manifestPath) {
|
|
36
|
+
let fromManifest = null;
|
|
37
|
+
try {
|
|
38
|
+
let content = fs.readFileSync(manifestPath, 'utf-8');
|
|
39
|
+
let parsed = parseToml(content);
|
|
40
|
+
fromManifest = parsed.project?.license;
|
|
41
|
+
if (typeof fromManifest === 'object' && fromManifest != null) {
|
|
42
|
+
fromManifest = fromManifest.text || null;
|
|
43
|
+
}
|
|
44
|
+
if (!fromManifest) {
|
|
45
|
+
fromManifest = parsed.tool?.poetry?.license || null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch (_) {
|
|
49
|
+
// leave fromManifest as null
|
|
50
|
+
}
|
|
51
|
+
return getLicense(fromManifest, manifestPath);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* @param {string} manifest - path to pyproject.toml
|
|
55
|
+
* @param {Object} [opts={}]
|
|
56
|
+
* @returns {Promise<Provided>}
|
|
57
|
+
*/
|
|
58
|
+
async provideStack(manifest, opts = {}) {
|
|
59
|
+
return {
|
|
60
|
+
ecosystem,
|
|
61
|
+
content: await this._createSbom(manifest, opts, true),
|
|
62
|
+
contentType: 'application/vnd.cyclonedx+json'
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* @param {string} manifest - path to pyproject.toml
|
|
67
|
+
* @param {Object} [opts={}]
|
|
68
|
+
* @returns {Promise<Provided>}
|
|
69
|
+
*/
|
|
70
|
+
async provideComponent(manifest, opts = {}) {
|
|
71
|
+
return {
|
|
72
|
+
ecosystem,
|
|
73
|
+
content: await this._createSbom(manifest, opts, false),
|
|
74
|
+
contentType: 'application/vnd.cyclonedx+json'
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
// --- abstract methods (subclasses must override) ---
|
|
78
|
+
/**
|
|
79
|
+
* @returns {string}
|
|
80
|
+
* @protected
|
|
81
|
+
*/
|
|
82
|
+
_lockFileName() {
|
|
83
|
+
throw new TypeError('_lockFileName must be implemented');
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* @returns {string}
|
|
87
|
+
* @protected
|
|
88
|
+
*/
|
|
89
|
+
_cmdName() {
|
|
90
|
+
throw new TypeError('_cmdName must be implemented');
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Resolve dependencies using the tool-specific command and parser.
|
|
94
|
+
* @param {string} manifestDir
|
|
95
|
+
* @param {object} parsed - parsed pyproject.toml
|
|
96
|
+
* @param {Object} opts
|
|
97
|
+
* @returns {Promise<DependencyData>}
|
|
98
|
+
* @protected
|
|
99
|
+
*/
|
|
100
|
+
// eslint-disable-next-line no-unused-vars
|
|
101
|
+
async _getDependencyData(manifestDir, parsed, opts) {
|
|
102
|
+
throw new TypeError('_getDependencyData must be implemented');
|
|
103
|
+
}
|
|
104
|
+
// --- shared helpers ---
|
|
105
|
+
/**
|
|
106
|
+
* Canonicalize a Python package name per PEP 503.
|
|
107
|
+
* @param {string} name
|
|
108
|
+
* @returns {string}
|
|
109
|
+
* @protected
|
|
110
|
+
*/
|
|
111
|
+
_canonicalize(name) {
|
|
112
|
+
return name.toLowerCase().replace(/[-_.]+/g, '-');
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Get the project name from pyproject.toml.
|
|
116
|
+
* @param {object} parsed
|
|
117
|
+
* @returns {string|null}
|
|
118
|
+
* @protected
|
|
119
|
+
*/
|
|
120
|
+
_getProjectName(parsed) {
|
|
121
|
+
return parsed.project?.name || parsed.tool?.poetry?.name || null;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Get the project version from pyproject.toml.
|
|
125
|
+
* @param {object} parsed
|
|
126
|
+
* @returns {string|null}
|
|
127
|
+
* @protected
|
|
128
|
+
*/
|
|
129
|
+
_getProjectVersion(parsed) {
|
|
130
|
+
return parsed.project?.version || parsed.tool?.poetry?.version || null;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Scan raw pyproject.toml text for dependencies with ignore markers.
|
|
134
|
+
* @param {string} manifestPath
|
|
135
|
+
* @returns {Set<string>}
|
|
136
|
+
* @protected
|
|
137
|
+
*/
|
|
138
|
+
_getIgnoredDeps(manifestPath) {
|
|
139
|
+
let ignored = new Set();
|
|
140
|
+
let content = fs.readFileSync(manifestPath, 'utf-8');
|
|
141
|
+
let lines = content.split(/\r?\n/);
|
|
142
|
+
for (let line of lines) {
|
|
143
|
+
if (!IGNORE_MARKERS.some(m => line.includes(m))) {
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
// PEP 621 style: "requests>=2.25" #exhortignore
|
|
147
|
+
let pep621Match = line.match(/^\s*"([^"]+)"/);
|
|
148
|
+
if (pep621Match) {
|
|
149
|
+
let reqStr = pep621Match[1];
|
|
150
|
+
let nameMatch = reqStr.match(/^([A-Za-z0-9]([A-Za-z0-9._-]*[A-Za-z0-9])?)/);
|
|
151
|
+
if (nameMatch) {
|
|
152
|
+
ignored.add(this._canonicalize(nameMatch[1]));
|
|
153
|
+
}
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
// Poetry style: requests = "^2.25" #exhortignore
|
|
157
|
+
let poetryMatch = line.match(/^\s*([A-Za-z0-9][A-Za-z0-9._-]*)\s*=/);
|
|
158
|
+
if (poetryMatch) {
|
|
159
|
+
ignored.add(this._canonicalize(poetryMatch[1]));
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return ignored;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Build dependency tree from graph, starting from direct deps.
|
|
166
|
+
* @param {Map<string, GraphEntry>} graph
|
|
167
|
+
* @param {string[]} directDeps - canonical names of direct deps
|
|
168
|
+
* @param {Set<string>} ignoredDeps
|
|
169
|
+
* @param {boolean} includeTransitive
|
|
170
|
+
* @returns {DepTreeEntry[]}
|
|
171
|
+
* @protected
|
|
172
|
+
*/
|
|
173
|
+
_buildDependencyTree(graph, directDeps, ignoredDeps, includeTransitive) {
|
|
174
|
+
let result = [];
|
|
175
|
+
for (let key of directDeps) {
|
|
176
|
+
if (ignoredDeps.has(key)) {
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
let entry = graph.get(key);
|
|
180
|
+
if (!entry) {
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
let depTree = [];
|
|
184
|
+
if (includeTransitive) {
|
|
185
|
+
let visited = new Set();
|
|
186
|
+
visited.add(key);
|
|
187
|
+
this._collectTransitive(graph, entry.children, depTree, ignoredDeps, visited);
|
|
188
|
+
}
|
|
189
|
+
result.push({ name: entry.name, version: entry.version, dependencies: depTree });
|
|
190
|
+
}
|
|
191
|
+
result.sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase()));
|
|
192
|
+
return result;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Recursively collect transitive dependencies.
|
|
196
|
+
* @param {Map<string, GraphEntry>} graph
|
|
197
|
+
* @param {string[]} childKeys
|
|
198
|
+
* @param {DepTreeEntry[]} result - mutated in place
|
|
199
|
+
* @param {Set<string>} ignoredDeps
|
|
200
|
+
* @param {Set<string>} visited
|
|
201
|
+
* @returns {void}
|
|
202
|
+
* @protected
|
|
203
|
+
*/
|
|
204
|
+
_collectTransitive(graph, childKeys, result, ignoredDeps, visited) {
|
|
205
|
+
for (let childKey of childKeys) {
|
|
206
|
+
let canonKey = this._canonicalize(childKey);
|
|
207
|
+
if (ignoredDeps.has(canonKey)) {
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
if (visited.has(canonKey)) {
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
visited.add(canonKey);
|
|
214
|
+
let entry = graph.get(canonKey);
|
|
215
|
+
if (!entry) {
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
let childDeps = [];
|
|
219
|
+
this._collectTransitive(graph, entry.children, childDeps, ignoredDeps, visited);
|
|
220
|
+
result.push({ name: entry.name, version: entry.version, dependencies: childDeps });
|
|
221
|
+
}
|
|
222
|
+
result.sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase()));
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* @param {string} name
|
|
226
|
+
* @param {string} version
|
|
227
|
+
* @returns {PackageURL}
|
|
228
|
+
* @protected
|
|
229
|
+
*/
|
|
230
|
+
_toPurl(name, version) {
|
|
231
|
+
return new PackageURL('pypi', undefined, name, version, undefined, undefined);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Recursively add a dependency and its transitive deps to the SBOM.
|
|
235
|
+
* @param {PackageURL} source
|
|
236
|
+
* @param {DepTreeEntry} dep
|
|
237
|
+
* @param {Sbom} sbom
|
|
238
|
+
* @returns {void}
|
|
239
|
+
* @private
|
|
240
|
+
*/
|
|
241
|
+
_addAllDependencies(source, dep, sbom) {
|
|
242
|
+
let targetPurl = this._toPurl(dep.name, dep.version);
|
|
243
|
+
sbom.addDependency(source, targetPurl);
|
|
244
|
+
if (dep.dependencies && dep.dependencies.length > 0) {
|
|
245
|
+
dep.dependencies.forEach(child => this._addAllDependencies(this._toPurl(dep.name, dep.version), child, sbom));
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Create SBOM json string for a pyproject.toml project.
|
|
250
|
+
* @param {string} manifest - path to pyproject.toml
|
|
251
|
+
* @param {Object} opts
|
|
252
|
+
* @param {boolean} includeTransitive
|
|
253
|
+
* @returns {Promise<string>}
|
|
254
|
+
* @private
|
|
255
|
+
*/
|
|
256
|
+
async _createSbom(manifest, opts, includeTransitive) {
|
|
257
|
+
let manifestDir = path.dirname(manifest);
|
|
258
|
+
let content = fs.readFileSync(manifest, 'utf-8');
|
|
259
|
+
let parsed = parseToml(content);
|
|
260
|
+
let { directDeps, graph } = await this._getDependencyData(manifestDir, parsed, opts);
|
|
261
|
+
let ignoredDeps = this._getIgnoredDeps(manifest);
|
|
262
|
+
let dependencies = this._buildDependencyTree(graph, directDeps, ignoredDeps, includeTransitive);
|
|
263
|
+
let sbom = new Sbom();
|
|
264
|
+
let rootName = this._getProjectName(parsed) || DEFAULT_ROOT_NAME;
|
|
265
|
+
let rootVersion = this._getProjectVersion(parsed) || DEFAULT_ROOT_VERSION;
|
|
266
|
+
let rootPurl = this._toPurl(rootName, rootVersion);
|
|
267
|
+
let license = this.readLicenseFromManifest(manifest);
|
|
268
|
+
sbom.addRoot(rootPurl, license);
|
|
269
|
+
dependencies.forEach(dep => {
|
|
270
|
+
if (includeTransitive) {
|
|
271
|
+
this._addAllDependencies(rootPurl, dep, sbom);
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
sbom.addDependency(rootPurl, this._toPurl(dep.name, dep.version));
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
return sbom.getAsJsonString(opts);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
@@ -9,6 +9,8 @@ export default class Manifest {
|
|
|
9
9
|
this.manifestPath = manifestPath;
|
|
10
10
|
const content = this.loadManifest();
|
|
11
11
|
this.dependencies = this.loadDependencies(content);
|
|
12
|
+
this.peerDependencies = content.peerDependencies || {};
|
|
13
|
+
this.optionalDependencies = content.optionalDependencies || {};
|
|
12
14
|
this.name = content.name;
|
|
13
15
|
this.version = content.version || DEFAULT_VERSION;
|
|
14
16
|
this.ignored = this.loadIgnored(content);
|
|
@@ -27,11 +29,27 @@ export default class Manifest {
|
|
|
27
29
|
}
|
|
28
30
|
loadDependencies(content) {
|
|
29
31
|
let deps = [];
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
const depSources = [
|
|
33
|
+
content.dependencies,
|
|
34
|
+
content.peerDependencies,
|
|
35
|
+
content.optionalDependencies,
|
|
36
|
+
];
|
|
37
|
+
for (const source of depSources) {
|
|
38
|
+
if (source) {
|
|
39
|
+
for (let dep in source) {
|
|
40
|
+
if (!deps.includes(dep)) {
|
|
41
|
+
deps.push(dep);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
32
45
|
}
|
|
33
|
-
|
|
34
|
-
|
|
46
|
+
// bundledDependencies is an array of package names (subset of dependencies)
|
|
47
|
+
if (Array.isArray(content.bundledDependencies)) {
|
|
48
|
+
for (const dep of content.bundledDependencies) {
|
|
49
|
+
if (!deps.includes(dep)) {
|
|
50
|
+
deps.push(dep);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
35
53
|
}
|
|
36
54
|
return deps;
|
|
37
55
|
}
|
|
@@ -48,13 +48,15 @@ export default class Yarn_berry_processor extends Yarn_processor {
|
|
|
48
48
|
if (!depTree) {
|
|
49
49
|
return new Map();
|
|
50
50
|
}
|
|
51
|
-
return new Map(depTree.filter(dep => !this.#isRoot(dep.value))
|
|
51
|
+
return new Map(depTree.filter(dep => !this.#isRoot(dep.value))
|
|
52
|
+
.map(dep => {
|
|
52
53
|
const depName = dep.value;
|
|
53
54
|
const idx = depName.lastIndexOf('@');
|
|
54
55
|
const name = depName.substring(0, idx);
|
|
55
56
|
const version = dep.children.Version;
|
|
56
57
|
return [name, toPurl(purlType, name, version)];
|
|
57
|
-
})
|
|
58
|
+
})
|
|
59
|
+
.filter(([name]) => this._manifest.dependencies.includes(name)));
|
|
58
60
|
}
|
|
59
61
|
/**
|
|
60
62
|
* Checks if a dependency is the root package
|
|
@@ -77,14 +79,58 @@ export default class Yarn_berry_processor extends Yarn_processor {
|
|
|
77
79
|
if (!depTree) {
|
|
78
80
|
return;
|
|
79
81
|
}
|
|
82
|
+
// Build index of nodes by their value for quick lookup
|
|
83
|
+
const nodeIndex = new Map();
|
|
84
|
+
depTree.forEach(n => nodeIndex.set(n.value, n));
|
|
85
|
+
// Determine the set of node values reachable from root via production deps
|
|
86
|
+
const prodDeps = new Set(this._manifest.dependencies);
|
|
87
|
+
const reachable = new Set();
|
|
88
|
+
const queue = [];
|
|
89
|
+
// Seed with root's production dependencies
|
|
90
|
+
const rootNode = depTree.find(n => this.#isRoot(n.value));
|
|
91
|
+
if (rootNode?.children?.Dependencies) {
|
|
92
|
+
for (const d of rootNode.children.Dependencies) {
|
|
93
|
+
const to = this.#purlFromLocator(d.locator);
|
|
94
|
+
if (to) {
|
|
95
|
+
const fullName = to.namespace ? `${to.namespace}/${to.name}` : to.name;
|
|
96
|
+
if (prodDeps.has(fullName)) {
|
|
97
|
+
queue.push(d.locator);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// BFS to find all transitively reachable packages
|
|
103
|
+
while (queue.length > 0) {
|
|
104
|
+
const locator = queue.shift();
|
|
105
|
+
if (reachable.has(locator)) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
reachable.add(locator);
|
|
109
|
+
const node = nodeIndex.get(this.#nodeValueFromLocator(locator));
|
|
110
|
+
if (node?.children?.Dependencies) {
|
|
111
|
+
for (const d of node.children.Dependencies) {
|
|
112
|
+
if (!reachable.has(d.locator)) {
|
|
113
|
+
queue.push(d.locator);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// Only emit edges for root and reachable nodes
|
|
80
119
|
depTree.forEach(n => {
|
|
81
120
|
const depName = n.value;
|
|
82
|
-
const
|
|
121
|
+
const isRoot = this.#isRoot(depName);
|
|
122
|
+
if (!isRoot && !this.#isReachableNode(depName, reachable)) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const from = isRoot ? toPurlFromString(sbom.getRoot().purl) : this.#purlFromNode(depName, n);
|
|
83
126
|
const deps = n.children?.Dependencies;
|
|
84
127
|
if (!deps) {
|
|
85
128
|
return;
|
|
86
129
|
}
|
|
87
130
|
deps.forEach(d => {
|
|
131
|
+
if (!reachable.has(d.locator)) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
88
134
|
const to = this.#purlFromLocator(d.locator);
|
|
89
135
|
if (to) {
|
|
90
136
|
sbom.addDependency(from, to);
|
|
@@ -92,6 +138,39 @@ export default class Yarn_berry_processor extends Yarn_processor {
|
|
|
92
138
|
});
|
|
93
139
|
});
|
|
94
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Converts a locator to the node value format used in yarn info output
|
|
143
|
+
* @param {string} locator - e.g. "express@npm:4.17.1"
|
|
144
|
+
* @returns {string} The node value, same as locator for non-virtual
|
|
145
|
+
* @private
|
|
146
|
+
*/
|
|
147
|
+
#nodeValueFromLocator(locator) {
|
|
148
|
+
// Virtual locators: "@scope/name@virtual:hash#npm:version" → "@scope/name@npm:version"
|
|
149
|
+
const virtualMatch = Yarn_berry_processor.VIRTUAL_LOCATOR_PATTERN.exec(locator);
|
|
150
|
+
if (virtualMatch) {
|
|
151
|
+
return `${virtualMatch[1]}@npm:${virtualMatch[2]}`;
|
|
152
|
+
}
|
|
153
|
+
return locator;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Checks if a node is in the reachable set by matching its value against reachable locators
|
|
157
|
+
* @param {string} depName - The node value (e.g. "express@npm:4.17.1")
|
|
158
|
+
* @param {Set<string>} reachable - Set of reachable locators
|
|
159
|
+
* @returns {boolean}
|
|
160
|
+
* @private
|
|
161
|
+
*/
|
|
162
|
+
#isReachableNode(depName, reachable) {
|
|
163
|
+
if (reachable.has(depName)) {
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
// Check if any reachable locator resolves to this node value
|
|
167
|
+
for (const locator of reachable) {
|
|
168
|
+
if (this.#nodeValueFromLocator(locator) === depName) {
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
95
174
|
/**
|
|
96
175
|
* Creates a PackageURL from a dependency locator
|
|
97
176
|
* @param {string} locator - The dependency locator
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export default class Python_poetry extends Base_pyproject {
|
|
2
|
+
/**
|
|
3
|
+
* Get poetry show --tree output.
|
|
4
|
+
* @param {string} manifestDir
|
|
5
|
+
* @param {Object} opts
|
|
6
|
+
* @returns {string}
|
|
7
|
+
*/
|
|
8
|
+
_getPoetryShowTreeOutput(manifestDir: string, opts: any): string;
|
|
9
|
+
/**
|
|
10
|
+
* Get poetry show --all output (flat list with resolved versions).
|
|
11
|
+
* @param {string} manifestDir
|
|
12
|
+
* @param {Object} opts
|
|
13
|
+
* @returns {string}
|
|
14
|
+
*/
|
|
15
|
+
_getPoetryShowAllOutput(manifestDir: string, opts: any): string;
|
|
16
|
+
/**
|
|
17
|
+
* Parse poetry show --all output into a version map.
|
|
18
|
+
* Lines look like: "name (!) 1.2.3 Description text..."
|
|
19
|
+
* or: "name 1.2.3 Description text..."
|
|
20
|
+
* @param {string} output
|
|
21
|
+
* @returns {Map<string, string>} canonical name -> version
|
|
22
|
+
*/
|
|
23
|
+
_parsePoetryShowAll(output: string): Map<string, string>;
|
|
24
|
+
/**
|
|
25
|
+
* Parse poetry show --tree output into a dependency graph structure.
|
|
26
|
+
* Top-level lines (no indentation/tree chars) are direct deps: "name version description"
|
|
27
|
+
* Indented lines are transitive deps with tree chars: "├── name >=constraint"
|
|
28
|
+
*
|
|
29
|
+
* @param {string} treeOutput
|
|
30
|
+
* @param {Map<string, string>} versionMap - canonical name -> resolved version
|
|
31
|
+
* @returns {{directDeps: string[], graph: Map<string, {name: string, version: string, children: string[]}>}}
|
|
32
|
+
*/
|
|
33
|
+
_parsePoetryTree(treeOutput: string, versionMap: Map<string, string>): {
|
|
34
|
+
directDeps: string[];
|
|
35
|
+
graph: Map<string, {
|
|
36
|
+
name: string;
|
|
37
|
+
version: string;
|
|
38
|
+
children: string[];
|
|
39
|
+
}>;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
import Base_pyproject from './base_pyproject.js';
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { environmentVariableIsPopulated, getCustomPath, invokeCommand } from '../tools.js';
|
|
2
|
+
import Base_pyproject from './base_pyproject.js';
|
|
3
|
+
export default class Python_poetry extends Base_pyproject {
|
|
4
|
+
/** @returns {string} */
|
|
5
|
+
_lockFileName() {
|
|
6
|
+
return 'poetry.lock';
|
|
7
|
+
}
|
|
8
|
+
/** @returns {string} */
|
|
9
|
+
_cmdName() {
|
|
10
|
+
return 'poetry';
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @param {string} manifestDir
|
|
14
|
+
* @param {object} parsed - parsed pyproject.toml
|
|
15
|
+
* @param {Object} opts
|
|
16
|
+
* @returns {Promise<{directDeps: string[], graph: Map<string, {name: string, version: string, children: string[]}>}>}
|
|
17
|
+
*/
|
|
18
|
+
async _getDependencyData(manifestDir, parsed, opts) {
|
|
19
|
+
let treeOutput = this._getPoetryShowTreeOutput(manifestDir, opts);
|
|
20
|
+
let showAllOutput = this._getPoetryShowAllOutput(manifestDir, opts);
|
|
21
|
+
let versionMap = this._parsePoetryShowAll(showAllOutput);
|
|
22
|
+
return this._parsePoetryTree(treeOutput, versionMap);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get poetry show --tree output.
|
|
26
|
+
* @param {string} manifestDir
|
|
27
|
+
* @param {Object} opts
|
|
28
|
+
* @returns {string}
|
|
29
|
+
*/
|
|
30
|
+
_getPoetryShowTreeOutput(manifestDir, opts) {
|
|
31
|
+
if (environmentVariableIsPopulated('TRUSTIFY_DA_POETRY_SHOW_TREE')) {
|
|
32
|
+
return Buffer.from(process.env['TRUSTIFY_DA_POETRY_SHOW_TREE'], 'base64').toString('utf-8');
|
|
33
|
+
}
|
|
34
|
+
let poetryBin = getCustomPath('poetry', opts);
|
|
35
|
+
return invokeCommand(poetryBin, ['show', '--tree', '--no-ansi'], { cwd: manifestDir }).toString();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get poetry show --all output (flat list with resolved versions).
|
|
39
|
+
* @param {string} manifestDir
|
|
40
|
+
* @param {Object} opts
|
|
41
|
+
* @returns {string}
|
|
42
|
+
*/
|
|
43
|
+
_getPoetryShowAllOutput(manifestDir, opts) {
|
|
44
|
+
if (environmentVariableIsPopulated('TRUSTIFY_DA_POETRY_SHOW_ALL')) {
|
|
45
|
+
return Buffer.from(process.env['TRUSTIFY_DA_POETRY_SHOW_ALL'], 'base64').toString('utf-8');
|
|
46
|
+
}
|
|
47
|
+
let poetryBin = getCustomPath('poetry', opts);
|
|
48
|
+
return invokeCommand(poetryBin, ['show', '--no-ansi', '--all'], { cwd: manifestDir }).toString();
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Parse poetry show --all output into a version map.
|
|
52
|
+
* Lines look like: "name (!) 1.2.3 Description text..."
|
|
53
|
+
* or: "name 1.2.3 Description text..."
|
|
54
|
+
* @param {string} output
|
|
55
|
+
* @returns {Map<string, string>} canonical name -> version
|
|
56
|
+
*/
|
|
57
|
+
_parsePoetryShowAll(output) {
|
|
58
|
+
let versions = new Map();
|
|
59
|
+
let lines = output.split(/\r?\n/);
|
|
60
|
+
for (let line of lines) {
|
|
61
|
+
let trimmed = line.trim();
|
|
62
|
+
if (!trimmed) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
let match = trimmed.match(/^([A-Za-z0-9][A-Za-z0-9._-]*)\s+(?:\(!\)\s+)?(\S+)/);
|
|
66
|
+
if (match) {
|
|
67
|
+
versions.set(this._canonicalize(match[1]), match[2]);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return versions;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Parse poetry show --tree output into a dependency graph structure.
|
|
74
|
+
* Top-level lines (no indentation/tree chars) are direct deps: "name version description"
|
|
75
|
+
* Indented lines are transitive deps with tree chars: "├── name >=constraint"
|
|
76
|
+
*
|
|
77
|
+
* @param {string} treeOutput
|
|
78
|
+
* @param {Map<string, string>} versionMap - canonical name -> resolved version
|
|
79
|
+
* @returns {{directDeps: string[], graph: Map<string, {name: string, version: string, children: string[]}>}}
|
|
80
|
+
*/
|
|
81
|
+
_parsePoetryTree(treeOutput, versionMap) {
|
|
82
|
+
let lines = treeOutput.split(/\r?\n/);
|
|
83
|
+
let graph = new Map();
|
|
84
|
+
let directDeps = [];
|
|
85
|
+
let stack = []; // [{key, depth}]
|
|
86
|
+
let currentDirectDep = null;
|
|
87
|
+
for (let line of lines) {
|
|
88
|
+
if (!line.trim()) {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
// top-level line: "name version description..."
|
|
92
|
+
let topMatch = line.match(/^([A-Za-z0-9][A-Za-z0-9._-]*)\s+(\S+)\s/);
|
|
93
|
+
if (topMatch) {
|
|
94
|
+
let name = topMatch[1];
|
|
95
|
+
let version = topMatch[2];
|
|
96
|
+
let key = this._canonicalize(name);
|
|
97
|
+
directDeps.push(key);
|
|
98
|
+
if (!graph.has(key)) {
|
|
99
|
+
graph.set(key, { name, version, children: [] });
|
|
100
|
+
}
|
|
101
|
+
currentDirectDep = key;
|
|
102
|
+
stack = [{ key, depth: -1 }];
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (!currentDirectDep) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
// indented line with tree chars (UTF-8 box-drawing: ├── └── │)
|
|
109
|
+
let nameStart = line.search(/[A-Za-z0-9]/);
|
|
110
|
+
if (nameStart < 0) {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
let rest = line.substring(nameStart);
|
|
114
|
+
let depMatch = rest.match(/^([A-Za-z0-9][A-Za-z0-9._-]*)/);
|
|
115
|
+
if (!depMatch) {
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
let depName = depMatch[1];
|
|
119
|
+
let depKey = this._canonicalize(depName);
|
|
120
|
+
// determine depth by counting tree-drawing groups in the prefix
|
|
121
|
+
let prefix = line.substring(0, nameStart);
|
|
122
|
+
let depth = (prefix.match(/(?:[├└│ ][\s─]{2} ?)/g) || []).length;
|
|
123
|
+
// resolve version from the version map
|
|
124
|
+
let version = versionMap.get(depKey) || null;
|
|
125
|
+
if (!version) {
|
|
126
|
+
throw new Error(`poetry: package '${depName}' has no resolved version`);
|
|
127
|
+
}
|
|
128
|
+
if (!graph.has(depKey)) {
|
|
129
|
+
graph.set(depKey, { name: depName, version, children: [] });
|
|
130
|
+
}
|
|
131
|
+
// pop stack back to find the parent at depth-1
|
|
132
|
+
while (stack.length > 0 && stack[stack.length - 1].depth >= depth) {
|
|
133
|
+
stack.pop();
|
|
134
|
+
}
|
|
135
|
+
if (stack.length > 0) {
|
|
136
|
+
let parentKey = stack[stack.length - 1].key;
|
|
137
|
+
let parentEntry = graph.get(parentKey);
|
|
138
|
+
if (parentEntry && !parentEntry.children.includes(depKey)) {
|
|
139
|
+
parentEntry.children.push(depKey);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
stack.push({ key: depKey, depth });
|
|
143
|
+
}
|
|
144
|
+
return { directDeps, graph };
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export default class Python_uv extends Base_pyproject {
|
|
2
|
+
/**
|
|
3
|
+
* Get the uv export output, either from env var or by running the command.
|
|
4
|
+
* @param {string} manifestDir
|
|
5
|
+
* @param {Object} opts
|
|
6
|
+
* @returns {string}
|
|
7
|
+
*/
|
|
8
|
+
_getUvExportOutput(manifestDir: string, opts: any): string;
|
|
9
|
+
/**
|
|
10
|
+
* Parse uv export output into a dependency graph using tree-sitter-requirements
|
|
11
|
+
* for package/version extraction and string parsing for "# via" comments.
|
|
12
|
+
*
|
|
13
|
+
* @param {string} output
|
|
14
|
+
* @param {string} projectName - canonical project name to identify direct deps
|
|
15
|
+
* @returns {Promise<{directDeps: string[], graph: Map<string, {name: string, version: string, children: string[]}>}>}
|
|
16
|
+
*/
|
|
17
|
+
_parseUvExport(output: string, projectName: string): Promise<{
|
|
18
|
+
directDeps: string[];
|
|
19
|
+
graph: Map<string, {
|
|
20
|
+
name: string;
|
|
21
|
+
version: string;
|
|
22
|
+
children: string[];
|
|
23
|
+
}>;
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
26
|
+
import Base_pyproject from './base_pyproject.js';
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { environmentVariableIsPopulated, getCustomPath, invokeCommand } from '../tools.js';
|
|
2
|
+
import Base_pyproject from './base_pyproject.js';
|
|
3
|
+
import { getParser, getPinnedVersionQuery } from './requirements_parser.js';
|
|
4
|
+
export default class Python_uv extends Base_pyproject {
|
|
5
|
+
/** @returns {string} */
|
|
6
|
+
_lockFileName() {
|
|
7
|
+
return 'uv.lock';
|
|
8
|
+
}
|
|
9
|
+
/** @returns {string} */
|
|
10
|
+
_cmdName() {
|
|
11
|
+
return 'uv';
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @param {string} manifestDir
|
|
15
|
+
* @param {object} parsed - parsed pyproject.toml
|
|
16
|
+
* @param {Object} opts
|
|
17
|
+
* @returns {Promise<{directDeps: string[], graph: Map<string, {name: string, version: string, children: string[]}>}>}
|
|
18
|
+
*/
|
|
19
|
+
async _getDependencyData(manifestDir, parsed, opts) {
|
|
20
|
+
let projectName = this._getProjectName(parsed);
|
|
21
|
+
let uvOutput = this._getUvExportOutput(manifestDir, opts);
|
|
22
|
+
return this._parseUvExport(uvOutput, projectName);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get the uv export output, either from env var or by running the command.
|
|
26
|
+
* @param {string} manifestDir
|
|
27
|
+
* @param {Object} opts
|
|
28
|
+
* @returns {string}
|
|
29
|
+
*/
|
|
30
|
+
_getUvExportOutput(manifestDir, opts) {
|
|
31
|
+
if (environmentVariableIsPopulated('TRUSTIFY_DA_UV_EXPORT')) {
|
|
32
|
+
return Buffer.from(process.env['TRUSTIFY_DA_UV_EXPORT'], 'base64').toString('ascii');
|
|
33
|
+
}
|
|
34
|
+
let uvBin = getCustomPath('uv', opts);
|
|
35
|
+
return invokeCommand(uvBin, ['export', '--format', 'requirements.txt', '--frozen', '--no-hashes'], { cwd: manifestDir }).toString();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Parse uv export output into a dependency graph using tree-sitter-requirements
|
|
39
|
+
* for package/version extraction and string parsing for "# via" comments.
|
|
40
|
+
*
|
|
41
|
+
* @param {string} output
|
|
42
|
+
* @param {string} projectName - canonical project name to identify direct deps
|
|
43
|
+
* @returns {Promise<{directDeps: string[], graph: Map<string, {name: string, version: string, children: string[]}>}>}
|
|
44
|
+
*/
|
|
45
|
+
async _parseUvExport(output, projectName) {
|
|
46
|
+
let [parser, pinnedVersionQuery] = await Promise.all([
|
|
47
|
+
getParser(), getPinnedVersionQuery()
|
|
48
|
+
]);
|
|
49
|
+
let tree = parser.parse(output);
|
|
50
|
+
let root = tree.rootNode;
|
|
51
|
+
let canonProjectName = this._canonicalize(projectName);
|
|
52
|
+
let packages = new Map(); // canonical name -> {name, version, parents: Set}
|
|
53
|
+
let currentPkg = null;
|
|
54
|
+
let collectingVia = false;
|
|
55
|
+
for (let child of root.children) {
|
|
56
|
+
if (child.type === 'requirement') {
|
|
57
|
+
let nameNode = child.children.find(c => c.type === 'package');
|
|
58
|
+
if (!nameNode) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
let name = nameNode.text;
|
|
62
|
+
let version = null;
|
|
63
|
+
let versionMatches = pinnedVersionQuery.matches(child);
|
|
64
|
+
if (versionMatches.length > 0) {
|
|
65
|
+
version = versionMatches[0].captures.find(c => c.name === 'version').node.text;
|
|
66
|
+
}
|
|
67
|
+
if (!version) {
|
|
68
|
+
throw new Error(`uv export: package '${name}' has no pinned version`);
|
|
69
|
+
}
|
|
70
|
+
let key = this._canonicalize(name);
|
|
71
|
+
currentPkg = { name, version, parents: new Set() };
|
|
72
|
+
packages.set(key, currentPkg);
|
|
73
|
+
collectingVia = false;
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (child.type === 'comment' && currentPkg) {
|
|
77
|
+
let text = child.text.trim();
|
|
78
|
+
let viaSingle = text.match(/^# via ([A-Za-z0-9][A-Za-z0-9._-]*)$/);
|
|
79
|
+
if (viaSingle) {
|
|
80
|
+
currentPkg.parents.add(this._canonicalize(viaSingle[1]));
|
|
81
|
+
collectingVia = false;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (text === '# via') {
|
|
85
|
+
collectingVia = true;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (collectingVia) {
|
|
89
|
+
let parentMatch = text.match(/^#\s+([A-Za-z0-9][A-Za-z0-9._-]*)$/);
|
|
90
|
+
if (parentMatch) {
|
|
91
|
+
currentPkg.parents.add(this._canonicalize(parentMatch[1]));
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
collectingVia = false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// Build forward dependency map and extract direct deps in one pass
|
|
99
|
+
let graph = new Map();
|
|
100
|
+
let directDeps = [];
|
|
101
|
+
for (let [key, pkg] of packages) {
|
|
102
|
+
graph.set(key, { name: pkg.name, version: pkg.version, children: [] });
|
|
103
|
+
}
|
|
104
|
+
for (let [childKey, pkg] of packages) {
|
|
105
|
+
for (let parentKey of pkg.parents) {
|
|
106
|
+
if (parentKey === canonProjectName) {
|
|
107
|
+
directDeps.push(childKey);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
let parentEntry = graph.get(parentKey);
|
|
111
|
+
if (parentEntry) {
|
|
112
|
+
parentEntry.children.push(childKey);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return { directDeps, graph };
|
|
117
|
+
}
|
|
118
|
+
}
|
package/dist/src/sbom.d.ts
CHANGED
|
@@ -53,6 +53,13 @@ export default class Sbom {
|
|
|
53
53
|
* @return {boolean}
|
|
54
54
|
*/
|
|
55
55
|
checkIfPackageInsideDependsOnList(component: any, name: string): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Checks if any entry in the dependsOn list of sourceRef starts with the given purl prefix.
|
|
58
|
+
* @param {PackageURL} sourceRef - The source component to check
|
|
59
|
+
* @param {string} purlPrefix - The purl prefix to match (e.g. "pkg:npm/minimist@")
|
|
60
|
+
* @return {boolean}
|
|
61
|
+
*/
|
|
62
|
+
checkDependsOnByPurlPrefix(sourceRef: PackageURL, purlPrefix: string): boolean;
|
|
56
63
|
/** Removes the root component from the sbom
|
|
57
64
|
*/
|
|
58
65
|
removeRootComponent(): void;
|
package/dist/src/sbom.js
CHANGED
|
@@ -77,6 +77,15 @@ export default class Sbom {
|
|
|
77
77
|
checkIfPackageInsideDependsOnList(component, name) {
|
|
78
78
|
return this.sbomModel.checkIfPackageInsideDependsOnList(component, name);
|
|
79
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Checks if any entry in the dependsOn list of sourceRef starts with the given purl prefix.
|
|
82
|
+
* @param {PackageURL} sourceRef - The source component to check
|
|
83
|
+
* @param {string} purlPrefix - The purl prefix to match (e.g. "pkg:npm/minimist@")
|
|
84
|
+
* @return {boolean}
|
|
85
|
+
*/
|
|
86
|
+
checkDependsOnByPurlPrefix(sourceRef, purlPrefix) {
|
|
87
|
+
return this.sbomModel.checkDependsOnByPurlPrefix(sourceRef, purlPrefix);
|
|
88
|
+
}
|
|
80
89
|
/** Removes the root component from the sbom
|
|
81
90
|
*/
|
|
82
91
|
removeRootComponent() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trustify-da/trustify-da-javascript-client",
|
|
3
|
-
"version": "0.3.0-ea.
|
|
3
|
+
"version": "0.3.0-ea.e5bb86c",
|
|
4
4
|
"description": "Code-Ready Dependency Analytics JavaScript API.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/guacsec/trustify-da-javascript-client#README.md",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"lint": "eslint src test --ext js",
|
|
39
39
|
"lint:fix": "eslint src test --ext js --fix",
|
|
40
40
|
"test": "c8 npm run tests",
|
|
41
|
-
"tests": "mocha --config .mocharc.json
|
|
41
|
+
"tests": "mocha --config .mocharc.json",
|
|
42
42
|
"tests:rep": "mocha --reporter-option maxDiffSize=0 --reporter json > unit-tests-result.json",
|
|
43
43
|
"pretest": "cp node_modules/tree-sitter-requirements/tree-sitter-requirements.wasm src/providers/tree-sitter-requirements.wasm && cp node_modules/tree-sitter-gomod/tree-sitter-gomod.wasm src/providers/tree-sitter-gomod.wasm",
|
|
44
44
|
"precompile": "rm -rf dist",
|