@coana-tech/cli 14.12.106 → 14.12.108
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/cli.mjs +11 -4
- package/package.json +1 -1
- package/reachability-analyzers-cli.mjs +129 -172
- package/repos/coana-tech/goana/bin/goana-darwin-amd64.gz +0 -0
- package/repos/coana-tech/goana/bin/goana-darwin-arm64.gz +0 -0
- package/repos/coana-tech/goana/bin/goana-linux-amd64.gz +0 -0
- package/repos/coana-tech/goana/bin/goana-linux-arm64.gz +0 -0
- package/repos/coana-tech/javap-service/javap-service.jar +0 -0
- package/repos/coana-tech/jelly-private/dist/bundle/approx.js +3 -3
- package/repos/coana-tech/jelly-private/dist/bundle/{chunk-QVZRZ7F3.js → chunk-AO2BBATE.js} +2 -2
- package/repos/coana-tech/jelly-private/dist/bundle/{chunk-VD62II65.js → chunk-PAV2YSLW.js} +2 -2
- package/repos/coana-tech/jelly-private/dist/bundle/{chunk-LY4UAG7A.js → chunk-VDHMBLB5.js} +11 -1
- package/repos/coana-tech/jelly-private/dist/bundle/{chunk-GSPO4CLX.js → chunk-XJM6ACML.js} +2 -2
- package/repos/coana-tech/jelly-private/dist/bundle/hooks.js +3 -3
- package/repos/coana-tech/jelly-private/dist/bundle/jelly.js +5 -3
package/cli.mjs
CHANGED
|
@@ -250700,10 +250700,11 @@ async function onlineScan(dependencyTree, apiKey, timeout) {
|
|
|
250700
250700
|
}
|
|
250701
250701
|
|
|
250702
250702
|
// dist/version.js
|
|
250703
|
-
var version3 = "14.12.
|
|
250703
|
+
var version3 = "14.12.108";
|
|
250704
250704
|
|
|
250705
250705
|
// dist/cli-core.js
|
|
250706
250706
|
var { mapValues, omit, partition, pick } = import_lodash15.default;
|
|
250707
|
+
var bucketedAnalysisTimeoutInSeconds = 60;
|
|
250707
250708
|
var SEVERITY_ORDER = {
|
|
250708
250709
|
INFO: 0,
|
|
250709
250710
|
LOW: 1,
|
|
@@ -250737,10 +250738,13 @@ var CliCore = class {
|
|
|
250737
250738
|
this.options = options;
|
|
250738
250739
|
this.analysisMemoryLimitInMb = +this.options.memoryLimit;
|
|
250739
250740
|
if (this.options.analysisTimeout !== void 0) {
|
|
250740
|
-
|
|
250741
|
-
if (isNaN(
|
|
250741
|
+
const parsedTimeout = Number(this.options.analysisTimeout);
|
|
250742
|
+
if (isNaN(parsedTimeout)) {
|
|
250742
250743
|
throw new Error("Invalid analysis timeout value");
|
|
250743
250744
|
}
|
|
250745
|
+
this.analysisTimeoutInSeconds = parsedTimeout;
|
|
250746
|
+
} else {
|
|
250747
|
+
this.analysisTimeoutInSeconds = 600;
|
|
250744
250748
|
}
|
|
250745
250749
|
this.rootWorkingDirectory = resolve43(rootWorkingDirectory);
|
|
250746
250750
|
this.spinner = Spinner.instance({
|
|
@@ -251354,7 +251358,10 @@ Subproject: ${subproject}`);
|
|
|
251354
251358
|
return result;
|
|
251355
251359
|
this.sendProgress("REACHABILITY_ANALYSIS", true, subprojectPath, workspacePath);
|
|
251356
251360
|
result.push(...await otherModulesCommunicator.runReachabilityAnalysis(subprojectPath, workspacePath, workspaceData, ecosystem, vulnerabilities, {
|
|
251357
|
-
|
|
251361
|
+
timeoutSeconds: {
|
|
251362
|
+
allVulnRuns: this.analysisTimeoutInSeconds,
|
|
251363
|
+
bucketedRuns: bucketedAnalysisTimeoutInSeconds
|
|
251364
|
+
},
|
|
251358
251365
|
memoryLimitInMB: this.analysisMemoryLimitInMb,
|
|
251359
251366
|
printLogFile: this.options.printAnalysisLogFile,
|
|
251360
251367
|
// entryPoints are only supported for root workspace atm.
|
package/package.json
CHANGED
|
@@ -95651,17 +95651,15 @@ var DotnetCodeAwareVulnerabilityScanner = class _DotnetCodeAwareVulnerabilitySca
|
|
|
95651
95651
|
apps;
|
|
95652
95652
|
deps;
|
|
95653
95653
|
depIdToPurl;
|
|
95654
|
-
timeoutInSeconds;
|
|
95655
95654
|
statusUpdater;
|
|
95656
95655
|
name = "COCOA";
|
|
95657
|
-
constructor(apps, deps, depIdToPurl,
|
|
95656
|
+
constructor(apps, deps, depIdToPurl, statusUpdater) {
|
|
95658
95657
|
this.apps = apps;
|
|
95659
95658
|
this.deps = deps;
|
|
95660
95659
|
this.depIdToPurl = depIdToPurl;
|
|
95661
|
-
this.timeoutInSeconds = timeoutInSeconds;
|
|
95662
95660
|
this.statusUpdater = statusUpdater;
|
|
95663
95661
|
}
|
|
95664
|
-
static initFromDependencyTree(dependencyTree,
|
|
95662
|
+
static initFromDependencyTree(dependencyTree, statusUpdater) {
|
|
95665
95663
|
const apps = {
|
|
95666
95664
|
"<app>": {
|
|
95667
95665
|
src: dependencyTree.src,
|
|
@@ -95677,9 +95675,9 @@ var DotnetCodeAwareVulnerabilityScanner = class _DotnetCodeAwareVulnerabilitySca
|
|
|
95677
95675
|
bin: dep.bin
|
|
95678
95676
|
};
|
|
95679
95677
|
}
|
|
95680
|
-
return new _DotnetCodeAwareVulnerabilityScanner(apps, deps, depIdToPurl,
|
|
95678
|
+
return new _DotnetCodeAwareVulnerabilityScanner(apps, deps, depIdToPurl, statusUpdater);
|
|
95681
95679
|
}
|
|
95682
|
-
static async initFromSocketArtifacts(subprojectDir, manifestFiles, artifacts, tmpDir,
|
|
95680
|
+
static async initFromSocketArtifacts(subprojectDir, manifestFiles, artifacts, tmpDir, statusUpdater) {
|
|
95683
95681
|
const projMatcher = (0, import_picomatch.default)("*.*proj", { basename: true });
|
|
95684
95682
|
const src = await asyncFlatMap(manifestFiles.filter((f2) => projMatcher(f2)), async (projFile) => {
|
|
95685
95683
|
const project = await loadNuGetProject(subprojectDir, projFile);
|
|
@@ -95691,7 +95689,7 @@ var DotnetCodeAwareVulnerabilityScanner = class _DotnetCodeAwareVulnerabilitySca
|
|
|
95691
95689
|
}
|
|
95692
95690
|
};
|
|
95693
95691
|
const { deps, depIdToPurl } = await convertSocketArtifacts(artifacts, tmpDir);
|
|
95694
|
-
return new _DotnetCodeAwareVulnerabilityScanner(apps, deps, depIdToPurl,
|
|
95692
|
+
return new _DotnetCodeAwareVulnerabilityScanner(apps, deps, depIdToPurl, statusUpdater);
|
|
95695
95693
|
}
|
|
95696
95694
|
static async runOnAlreadyDownloadedPackages([appPath, ...depPaths], vulnerability, options) {
|
|
95697
95695
|
const apps = {
|
|
@@ -95708,8 +95706,8 @@ var DotnetCodeAwareVulnerabilityScanner = class _DotnetCodeAwareVulnerabilitySca
|
|
|
95708
95706
|
bin: await isDirectory(depPath) ? await getFiles(depPath) : [depPath]
|
|
95709
95707
|
};
|
|
95710
95708
|
}
|
|
95711
|
-
const scanner = new _DotnetCodeAwareVulnerabilityScanner(apps, deps, depIdToPurl
|
|
95712
|
-
const result = await scanner.runAnalysis([vulnerability], CocoaHeuristics.ALL_PACKAGES,
|
|
95709
|
+
const scanner = new _DotnetCodeAwareVulnerabilityScanner(apps, deps, depIdToPurl);
|
|
95710
|
+
const result = await scanner.runAnalysis([vulnerability], CocoaHeuristics.ALL_PACKAGES, options.timeoutSeconds.allVulnRuns);
|
|
95713
95711
|
if (result.type === "error")
|
|
95714
95712
|
return { error: result.message, terminatedEarly: true };
|
|
95715
95713
|
return {
|
|
@@ -95737,8 +95735,8 @@ var DotnetCodeAwareVulnerabilityScanner = class _DotnetCodeAwareVulnerabilitySca
|
|
|
95737
95735
|
bin: dep.bin
|
|
95738
95736
|
};
|
|
95739
95737
|
});
|
|
95740
|
-
const scanner = new _DotnetCodeAwareVulnerabilityScanner(apps, deps, depIdToPurl,
|
|
95741
|
-
const result = await scanner.actuallyRunAnalysis(vulnerability.vulnerabilityAccessPaths);
|
|
95738
|
+
const scanner = new _DotnetCodeAwareVulnerabilityScanner(apps, deps, depIdToPurl, statusUpdater);
|
|
95739
|
+
const result = await scanner.actuallyRunAnalysis(vulnerability.vulnerabilityAccessPaths, timeoutInSeconds);
|
|
95742
95740
|
if (result.type === "error")
|
|
95743
95741
|
return { error: result.message, terminatedEarly: false };
|
|
95744
95742
|
return {
|
|
@@ -95750,7 +95748,7 @@ var DotnetCodeAwareVulnerabilityScanner = class _DotnetCodeAwareVulnerabilitySca
|
|
|
95750
95748
|
}
|
|
95751
95749
|
});
|
|
95752
95750
|
}
|
|
95753
|
-
async runPhantomDependencyAnalysis() {
|
|
95751
|
+
async runPhantomDependencyAnalysis(timeoutInSeconds) {
|
|
95754
95752
|
return withTmpDirectory("dotnet-direct-dependency-analysis", async (tmpDir) => {
|
|
95755
95753
|
try {
|
|
95756
95754
|
await ensureDotnet6OrAbove();
|
|
@@ -95760,12 +95758,12 @@ var DotnetCodeAwareVulnerabilityScanner = class _DotnetCodeAwareVulnerabilitySca
|
|
|
95760
95758
|
const options = {
|
|
95761
95759
|
apps: this.apps,
|
|
95762
95760
|
deps: this.deps,
|
|
95763
|
-
timeoutInSeconds
|
|
95761
|
+
timeoutInSeconds
|
|
95764
95762
|
};
|
|
95765
95763
|
const inputFile = resolve10(tmpDir, "input.json");
|
|
95766
95764
|
const outputFile = resolve10(tmpDir, "output.json");
|
|
95767
95765
|
await writeFile4(inputFile, JSON.stringify(options));
|
|
95768
|
-
const timeoutMs =
|
|
95766
|
+
const timeoutMs = Math.max(timeoutInSeconds * 1.5, timeoutInSeconds + 30) * 1e3;
|
|
95769
95767
|
const result = await execNeverFail2(cmdt`${await getNodeExecutable(ToolPathResolver.nodeExecutablePath)} ${getClassGraphAnalysisCliPath()} runDotnetDirectDependencyAnalysis -i ${inputFile} -o ${outputFile} --cocoa ${getCocoaPath()} --tree-sitter-c-sharp ${getTreeSitterCSharpPath()}`, void 0, { timeout: timeoutMs });
|
|
95770
95768
|
if (result.error)
|
|
95771
95769
|
return void 0;
|
|
@@ -95773,7 +95771,7 @@ var DotnetCodeAwareVulnerabilityScanner = class _DotnetCodeAwareVulnerabilitySca
|
|
|
95773
95771
|
return packageIds?.map((packageId) => this.depIdToPurl.get(packageId)).filter((purl) => purl !== void 0).map((purl) => purl.name ?? "");
|
|
95774
95772
|
});
|
|
95775
95773
|
}
|
|
95776
|
-
async runAnalysis(vulnerabilities, heuristic,
|
|
95774
|
+
async runAnalysis(vulnerabilities, heuristic, timeoutInSeconds, _experiment) {
|
|
95777
95775
|
try {
|
|
95778
95776
|
this.statusUpdater?.("Preparing code for analysis...");
|
|
95779
95777
|
const packagesToAnalyze = heuristic.getPackagesToAnalyze(vulnerabilities);
|
|
@@ -95782,12 +95780,12 @@ var DotnetCodeAwareVulnerabilityScanner = class _DotnetCodeAwareVulnerabilitySca
|
|
|
95782
95780
|
const purl = this.depIdToPurl.get(packageId);
|
|
95783
95781
|
return purl?.name && packagesToAnalyzeSet.has(purl.name);
|
|
95784
95782
|
}));
|
|
95785
|
-
return await this.actuallyRunAnalysis(vulnerabilities.flatMap((v) => v.vulnerabilityAccessPaths), filteredDeps);
|
|
95783
|
+
return await this.actuallyRunAnalysis(vulnerabilities.flatMap((v) => v.vulnerabilityAccessPaths), timeoutInSeconds, filteredDeps);
|
|
95786
95784
|
} catch (e) {
|
|
95787
95785
|
return { type: "error", message: e.message };
|
|
95788
95786
|
}
|
|
95789
95787
|
}
|
|
95790
|
-
async actuallyRunAnalysis(vulnerabilityAccessPaths, filteredDeps) {
|
|
95788
|
+
async actuallyRunAnalysis(vulnerabilityAccessPaths, timeoutInSeconds, filteredDeps) {
|
|
95791
95789
|
this.statusUpdater?.("Running analysis...");
|
|
95792
95790
|
return withTmpDirectory("dotnet-run-analysis", async (tmpDir) => {
|
|
95793
95791
|
try {
|
|
@@ -95799,12 +95797,12 @@ var DotnetCodeAwareVulnerabilityScanner = class _DotnetCodeAwareVulnerabilitySca
|
|
|
95799
95797
|
apps: this.apps,
|
|
95800
95798
|
deps: filteredDeps ?? this.deps,
|
|
95801
95799
|
vulnerableClasses: uniq2(vulnerabilityAccessPaths?.map((vulnFunction) => vulnFunction.slice(1).split(":")[0])),
|
|
95802
|
-
timeoutInSeconds
|
|
95800
|
+
timeoutInSeconds
|
|
95803
95801
|
};
|
|
95804
95802
|
const inputFile = resolve10(tmpDir, "input.json");
|
|
95805
95803
|
const outputFile = resolve10(tmpDir, "output.json");
|
|
95806
95804
|
await writeFile4(inputFile, JSON.stringify(options));
|
|
95807
|
-
const timeoutMs =
|
|
95805
|
+
const timeoutMs = Math.max(timeoutInSeconds * 1.5, timeoutInSeconds + 30) * 1e3;
|
|
95808
95806
|
const result = await execNeverFail2(cmdt`${await getNodeExecutable(ToolPathResolver.nodeExecutablePath)} ${getClassGraphAnalysisCliPath()} runDotnetReachabilityAnalysis -i ${inputFile} -o ${outputFile} --cocoa ${getCocoaPath()} --tree-sitter-c-sharp ${getTreeSitterCSharpPath()}`, void 0, { timeout: timeoutMs });
|
|
95809
95807
|
if (result.error)
|
|
95810
95808
|
return { type: "error", message: result.error.message ?? "unknown error" };
|
|
@@ -109628,17 +109626,15 @@ var JavaCodeAwareVulnerabilityScanner = class _JavaCodeAwareVulnerabilityScanner
|
|
|
109628
109626
|
apps;
|
|
109629
109627
|
deps;
|
|
109630
109628
|
depIdToPurl;
|
|
109631
|
-
timeoutInSeconds;
|
|
109632
109629
|
statusUpdater;
|
|
109633
109630
|
name = "ALUCARD";
|
|
109634
|
-
constructor(apps, deps, depIdToPurl,
|
|
109631
|
+
constructor(apps, deps, depIdToPurl, statusUpdater) {
|
|
109635
109632
|
this.apps = apps;
|
|
109636
109633
|
this.deps = deps;
|
|
109637
109634
|
this.depIdToPurl = depIdToPurl;
|
|
109638
|
-
this.timeoutInSeconds = timeoutInSeconds;
|
|
109639
109635
|
this.statusUpdater = statusUpdater;
|
|
109640
109636
|
}
|
|
109641
|
-
static async initFromDependencyTree(dependencyTree, tmpDir,
|
|
109637
|
+
static async initFromDependencyTree(dependencyTree, tmpDir, statusUpdater) {
|
|
109642
109638
|
const apps = {
|
|
109643
109639
|
"<app>": {
|
|
109644
109640
|
src: dependencyTree.src
|
|
@@ -109655,9 +109651,9 @@ var JavaCodeAwareVulnerabilityScanner = class _JavaCodeAwareVulnerabilityScanner
|
|
|
109655
109651
|
};
|
|
109656
109652
|
}
|
|
109657
109653
|
await extractArchivesIfNeeded(tmpDir, apps, deps);
|
|
109658
|
-
return new _JavaCodeAwareVulnerabilityScanner(apps, deps, depIdToPurl,
|
|
109654
|
+
return new _JavaCodeAwareVulnerabilityScanner(apps, deps, depIdToPurl, statusUpdater);
|
|
109659
109655
|
}
|
|
109660
|
-
static async initFromSocketArtifacts(subprojectDir, artifacts, tmpDir,
|
|
109656
|
+
static async initFromSocketArtifacts(subprojectDir, artifacts, tmpDir, statusUpdater) {
|
|
109661
109657
|
const apps = {
|
|
109662
109658
|
"<app>": {
|
|
109663
109659
|
src: [subprojectDir]
|
|
@@ -109665,7 +109661,7 @@ var JavaCodeAwareVulnerabilityScanner = class _JavaCodeAwareVulnerabilityScanner
|
|
|
109665
109661
|
};
|
|
109666
109662
|
const { deps, depIdToPurl } = await convertSocketArtifacts2(subprojectDir, artifacts, tmpDir);
|
|
109667
109663
|
await extractArchivesIfNeeded(tmpDir, apps, deps);
|
|
109668
|
-
return new _JavaCodeAwareVulnerabilityScanner(apps, deps, depIdToPurl,
|
|
109664
|
+
return new _JavaCodeAwareVulnerabilityScanner(apps, deps, depIdToPurl, statusUpdater);
|
|
109669
109665
|
}
|
|
109670
109666
|
static async runOnAlreadyDownloadedPackages([appPath, ...depPaths], vulnerability, options) {
|
|
109671
109667
|
return withTmpDirectory("java-run-on-dependency-chain", async (tmpDir) => {
|
|
@@ -109683,8 +109679,8 @@ var JavaCodeAwareVulnerabilityScanner = class _JavaCodeAwareVulnerabilityScanner
|
|
|
109683
109679
|
};
|
|
109684
109680
|
}
|
|
109685
109681
|
await extractArchivesIfNeeded(tmpDir, apps, deps);
|
|
109686
|
-
const scanner = new _JavaCodeAwareVulnerabilityScanner(apps, deps, depIdToPurl
|
|
109687
|
-
const result = await scanner.runAnalysis([vulnerability], AlucardHeuristics.ALL_PACKAGES,
|
|
109682
|
+
const scanner = new _JavaCodeAwareVulnerabilityScanner(apps, deps, depIdToPurl);
|
|
109683
|
+
const result = await scanner.runAnalysis([vulnerability], AlucardHeuristics.ALL_PACKAGES, options.timeoutSeconds.allVulnRuns);
|
|
109688
109684
|
if (result.type === "error")
|
|
109689
109685
|
return { error: result.message, terminatedEarly: true };
|
|
109690
109686
|
return {
|
|
@@ -109715,8 +109711,8 @@ var JavaCodeAwareVulnerabilityScanner = class _JavaCodeAwareVulnerabilityScanner
|
|
|
109715
109711
|
};
|
|
109716
109712
|
});
|
|
109717
109713
|
await extractArchivesIfNeeded(tmpDir, apps, deps);
|
|
109718
|
-
const scanner = new _JavaCodeAwareVulnerabilityScanner(apps, deps, depIdToPurl,
|
|
109719
|
-
const result = await scanner.actuallyRunAnalysis(vulnerability.vulnerabilityAccessPaths);
|
|
109714
|
+
const scanner = new _JavaCodeAwareVulnerabilityScanner(apps, deps, depIdToPurl, statusUpdater);
|
|
109715
|
+
const result = await scanner.actuallyRunAnalysis(vulnerability.vulnerabilityAccessPaths, timeoutInSeconds);
|
|
109720
109716
|
if (result.type === "error")
|
|
109721
109717
|
return { error: result.message, terminatedEarly: false };
|
|
109722
109718
|
return {
|
|
@@ -109728,7 +109724,7 @@ var JavaCodeAwareVulnerabilityScanner = class _JavaCodeAwareVulnerabilityScanner
|
|
|
109728
109724
|
}
|
|
109729
109725
|
});
|
|
109730
109726
|
}
|
|
109731
|
-
async runPhantomDependencyAnalysis() {
|
|
109727
|
+
async runPhantomDependencyAnalysis(timeoutInSeconds) {
|
|
109732
109728
|
return withTmpDirectory("java-direct-dependency-analysis", async (tmpDir) => {
|
|
109733
109729
|
try {
|
|
109734
109730
|
await ensureJdk8OrAbove();
|
|
@@ -109738,12 +109734,12 @@ var JavaCodeAwareVulnerabilityScanner = class _JavaCodeAwareVulnerabilityScanner
|
|
|
109738
109734
|
const options = {
|
|
109739
109735
|
apps: this.apps,
|
|
109740
109736
|
deps: this.deps,
|
|
109741
|
-
timeoutInSeconds
|
|
109737
|
+
timeoutInSeconds
|
|
109742
109738
|
};
|
|
109743
109739
|
const inputFile = resolve11(tmpDir, "input.json");
|
|
109744
109740
|
const outputFile = resolve11(tmpDir, "output.json");
|
|
109745
109741
|
await writeFile5(inputFile, JSON.stringify(options));
|
|
109746
|
-
const timeoutMs =
|
|
109742
|
+
const timeoutMs = Math.max(timeoutInSeconds * 1.5, timeoutInSeconds + 30) * 1e3;
|
|
109747
109743
|
const result = await execNeverFail2(cmdt`${await getNodeExecutable(ToolPathResolver.nodeExecutablePath)} ${getClassGraphAnalysisCliPath()} runJvmDirectDependencyAnalysis -i ${inputFile} -o ${outputFile} --javap-service ${getJavapServicePath()} --tree-sitter-java ${getTreeSitterJavaPath()} --tree-sitter-kotlin ${getTreeSitterKotlinPath()} --tree-sitter-scala ${getTreeSitterScalaPath()}`, void 0, { timeout: timeoutMs });
|
|
109748
109744
|
if (result.error)
|
|
109749
109745
|
return void 0;
|
|
@@ -109751,7 +109747,7 @@ var JavaCodeAwareVulnerabilityScanner = class _JavaCodeAwareVulnerabilityScanner
|
|
|
109751
109747
|
return packageIds?.map((packageId) => this.depIdToPurl.get(packageId)).filter((purl) => purl !== void 0).map((purl) => `${purl.namespace}:${purl.name}}`);
|
|
109752
109748
|
});
|
|
109753
109749
|
}
|
|
109754
|
-
async runAnalysis(vulnerabilities, heuristic,
|
|
109750
|
+
async runAnalysis(vulnerabilities, heuristic, timeoutInSeconds, _experiment) {
|
|
109755
109751
|
try {
|
|
109756
109752
|
this.statusUpdater?.("Preparing code for analysis...");
|
|
109757
109753
|
const packagesToAnalyze = heuristic.getPackagesToAnalyze(vulnerabilities);
|
|
@@ -109760,12 +109756,12 @@ var JavaCodeAwareVulnerabilityScanner = class _JavaCodeAwareVulnerabilityScanner
|
|
|
109760
109756
|
const purl = this.depIdToPurl.get(packageId);
|
|
109761
109757
|
return purl && packagesToAnalyzeSet.has(`${purl.namespace}:${purl.name}}`);
|
|
109762
109758
|
}));
|
|
109763
|
-
return await this.actuallyRunAnalysis(vulnerabilities.flatMap((v) => v.vulnerabilityAccessPaths), filteredDeps);
|
|
109759
|
+
return await this.actuallyRunAnalysis(vulnerabilities.flatMap((v) => v.vulnerabilityAccessPaths), timeoutInSeconds, filteredDeps);
|
|
109764
109760
|
} catch (e) {
|
|
109765
109761
|
return { type: "error", message: e.message };
|
|
109766
109762
|
}
|
|
109767
109763
|
}
|
|
109768
|
-
async actuallyRunAnalysis(vulnerabilityAccessPaths, filteredDeps) {
|
|
109764
|
+
async actuallyRunAnalysis(vulnerabilityAccessPaths, timeoutInSeconds, filteredDeps) {
|
|
109769
109765
|
this.statusUpdater?.("Running analysis...");
|
|
109770
109766
|
return withTmpDirectory("java-run-analysis", async (tmpDir) => {
|
|
109771
109767
|
try {
|
|
@@ -109777,12 +109773,12 @@ var JavaCodeAwareVulnerabilityScanner = class _JavaCodeAwareVulnerabilityScanner
|
|
|
109777
109773
|
apps: this.apps,
|
|
109778
109774
|
deps: filteredDeps ?? this.deps,
|
|
109779
109775
|
vulnerableClasses: uniq3(vulnerabilityAccessPaths?.map((vulnFunction) => vulnFunction.slice(1).split(":")[0])),
|
|
109780
|
-
timeoutInSeconds
|
|
109776
|
+
timeoutInSeconds
|
|
109781
109777
|
};
|
|
109782
109778
|
const inputFile = resolve11(tmpDir, "input.json");
|
|
109783
109779
|
const outputFile = resolve11(tmpDir, "output.json");
|
|
109784
109780
|
await writeFile5(inputFile, JSON.stringify(options));
|
|
109785
|
-
const timeoutMs =
|
|
109781
|
+
const timeoutMs = Math.max(timeoutInSeconds * 1.5, timeoutInSeconds + 30) * 1e3;
|
|
109786
109782
|
const result = await execNeverFail2(cmdt`${await getNodeExecutable(ToolPathResolver.nodeExecutablePath)} ${getClassGraphAnalysisCliPath()} runJvmReachabilityAnalysis -i ${inputFile} -o ${outputFile} --javap-service ${getJavapServicePath()} --tree-sitter-java ${getTreeSitterJavaPath()} --tree-sitter-kotlin ${getTreeSitterKotlinPath()} --tree-sitter-scala ${getTreeSitterScalaPath()}`, void 0, { timeout: timeoutMs });
|
|
109787
109783
|
if (result.error)
|
|
109788
109784
|
return { type: "error", message: result.error.message ?? "unknown error" };
|
|
@@ -110416,24 +110412,11 @@ function getMaxRoundsHeuristicOptions(maxRounds) {
|
|
|
110416
110412
|
}
|
|
110417
110413
|
function getOnlyPackagesInVulnPathsWithoutLeafPackagesHeuristicOptions(vulnerabilities) {
|
|
110418
110414
|
return {
|
|
110419
|
-
includePackages:
|
|
110415
|
+
includePackages: computePackagesOnVulnPath(vulnerabilities)
|
|
110420
110416
|
};
|
|
110421
110417
|
}
|
|
110422
|
-
function
|
|
110423
|
-
|
|
110424
|
-
vulnerabilities.filter((v) => !v.vulnerabilityAccessPaths || typeof v.vulnerabilityAccessPaths !== "string").forEach((v) => {
|
|
110425
|
-
const visitedIdentifiers = [];
|
|
110426
|
-
const helper = (node) => {
|
|
110427
|
-
if (node.children && node.children.length > 0)
|
|
110428
|
-
packagesToAnalyze.add(node.packageName);
|
|
110429
|
-
node.children?.filter((c) => !visitedIdentifiers.includes(c)).forEach((c) => {
|
|
110430
|
-
visitedIdentifiers.push(c);
|
|
110431
|
-
helper(v.vulnChainDetails.transitiveDependencies[c]);
|
|
110432
|
-
});
|
|
110433
|
-
};
|
|
110434
|
-
helper(v.vulnChainDetails);
|
|
110435
|
-
});
|
|
110436
|
-
return [...packagesToAnalyze];
|
|
110418
|
+
function computePackagesOnVulnPath(vulnerabilities, { includeLeafPackages = false } = {}) {
|
|
110419
|
+
return [...new Set(vulnerabilities.filter((v) => !v.vulnerabilityAccessPaths || typeof v.vulnerabilityAccessPaths !== "string").flatMap((v) => Object.values(v.vulnChainDetails?.transitiveDependencies ?? {}).filter((d) => includeLeafPackages || d.children?.length).map((d) => d.packageName)))];
|
|
110437
110420
|
}
|
|
110438
110421
|
|
|
110439
110422
|
// dist/whole-program-code-aware-vulnerability-scanner/js/jelly-runner.js
|
|
@@ -110442,10 +110425,10 @@ import { readFile as readFile8, rm as rm2, writeFile as writeFile6 } from "fs/pr
|
|
|
110442
110425
|
import { relative as relative6, resolve as resolve14 } from "path";
|
|
110443
110426
|
var { map: map2, uniq: uniq4 } = import_lodash10.default;
|
|
110444
110427
|
var PRINT_JELLY_COMMAND = false;
|
|
110445
|
-
async function runJellyAnalysis(mainProjectRoot, projectRoot, jellyOptions, reachabilityAnalysisOptions, vulnerabilities, experiment) {
|
|
110428
|
+
async function runJellyAnalysis(mainProjectRoot, projectRoot, jellyOptions, reachabilityAnalysisOptions, timeoutInSeconds, vulnerabilities, experiment) {
|
|
110446
110429
|
const tmpFolder = await createTmpDirectory("jelly-analysis");
|
|
110447
110430
|
try {
|
|
110448
|
-
const filesToAnalyze = reachabilityAnalysisOptions.entryPoints
|
|
110431
|
+
const filesToAnalyze = reachabilityAnalysisOptions.entryPoints ?? [projectRoot];
|
|
110449
110432
|
const jellyExecutable = ToolPathResolver.jellyPath;
|
|
110450
110433
|
const vulnerabilitiesInJellyFormat = vulnerabilities.map((v) => ({
|
|
110451
110434
|
osv: v,
|
|
@@ -110458,23 +110441,17 @@ async function runJellyAnalysis(mainProjectRoot, projectRoot, jellyOptions, reac
|
|
|
110458
110441
|
const affectedPackagesFile = resolve14(tmpFolder, "affected-packages.json");
|
|
110459
110442
|
const logFile = reachabilityAnalysisOptions.analysisLogFile ?? (reachabilityAnalysisOptions.printLogFile && resolve14(projectRoot, "js-analysis.log"));
|
|
110460
110443
|
await writeFile6(vulnerabilitiesFile, JSON.stringify(vulnerabilitiesInJellyFormat));
|
|
110461
|
-
let excludeEntries;
|
|
110462
|
-
if (reachabilityAnalysisOptions.excludeDirs?.length) {
|
|
110463
|
-
const excludeDirsRelativeToProjectRoot = reachabilityAnalysisOptions.excludeDirs.map((d) => relative6(projectRoot, resolve14(mainProjectRoot, d)));
|
|
110464
|
-
const excludeDirsRelativeToProjectRootWithWildcards = excludeDirsRelativeToProjectRoot.map((d) => `${d}/**`);
|
|
110465
|
-
excludeEntries = [...excludeDirsRelativeToProjectRoot, ...excludeDirsRelativeToProjectRootWithWildcards];
|
|
110466
|
-
}
|
|
110467
110444
|
const jellyCmd = cmdt`
|
|
110468
110445
|
${await getNodeExecutable(ToolPathResolver.nodeExecutablePath)} --max-old-space-size=${reachabilityAnalysisOptions.memoryLimitInMB ?? 8192}
|
|
110469
110446
|
${jellyExecutable}
|
|
110470
110447
|
--basedir ${mainProjectRoot}
|
|
110471
|
-
--timeout ${
|
|
110448
|
+
--timeout ${timeoutInSeconds}
|
|
110472
110449
|
--vulnerabilities ${vulnerabilitiesFile}
|
|
110473
110450
|
--reachable-json ${affectedPackagesFile}
|
|
110474
|
-
${
|
|
110451
|
+
${getExcludes(mainProjectRoot, projectRoot, reachabilityAnalysisOptions)}
|
|
110475
110452
|
--diagnostics-json ${diagnosticsFile}
|
|
110476
110453
|
--max-indirections=${jellyOptions.maxIndirections}
|
|
110477
|
-
${jellyOptions.includePackages && ["--include-packages", ...jellyOptions.includePackages]}
|
|
110454
|
+
${!!jellyOptions.includePackages?.length && ["--include-packages", ...jellyOptions.includePackages]}
|
|
110478
110455
|
${jellyOptions.approx && "--approx"}
|
|
110479
110456
|
${logFile ? ["--logfile", logFile] : []}
|
|
110480
110457
|
--callstacks-json ${callStackFile}
|
|
@@ -110487,7 +110464,7 @@ async function runJellyAnalysis(mainProjectRoot, projectRoot, jellyOptions, reac
|
|
|
110487
110464
|
void 0,
|
|
110488
110465
|
// If it is an experimental run, make sure to crash the process if Jelly takes more than 50% longer than the timeout.
|
|
110489
110466
|
// This is done to mitigate the scenario where the Jelly process gets close to the memory limit and thus ends up spending most of its time on garbage collection, which can increase the time between timeout checks dramatically.
|
|
110490
|
-
experiment
|
|
110467
|
+
experiment ? { timeout: timeoutInSeconds * 1e3 * 1.5 } : void 0
|
|
110491
110468
|
);
|
|
110492
110469
|
if (reachabilityAnalysisOptions.printLogFile)
|
|
110493
110470
|
logger.info("JS analysis log file:", await readFile8(logFile, "utf-8"));
|
|
@@ -110526,26 +110503,36 @@ async function runJellyPhantomDependencyAnalysis(projectRoot, options) {
|
|
|
110526
110503
|
const jellyCmd = cmdt`${await getNodeExecutable(ToolPathResolver.nodeExecutablePath)} --max-old-space-size=${options.memoryLimitInMB}
|
|
110527
110504
|
${jellyExecutable} --basedir ${projectRoot} --modules-only --ignore-dependencies
|
|
110528
110505
|
--reachable-json ${reachablePackagesFile} ${projectRoot}`;
|
|
110529
|
-
await runCommandResolveStdOut2(jellyCmd);
|
|
110506
|
+
await runCommandResolveStdOut2(jellyCmd, void 0, { timeout: options.timeoutSeconds.allVulnRuns * 1e3 });
|
|
110530
110507
|
return JSON.parse(await readFile8(reachablePackagesFile, "utf-8")).packages;
|
|
110531
110508
|
} finally {
|
|
110532
110509
|
await rm2(tmpFolder, { recursive: true });
|
|
110533
110510
|
}
|
|
110534
110511
|
}
|
|
110535
|
-
async function runJellyImportReachabilityAnalysis(
|
|
110512
|
+
async function runJellyImportReachabilityAnalysis(mainProjectRoot, projectRoot, vulnerabilities, options) {
|
|
110536
110513
|
const tmpFolder = await createTmpDirectory("jelly-analysis");
|
|
110537
110514
|
try {
|
|
110538
|
-
const
|
|
110515
|
+
const includePackages = computePackagesOnVulnPath(vulnerabilities, { includeLeafPackages: true });
|
|
110539
110516
|
const reachableModulesFile = resolve14(tmpFolder, "reachable-modules.json");
|
|
110540
110517
|
const jellyCmd = cmdt`${await getNodeExecutable(ToolPathResolver.nodeExecutablePath)} --max-old-space-size=${options.memoryLimitInMB}
|
|
110541
|
-
${
|
|
110542
|
-
--
|
|
110543
|
-
|
|
110518
|
+
${ToolPathResolver.jellyPath} --basedir ${mainProjectRoot} --modules-only
|
|
110519
|
+
${!!includePackages.length && ["--include-packages", ...includePackages]}
|
|
110520
|
+
${getExcludes(mainProjectRoot, projectRoot, options)}
|
|
110521
|
+
--reachable-json ${reachableModulesFile}
|
|
110522
|
+
${options.entryPoints ?? projectRoot}`;
|
|
110523
|
+
await runCommandResolveStdOut2(jellyCmd, void 0, { timeout: options.timeoutSeconds.allVulnRuns * 1e3 });
|
|
110544
110524
|
return JSON.parse(await readFile8(reachableModulesFile, "utf-8"));
|
|
110545
110525
|
} finally {
|
|
110546
110526
|
await rm2(tmpFolder, { recursive: true });
|
|
110547
110527
|
}
|
|
110548
110528
|
}
|
|
110529
|
+
function getExcludes(mainProjectRoot, projectRoot, options) {
|
|
110530
|
+
if (options.excludeDirs?.length) {
|
|
110531
|
+
const excludeDirsRelativeToProjectRoot = options.excludeDirs.map((d) => relative6(projectRoot, resolve14(mainProjectRoot, d)));
|
|
110532
|
+
const excludeDirsRelativeToProjectRootWithWildcards = excludeDirsRelativeToProjectRoot.map((d) => `${d}/**`);
|
|
110533
|
+
return [...excludeDirsRelativeToProjectRoot, ...excludeDirsRelativeToProjectRootWithWildcards];
|
|
110534
|
+
}
|
|
110535
|
+
}
|
|
110549
110536
|
function relativizeSourceLocations(projectDir, paths) {
|
|
110550
110537
|
return {
|
|
110551
110538
|
...paths,
|
|
@@ -110571,7 +110558,7 @@ var JSCodeAwareVulnerabilityScanner = class _JSCodeAwareVulnerabilityScanner {
|
|
|
110571
110558
|
numberAnalysesRun = 0;
|
|
110572
110559
|
packagesExcludedUnrelatedToHeuristic = [];
|
|
110573
110560
|
socketMode = false;
|
|
110574
|
-
constructor(mainProjectDir, projectDir, options
|
|
110561
|
+
constructor(mainProjectDir, projectDir, options) {
|
|
110575
110562
|
this.mainProjectDir = mainProjectDir;
|
|
110576
110563
|
this.projectDir = projectDir;
|
|
110577
110564
|
this.options = options;
|
|
@@ -110587,15 +110574,11 @@ var JSCodeAwareVulnerabilityScanner = class _JSCodeAwareVulnerabilityScanner {
|
|
|
110587
110574
|
const { failedPackages } = await prepareNpmDependencies(state.rootWorkingDir, this.projectDir, state.workspaceData.type === "coana" ? state.workspaceData.data.dependencyTree.transitiveDependencies : Object.fromEntries(state.workspaceData.data.artifacts.map((d) => [d.id, d])), state.workspaceData.type === "coana" ? state.workspaceData.data.dependencyTree.dependencies ?? [] : state.workspaceData.data.artifacts.filter((a2) => a2.direct).map((a2) => a2.id), packagesToInstall);
|
|
110588
110575
|
this.packagesExcludedUnrelatedToHeuristic = failedPackages.map((p) => getPackageName(p));
|
|
110589
110576
|
}
|
|
110590
|
-
async runAnalysis(vulnerabilities, heuristic,
|
|
110577
|
+
async runAnalysis(vulnerabilities, heuristic, timeoutInSeconds, experiment) {
|
|
110591
110578
|
const analysisOptionsFromHeuristic = heuristic.getOptions(vulnerabilities);
|
|
110592
|
-
const timeoutInSeconds = analyzesAllVulns ? this.options.timeoutInSeconds ?? 600 : 60;
|
|
110593
110579
|
try {
|
|
110594
110580
|
analysisOptionsFromHeuristic.approx = process.env.JELLY_APPROX === "true" || experiment === "JELLY_APPROX";
|
|
110595
|
-
const analysisRes = await runJellyAnalysis(this.mainProjectDir, this.projectDir, analysisOptionsFromHeuristic,
|
|
110596
|
-
...this.options,
|
|
110597
|
-
timeoutInSeconds
|
|
110598
|
-
}, vulnerabilities, experiment);
|
|
110581
|
+
const analysisRes = await runJellyAnalysis(this.mainProjectDir, this.projectDir, analysisOptionsFromHeuristic, this.options, timeoutInSeconds, vulnerabilities, experiment);
|
|
110599
110582
|
const { analysisDiagnostics: diagnostics, matches } = analysisRes;
|
|
110600
110583
|
return {
|
|
110601
110584
|
type: "success",
|
|
@@ -110659,7 +110642,7 @@ var JSCodeAwareVulnerabilityScanner = class _JSCodeAwareVulnerabilityScanner {
|
|
|
110659
110642
|
const projectDir = join14(tmpDir, "node_modules", firstPackageName);
|
|
110660
110643
|
const scanner = new _JSCodeAwareVulnerabilityScanner(projectDir, projectDir, reachabilityAnalysisOptions);
|
|
110661
110644
|
logger.info(`Started analysis of ${projectDir}`);
|
|
110662
|
-
const result = await scanner.runAnalysis([vulnerability], heuristics.createIncludePackagesHeuristic(otherPackageNames, baseHeuristic.getOptions([vulnerability])),
|
|
110645
|
+
const result = await scanner.runAnalysis([vulnerability], heuristics.createIncludePackagesHeuristic(otherPackageNames, baseHeuristic.getOptions([vulnerability])), reachabilityAnalysisOptions.timeoutSeconds.allVulnRuns);
|
|
110663
110646
|
if (result.type === "error") {
|
|
110664
110647
|
return {
|
|
110665
110648
|
error: result.message,
|
|
@@ -110683,7 +110666,7 @@ var JSCodeAwareVulnerabilityScanner = class _JSCodeAwareVulnerabilityScanner {
|
|
|
110683
110666
|
const restWithoutLast = rest.slice(0, -1);
|
|
110684
110667
|
const projectDir = join14(tmpDir, "node_modules", first2.packageName);
|
|
110685
110668
|
const scanner = new _JSCodeAwareVulnerabilityScanner(tmpDir, projectDir, reachabilityAnalysisOptions);
|
|
110686
|
-
const result = await scanner.runAnalysis([vulnerability], heuristics.createIncludePackagesHeuristic(restWithoutLast.map((p) => p.packageName), baseHeuristic.getOptions([vulnerability])),
|
|
110669
|
+
const result = await scanner.runAnalysis([vulnerability], heuristics.createIncludePackagesHeuristic(restWithoutLast.map((p) => p.packageName), baseHeuristic.getOptions([vulnerability])), reachabilityAnalysisOptions.timeoutSeconds.allVulnRuns);
|
|
110687
110670
|
await rm3(tmpDir, { recursive: true, force: true });
|
|
110688
110671
|
if (result.type === "error") {
|
|
110689
110672
|
return {
|
|
@@ -110774,11 +110757,11 @@ var GoCodeAwareVulnerabilityScanner = class {
|
|
|
110774
110757
|
this.projectDir = projectDir;
|
|
110775
110758
|
this.options = options;
|
|
110776
110759
|
}
|
|
110777
|
-
async runAnalysis(vulns, heuristic,
|
|
110760
|
+
async runAnalysis(vulns, heuristic, timeoutInSeconds) {
|
|
110778
110761
|
logger.info("Started instantiating Go code-aware analysis");
|
|
110779
110762
|
if (!existsSync10(join15(this.projectDir, "go.mod")))
|
|
110780
110763
|
throw new Error("go.mod file not found in the project directory");
|
|
110781
|
-
const {
|
|
110764
|
+
const { memoryLimitInMB } = this.options;
|
|
110782
110765
|
const tmpDir = await createTmpDirectory("goana-output");
|
|
110783
110766
|
const vulnsOutputFile = join15(tmpDir, "vulns.json");
|
|
110784
110767
|
const diagnosticsOutputFile = join15(tmpDir, "diagnostics.json");
|
|
@@ -110795,7 +110778,7 @@ var GoCodeAwareVulnerabilityScanner = class {
|
|
|
110795
110778
|
-output-reached-modules ${reachedModulesOutputFile}
|
|
110796
110779
|
-topk=4 ${heuristic.includeTests && "-tests"}
|
|
110797
110780
|
${this.projectDir} ${vulnAccPaths}`, void 0, {
|
|
110798
|
-
timeout: timeoutInSeconds
|
|
110781
|
+
timeout: timeoutInSeconds * 1e3,
|
|
110799
110782
|
env: memoryLimitInMB ? { ...process.env, GOMEMLIMIT: `${memoryLimitInMB}MiB` } : void 0
|
|
110800
110783
|
});
|
|
110801
110784
|
if (error) {
|
|
@@ -110840,7 +110823,7 @@ ${stderr}`);
|
|
|
110840
110823
|
await rm4(tmpDir, { recursive: true, force: true });
|
|
110841
110824
|
}
|
|
110842
110825
|
}
|
|
110843
|
-
static async runOnDependencyChain([first2, ...rest], vuln, options
|
|
110826
|
+
static async runOnDependencyChain([first2, ...rest], vuln, options) {
|
|
110844
110827
|
assert4(first2.version);
|
|
110845
110828
|
const { Dir, GoMod } = JSON.parse(await runCommandResolveStdOut2(cmdt`go mod download -json ${first2.packageName}@v${first2.version}`));
|
|
110846
110829
|
const projectDir = await createTmpDirectory("go-run-on-dependency-chain-");
|
|
@@ -110857,7 +110840,7 @@ ${stderr}`);
|
|
|
110857
110840
|
await runGoModTidy(projectDir);
|
|
110858
110841
|
}
|
|
110859
110842
|
const heuristic = GoanaHeuristics.NO_TESTS;
|
|
110860
|
-
const result = await new this(projectDir, options).runAnalysis([vuln], heuristic,
|
|
110843
|
+
const result = await new this(projectDir, options).runAnalysis([vuln], heuristic, options.timeoutSeconds.allVulnRuns);
|
|
110861
110844
|
if (result.type === "error")
|
|
110862
110845
|
return {
|
|
110863
110846
|
error: result.message,
|
|
@@ -110873,7 +110856,7 @@ ${stderr}`);
|
|
|
110873
110856
|
await rm4(projectDir, { recursive: true, force: true });
|
|
110874
110857
|
}
|
|
110875
110858
|
}
|
|
110876
|
-
static async runOnAlreadyDownloadedPackages(packages, vuln, options
|
|
110859
|
+
static async runOnAlreadyDownloadedPackages(packages, vuln, options) {
|
|
110877
110860
|
for (const pkg of packages)
|
|
110878
110861
|
assert4(existsSync10(join15(pkg, "go.mod")), `${pkg} does not contain a go.mod file`);
|
|
110879
110862
|
const [app, ...dependencies] = packages;
|
|
@@ -110890,7 +110873,7 @@ ${stderr}`);
|
|
|
110890
110873
|
await runGoModTidy(projectDir);
|
|
110891
110874
|
}
|
|
110892
110875
|
const heuristic = GoanaHeuristics.NO_TESTS;
|
|
110893
|
-
const result = await new this(projectDir, options).runAnalysis([vuln], heuristic,
|
|
110876
|
+
const result = await new this(projectDir, options).runAnalysis([vuln], heuristic, options.timeoutSeconds.allVulnRuns);
|
|
110894
110877
|
if (result.type === "error")
|
|
110895
110878
|
return {
|
|
110896
110879
|
error: result.message,
|
|
@@ -110948,17 +110931,15 @@ var RustCodeAwareVulnerabilityScanner = class _RustCodeAwareVulnerabilityScanner
|
|
|
110948
110931
|
apps;
|
|
110949
110932
|
deps;
|
|
110950
110933
|
depIdToPurl;
|
|
110951
|
-
timeoutInSeconds;
|
|
110952
110934
|
statusUpdater;
|
|
110953
110935
|
name = "RUSTICA";
|
|
110954
|
-
constructor(apps, deps, depIdToPurl,
|
|
110936
|
+
constructor(apps, deps, depIdToPurl, statusUpdater) {
|
|
110955
110937
|
this.apps = apps;
|
|
110956
110938
|
this.deps = deps;
|
|
110957
110939
|
this.depIdToPurl = depIdToPurl;
|
|
110958
|
-
this.timeoutInSeconds = timeoutInSeconds;
|
|
110959
110940
|
this.statusUpdater = statusUpdater;
|
|
110960
110941
|
}
|
|
110961
|
-
static initFromDependencyTree(dependencyTree,
|
|
110942
|
+
static initFromDependencyTree(dependencyTree, statusUpdater) {
|
|
110962
110943
|
const appDependencies = {};
|
|
110963
110944
|
if (dependencyTree.dependenciesWithAliases) {
|
|
110964
110945
|
for (const [depId, names] of Object.entries(dependencyTree.dependenciesWithAliases)) {
|
|
@@ -110992,9 +110973,9 @@ var RustCodeAwareVulnerabilityScanner = class _RustCodeAwareVulnerabilityScanner
|
|
|
110992
110973
|
}
|
|
110993
110974
|
};
|
|
110994
110975
|
}
|
|
110995
|
-
return new _RustCodeAwareVulnerabilityScanner(apps, deps, depIdToPurl,
|
|
110976
|
+
return new _RustCodeAwareVulnerabilityScanner(apps, deps, depIdToPurl, statusUpdater);
|
|
110996
110977
|
}
|
|
110997
|
-
static async initFromSocketArtifacts(subprojectDir, workspacePath, artifacts, tmpDir,
|
|
110978
|
+
static async initFromSocketArtifacts(subprojectDir, workspacePath, artifacts, tmpDir, statusUpdater) {
|
|
110998
110979
|
const cargoTomlToArtifacts = /* @__PURE__ */ new Map();
|
|
110999
110980
|
for (const artifact of artifacts) {
|
|
111000
110981
|
for (const mf of artifact.manifestFiles ?? []) {
|
|
@@ -111048,7 +111029,7 @@ var RustCodeAwareVulnerabilityScanner = class _RustCodeAwareVulnerabilityScanner
|
|
|
111048
111029
|
}
|
|
111049
111030
|
};
|
|
111050
111031
|
const { deps, depIdToPurl } = await convertSocketArtifacts3(artifacts, tmpDir, artifactNameToId);
|
|
111051
|
-
return new _RustCodeAwareVulnerabilityScanner(apps, deps, depIdToPurl,
|
|
111032
|
+
return new _RustCodeAwareVulnerabilityScanner(apps, deps, depIdToPurl, statusUpdater);
|
|
111052
111033
|
}
|
|
111053
111034
|
/** @deprecated */
|
|
111054
111035
|
static async runOnAlreadyDownloadedPackages([appPath, ...depPaths], vulnerability, options) {
|
|
@@ -111106,8 +111087,8 @@ var RustCodeAwareVulnerabilityScanner = class _RustCodeAwareVulnerabilityScanner
|
|
|
111106
111087
|
deps[packageId] = packageInfo;
|
|
111107
111088
|
}
|
|
111108
111089
|
}
|
|
111109
|
-
const scanner = new _RustCodeAwareVulnerabilityScanner(apps, deps, depIdToPurl
|
|
111110
|
-
const result = await scanner.runAnalysis([vulnerability], RusticaHeuristics.ALL_PACKAGES,
|
|
111090
|
+
const scanner = new _RustCodeAwareVulnerabilityScanner(apps, deps, depIdToPurl);
|
|
111091
|
+
const result = await scanner.runAnalysis([vulnerability], RusticaHeuristics.ALL_PACKAGES, options.timeoutSeconds.allVulnRuns);
|
|
111111
111092
|
if (result.type === "error")
|
|
111112
111093
|
return { error: result.message, terminatedEarly: true };
|
|
111113
111094
|
return {
|
|
@@ -111173,8 +111154,8 @@ var RustCodeAwareVulnerabilityScanner = class _RustCodeAwareVulnerabilityScanner
|
|
|
111173
111154
|
}
|
|
111174
111155
|
};
|
|
111175
111156
|
}
|
|
111176
|
-
const scanner = new _RustCodeAwareVulnerabilityScanner(apps, deps, depIdToPurl,
|
|
111177
|
-
const result = await scanner.actuallyRunAnalysis(vulnerability.vulnerabilityAccessPaths);
|
|
111157
|
+
const scanner = new _RustCodeAwareVulnerabilityScanner(apps, deps, depIdToPurl, statusUpdater);
|
|
111158
|
+
const result = await scanner.actuallyRunAnalysis(vulnerability.vulnerabilityAccessPaths, timeoutInSeconds);
|
|
111178
111159
|
if (result.type === "error")
|
|
111179
111160
|
return { error: result.message, terminatedEarly: false };
|
|
111180
111161
|
return {
|
|
@@ -111186,17 +111167,17 @@ var RustCodeAwareVulnerabilityScanner = class _RustCodeAwareVulnerabilityScanner
|
|
|
111186
111167
|
}
|
|
111187
111168
|
});
|
|
111188
111169
|
}
|
|
111189
|
-
async runPhantomDependencyAnalysis() {
|
|
111170
|
+
async runPhantomDependencyAnalysis(timeoutInSeconds) {
|
|
111190
111171
|
return withTmpDirectory("rust-direct-dependency-analysis", async (tmpDir) => {
|
|
111191
111172
|
const options = {
|
|
111192
111173
|
apps: this.apps,
|
|
111193
111174
|
deps: this.deps,
|
|
111194
|
-
timeoutInSeconds
|
|
111175
|
+
timeoutInSeconds
|
|
111195
111176
|
};
|
|
111196
111177
|
const inputFile = resolve16(tmpDir, "input.json");
|
|
111197
111178
|
const outputFile = resolve16(tmpDir, "output.json");
|
|
111198
111179
|
await writeFile8(inputFile, JSON.stringify(options));
|
|
111199
|
-
const timeoutMs =
|
|
111180
|
+
const timeoutMs = Math.max(timeoutInSeconds * 1.5, timeoutInSeconds + 30) * 1e3;
|
|
111200
111181
|
const result = await execNeverFail2(cmdt`${await getNodeExecutable(ToolPathResolver.nodeExecutablePath)} ${getClassGraphAnalysisCliPath()} runRustDirectDependencyAnalysis -i ${inputFile} -o ${outputFile} --tree-sitter-rust ${getTreeSitterRustPath()}`, void 0, { timeout: timeoutMs });
|
|
111201
111182
|
if (result.error)
|
|
111202
111183
|
return void 0;
|
|
@@ -111204,7 +111185,7 @@ var RustCodeAwareVulnerabilityScanner = class _RustCodeAwareVulnerabilityScanner
|
|
|
111204
111185
|
return packageIds?.map((packageId) => this.depIdToPurl.get(packageId)?.name).filter((name2) => name2 !== void 0).map((name2) => name2);
|
|
111205
111186
|
});
|
|
111206
111187
|
}
|
|
111207
|
-
async runAnalysis(vulnerabilities, heuristic,
|
|
111188
|
+
async runAnalysis(vulnerabilities, heuristic, timeoutInSeconds) {
|
|
111208
111189
|
try {
|
|
111209
111190
|
this.statusUpdater?.("Preparing code for analysis...");
|
|
111210
111191
|
const packagesToAnalyze = heuristic.getPackagesToAnalyze(vulnerabilities);
|
|
@@ -111213,25 +111194,26 @@ var RustCodeAwareVulnerabilityScanner = class _RustCodeAwareVulnerabilityScanner
|
|
|
111213
111194
|
const purl = this.depIdToPurl.get(packageId);
|
|
111214
111195
|
return purl?.name && packagesToAnalyzeSet.has(purl.name);
|
|
111215
111196
|
}));
|
|
111216
|
-
return await this.actuallyRunAnalysis(vulnerabilities.flatMap((v) => v.vulnerabilityAccessPaths), filteredDeps);
|
|
111197
|
+
return await this.actuallyRunAnalysis(vulnerabilities.flatMap((v) => v.vulnerabilityAccessPaths), timeoutInSeconds, filteredDeps);
|
|
111217
111198
|
} catch (e) {
|
|
111218
111199
|
return { type: "error", message: e.message };
|
|
111219
111200
|
}
|
|
111220
111201
|
}
|
|
111221
|
-
async actuallyRunAnalysis(vulnerabilityAccessPaths, filteredDeps) {
|
|
111202
|
+
async actuallyRunAnalysis(vulnerabilityAccessPaths, timeoutInSeconds, filteredDeps) {
|
|
111222
111203
|
this.statusUpdater?.("Running analysis...");
|
|
111223
111204
|
return withTmpDirectory("rust-run-analysis", async (tmpDir) => {
|
|
111205
|
+
const effectiveTimeout = timeoutInSeconds;
|
|
111224
111206
|
const options = {
|
|
111225
111207
|
apps: this.apps,
|
|
111226
111208
|
deps: filteredDeps ?? this.deps,
|
|
111227
111209
|
// Note, rust uses '::' as path separator, so we need to split on ': ' and not only ':'
|
|
111228
111210
|
vulnerableClasses: uniq6(vulnerabilityAccessPaths?.map((vulnFunction) => vulnFunction.slice(1).split(": ")[0])),
|
|
111229
|
-
timeoutInSeconds:
|
|
111211
|
+
timeoutInSeconds: effectiveTimeout
|
|
111230
111212
|
};
|
|
111231
111213
|
const inputFile = resolve16(tmpDir, "input.json");
|
|
111232
111214
|
const outputFile = resolve16(tmpDir, "output.json");
|
|
111233
111215
|
await writeFile8(inputFile, JSON.stringify(options));
|
|
111234
|
-
const timeoutMs =
|
|
111216
|
+
const timeoutMs = Math.max(effectiveTimeout * 1.5, effectiveTimeout + 30) * 1e3;
|
|
111235
111217
|
const result = await execNeverFail2(cmdt`${await getNodeExecutable(ToolPathResolver.nodeExecutablePath)} ${getClassGraphAnalysisCliPath()} runRustReachabilityAnalysis -i ${inputFile} -o ${outputFile} --tree-sitter-rust ${getTreeSitterRustPath()}`, void 0, { timeout: timeoutMs });
|
|
111236
111218
|
if (result.error)
|
|
111237
111219
|
return { type: "error", message: result.error.message ?? "unknown error" };
|
|
@@ -111549,36 +111531,27 @@ async function analyzePackages(ecosystem, packages, vulnerability, options) {
|
|
|
111549
111531
|
switch (ecosystem) {
|
|
111550
111532
|
case "NPM":
|
|
111551
111533
|
analysisName = "Jelly";
|
|
111552
|
-
result = await runWithJSHeuristics(async (h) => await JSCodeAwareVulnerabilityScanner.runOnDependencyChain(packages, vulnerability,
|
|
111553
|
-
timeoutInSeconds: options?.timeoutInSeconds ?? 60,
|
|
111554
|
-
memoryLimitInMB: options?.memoryLimitInMB ?? 16384
|
|
111555
|
-
}, h));
|
|
111534
|
+
result = await runWithJSHeuristics(async (h) => await JSCodeAwareVulnerabilityScanner.runOnDependencyChain(packages, vulnerability, options, h));
|
|
111556
111535
|
break;
|
|
111557
111536
|
case "MAVEN":
|
|
111558
111537
|
analysisName = "Alucard";
|
|
111559
|
-
result = await JavaCodeAwareVulnerabilityScanner.runOnDependencyChain(packages, vulnerability, options
|
|
111538
|
+
result = await JavaCodeAwareVulnerabilityScanner.runOnDependencyChain(packages, vulnerability, options.timeoutSeconds.allVulnRuns);
|
|
111560
111539
|
break;
|
|
111561
111540
|
case "NUGET":
|
|
111562
111541
|
analysisName = "Cocoa";
|
|
111563
|
-
result = await DotnetCodeAwareVulnerabilityScanner.runOnDependencyChain(packages, vulnerability, options
|
|
111542
|
+
result = await DotnetCodeAwareVulnerabilityScanner.runOnDependencyChain(packages, vulnerability, options.timeoutSeconds.allVulnRuns);
|
|
111564
111543
|
break;
|
|
111565
111544
|
case "PIP":
|
|
111566
111545
|
analysisName = "Mambalade";
|
|
111567
|
-
result = await PythonCodeAwareVulnerabilityScanner.runOnDependencyChain(packages, vulnerability,
|
|
111568
|
-
timeoutInSeconds: options?.timeoutInSeconds ?? 60,
|
|
111569
|
-
memoryLimitInMB: options?.memoryLimitInMB ?? 16384
|
|
111570
|
-
});
|
|
111546
|
+
result = await PythonCodeAwareVulnerabilityScanner.runOnDependencyChain(packages, vulnerability, options);
|
|
111571
111547
|
break;
|
|
111572
111548
|
case "GO":
|
|
111573
111549
|
analysisName = "Goana";
|
|
111574
|
-
result = await GoCodeAwareVulnerabilityScanner.runOnDependencyChain(packages, vulnerability,
|
|
111575
|
-
timeoutInSeconds: options?.timeoutInSeconds ?? 60,
|
|
111576
|
-
memoryLimitInMB: options?.memoryLimitInMB ?? 16384
|
|
111577
|
-
});
|
|
111550
|
+
result = await GoCodeAwareVulnerabilityScanner.runOnDependencyChain(packages, vulnerability, options);
|
|
111578
111551
|
break;
|
|
111579
111552
|
case "RUST":
|
|
111580
111553
|
analysisName = "Rustica";
|
|
111581
|
-
result = await RustCodeAwareVulnerabilityScanner.runOnDependencyChain(packages, vulnerability, options
|
|
111554
|
+
result = await RustCodeAwareVulnerabilityScanner.runOnDependencyChain(packages, vulnerability, options.timeoutSeconds.allVulnRuns);
|
|
111582
111555
|
break;
|
|
111583
111556
|
default:
|
|
111584
111557
|
throw new Error(`Analyze dependency chain not implemented for ${ecosystem}.`);
|
|
@@ -111591,45 +111564,27 @@ async function analyzeAlreadyInstalledPackages(ecosystem, packages, vulnerabilit
|
|
|
111591
111564
|
switch (ecosystem) {
|
|
111592
111565
|
case "NPM":
|
|
111593
111566
|
analysisName = "Jelly";
|
|
111594
|
-
result = await runWithJSHeuristics(async (h) => await JSCodeAwareVulnerabilityScanner.runOnAlreadyDownloadedPackages(packages, vulnerability,
|
|
111595
|
-
timeoutInSeconds: options?.timeoutInSeconds ?? 60,
|
|
111596
|
-
memoryLimitInMB: options?.memoryLimitInMB ?? 16384
|
|
111597
|
-
}, h));
|
|
111567
|
+
result = await runWithJSHeuristics(async (h) => await JSCodeAwareVulnerabilityScanner.runOnAlreadyDownloadedPackages(packages, vulnerability, options, h));
|
|
111598
111568
|
break;
|
|
111599
111569
|
case "MAVEN":
|
|
111600
111570
|
analysisName = "Alucard";
|
|
111601
|
-
result = await JavaCodeAwareVulnerabilityScanner.runOnAlreadyDownloadedPackages(packages, vulnerability,
|
|
111602
|
-
timeoutInSeconds: options?.timeoutInSeconds ?? 60,
|
|
111603
|
-
memoryLimitInMB: options?.memoryLimitInMB ?? 16384
|
|
111604
|
-
});
|
|
111571
|
+
result = await JavaCodeAwareVulnerabilityScanner.runOnAlreadyDownloadedPackages(packages, vulnerability, options);
|
|
111605
111572
|
break;
|
|
111606
111573
|
case "NUGET":
|
|
111607
111574
|
analysisName = "Cocoa";
|
|
111608
|
-
result = await DotnetCodeAwareVulnerabilityScanner.runOnAlreadyDownloadedPackages(packages, vulnerability,
|
|
111609
|
-
timeoutInSeconds: options?.timeoutInSeconds ?? 60,
|
|
111610
|
-
memoryLimitInMB: options?.memoryLimitInMB ?? 16384
|
|
111611
|
-
});
|
|
111575
|
+
result = await DotnetCodeAwareVulnerabilityScanner.runOnAlreadyDownloadedPackages(packages, vulnerability, options);
|
|
111612
111576
|
break;
|
|
111613
111577
|
case "PIP":
|
|
111614
111578
|
analysisName = "Mambalade";
|
|
111615
|
-
result = await PythonCodeAwareVulnerabilityScanner.runOnAlreadyDownloadedPackages(packages, vulnerability,
|
|
111616
|
-
timeoutInSeconds: options?.timeoutInSeconds ?? 60,
|
|
111617
|
-
memoryLimitInMB: options?.memoryLimitInMB ?? 16384
|
|
111618
|
-
});
|
|
111579
|
+
result = await PythonCodeAwareVulnerabilityScanner.runOnAlreadyDownloadedPackages(packages, vulnerability, options);
|
|
111619
111580
|
break;
|
|
111620
111581
|
case "GO":
|
|
111621
111582
|
analysisName = "Goana";
|
|
111622
|
-
result = await GoCodeAwareVulnerabilityScanner.runOnAlreadyDownloadedPackages(packages, vulnerability,
|
|
111623
|
-
timeoutInSeconds: options?.timeoutInSeconds ?? 60,
|
|
111624
|
-
memoryLimitInMB: options?.memoryLimitInMB ?? 16384
|
|
111625
|
-
});
|
|
111583
|
+
result = await GoCodeAwareVulnerabilityScanner.runOnAlreadyDownloadedPackages(packages, vulnerability, options);
|
|
111626
111584
|
break;
|
|
111627
111585
|
case "RUST":
|
|
111628
111586
|
analysisName = "Rustica";
|
|
111629
|
-
result = await RustCodeAwareVulnerabilityScanner.runOnAlreadyDownloadedPackages(packages, vulnerability,
|
|
111630
|
-
timeoutInSeconds: options?.timeoutInSeconds ?? 60,
|
|
111631
|
-
memoryLimitInMB: options?.memoryLimitInMB ?? 16384
|
|
111632
|
-
});
|
|
111587
|
+
result = await RustCodeAwareVulnerabilityScanner.runOnAlreadyDownloadedPackages(packages, vulnerability, options);
|
|
111633
111588
|
break;
|
|
111634
111589
|
default:
|
|
111635
111590
|
throw new Error(`analyzePackageRegistryPackage is not implemented for ${ecosystem}.`);
|
|
@@ -111723,7 +111678,7 @@ var PythonCodeAwareVulnerabilityScanner = class {
|
|
|
111723
111678
|
logger.info("Done setting up virtual environment");
|
|
111724
111679
|
}
|
|
111725
111680
|
}
|
|
111726
|
-
async runAnalysis(vulns, heuristic,
|
|
111681
|
+
async runAnalysis(vulns, heuristic, timeoutInSeconds) {
|
|
111727
111682
|
if (!this.virtualEnvInfo)
|
|
111728
111683
|
throw new Error("Virtual environment not set up");
|
|
111729
111684
|
this.mambaladeVenvPath ??= await setupMambalade();
|
|
@@ -111753,8 +111708,6 @@ var PythonCodeAwareVulnerabilityScanner = class {
|
|
|
111753
111708
|
const vulnsOutputFile = join16(tmpDir, "vulns.json");
|
|
111754
111709
|
const diagnosticsOutputFile = join16(tmpDir, "diagnostics.json");
|
|
111755
111710
|
const reachedPackagesOutputFile = join16(tmpDir, "reached-packages.json");
|
|
111756
|
-
const timeout = reachabilityAnalysisOptions.timeoutInSeconds ?? // 10 minutes for the first analysis, 1 minute for subsequent analyses
|
|
111757
|
-
(analyzesAllVulns ? 60 * 10 : 60);
|
|
111758
111711
|
const pythonExecutable = join16(this.mambaladeVenvPath, "bin", "python");
|
|
111759
111712
|
const mambaladeArgs = cmdt`\
|
|
111760
111713
|
${pythonExecutable} - ${reachabilityAnalysisOptions.memoryLimitInMB ?? 0}
|
|
@@ -111764,7 +111717,7 @@ var PythonCodeAwareVulnerabilityScanner = class {
|
|
|
111764
111717
|
--output-vulnerabilities ${vulnsOutputFile}
|
|
111765
111718
|
--output-diagnostics ${diagnosticsOutputFile}
|
|
111766
111719
|
--output-reached-distributions ${reachedPackagesOutputFile}
|
|
111767
|
-
--timeout=${
|
|
111720
|
+
--timeout=${timeoutInSeconds}
|
|
111768
111721
|
${packagesToExclude?.size ? ["--exclude-distributions", ...packagesToExclude] : []}
|
|
111769
111722
|
--
|
|
111770
111723
|
${filesToAnalyze}`;
|
|
@@ -111782,7 +111735,7 @@ ${vulnAccPaths.join("\n")}`);
|
|
|
111782
111735
|
PYPY_GC_MAX: `${reachabilityAnalysisOptions.memoryLimitInMB ?? 0}MB`
|
|
111783
111736
|
},
|
|
111784
111737
|
// Forcefully kill the process if the internal timeout mechanism fails
|
|
111785
|
-
timeout: (
|
|
111738
|
+
timeout: (timeoutInSeconds * 1.5 + 15) * 1e3
|
|
111786
111739
|
});
|
|
111787
111740
|
logger.debug("Done running mambalade");
|
|
111788
111741
|
const errors = stderr.split("\n").filter((line) => line.startsWith("ERROR:") && !/^ERROR: Excluded distribution/.test(line));
|
|
@@ -111876,7 +111829,7 @@ ${msg}`;
|
|
|
111876
111829
|
await cp6(dep, dependencyDir, { recursive: true });
|
|
111877
111830
|
fileMappings.set(dependencyDir, dep);
|
|
111878
111831
|
}
|
|
111879
|
-
const result = await scanner.runAnalysis([vuln], MambaladeHeuristics.ALL_PACKAGES,
|
|
111832
|
+
const result = await scanner.runAnalysis([vuln], MambaladeHeuristics.ALL_PACKAGES, options.timeoutSeconds.allVulnRuns);
|
|
111880
111833
|
if (result.type === "error")
|
|
111881
111834
|
return { error: result.message, terminatedEarly: true };
|
|
111882
111835
|
return {
|
|
@@ -111916,7 +111869,7 @@ ${msg}`;
|
|
|
111916
111869
|
]);
|
|
111917
111870
|
if (scanner.virtualEnvInfo.packageInstallationStats.failedToInstall.length)
|
|
111918
111871
|
throw new Error("Failed to install some packages");
|
|
111919
|
-
const result = await scanner.runAnalysis([vuln], MambaladeHeuristics.ALL_PACKAGES,
|
|
111872
|
+
const result = await scanner.runAnalysis([vuln], MambaladeHeuristics.ALL_PACKAGES, options.timeoutSeconds.allVulnRuns);
|
|
111920
111873
|
if (result.type === "error")
|
|
111921
111874
|
return { error: result.message, terminatedEarly: true };
|
|
111922
111875
|
return {
|
|
@@ -112510,8 +112463,9 @@ async function analyzeWithHeuristics(state, vulns, heuristicsInOrder, doNotRecom
|
|
|
112510
112463
|
try {
|
|
112511
112464
|
newAnalysisRunListener();
|
|
112512
112465
|
const initialBucketContainingAllVulns = buckets.length === 1 && buckets[0] === bucket;
|
|
112466
|
+
const timeoutInSeconds = initialBucketContainingAllVulns ? state.reachabilityAnalysisOptions.timeoutSeconds.allVulnRuns : state.reachabilityAnalysisOptions.timeoutSeconds.bucketedRuns;
|
|
112513
112467
|
logger.info(`Running full reachability analysis for ${vulnsForBucket.length}/${vulnerabilities.length} vulnerabilities.`);
|
|
112514
|
-
const result = await codeAwareScanner.runAnalysis(vulnsForBucket, bucket.heuristic,
|
|
112468
|
+
const result = await codeAwareScanner.runAnalysis(vulnsForBucket, bucket.heuristic, timeoutInSeconds, experiment);
|
|
112515
112469
|
const allowSplitInBuckets = !disableBucketing && bucket.heuristic.splitAnalysisInBuckets && !state.otherAnalysisOptions.disableBucketing && vulnDepIdentifiers.length > 1 && (result.type === "error" || result.reachedDependencies);
|
|
112516
112470
|
if (result.type === "success") {
|
|
112517
112471
|
result.diagnostics.timings ??= {};
|
|
@@ -112532,13 +112486,7 @@ async function analyzeWithHeuristics(state, vulns, heuristicsInOrder, doNotRecom
|
|
|
112532
112486
|
await analysisMetadataCollector2?.(finalAnalysisMetadata);
|
|
112533
112487
|
} else {
|
|
112534
112488
|
result.type;
|
|
112535
|
-
|
|
112536
|
-
await sendErrorAnalysisMetadata(result.message, !allowSplitInBuckets && isLastHeuristic(bucket.heuristic.name) && !enqueueWithoutSplitting, !allowSplitInBuckets);
|
|
112537
|
-
if (enqueueWithoutSplitting) {
|
|
112538
|
-
logger.info("Analysis failed, retrying different configuration.");
|
|
112539
|
-
enqueueBucket(vulnDepIdentifiers);
|
|
112540
|
-
return;
|
|
112541
|
-
}
|
|
112489
|
+
await sendErrorAnalysisMetadata(result.message, !allowSplitInBuckets && isLastHeuristic(bucket.heuristic.name), !allowSplitInBuckets);
|
|
112542
112490
|
if (!allowSplitInBuckets) {
|
|
112543
112491
|
augmentVulnsWithErrorMessage(vulnsForBucket, result.message);
|
|
112544
112492
|
return;
|
|
@@ -112794,12 +112742,12 @@ var MavenAnalyzer = class {
|
|
|
112794
112742
|
async runPhantomDependencyAnalysis() {
|
|
112795
112743
|
return withTmpDirectory("maven-phantom-dependency-analysis", async (tmpDir) => {
|
|
112796
112744
|
const scanner = this.state.workspaceData.type === "coana" ? await JavaCodeAwareVulnerabilityScanner.initFromDependencyTree(this.state.workspaceData.data.dependencyTree, tmpDir) : await JavaCodeAwareVulnerabilityScanner.initFromSocketArtifacts(this.state.subprojectDir, this.state.workspaceData.data.artifacts, tmpDir);
|
|
112797
|
-
return scanner.runPhantomDependencyAnalysis();
|
|
112745
|
+
return scanner.runPhantomDependencyAnalysis(this.state.reachabilityAnalysisOptions.timeoutSeconds.allVulnRuns);
|
|
112798
112746
|
});
|
|
112799
112747
|
}
|
|
112800
112748
|
async runReachabilityAnalysis(vulns, analysisMetadataCollector, statusUpdater) {
|
|
112801
112749
|
return withTmpDirectory("maven-reachability-analysis", async (tmpDir) => {
|
|
112802
|
-
const scanner = this.state.workspaceData.type === "coana" ? await JavaCodeAwareVulnerabilityScanner.initFromDependencyTree(this.state.workspaceData.data.dependencyTree, tmpDir,
|
|
112750
|
+
const scanner = this.state.workspaceData.type === "coana" ? await JavaCodeAwareVulnerabilityScanner.initFromDependencyTree(this.state.workspaceData.data.dependencyTree, tmpDir, statusUpdater) : await JavaCodeAwareVulnerabilityScanner.initFromSocketArtifacts(this.state.subprojectDir, this.state.workspaceData.data.artifacts, tmpDir, statusUpdater);
|
|
112803
112751
|
const heuristicsInOrder = [AlucardHeuristics.ALL_PACKAGES];
|
|
112804
112752
|
return await analyzeWithHeuristics(this.state, vulns, heuristicsInOrder, false, scanner, analysisMetadataCollector, statusUpdater);
|
|
112805
112753
|
});
|
|
@@ -112854,7 +112802,7 @@ var NpmAnalyzer = class {
|
|
|
112854
112802
|
try {
|
|
112855
112803
|
statusUpdater?.("Running import reachability analysis");
|
|
112856
112804
|
logger.debug("Starting jelly import reachability analysis");
|
|
112857
|
-
reachable = await runJellyImportReachabilityAnalysis(this.state.rootWorkingDir, this.projectDir, this.state.reachabilityAnalysisOptions);
|
|
112805
|
+
reachable = await runJellyImportReachabilityAnalysis(this.state.rootWorkingDir, this.projectDir, vulns, this.state.reachabilityAnalysisOptions);
|
|
112858
112806
|
} catch (e) {
|
|
112859
112807
|
logger.debug("Error while running jelly import reachability analysis:", e);
|
|
112860
112808
|
}
|
|
@@ -112932,12 +112880,12 @@ var NugetAnalyzer = class {
|
|
|
112932
112880
|
async runPhantomDependencyAnalysis() {
|
|
112933
112881
|
return withTmpDirectory("nuget-phantom-dependency-analysis", async (tmpDir) => {
|
|
112934
112882
|
const scanner = this.state.workspaceData.type === "coana" ? DotnetCodeAwareVulnerabilityScanner.initFromDependencyTree(this.state.workspaceData.data.dependencyTree) : await DotnetCodeAwareVulnerabilityScanner.initFromSocketArtifacts(this.state.subprojectDir, this.state.workspaceData.data.manifestFiles, this.state.workspaceData.data.artifacts, tmpDir);
|
|
112935
|
-
return scanner.runPhantomDependencyAnalysis();
|
|
112883
|
+
return scanner.runPhantomDependencyAnalysis(this.state.reachabilityAnalysisOptions.timeoutSeconds.allVulnRuns);
|
|
112936
112884
|
});
|
|
112937
112885
|
}
|
|
112938
112886
|
async runReachabilityAnalysis(vulns, analysisMetadataCollector, statusUpdater) {
|
|
112939
112887
|
return withTmpDirectory("nuget-reachability-analysis", async (tmpDir) => {
|
|
112940
|
-
const scanner = this.state.workspaceData.type === "coana" ? DotnetCodeAwareVulnerabilityScanner.initFromDependencyTree(this.state.workspaceData.data.dependencyTree,
|
|
112888
|
+
const scanner = this.state.workspaceData.type === "coana" ? DotnetCodeAwareVulnerabilityScanner.initFromDependencyTree(this.state.workspaceData.data.dependencyTree, statusUpdater) : await DotnetCodeAwareVulnerabilityScanner.initFromSocketArtifacts(this.state.subprojectDir, this.state.workspaceData.data.manifestFiles, this.state.workspaceData.data.artifacts, tmpDir, statusUpdater);
|
|
112941
112889
|
const heuristicsInOrder = [CocoaHeuristics.ALL_PACKAGES];
|
|
112942
112890
|
return await analyzeWithHeuristics(this.state, vulns, heuristicsInOrder, false, scanner, analysisMetadataCollector, statusUpdater);
|
|
112943
112891
|
});
|
|
@@ -116307,7 +116255,7 @@ var RubyCodeAwareVulnerabilityScanner = class {
|
|
|
116307
116255
|
this.vendorDirWasCreated = true;
|
|
116308
116256
|
logger.info("Done setting up vendor directory");
|
|
116309
116257
|
}
|
|
116310
|
-
async runAnalysis(vulns, heuristic,
|
|
116258
|
+
async runAnalysis(vulns, heuristic, timeoutInSeconds, _experiment) {
|
|
116311
116259
|
return await withTmpDirectory("ruby-analyzer-output", async (tmpDir) => {
|
|
116312
116260
|
if (!this.vendorDir)
|
|
116313
116261
|
throw new Error("Assertion error: The vendor directory is not correctly initialized");
|
|
@@ -116334,7 +116282,7 @@ var RubyCodeAwareVulnerabilityScanner = class {
|
|
|
116334
116282
|
const cmd = cmdt`
|
|
116335
116283
|
${await getNodeExecutable(ToolPathResolver.nodeExecutablePath)} --max-old-space-size=${this.options.memoryLimitInMB}
|
|
116336
116284
|
${analyzerPath}
|
|
116337
|
-
--timeout ${
|
|
116285
|
+
--timeout ${timeoutInSeconds}
|
|
116338
116286
|
--load-path ${loadPaths}
|
|
116339
116287
|
--vulnerabilities ${vulnAccPaths}
|
|
116340
116288
|
--output-diagnostics ${diagnosticsOutputFile}
|
|
@@ -116533,12 +116481,12 @@ var RustAnalyzer = class {
|
|
|
116533
116481
|
async runPhantomDependencyAnalysis() {
|
|
116534
116482
|
return withTmpDirectory("cargo-phantom-dependency-analysis", async (tmpDir) => {
|
|
116535
116483
|
const scanner = this.state.workspaceData.type === "coana" ? RustCodeAwareVulnerabilityScanner.initFromDependencyTree(this.state.workspaceData.data.dependencyTree) : await RustCodeAwareVulnerabilityScanner.initFromSocketArtifacts(this.state.subprojectDir, this.state.workspacePath, this.state.workspaceData.data.artifacts, tmpDir);
|
|
116536
|
-
return scanner.runPhantomDependencyAnalysis();
|
|
116484
|
+
return scanner.runPhantomDependencyAnalysis(this.state.reachabilityAnalysisOptions.timeoutSeconds.allVulnRuns);
|
|
116537
116485
|
});
|
|
116538
116486
|
}
|
|
116539
116487
|
async runReachabilityAnalysis(vulns, analysisMetadataCollector, statusUpdater) {
|
|
116540
116488
|
return withTmpDirectory("cargo-reachability-analysis", async (tmpDir) => {
|
|
116541
|
-
const scanner = this.state.workspaceData.type === "coana" ? RustCodeAwareVulnerabilityScanner.initFromDependencyTree(this.state.workspaceData.data.dependencyTree,
|
|
116489
|
+
const scanner = this.state.workspaceData.type === "coana" ? RustCodeAwareVulnerabilityScanner.initFromDependencyTree(this.state.workspaceData.data.dependencyTree, statusUpdater) : await RustCodeAwareVulnerabilityScanner.initFromSocketArtifacts(this.state.subprojectDir, this.state.workspacePath, this.state.workspaceData.data.artifacts, tmpDir, statusUpdater);
|
|
116542
116490
|
const heuristicsInOrder = [RusticaHeuristics.ALL_PACKAGES];
|
|
116543
116491
|
return await analyzeWithHeuristics(this.state, vulns, heuristicsInOrder, false, scanner, analysisMetadataCollector, statusUpdater);
|
|
116544
116492
|
});
|
|
@@ -116597,7 +116545,11 @@ var runReachabilityAnalysisCmd = new Command().name("runReachabilityAnalysis").a
|
|
|
116597
116545
|
}, "reachability-analyzer"));
|
|
116598
116546
|
var runOnDependencyChainCmd = new Command().name("runOnDependencyChain").option("-d, --debug", "Enable debug logging", false).option("-s, --silent", "Silence all debug/warning output", false).option("--coana-socket-path <socketPath>", "Coana socket path").option("--silent-spinner", "Silence spinner", "CI" in process.env || !process.stdin.isTTY).requiredOption("-i, --input-file <inputFile>", "Input file for data and vulnerabilities").requiredOption("-o, --output-file <outputFile>", "Output file for the results").configureHelp({ sortSubcommands: true, sortOptions: true }).action(async (options) => withLoggerAndSpinner("Coana Reachability Analyzers", options, async () => {
|
|
116599
116547
|
const { ecosystem, dependencyChain, vulnerability } = JSON.parse(await readFile14(options.inputFile, "utf-8"));
|
|
116600
|
-
const
|
|
116548
|
+
const defaultOptions2 = {
|
|
116549
|
+
timeoutSeconds: { allVulnRuns: 60, bucketedRuns: 60 },
|
|
116550
|
+
memoryLimitInMB: 16384
|
|
116551
|
+
};
|
|
116552
|
+
const result = await analyzePackages(ecosystem, deserializeDependencyChain(ecosystem, dependencyChain), vulnerability, defaultOptions2);
|
|
116601
116553
|
if (options.outputFile) {
|
|
116602
116554
|
logger.debug("Writing result to file", options.outputFile);
|
|
116603
116555
|
await writeFile9(options.outputFile, JSON.stringify({ result }));
|
|
@@ -116625,7 +116577,12 @@ var runOnPackageRegistryPackageCmd = new Command().name("runOnPackageRegistryPac
|
|
|
116625
116577
|
else if (typeof vulnerability.vulnerabilityAccessPaths === "string")
|
|
116626
116578
|
throw new Error(`Vulnerability ${options.vulnerability} has undeterminable reachability, so running the reachability analysis is not possible.`);
|
|
116627
116579
|
const isFile4 = mainPackage.startsWith("file://");
|
|
116628
|
-
const
|
|
116580
|
+
const analysisTimeout = +options.analysisTimeout;
|
|
116581
|
+
const reachabilityOptions = {
|
|
116582
|
+
timeoutSeconds: { allVulnRuns: analysisTimeout, bucketedRuns: analysisTimeout },
|
|
116583
|
+
memoryLimitInMB: +options.memoryLimit
|
|
116584
|
+
};
|
|
116585
|
+
const result = isFile4 ? await analyzeAlreadyInstalledPackages(options.ecosystem, [mainPackage, ...options.dependencies].map((p) => p.replace("file://", "")), vulnerability, reachabilityOptions) : await analyzePackages(options.ecosystem, deserializeDependencyChain(options.ecosystem, `${mainPackage}${options.dependencies.length > 0 ? ` > ${options.dependencies.join(" > ")}` : ""}`), vulnerability, reachabilityOptions);
|
|
116629
116586
|
if (options.outputFile) {
|
|
116630
116587
|
logger.info("Writing result to file", options.outputFile);
|
|
116631
116588
|
await writeFile9(options.outputFile, JSON.stringify(result, null, 2));
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -7,11 +7,11 @@ import "./iterator-helpers-polyfill.js";
|
|
|
7
7
|
import {
|
|
8
8
|
require_hints,
|
|
9
9
|
require_parser
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-PAV2YSLW.js";
|
|
11
11
|
import {
|
|
12
12
|
require_proxy,
|
|
13
13
|
require_sandbox
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-XJM6ACML.js";
|
|
15
15
|
import {
|
|
16
16
|
__commonJS,
|
|
17
17
|
__name,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
require_options,
|
|
22
22
|
require_transform,
|
|
23
23
|
require_util
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-VDHMBLB5.js";
|
|
25
25
|
|
|
26
26
|
// lib/approx/approx.js
|
|
27
27
|
var require_approx = __commonJS({
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
__require,
|
|
11
11
|
require_logger,
|
|
12
12
|
require_options
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-VDHMBLB5.js";
|
|
14
14
|
|
|
15
15
|
// node_modules/source-map/lib/base64.js
|
|
16
16
|
var require_base64 = __commonJS({
|
|
@@ -224314,4 +224314,4 @@ typescript/lib/typescript.js:
|
|
|
224314
224314
|
and limitations under the License.
|
|
224315
224315
|
***************************************************************************** *)
|
|
224316
224316
|
*/
|
|
224317
|
-
//# sourceMappingURL=chunk-
|
|
224317
|
+
//# sourceMappingURL=chunk-AO2BBATE.js.map
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
require_options,
|
|
15
15
|
require_tokens,
|
|
16
16
|
require_util
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-VDHMBLB5.js";
|
|
18
18
|
|
|
19
19
|
// lib/parsing/parser.js
|
|
20
20
|
var require_parser = __commonJS({
|
|
@@ -516,4 +516,4 @@ export {
|
|
|
516
516
|
require_patching,
|
|
517
517
|
require_hints
|
|
518
518
|
};
|
|
519
|
-
//# sourceMappingURL=chunk-
|
|
519
|
+
//# sourceMappingURL=chunk-PAV2YSLW.js.map
|
|
@@ -10924,6 +10924,16 @@ var require_logger2 = __commonJS({
|
|
|
10924
10924
|
exports.default = logger;
|
|
10925
10925
|
function setLogLevel(level) {
|
|
10926
10926
|
logger.level = options_1.options.loglevel = level;
|
|
10927
|
+
for (const lvl of Object.keys(colors)) {
|
|
10928
|
+
const fnName = `is${lvl.charAt(0).toUpperCase() + lvl.slice(1)}Enabled`;
|
|
10929
|
+
delete logger[fnName];
|
|
10930
|
+
Object.defineProperty(logger, fnName, {
|
|
10931
|
+
value: logger.isLevelEnabled(lvl) ? () => true : () => false,
|
|
10932
|
+
writable: false,
|
|
10933
|
+
configurable: true,
|
|
10934
|
+
enumerable: false
|
|
10935
|
+
});
|
|
10936
|
+
}
|
|
10927
10937
|
}
|
|
10928
10938
|
__name(setLogLevel, "setLogLevel");
|
|
10929
10939
|
function logToFile(file) {
|
|
@@ -19701,4 +19711,4 @@ fill-range/index.js:
|
|
|
19701
19711
|
* Licensed under the MIT License.
|
|
19702
19712
|
*)
|
|
19703
19713
|
*/
|
|
19704
|
-
//# sourceMappingURL=chunk-
|
|
19714
|
+
//# sourceMappingURL=chunk-VDHMBLB5.js.map
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
__name,
|
|
10
10
|
__require,
|
|
11
11
|
require_transform
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-VDHMBLB5.js";
|
|
13
13
|
|
|
14
14
|
// lib/approx/proxy.js
|
|
15
15
|
var require_proxy = __commonJS({
|
|
@@ -268,4 +268,4 @@ export {
|
|
|
268
268
|
require_proxy,
|
|
269
269
|
require_sandbox
|
|
270
270
|
};
|
|
271
|
-
//# sourceMappingURL=chunk-
|
|
271
|
+
//# sourceMappingURL=chunk-XJM6ACML.js.map
|
|
@@ -6,10 +6,10 @@ import "./iterator-helpers-polyfill.js";
|
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
require_moduleresolver
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-AO2BBATE.js";
|
|
10
10
|
import {
|
|
11
11
|
require_sandbox
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-XJM6ACML.js";
|
|
13
13
|
import {
|
|
14
14
|
__commonJS,
|
|
15
15
|
__name,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
require_files,
|
|
18
18
|
require_options,
|
|
19
19
|
require_transform
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-VDHMBLB5.js";
|
|
21
21
|
|
|
22
22
|
// lib/approx/hooks.js
|
|
23
23
|
var require_hooks = __commonJS({
|
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
require_hints,
|
|
10
10
|
require_parser,
|
|
11
11
|
require_patching
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-PAV2YSLW.js";
|
|
13
13
|
import {
|
|
14
14
|
require_moduleresolver,
|
|
15
15
|
require_typescript
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-AO2BBATE.js";
|
|
17
17
|
import {
|
|
18
18
|
__commonJS,
|
|
19
19
|
__name,
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
require_tokens,
|
|
38
38
|
require_transform,
|
|
39
39
|
require_util
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-VDHMBLB5.js";
|
|
41
41
|
|
|
42
42
|
// lib/misc/timer.js
|
|
43
43
|
var require_timer = __commonJS({
|
|
@@ -4367,6 +4367,8 @@ var require_analyzer = __commonJS({
|
|
|
4367
4367
|
}
|
|
4368
4368
|
if (options_1.options.modulesOnly) {
|
|
4369
4369
|
(0, modulefinder_1.findModules)(ast, solver.fragmentState, moduleInfo);
|
|
4370
|
+
if (d.modules % 16 === 0)
|
|
4371
|
+
a.timeoutTimer.checkTimeout();
|
|
4370
4372
|
} else {
|
|
4371
4373
|
const moduleParams = (0, extras_1.preprocessAst)(ast, moduleInfo);
|
|
4372
4374
|
(0, logger_1.writeStdOutIfActive)("Initializing...");
|