@coana-tech/cli 14.12.145 → 14.12.148
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 +619 -4978
- package/package.json +1 -1
- package/reachability-analyzers-cli.mjs +374 -240
- 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/jelly.js +90 -2
|
@@ -4287,7 +4287,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
4287
4287
|
return circularValue;
|
|
4288
4288
|
}
|
|
4289
4289
|
let res = "";
|
|
4290
|
-
let
|
|
4290
|
+
let join19 = ",";
|
|
4291
4291
|
const originalIndentation = indentation;
|
|
4292
4292
|
if (Array.isArray(value2)) {
|
|
4293
4293
|
if (value2.length === 0) {
|
|
@@ -4301,7 +4301,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
4301
4301
|
indentation += spacer;
|
|
4302
4302
|
res += `
|
|
4303
4303
|
${indentation}`;
|
|
4304
|
-
|
|
4304
|
+
join19 = `,
|
|
4305
4305
|
${indentation}`;
|
|
4306
4306
|
}
|
|
4307
4307
|
const maximumValuesToStringify = Math.min(value2.length, maximumBreadth);
|
|
@@ -4309,13 +4309,13 @@ ${indentation}`;
|
|
|
4309
4309
|
for (; i4 < maximumValuesToStringify - 1; i4++) {
|
|
4310
4310
|
const tmp2 = stringifyFnReplacer(String(i4), value2, stack, replacer, spacer, indentation);
|
|
4311
4311
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
4312
|
-
res +=
|
|
4312
|
+
res += join19;
|
|
4313
4313
|
}
|
|
4314
4314
|
const tmp = stringifyFnReplacer(String(i4), value2, stack, replacer, spacer, indentation);
|
|
4315
4315
|
res += tmp !== void 0 ? tmp : "null";
|
|
4316
4316
|
if (value2.length - 1 > maximumBreadth) {
|
|
4317
4317
|
const removedKeys = value2.length - maximumBreadth - 1;
|
|
4318
|
-
res += `${
|
|
4318
|
+
res += `${join19}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
4319
4319
|
}
|
|
4320
4320
|
if (spacer !== "") {
|
|
4321
4321
|
res += `
|
|
@@ -4336,7 +4336,7 @@ ${originalIndentation}`;
|
|
|
4336
4336
|
let separator = "";
|
|
4337
4337
|
if (spacer !== "") {
|
|
4338
4338
|
indentation += spacer;
|
|
4339
|
-
|
|
4339
|
+
join19 = `,
|
|
4340
4340
|
${indentation}`;
|
|
4341
4341
|
whitespace2 = " ";
|
|
4342
4342
|
}
|
|
@@ -4350,13 +4350,13 @@ ${indentation}`;
|
|
|
4350
4350
|
const tmp = stringifyFnReplacer(key2, value2, stack, replacer, spacer, indentation);
|
|
4351
4351
|
if (tmp !== void 0) {
|
|
4352
4352
|
res += `${separator}${strEscape(key2)}:${whitespace2}${tmp}`;
|
|
4353
|
-
separator =
|
|
4353
|
+
separator = join19;
|
|
4354
4354
|
}
|
|
4355
4355
|
}
|
|
4356
4356
|
if (keyLength > maximumBreadth) {
|
|
4357
4357
|
const removedKeys = keyLength - maximumBreadth;
|
|
4358
4358
|
res += `${separator}"...":${whitespace2}"${getItemCount(removedKeys)} not stringified"`;
|
|
4359
|
-
separator =
|
|
4359
|
+
separator = join19;
|
|
4360
4360
|
}
|
|
4361
4361
|
if (spacer !== "" && separator.length > 1) {
|
|
4362
4362
|
res = `
|
|
@@ -4397,7 +4397,7 @@ ${originalIndentation}`;
|
|
|
4397
4397
|
}
|
|
4398
4398
|
const originalIndentation = indentation;
|
|
4399
4399
|
let res = "";
|
|
4400
|
-
let
|
|
4400
|
+
let join19 = ",";
|
|
4401
4401
|
if (Array.isArray(value2)) {
|
|
4402
4402
|
if (value2.length === 0) {
|
|
4403
4403
|
return "[]";
|
|
@@ -4410,7 +4410,7 @@ ${originalIndentation}`;
|
|
|
4410
4410
|
indentation += spacer;
|
|
4411
4411
|
res += `
|
|
4412
4412
|
${indentation}`;
|
|
4413
|
-
|
|
4413
|
+
join19 = `,
|
|
4414
4414
|
${indentation}`;
|
|
4415
4415
|
}
|
|
4416
4416
|
const maximumValuesToStringify = Math.min(value2.length, maximumBreadth);
|
|
@@ -4418,13 +4418,13 @@ ${indentation}`;
|
|
|
4418
4418
|
for (; i4 < maximumValuesToStringify - 1; i4++) {
|
|
4419
4419
|
const tmp2 = stringifyArrayReplacer(String(i4), value2[i4], stack, replacer, spacer, indentation);
|
|
4420
4420
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
4421
|
-
res +=
|
|
4421
|
+
res += join19;
|
|
4422
4422
|
}
|
|
4423
4423
|
const tmp = stringifyArrayReplacer(String(i4), value2[i4], stack, replacer, spacer, indentation);
|
|
4424
4424
|
res += tmp !== void 0 ? tmp : "null";
|
|
4425
4425
|
if (value2.length - 1 > maximumBreadth) {
|
|
4426
4426
|
const removedKeys = value2.length - maximumBreadth - 1;
|
|
4427
|
-
res += `${
|
|
4427
|
+
res += `${join19}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
4428
4428
|
}
|
|
4429
4429
|
if (spacer !== "") {
|
|
4430
4430
|
res += `
|
|
@@ -4437,7 +4437,7 @@ ${originalIndentation}`;
|
|
|
4437
4437
|
let whitespace2 = "";
|
|
4438
4438
|
if (spacer !== "") {
|
|
4439
4439
|
indentation += spacer;
|
|
4440
|
-
|
|
4440
|
+
join19 = `,
|
|
4441
4441
|
${indentation}`;
|
|
4442
4442
|
whitespace2 = " ";
|
|
4443
4443
|
}
|
|
@@ -4446,7 +4446,7 @@ ${indentation}`;
|
|
|
4446
4446
|
const tmp = stringifyArrayReplacer(key2, value2[key2], stack, replacer, spacer, indentation);
|
|
4447
4447
|
if (tmp !== void 0) {
|
|
4448
4448
|
res += `${separator}${strEscape(key2)}:${whitespace2}${tmp}`;
|
|
4449
|
-
separator =
|
|
4449
|
+
separator = join19;
|
|
4450
4450
|
}
|
|
4451
4451
|
}
|
|
4452
4452
|
if (spacer !== "" && separator.length > 1) {
|
|
@@ -4504,20 +4504,20 @@ ${originalIndentation}`;
|
|
|
4504
4504
|
indentation += spacer;
|
|
4505
4505
|
let res2 = `
|
|
4506
4506
|
${indentation}`;
|
|
4507
|
-
const
|
|
4507
|
+
const join20 = `,
|
|
4508
4508
|
${indentation}`;
|
|
4509
4509
|
const maximumValuesToStringify = Math.min(value2.length, maximumBreadth);
|
|
4510
4510
|
let i4 = 0;
|
|
4511
4511
|
for (; i4 < maximumValuesToStringify - 1; i4++) {
|
|
4512
4512
|
const tmp2 = stringifyIndent(String(i4), value2[i4], stack, spacer, indentation);
|
|
4513
4513
|
res2 += tmp2 !== void 0 ? tmp2 : "null";
|
|
4514
|
-
res2 +=
|
|
4514
|
+
res2 += join20;
|
|
4515
4515
|
}
|
|
4516
4516
|
const tmp = stringifyIndent(String(i4), value2[i4], stack, spacer, indentation);
|
|
4517
4517
|
res2 += tmp !== void 0 ? tmp : "null";
|
|
4518
4518
|
if (value2.length - 1 > maximumBreadth) {
|
|
4519
4519
|
const removedKeys = value2.length - maximumBreadth - 1;
|
|
4520
|
-
res2 += `${
|
|
4520
|
+
res2 += `${join20}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
4521
4521
|
}
|
|
4522
4522
|
res2 += `
|
|
4523
4523
|
${originalIndentation}`;
|
|
@@ -4533,16 +4533,16 @@ ${originalIndentation}`;
|
|
|
4533
4533
|
return '"[Object]"';
|
|
4534
4534
|
}
|
|
4535
4535
|
indentation += spacer;
|
|
4536
|
-
const
|
|
4536
|
+
const join19 = `,
|
|
4537
4537
|
${indentation}`;
|
|
4538
4538
|
let res = "";
|
|
4539
4539
|
let separator = "";
|
|
4540
4540
|
let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
|
|
4541
4541
|
if (isTypedArrayWithEntries(value2)) {
|
|
4542
|
-
res += stringifyTypedArray(value2,
|
|
4542
|
+
res += stringifyTypedArray(value2, join19, maximumBreadth);
|
|
4543
4543
|
keys = keys.slice(value2.length);
|
|
4544
4544
|
maximumPropertiesToStringify -= value2.length;
|
|
4545
|
-
separator =
|
|
4545
|
+
separator = join19;
|
|
4546
4546
|
}
|
|
4547
4547
|
if (deterministic) {
|
|
4548
4548
|
keys = insertSort(keys);
|
|
@@ -4553,13 +4553,13 @@ ${indentation}`;
|
|
|
4553
4553
|
const tmp = stringifyIndent(key2, value2[key2], stack, spacer, indentation);
|
|
4554
4554
|
if (tmp !== void 0) {
|
|
4555
4555
|
res += `${separator}${strEscape(key2)}: ${tmp}`;
|
|
4556
|
-
separator =
|
|
4556
|
+
separator = join19;
|
|
4557
4557
|
}
|
|
4558
4558
|
}
|
|
4559
4559
|
if (keyLength > maximumBreadth) {
|
|
4560
4560
|
const removedKeys = keyLength - maximumBreadth;
|
|
4561
4561
|
res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
|
|
4562
|
-
separator =
|
|
4562
|
+
separator = join19;
|
|
4563
4563
|
}
|
|
4564
4564
|
if (separator !== "") {
|
|
4565
4565
|
res = `
|
|
@@ -6126,7 +6126,7 @@ var require_buffer_list = __commonJS({
|
|
|
6126
6126
|
}
|
|
6127
6127
|
}, {
|
|
6128
6128
|
key: "join",
|
|
6129
|
-
value: function
|
|
6129
|
+
value: function join19(s2) {
|
|
6130
6130
|
if (this.length === 0) return "";
|
|
6131
6131
|
var p = this.head;
|
|
6132
6132
|
var ret = "" + p.data;
|
|
@@ -17210,7 +17210,7 @@ var require_lodash = __commonJS({
|
|
|
17210
17210
|
}
|
|
17211
17211
|
return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, undefined2, comparator) : [];
|
|
17212
17212
|
});
|
|
17213
|
-
function
|
|
17213
|
+
function join19(array, separator) {
|
|
17214
17214
|
return array == null ? "" : nativeJoin.call(array, separator);
|
|
17215
17215
|
}
|
|
17216
17216
|
function last2(array) {
|
|
@@ -19129,7 +19129,7 @@ var require_lodash = __commonJS({
|
|
|
19129
19129
|
lodash23.isUndefined = isUndefined2;
|
|
19130
19130
|
lodash23.isWeakMap = isWeakMap;
|
|
19131
19131
|
lodash23.isWeakSet = isWeakSet;
|
|
19132
|
-
lodash23.join =
|
|
19132
|
+
lodash23.join = join19;
|
|
19133
19133
|
lodash23.kebabCase = kebabCase;
|
|
19134
19134
|
lodash23.last = last2;
|
|
19135
19135
|
lodash23.lastIndexOf = lastIndexOf;
|
|
@@ -54200,7 +54200,7 @@ var require_summary = __commonJS({
|
|
|
54200
54200
|
exports.summary = exports.markdownSummary = exports.SUMMARY_DOCS_URL = exports.SUMMARY_ENV_VAR = void 0;
|
|
54201
54201
|
var os_1 = __require("os");
|
|
54202
54202
|
var fs_1 = __require("fs");
|
|
54203
|
-
var { access: access3, appendFile, writeFile:
|
|
54203
|
+
var { access: access3, appendFile, writeFile: writeFile11 } = fs_1.promises;
|
|
54204
54204
|
exports.SUMMARY_ENV_VAR = "GITHUB_STEP_SUMMARY";
|
|
54205
54205
|
exports.SUMMARY_DOCS_URL = "https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary";
|
|
54206
54206
|
var Summary = class {
|
|
@@ -54258,7 +54258,7 @@ var require_summary = __commonJS({
|
|
|
54258
54258
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54259
54259
|
const overwrite = !!(options === null || options === void 0 ? void 0 : options.overwrite);
|
|
54260
54260
|
const filePath = yield this.filePath();
|
|
54261
|
-
const writeFunc = overwrite ?
|
|
54261
|
+
const writeFunc = overwrite ? writeFile11 : appendFile;
|
|
54262
54262
|
yield writeFunc(filePath, this._buffer, { encoding: "utf8" });
|
|
54263
54263
|
return this.emptyBuffer();
|
|
54264
54264
|
});
|
|
@@ -72767,8 +72767,8 @@ var require_adm_zip = __commonJS({
|
|
|
72767
72767
|
return null;
|
|
72768
72768
|
}
|
|
72769
72769
|
function fixPath(zipPath) {
|
|
72770
|
-
const { join:
|
|
72771
|
-
return
|
|
72770
|
+
const { join: join19, normalize: normalize3, sep: sep6 } = pth.posix;
|
|
72771
|
+
return join19(".", normalize3(sep6 + zipPath.split("\\").join(sep6) + sep6));
|
|
72772
72772
|
}
|
|
72773
72773
|
function filenameFilter(filterfn) {
|
|
72774
72774
|
if (filterfn instanceof RegExp) {
|
|
@@ -75394,7 +75394,7 @@ var {
|
|
|
75394
75394
|
} = import_index.default;
|
|
75395
75395
|
|
|
75396
75396
|
// dist/reachability-analyzers-cli.js
|
|
75397
|
-
import { readFile as readFile14, writeFile as
|
|
75397
|
+
import { readFile as readFile14, writeFile as writeFile10 } from "fs/promises";
|
|
75398
75398
|
|
|
75399
75399
|
// ../web-compat-utils/src/logger-singleton.ts
|
|
75400
75400
|
var import_winston = __toESM(require_winston(), 1);
|
|
@@ -80667,6 +80667,18 @@ async function sendTelemetrySocket(analysisMetadataId, telemetry) {
|
|
|
80667
80667
|
console.warn("Failed to send telemetry to Socket:", error.message);
|
|
80668
80668
|
}
|
|
80669
80669
|
}
|
|
80670
|
+
async function sendAnalyzerTelemetrySocket(analysisMetadataId, telemetry) {
|
|
80671
|
+
try {
|
|
80672
|
+
const url2 = getSocketApiUrl("tier1-reachability-scan/add-analyzer-telemetry");
|
|
80673
|
+
const data2 = {
|
|
80674
|
+
analysis_metadata_id: analysisMetadataId,
|
|
80675
|
+
telemetry
|
|
80676
|
+
};
|
|
80677
|
+
await axios2.post(url2, data2, { headers: getAuthHeaders() });
|
|
80678
|
+
} catch (error) {
|
|
80679
|
+
console.warn("Failed to send analyzer telemetry to Socket:", error.message);
|
|
80680
|
+
}
|
|
80681
|
+
}
|
|
80670
80682
|
async function registerDiagnosticsToAnalysisMetadataSocket(analysisMetadataId, diagnosticsData) {
|
|
80671
80683
|
const abnormalExit = diagnosticsData.analysisDiagnostics.aborted ? "ABORTED" : diagnosticsData.analysisDiagnostics.timeout ? "TIMEOUT" : "NONE";
|
|
80672
80684
|
try {
|
|
@@ -80698,6 +80710,7 @@ function getSocketAPI() {
|
|
|
80698
80710
|
sendLogChunkSocket,
|
|
80699
80711
|
createAnalysisMetadataSocket,
|
|
80700
80712
|
sendTelemetrySocket,
|
|
80713
|
+
sendAnalyzerTelemetrySocket,
|
|
80701
80714
|
registerDiagnosticsToAnalysisMetadataSocket
|
|
80702
80715
|
};
|
|
80703
80716
|
}
|
|
@@ -80840,6 +80853,14 @@ var DashboardAPI = class {
|
|
|
80840
80853
|
await this.socketAPI.sendTelemetrySocket(analysisMetadataId, telemetry);
|
|
80841
80854
|
}
|
|
80842
80855
|
}
|
|
80856
|
+
async sendAnalyzerTelemetry(analysisMetadataId, telemetry) {
|
|
80857
|
+
if (this.disableAnalyticsSharing) {
|
|
80858
|
+
return;
|
|
80859
|
+
}
|
|
80860
|
+
if (this.socketMode) {
|
|
80861
|
+
await this.socketAPI.sendAnalyzerTelemetrySocket(analysisMetadataId, telemetry);
|
|
80862
|
+
}
|
|
80863
|
+
}
|
|
80843
80864
|
async registerDiagnosticsToAnalysisMetadata(analysisMetadataId, diagnosticsData) {
|
|
80844
80865
|
if (this.disableAnalyticsSharing || !analysisMetadataId) {
|
|
80845
80866
|
return;
|
|
@@ -80871,7 +80892,7 @@ function createWorkspaceWarning(type) {
|
|
|
80871
80892
|
|
|
80872
80893
|
// ../utils/src/go-utils.ts
|
|
80873
80894
|
import { constants, copyFile, cp as cp2, mkdtemp } from "fs/promises";
|
|
80874
|
-
import { join as
|
|
80895
|
+
import { join as join4 } from "path";
|
|
80875
80896
|
|
|
80876
80897
|
// ../utils/src/command-utils.ts
|
|
80877
80898
|
import assert from "assert";
|
|
@@ -80936,6 +80957,71 @@ var TelemetryCollector = class {
|
|
|
80936
80957
|
}
|
|
80937
80958
|
};
|
|
80938
80959
|
|
|
80960
|
+
// ../utils/src/telemetry/analyzer-telemetry-server.ts
|
|
80961
|
+
import { existsSync, readFileSync, watchFile, unwatchFile } from "fs";
|
|
80962
|
+
import { unlink, writeFile as writeFile2 } from "fs/promises";
|
|
80963
|
+
import { tmpdir } from "os";
|
|
80964
|
+
import { join as join2 } from "path";
|
|
80965
|
+
import { randomBytes } from "crypto";
|
|
80966
|
+
var AnalyzerTelemetryServer = class {
|
|
80967
|
+
constructor(handler) {
|
|
80968
|
+
this.handler = handler;
|
|
80969
|
+
const fileId = randomBytes(8).toString("hex");
|
|
80970
|
+
this.filePath = join2(tmpdir(), `analyzer-telemetry-${fileId}.jsonl`);
|
|
80971
|
+
}
|
|
80972
|
+
filePath;
|
|
80973
|
+
lastReadPosition = 0;
|
|
80974
|
+
watching = false;
|
|
80975
|
+
/**
|
|
80976
|
+
* Starts the server and returns the file path that analyzers should write to.
|
|
80977
|
+
*/
|
|
80978
|
+
async start() {
|
|
80979
|
+
await writeFile2(this.filePath, "");
|
|
80980
|
+
this.watching = true;
|
|
80981
|
+
watchFile(this.filePath, { interval: 1e3 }, () => {
|
|
80982
|
+
this.processNewEvents();
|
|
80983
|
+
});
|
|
80984
|
+
return this.filePath;
|
|
80985
|
+
}
|
|
80986
|
+
processNewEvents() {
|
|
80987
|
+
if (!existsSync(this.filePath)) return;
|
|
80988
|
+
try {
|
|
80989
|
+
const content = readFileSync(this.filePath, "utf-8");
|
|
80990
|
+
const newContent = content.substring(this.lastReadPosition);
|
|
80991
|
+
this.lastReadPosition = content.length;
|
|
80992
|
+
if (!newContent) return;
|
|
80993
|
+
const lines = newContent.split("\n");
|
|
80994
|
+
for (const line of lines) {
|
|
80995
|
+
if (line.trim()) {
|
|
80996
|
+
try {
|
|
80997
|
+
const event = JSON.parse(line);
|
|
80998
|
+
this.handler.onAnalyzerEvent(event);
|
|
80999
|
+
} catch {
|
|
81000
|
+
}
|
|
81001
|
+
}
|
|
81002
|
+
}
|
|
81003
|
+
} catch {
|
|
81004
|
+
}
|
|
81005
|
+
}
|
|
81006
|
+
/**
|
|
81007
|
+
* Closes the server and cleans up the file.
|
|
81008
|
+
*/
|
|
81009
|
+
async close() {
|
|
81010
|
+
this.processNewEvents();
|
|
81011
|
+
this.handler.close?.();
|
|
81012
|
+
if (this.watching) {
|
|
81013
|
+
unwatchFile(this.filePath);
|
|
81014
|
+
this.watching = false;
|
|
81015
|
+
}
|
|
81016
|
+
if (existsSync(this.filePath)) {
|
|
81017
|
+
try {
|
|
81018
|
+
await unlink(this.filePath);
|
|
81019
|
+
} catch {
|
|
81020
|
+
}
|
|
81021
|
+
}
|
|
81022
|
+
}
|
|
81023
|
+
};
|
|
81024
|
+
|
|
80939
81025
|
// ../utils/src/command-utils.ts
|
|
80940
81026
|
var DEFAULT_TIMEOUT_MS = 30 * 60 * 1e3;
|
|
80941
81027
|
async function execAndLogOnFailure(cmd, dir, options, logLevel = "info") {
|
|
@@ -80988,15 +81074,22 @@ function startTelemetry(pid, handler) {
|
|
|
80988
81074
|
async function execNeverFail(cmd, dir, options) {
|
|
80989
81075
|
const stopHeartbeat = options?.heartbeat ? startHeartbeat(options.heartbeat) : void 0;
|
|
80990
81076
|
let stopTelemetry;
|
|
81077
|
+
let analyzerTelemetryServer;
|
|
81078
|
+
let analyzerTelemetryFilePath;
|
|
81079
|
+
if (options?.analyzerTelemetryHandler) {
|
|
81080
|
+
analyzerTelemetryServer = new AnalyzerTelemetryServer(options.analyzerTelemetryHandler);
|
|
81081
|
+
analyzerTelemetryFilePath = await analyzerTelemetryServer.start();
|
|
81082
|
+
}
|
|
80991
81083
|
try {
|
|
80992
81084
|
return await new Promise((resolve23) => {
|
|
80993
81085
|
let args;
|
|
80994
81086
|
if (typeof cmd !== "string") [cmd, ...args] = cmd;
|
|
80995
81087
|
const timeout = options?.timeout ?? DEFAULT_TIMEOUT_MS;
|
|
81088
|
+
const env = analyzerTelemetryFilePath ? { ...options?.env ?? process.env, ANALYZER_TELEMETRY_FILE_PATH: analyzerTelemetryFilePath } : options?.env;
|
|
80996
81089
|
const childProcess = execFile2(
|
|
80997
81090
|
cmd,
|
|
80998
81091
|
args,
|
|
80999
|
-
{ ...options, cwd: dir, maxBuffer: 1024 * 1024 * 1024, shell: args === void 0, timeout },
|
|
81092
|
+
{ ...options, env, cwd: dir, maxBuffer: 1024 * 1024 * 1024, shell: args === void 0, timeout },
|
|
81000
81093
|
(error, stdout, stderr) => {
|
|
81001
81094
|
resolve23({ error, stdout, stderr });
|
|
81002
81095
|
}
|
|
@@ -81022,6 +81115,7 @@ async function execNeverFail(cmd, dir, options) {
|
|
|
81022
81115
|
} finally {
|
|
81023
81116
|
stopHeartbeat?.();
|
|
81024
81117
|
stopTelemetry?.();
|
|
81118
|
+
await analyzerTelemetryServer?.close();
|
|
81025
81119
|
}
|
|
81026
81120
|
}
|
|
81027
81121
|
async function exec(cmd, dir, options) {
|
|
@@ -81129,9 +81223,9 @@ async function runCommandResolveStdOut2(cmd, dir, options) {
|
|
|
81129
81223
|
// ../utils/src/file-utils.ts
|
|
81130
81224
|
var import_lodash3 = __toESM(require_lodash(), 1);
|
|
81131
81225
|
var import_micromatch = __toESM(require_micromatch(), 1);
|
|
81132
|
-
import { existsSync } from "fs";
|
|
81226
|
+
import { existsSync as existsSync2 } from "fs";
|
|
81133
81227
|
import { access, cp, readdir, stat } from "fs/promises";
|
|
81134
|
-
import { basename, join as
|
|
81228
|
+
import { basename, join as join3, relative, resolve } from "path";
|
|
81135
81229
|
|
|
81136
81230
|
// ../web-compat-utils/src/async.ts
|
|
81137
81231
|
async function asyncMap(array, mapper, concurrency = 1) {
|
|
@@ -81193,7 +81287,7 @@ function findParent(dir, predicate, wholePath) {
|
|
|
81193
81287
|
async function getFiles(dir, excludeDirs) {
|
|
81194
81288
|
async function helper(currDir, arrayOfFiles) {
|
|
81195
81289
|
for (const item of await readdir(currDir, { withFileTypes: true })) {
|
|
81196
|
-
const itemPath =
|
|
81290
|
+
const itemPath = join3(currDir, item.name);
|
|
81197
81291
|
if (item.isDirectory()) {
|
|
81198
81292
|
if (!excludeDirs?.includes(item.name)) await helper(itemPath, arrayOfFiles);
|
|
81199
81293
|
} else if (item.isFile()) {
|
|
@@ -81202,7 +81296,7 @@ async function getFiles(dir, excludeDirs) {
|
|
|
81202
81296
|
}
|
|
81203
81297
|
return arrayOfFiles;
|
|
81204
81298
|
}
|
|
81205
|
-
if (!
|
|
81299
|
+
if (!existsSync2(dir)) return [];
|
|
81206
81300
|
return uniq(await helper(dir, []));
|
|
81207
81301
|
}
|
|
81208
81302
|
async function isDirectory(filePath) {
|
|
@@ -81236,7 +81330,7 @@ async function runGoModWhy(moduleMode, projectFolder, toCheck) {
|
|
|
81236
81330
|
var getIrrelevantModules = runGoModWhy.bind(null, true);
|
|
81237
81331
|
var getIrrelevantPackages = runGoModWhy.bind(null, false);
|
|
81238
81332
|
async function getModuleInfo(goModPath) {
|
|
81239
|
-
if (!goModPath.endsWith(".mod")) goModPath =
|
|
81333
|
+
if (!goModPath.endsWith(".mod")) goModPath = join4(goModPath, "go.mod");
|
|
81240
81334
|
const stdout = await runCommandResolveStdOut2(["go", "mod", "edit", "-json", goModPath]);
|
|
81241
81335
|
return JSON.parse(stdout);
|
|
81242
81336
|
}
|
|
@@ -87648,6 +87742,41 @@ function createTelemetryHandler(dashboardAPI4, analysisMetadataId) {
|
|
|
87648
87742
|
intervalMs: 5e3
|
|
87649
87743
|
};
|
|
87650
87744
|
}
|
|
87745
|
+
function createAnalyzerTelemetryHandler(dashboardAPI4, analysisMetadataId) {
|
|
87746
|
+
if (!analysisMetadataId) {
|
|
87747
|
+
return void 0;
|
|
87748
|
+
}
|
|
87749
|
+
let eventBuffer = [];
|
|
87750
|
+
let flushTimer;
|
|
87751
|
+
const flushEvents = () => {
|
|
87752
|
+
if (eventBuffer.length === 0) return;
|
|
87753
|
+
const eventsToSend = eventBuffer;
|
|
87754
|
+
eventBuffer = [];
|
|
87755
|
+
dashboardAPI4.sendAnalyzerTelemetry(analysisMetadataId, eventsToSend).catch((err) => logger.debug("Failed to send analyzer telemetry:", err));
|
|
87756
|
+
};
|
|
87757
|
+
return {
|
|
87758
|
+
onAnalyzerEvent: (event) => {
|
|
87759
|
+
eventBuffer.push({
|
|
87760
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
87761
|
+
event
|
|
87762
|
+
});
|
|
87763
|
+
if (flushTimer) clearTimeout(flushTimer);
|
|
87764
|
+
if (eventBuffer.length >= 10) {
|
|
87765
|
+
flushEvents();
|
|
87766
|
+
} else {
|
|
87767
|
+
flushTimer = setTimeout(flushEvents, 1e3);
|
|
87768
|
+
flushTimer.unref?.();
|
|
87769
|
+
}
|
|
87770
|
+
},
|
|
87771
|
+
close: () => {
|
|
87772
|
+
if (flushTimer) {
|
|
87773
|
+
clearTimeout(flushTimer);
|
|
87774
|
+
flushTimer = void 0;
|
|
87775
|
+
}
|
|
87776
|
+
flushEvents();
|
|
87777
|
+
}
|
|
87778
|
+
};
|
|
87779
|
+
}
|
|
87651
87780
|
|
|
87652
87781
|
// ../utils/src/promise-queue.ts
|
|
87653
87782
|
var PromiseQueue = class {
|
|
@@ -87768,7 +87897,7 @@ import assert7 from "assert";
|
|
|
87768
87897
|
import { resolve as resolve19 } from "path";
|
|
87769
87898
|
|
|
87770
87899
|
// ../utils/src/pip-utils.ts
|
|
87771
|
-
import { existsSync as
|
|
87900
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
87772
87901
|
import { readFile as readFile4 } from "node:fs/promises";
|
|
87773
87902
|
import { dirname, resolve as resolve3 } from "node:path";
|
|
87774
87903
|
import util4 from "node:util";
|
|
@@ -87779,7 +87908,7 @@ var import_semver = __toESM(require_semver4(), 1);
|
|
|
87779
87908
|
import { execFileSync } from "child_process";
|
|
87780
87909
|
import { constants as constants2 } from "fs";
|
|
87781
87910
|
import { access as access2, readFile as readFile3 } from "fs/promises";
|
|
87782
|
-
import { join as
|
|
87911
|
+
import { join as join5, resolve as resolve2 } from "path";
|
|
87783
87912
|
import util3 from "util";
|
|
87784
87913
|
var { once } = import_lodash4.default;
|
|
87785
87914
|
var systemPython = once(() => {
|
|
@@ -87826,7 +87955,7 @@ var PythonVersionsManager = class _PythonVersionsManager {
|
|
|
87826
87955
|
const absPath = resolve2(this.projectDir, workspacePath);
|
|
87827
87956
|
for (const parent2 of parents(absPath))
|
|
87828
87957
|
try {
|
|
87829
|
-
return [(await readFile3(
|
|
87958
|
+
return [(await readFile3(join5(parent2, ".python-version"), "utf-8")).split("\n")[0].trim()];
|
|
87830
87959
|
} catch (e) {
|
|
87831
87960
|
if (e.code !== "ENOENT") logger.warn("Failed to read python version file with error", e);
|
|
87832
87961
|
}
|
|
@@ -88130,7 +88259,7 @@ async function parseTomlFile(file) {
|
|
|
88130
88259
|
}
|
|
88131
88260
|
async function getPyProjectParsed(dir) {
|
|
88132
88261
|
const pyprojectLoc = resolve3(dir, "pyproject.toml");
|
|
88133
|
-
if (!
|
|
88262
|
+
if (!existsSync3(pyprojectLoc)) return void 0;
|
|
88134
88263
|
return parseTomlFile(pyprojectLoc);
|
|
88135
88264
|
}
|
|
88136
88265
|
var uvPythonPlatform = "x86_64-manylinux_2_40";
|
|
@@ -88185,15 +88314,15 @@ function addPathToTrie(root3, vulnPath) {
|
|
|
88185
88314
|
// dist/whole-program-code-aware-vulnerability-scanner/python/python-code-aware-vulnerability-scanner.js
|
|
88186
88315
|
var import_lodash14 = __toESM(require_lodash(), 1);
|
|
88187
88316
|
import assert6 from "assert";
|
|
88188
|
-
import { existsSync as
|
|
88317
|
+
import { existsSync as existsSync13 } from "fs";
|
|
88189
88318
|
import { cp as cp7, readdir as readdir4, readFile as readFile11, rm as rm5 } from "fs/promises";
|
|
88190
88319
|
var import_semver3 = __toESM(require_semver2(), 1);
|
|
88191
|
-
import { basename as basename11, dirname as dirname15, join as
|
|
88320
|
+
import { basename as basename11, dirname as dirname15, join as join17, resolve as resolve17, sep as sep5 } from "path";
|
|
88192
88321
|
import util5 from "util";
|
|
88193
88322
|
|
|
88194
88323
|
// ../utils/src/constants.ts
|
|
88195
88324
|
var import_lodash5 = __toESM(require_lodash(), 1);
|
|
88196
|
-
import { dirname as dirname2, join as
|
|
88325
|
+
import { dirname as dirname2, join as join6 } from "node:path";
|
|
88197
88326
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
88198
88327
|
var { once: once2 } = import_lodash5.default;
|
|
88199
88328
|
var fileName = fileURLToPath3(import.meta.url);
|
|
@@ -88206,16 +88335,16 @@ var COANA_ROOT = once2(() => {
|
|
|
88206
88335
|
return coanaRoot;
|
|
88207
88336
|
});
|
|
88208
88337
|
var REPOS_PATH = once2(() => {
|
|
88209
|
-
return process.env.REPOS_PATH ??
|
|
88338
|
+
return process.env.REPOS_PATH ?? join6(COANA_ROOT(), "repos");
|
|
88210
88339
|
});
|
|
88211
88340
|
var COANA_REPOS_PATH = once2(() => {
|
|
88212
|
-
return process.env.COANA_REPOS_PATH ??
|
|
88341
|
+
return process.env.COANA_REPOS_PATH ?? join6(REPOS_PATH(), "coana-tech");
|
|
88213
88342
|
});
|
|
88214
88343
|
var REQUIREMENTS_FILES_SEARCH_DEPTH = 2;
|
|
88215
88344
|
|
|
88216
88345
|
// ../utils/src/download-utils.ts
|
|
88217
|
-
import { existsSync as
|
|
88218
|
-
import { writeFile as
|
|
88346
|
+
import { existsSync as existsSync4 } from "fs";
|
|
88347
|
+
import { writeFile as writeFile3 } from "fs/promises";
|
|
88219
88348
|
async function downloadFile(fileUrl, outputFile) {
|
|
88220
88349
|
try {
|
|
88221
88350
|
const response = await axios_default.get(fileUrl, {
|
|
@@ -88227,8 +88356,8 @@ async function downloadFile(fileUrl, outputFile) {
|
|
|
88227
88356
|
}
|
|
88228
88357
|
});
|
|
88229
88358
|
if (response.status < 200 || response.status >= 300) return false;
|
|
88230
|
-
await
|
|
88231
|
-
return
|
|
88359
|
+
await writeFile3(outputFile, Buffer.from(response.data));
|
|
88360
|
+
return existsSync4(outputFile);
|
|
88232
88361
|
} catch {
|
|
88233
88362
|
return false;
|
|
88234
88363
|
}
|
|
@@ -88237,11 +88366,11 @@ async function downloadFile(fileUrl, outputFile) {
|
|
|
88237
88366
|
// ../utils/src/file-tree-utils.ts
|
|
88238
88367
|
import { closeSync, lstatSync as lstatSync2, openSync, readdirSync as readdirSync3, readSync } from "fs";
|
|
88239
88368
|
import { readdir as readdir3 } from "fs/promises";
|
|
88240
|
-
import { basename as basename3, join as
|
|
88369
|
+
import { basename as basename3, join as join8, relative as relative3, resolve as resolve5 } from "path";
|
|
88241
88370
|
|
|
88242
88371
|
// ../utils/src/package-utils.ts
|
|
88243
|
-
import { parse as parse2, join as
|
|
88244
|
-
import { existsSync as
|
|
88372
|
+
import { parse as parse2, join as join7, resolve as resolve4, normalize as normalize2, dirname as dirname3, basename as basename2, relative as relative2 } from "path";
|
|
88373
|
+
import { existsSync as existsSync5, readFileSync as readFileSync2, readdirSync as readdirSync2, statSync, writeFileSync } from "fs";
|
|
88245
88374
|
function getPackageJsonObject(workspaceRoot) {
|
|
88246
88375
|
const packageJSONContent = getPackageJsonContent(workspaceRoot);
|
|
88247
88376
|
if (!packageJSONContent) return void 0;
|
|
@@ -88249,11 +88378,11 @@ function getPackageJsonObject(workspaceRoot) {
|
|
|
88249
88378
|
}
|
|
88250
88379
|
function getPackageJsonContent(workspaceRoot) {
|
|
88251
88380
|
const packageJsonPath = getPackageJSONPath(workspaceRoot);
|
|
88252
|
-
if (
|
|
88381
|
+
if (existsSync5(packageJsonPath)) return readFileSync2(packageJsonPath, "utf8");
|
|
88253
88382
|
return void 0;
|
|
88254
88383
|
}
|
|
88255
88384
|
function getPackageJSONPath(workspaceRoot) {
|
|
88256
|
-
return
|
|
88385
|
+
return join7(workspaceRoot, "package.json");
|
|
88257
88386
|
}
|
|
88258
88387
|
|
|
88259
88388
|
// ../utils/src/file-tree-utils.ts
|
|
@@ -88267,7 +88396,7 @@ async function findFilesInPythonProjectMatching(projectDir, fileMatcher, maxDept
|
|
|
88267
88396
|
) || requirementsFilesDepth <= 0 && filesAndDirectories.some(({ name: name2 }) => /requirements.*\.txt/.test(name2)))
|
|
88268
88397
|
return;
|
|
88269
88398
|
for (const fileOrDirectory of filesAndDirectories) {
|
|
88270
|
-
const fullPath =
|
|
88399
|
+
const fullPath = join8(path10, fileOrDirectory.name);
|
|
88271
88400
|
if (fileOrDirectory.isDirectory()) {
|
|
88272
88401
|
if (shouldIgnoreDir(fileOrDirectory.name, projectDir === path10)) continue;
|
|
88273
88402
|
directoriesToTraverse.push(fileOrDirectory.name);
|
|
@@ -88277,7 +88406,7 @@ async function findFilesInPythonProjectMatching(projectDir, fileMatcher, maxDept
|
|
|
88277
88406
|
}
|
|
88278
88407
|
if (depthLeft === 0) return;
|
|
88279
88408
|
for (const dir of directoriesToTraverse) {
|
|
88280
|
-
await recHelper(
|
|
88409
|
+
await recHelper(join8(path10, dir), depthLeft - 1, requirementsFilesDepth - 1);
|
|
88281
88410
|
}
|
|
88282
88411
|
};
|
|
88283
88412
|
await recHelper(projectDir, maxDepth, maxRequirementsFileDepth);
|
|
@@ -88289,11 +88418,11 @@ async function findFilesInPythonProjectMatching(projectDir, fileMatcher, maxDept
|
|
|
88289
88418
|
|
|
88290
88419
|
// ../utils/src/tmp-file.ts
|
|
88291
88420
|
import { rm, mkdtemp as mkdtemp2, cp as cp3, lstat as lstat2 } from "fs/promises";
|
|
88292
|
-
import { tmpdir } from "os";
|
|
88293
|
-
import { join as
|
|
88421
|
+
import { tmpdir as tmpdir2 } from "os";
|
|
88422
|
+
import { join as join9, relative as relative4, sep as sep2, extname } from "path";
|
|
88294
88423
|
async function createTmpDirectory(prefix) {
|
|
88295
88424
|
try {
|
|
88296
|
-
const tmpDir = await mkdtemp2(
|
|
88425
|
+
const tmpDir = await mkdtemp2(join9(tmpdir2(), prefix));
|
|
88297
88426
|
return tmpDir;
|
|
88298
88427
|
} catch (err) {
|
|
88299
88428
|
console.log("Error creating tmp directory", err);
|
|
@@ -88532,12 +88661,12 @@ var ToolPathResolver = class {
|
|
|
88532
88661
|
|
|
88533
88662
|
// dist/whole-program-code-aware-vulnerability-scanner/code-aware-vulnerability-scanner.js
|
|
88534
88663
|
var import_lodash13 = __toESM(require_lodash(), 1);
|
|
88535
|
-
import { readFileSync as
|
|
88664
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
88536
88665
|
import { resolve as resolve16 } from "path";
|
|
88537
88666
|
|
|
88538
88667
|
// dist/whole-program-code-aware-vulnerability-scanner/dotnet/dotnet-code-aware-vulnerability-scanner.js
|
|
88539
88668
|
var import_lodash6 = __toESM(require_lodash(), 1);
|
|
88540
|
-
import { existsSync as
|
|
88669
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
88541
88670
|
import { basename as basename7, dirname as dirname10, extname as extname3, resolve as resolve9 } from "node:path";
|
|
88542
88671
|
|
|
88543
88672
|
// ../utils/src/nuget-utils.ts
|
|
@@ -88549,10 +88678,10 @@ function getUrlForPackage(packageName, version3) {
|
|
|
88549
88678
|
|
|
88550
88679
|
// ../utils/src/tool-extractor.ts
|
|
88551
88680
|
import { createHash } from "node:crypto";
|
|
88552
|
-
import { createReadStream, createWriteStream as createWriteStream2, readFileSync as
|
|
88553
|
-
import { copyFile as copyFile2, cp as cp4, mkdir as mkdir4, writeFile as
|
|
88554
|
-
import { tmpdir as
|
|
88555
|
-
import { basename as basename5, dirname as dirname8, join as
|
|
88681
|
+
import { createReadStream, createWriteStream as createWriteStream2, readFileSync as readFileSync3, statSync as statSync3 } from "node:fs";
|
|
88682
|
+
import { copyFile as copyFile2, cp as cp4, mkdir as mkdir4, writeFile as writeFile4 } from "node:fs/promises";
|
|
88683
|
+
import { tmpdir as tmpdir3 } from "node:os";
|
|
88684
|
+
import { basename as basename5, dirname as dirname8, join as join11 } from "node:path";
|
|
88556
88685
|
import { pipeline } from "node:stream/promises";
|
|
88557
88686
|
import { createGunzip } from "node:zlib";
|
|
88558
88687
|
|
|
@@ -92051,7 +92180,7 @@ import fs9 from "node:fs";
|
|
|
92051
92180
|
|
|
92052
92181
|
// ../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/unpack.js
|
|
92053
92182
|
import assert3 from "node:assert";
|
|
92054
|
-
import { randomBytes } from "node:crypto";
|
|
92183
|
+
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
92055
92184
|
import fs8 from "node:fs";
|
|
92056
92185
|
import path7 from "node:path";
|
|
92057
92186
|
|
|
@@ -92424,7 +92553,7 @@ var mkdir3 = (dir, opt, cb) => {
|
|
|
92424
92553
|
const gid = opt.gid;
|
|
92425
92554
|
const doChown = typeof uid === "number" && typeof gid === "number" && (uid !== opt.processUid || gid !== opt.processGid);
|
|
92426
92555
|
const preserve = opt.preserve;
|
|
92427
|
-
const
|
|
92556
|
+
const unlink2 = opt.unlink;
|
|
92428
92557
|
const cache = opt.cache;
|
|
92429
92558
|
const cwd = normalizeWindowsPath(opt.cwd);
|
|
92430
92559
|
const done = (er, created) => {
|
|
@@ -92456,33 +92585,33 @@ var mkdir3 = (dir, opt, cb) => {
|
|
|
92456
92585
|
}
|
|
92457
92586
|
const sub = normalizeWindowsPath(path6.relative(cwd, dir));
|
|
92458
92587
|
const parts = sub.split("/");
|
|
92459
|
-
mkdir_(cwd, parts, mode, cache,
|
|
92588
|
+
mkdir_(cwd, parts, mode, cache, unlink2, cwd, void 0, done);
|
|
92460
92589
|
};
|
|
92461
|
-
var mkdir_ = (base, parts, mode, cache,
|
|
92590
|
+
var mkdir_ = (base, parts, mode, cache, unlink2, cwd, created, cb) => {
|
|
92462
92591
|
if (!parts.length) {
|
|
92463
92592
|
return cb(null, created);
|
|
92464
92593
|
}
|
|
92465
92594
|
const p = parts.shift();
|
|
92466
92595
|
const part = normalizeWindowsPath(path6.resolve(base + "/" + p));
|
|
92467
92596
|
if (cGet(cache, part)) {
|
|
92468
|
-
return mkdir_(part, parts, mode, cache,
|
|
92597
|
+
return mkdir_(part, parts, mode, cache, unlink2, cwd, created, cb);
|
|
92469
92598
|
}
|
|
92470
|
-
fs7.mkdir(part, mode, onmkdir(part, parts, mode, cache,
|
|
92599
|
+
fs7.mkdir(part, mode, onmkdir(part, parts, mode, cache, unlink2, cwd, created, cb));
|
|
92471
92600
|
};
|
|
92472
|
-
var onmkdir = (part, parts, mode, cache,
|
|
92601
|
+
var onmkdir = (part, parts, mode, cache, unlink2, cwd, created, cb) => (er) => {
|
|
92473
92602
|
if (er) {
|
|
92474
92603
|
fs7.lstat(part, (statEr, st) => {
|
|
92475
92604
|
if (statEr) {
|
|
92476
92605
|
statEr.path = statEr.path && normalizeWindowsPath(statEr.path);
|
|
92477
92606
|
cb(statEr);
|
|
92478
92607
|
} else if (st.isDirectory()) {
|
|
92479
|
-
mkdir_(part, parts, mode, cache,
|
|
92480
|
-
} else if (
|
|
92608
|
+
mkdir_(part, parts, mode, cache, unlink2, cwd, created, cb);
|
|
92609
|
+
} else if (unlink2) {
|
|
92481
92610
|
fs7.unlink(part, (er2) => {
|
|
92482
92611
|
if (er2) {
|
|
92483
92612
|
return cb(er2);
|
|
92484
92613
|
}
|
|
92485
|
-
fs7.mkdir(part, mode, onmkdir(part, parts, mode, cache,
|
|
92614
|
+
fs7.mkdir(part, mode, onmkdir(part, parts, mode, cache, unlink2, cwd, created, cb));
|
|
92486
92615
|
});
|
|
92487
92616
|
} else if (st.isSymbolicLink()) {
|
|
92488
92617
|
return cb(new SymlinkError(part, part + "/" + parts.join("/")));
|
|
@@ -92492,7 +92621,7 @@ var onmkdir = (part, parts, mode, cache, unlink, cwd, created, cb) => (er) => {
|
|
|
92492
92621
|
});
|
|
92493
92622
|
} else {
|
|
92494
92623
|
created = created || part;
|
|
92495
|
-
mkdir_(part, parts, mode, cache,
|
|
92624
|
+
mkdir_(part, parts, mode, cache, unlink2, cwd, created, cb);
|
|
92496
92625
|
}
|
|
92497
92626
|
};
|
|
92498
92627
|
var checkCwdSync = (dir) => {
|
|
@@ -92517,7 +92646,7 @@ var mkdirSync3 = (dir, opt) => {
|
|
|
92517
92646
|
const gid = opt.gid;
|
|
92518
92647
|
const doChown = typeof uid === "number" && typeof gid === "number" && (uid !== opt.processUid || gid !== opt.processGid);
|
|
92519
92648
|
const preserve = opt.preserve;
|
|
92520
|
-
const
|
|
92649
|
+
const unlink2 = opt.unlink;
|
|
92521
92650
|
const cache = opt.cache;
|
|
92522
92651
|
const cwd = normalizeWindowsPath(opt.cwd);
|
|
92523
92652
|
const done = (created2) => {
|
|
@@ -92556,7 +92685,7 @@ var mkdirSync3 = (dir, opt) => {
|
|
|
92556
92685
|
if (st.isDirectory()) {
|
|
92557
92686
|
cSet(cache, part, true);
|
|
92558
92687
|
continue;
|
|
92559
|
-
} else if (
|
|
92688
|
+
} else if (unlink2) {
|
|
92560
92689
|
fs7.unlinkSync(part);
|
|
92561
92690
|
fs7.mkdirSync(part, mode);
|
|
92562
92691
|
created = created || part;
|
|
@@ -92581,14 +92710,14 @@ var normalizeUnicode = (s2) => {
|
|
|
92581
92710
|
};
|
|
92582
92711
|
|
|
92583
92712
|
// ../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/path-reservations.js
|
|
92584
|
-
import { join as
|
|
92713
|
+
import { join as join10 } from "node:path";
|
|
92585
92714
|
var platform5 = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
|
|
92586
92715
|
var isWindows2 = platform5 === "win32";
|
|
92587
92716
|
var getDirs = (path10) => {
|
|
92588
92717
|
const dirs = path10.split("/").slice(0, -1).reduce((set, path11) => {
|
|
92589
92718
|
const s2 = set[set.length - 1];
|
|
92590
92719
|
if (s2 !== void 0) {
|
|
92591
|
-
path11 =
|
|
92720
|
+
path11 = join10(s2, path11);
|
|
92592
92721
|
}
|
|
92593
92722
|
set.push(path11 || "/");
|
|
92594
92723
|
return set;
|
|
@@ -92606,7 +92735,7 @@ var PathReservations = class {
|
|
|
92606
92735
|
#running = /* @__PURE__ */ new Set();
|
|
92607
92736
|
reserve(paths, fn) {
|
|
92608
92737
|
paths = isWindows2 ? ["win32 parallelization disabled"] : paths.map((p) => {
|
|
92609
|
-
return stripTrailingSlashes(
|
|
92738
|
+
return stripTrailingSlashes(join10(normalizeUnicode(p))).toLowerCase();
|
|
92610
92739
|
});
|
|
92611
92740
|
const dirs = new Set(paths.map((path10) => getDirs(path10)).reduce((a2, b) => a2.concat(b)));
|
|
92612
92741
|
this.#reservations.set(fn, { dirs, paths });
|
|
@@ -92746,7 +92875,7 @@ var unlinkFile = (path10, cb) => {
|
|
|
92746
92875
|
if (!isWindows3) {
|
|
92747
92876
|
return fs8.unlink(path10, cb);
|
|
92748
92877
|
}
|
|
92749
|
-
const name2 = path10 + ".DELETE." +
|
|
92878
|
+
const name2 = path10 + ".DELETE." + randomBytes2(16).toString("hex");
|
|
92750
92879
|
fs8.rename(path10, name2, (er) => {
|
|
92751
92880
|
if (er) {
|
|
92752
92881
|
return cb(er);
|
|
@@ -92758,7 +92887,7 @@ var unlinkFileSync = (path10) => {
|
|
|
92758
92887
|
if (!isWindows3) {
|
|
92759
92888
|
return fs8.unlinkSync(path10);
|
|
92760
92889
|
}
|
|
92761
|
-
const name2 = path10 + ".DELETE." +
|
|
92890
|
+
const name2 = path10 + ".DELETE." + randomBytes2(16).toString("hex");
|
|
92762
92891
|
fs8.renameSync(path10, name2);
|
|
92763
92892
|
fs8.unlinkSync(name2);
|
|
92764
92893
|
};
|
|
@@ -93690,13 +93819,13 @@ async function getNodeExecutable(overridePath) {
|
|
|
93690
93819
|
const nodeArch = arch === "arm" ? "arm64" : arch;
|
|
93691
93820
|
const isWindows4 = platform7 === "win32";
|
|
93692
93821
|
const binaryName = isWindows4 ? `node-${platform7}-${nodeArch}.exe.gz` : `node-${platform7}-${nodeArch}.gz`;
|
|
93693
|
-
const compressedBinaryPath =
|
|
93822
|
+
const compressedBinaryPath = join11(extractedPath, binaryName);
|
|
93694
93823
|
if (!await exists(compressedBinaryPath)) {
|
|
93695
93824
|
throw new Error(`Node.js binary not found: ${compressedBinaryPath}. Platform: ${platform7}-${nodeArch}`);
|
|
93696
93825
|
}
|
|
93697
|
-
const tmpDir =
|
|
93826
|
+
const tmpDir = join11(getExtractionBaseDir(), "node-runtime");
|
|
93698
93827
|
await mkdir4(tmpDir, { recursive: true });
|
|
93699
|
-
const nodeBinaryPath =
|
|
93828
|
+
const nodeBinaryPath = join11(tmpDir, isWindows4 ? "node.exe" : "node");
|
|
93700
93829
|
logger.debug(`Decompressing Node.js binary to ${nodeBinaryPath}...`);
|
|
93701
93830
|
await pipeline(
|
|
93702
93831
|
createReadStream(compressedBinaryPath),
|
|
@@ -93712,8 +93841,8 @@ var cliVersion;
|
|
|
93712
93841
|
function getCliVersion() {
|
|
93713
93842
|
if (cliVersion) return cliVersion;
|
|
93714
93843
|
try {
|
|
93715
|
-
const packageJsonPath = isNexeMode() ?
|
|
93716
|
-
const packageJson = JSON.parse(
|
|
93844
|
+
const packageJsonPath = isNexeMode() ? join11(NEXE_VIRTUAL_FS_ROOT, "package.json") : join11(dirname8(dirname8(dirname8(dirname8(__filename)))), "npm-package-cli", "package.json");
|
|
93845
|
+
const packageJson = JSON.parse(readFileSync3(packageJsonPath, "utf-8"));
|
|
93717
93846
|
if (process.env.ALWAYS_REEXTRACT_TOOLS === "true") {
|
|
93718
93847
|
logger.info("ALWAYS_REEXTRACT_TOOLS is set to true, re-extracting tools");
|
|
93719
93848
|
const randomVersion = Math.random().toString().slice(2, 8);
|
|
@@ -93729,7 +93858,7 @@ function getCliVersion() {
|
|
|
93729
93858
|
}
|
|
93730
93859
|
function getExtractionBaseDir() {
|
|
93731
93860
|
const version3 = getCliVersion();
|
|
93732
|
-
return
|
|
93861
|
+
return join11(tmpdir3(), `coana-cli-v${version3}`);
|
|
93733
93862
|
}
|
|
93734
93863
|
async function calculateChecksum(filePath) {
|
|
93735
93864
|
const hash = createHash("sha256");
|
|
@@ -93741,8 +93870,8 @@ function loadChecksums() {
|
|
|
93741
93870
|
if (!isNexeMode()) {
|
|
93742
93871
|
throw new Error("Tool extraction is only supported in nexe mode");
|
|
93743
93872
|
}
|
|
93744
|
-
const checksumsPath =
|
|
93745
|
-
return JSON.parse(
|
|
93873
|
+
const checksumsPath = join11(NEXE_VIRTUAL_FS_ROOT, "checksums.json");
|
|
93874
|
+
return JSON.parse(readFileSync3(checksumsPath, "utf-8"));
|
|
93746
93875
|
} catch (error) {
|
|
93747
93876
|
logger.warn("Failed to load checksums.json:", error);
|
|
93748
93877
|
throw new Error(
|
|
@@ -93753,7 +93882,7 @@ function loadChecksums() {
|
|
|
93753
93882
|
async function verifyToolIntegrity(toolName, extractedPath, checksums) {
|
|
93754
93883
|
try {
|
|
93755
93884
|
for (const [relPath, expectedChecksum] of Object.entries(checksums)) {
|
|
93756
|
-
const filePath =
|
|
93885
|
+
const filePath = join11(extractedPath, relPath);
|
|
93757
93886
|
if (!await exists(filePath)) {
|
|
93758
93887
|
logger.debug(`File ${filePath} does not exist`);
|
|
93759
93888
|
return false;
|
|
@@ -93786,8 +93915,8 @@ async function extractTool(toolName, resourcePath) {
|
|
|
93786
93915
|
return cached.extractedPath;
|
|
93787
93916
|
}
|
|
93788
93917
|
const baseDir = getExtractionBaseDir();
|
|
93789
|
-
const extractedPath =
|
|
93790
|
-
const markerFile =
|
|
93918
|
+
const extractedPath = join11(baseDir, resourcePath);
|
|
93919
|
+
const markerFile = join11(extractedPath, ".extracted");
|
|
93791
93920
|
if (await exists(markerFile)) {
|
|
93792
93921
|
const checksums = loadChecksums();
|
|
93793
93922
|
const toolChecksums = checksums[toolName];
|
|
@@ -93802,7 +93931,7 @@ async function extractTool(toolName, resourcePath) {
|
|
|
93802
93931
|
logger.debug(`Extracting ${toolName} to ${extractedPath}...`);
|
|
93803
93932
|
try {
|
|
93804
93933
|
await mkdir4(extractedPath, { recursive: true });
|
|
93805
|
-
const sourcePath = isNexeMode() ?
|
|
93934
|
+
const sourcePath = isNexeMode() ? join11(NEXE_VIRTUAL_FS_ROOT, resourcePath) : resourcePath;
|
|
93806
93935
|
if (!await exists(sourcePath)) {
|
|
93807
93936
|
throw new Error(
|
|
93808
93937
|
`Tool source not found: ${sourcePath}. isNexeMode=${isNexeMode()}, NEXE_VIRTUAL_FS_ROOT=${NEXE_VIRTUAL_FS_ROOT}`
|
|
@@ -93813,12 +93942,12 @@ async function extractTool(toolName, resourcePath) {
|
|
|
93813
93942
|
await cp4(sourcePath, extractedPath, { recursive: true });
|
|
93814
93943
|
} else if (stats.isFile()) {
|
|
93815
93944
|
const fileName2 = basename5(sourcePath);
|
|
93816
|
-
const destFile =
|
|
93945
|
+
const destFile = join11(extractedPath, fileName2);
|
|
93817
93946
|
await copyFile2(sourcePath, destFile);
|
|
93818
93947
|
} else {
|
|
93819
93948
|
throw new Error(`Tool source is neither a file nor a directory: ${sourcePath}`);
|
|
93820
93949
|
}
|
|
93821
|
-
await
|
|
93950
|
+
await writeFile4(markerFile, (/* @__PURE__ */ new Date()).toISOString());
|
|
93822
93951
|
logger.debug(`Successfully extracted ${toolName}`);
|
|
93823
93952
|
extractedTools.set(toolName, { extractedPath });
|
|
93824
93953
|
return extractedPath;
|
|
@@ -93858,7 +93987,7 @@ var CocoaHeuristics = {
|
|
|
93858
93987
|
|
|
93859
93988
|
// dist/whole-program-code-aware-vulnerability-scanner/dotnet/dotnet-code-aware-vulnerability-scanner.js
|
|
93860
93989
|
var import_adm_zip = __toESM(require_adm_zip(), 1);
|
|
93861
|
-
import { mkdir as mkdir5, readFile as readFile6, writeFile as
|
|
93990
|
+
import { mkdir as mkdir5, readFile as readFile6, writeFile as writeFile5 } from "fs/promises";
|
|
93862
93991
|
import { randomUUID } from "node:crypto";
|
|
93863
93992
|
|
|
93864
93993
|
// dist/whole-program-code-aware-vulnerability-scanner/dotnet/constants.js
|
|
@@ -93877,7 +94006,7 @@ function getClassGraphAnalysisCliPath() {
|
|
|
93877
94006
|
// ../utils/src/nuget-project-utils.ts
|
|
93878
94007
|
var import_parse_xml2 = __toESM(require_dist(), 1);
|
|
93879
94008
|
import { readFile as readFile5 } from "node:fs/promises";
|
|
93880
|
-
import { dirname as dirname9, join as
|
|
94009
|
+
import { dirname as dirname9, join as join12, relative as relative5, resolve as resolve8, basename as basename6, extname as extname2 } from "node:path";
|
|
93881
94010
|
|
|
93882
94011
|
// ../utils/src/xml-utils.ts
|
|
93883
94012
|
var import_parse_xml = __toESM(require_dist(), 1);
|
|
@@ -93983,7 +94112,7 @@ function createAttributeMap(xmlElement, xmlContent) {
|
|
|
93983
94112
|
}
|
|
93984
94113
|
|
|
93985
94114
|
// ../utils/src/nuget-project-utils.ts
|
|
93986
|
-
import { existsSync as
|
|
94115
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
93987
94116
|
|
|
93988
94117
|
// ../utils/dist/version-comparison/version-satisfies.js
|
|
93989
94118
|
var import_semver2 = __toESM(require_semver4(), 1);
|
|
@@ -95414,7 +95543,7 @@ var ecosystemMap = {
|
|
|
95414
95543
|
RUST: {
|
|
95415
95544
|
sortVersions: import_semver2.sort,
|
|
95416
95545
|
isPrerelease: semverIsPrerelease,
|
|
95417
|
-
versionSatisfiesSpecifier: (version3, specifier) => semverSatisfiesSpecifier(version3, /^\d/.test(
|
|
95546
|
+
versionSatisfiesSpecifier: (version3, specifier) => specifier.split(",").map((part) => part.trim()).every((trimmed) => semverSatisfiesSpecifier(version3, /^\d/.test(trimmed) ? `^${trimmed}` : trimmed)),
|
|
95418
95547
|
versionSatisfiesRelation: import_semver2.cmp,
|
|
95419
95548
|
versionSatisfiesRange: semverSatisfiesRange
|
|
95420
95549
|
},
|
|
@@ -95533,7 +95662,7 @@ async function loadNuGetProject(rootDir, projectFile, validateFile) {
|
|
|
95533
95662
|
}
|
|
95534
95663
|
async function loadNuGetProjectOrTarget(rootDir, projectFile, mainProject, visited, validateFile) {
|
|
95535
95664
|
const validatedProjectPath = validateFile ? validateFile(resolve8(rootDir, projectFile)) : resolve8(rootDir, projectFile);
|
|
95536
|
-
if (!validatedProjectPath || !
|
|
95665
|
+
if (!validatedProjectPath || !existsSync6(validatedProjectPath)) return void 0;
|
|
95537
95666
|
if (visited.has(validatedProjectPath)) return void 0;
|
|
95538
95667
|
visited.set(validatedProjectPath);
|
|
95539
95668
|
const sourceText = await readFile5(validatedProjectPath, "utf-8");
|
|
@@ -95610,7 +95739,7 @@ async function findDirectoryBuildPropsProjects(currentProject, mainProject, visi
|
|
|
95610
95739
|
const projectsReverse = [];
|
|
95611
95740
|
let currentDir = dirname9(currentProject.validatedProjectPath);
|
|
95612
95741
|
while (currentDir.startsWith(currentProject.rootDir) && currentDir !== dirname9(currentDir)) {
|
|
95613
|
-
const unvalidatedPath =
|
|
95742
|
+
const unvalidatedPath = join12(currentDir, "Directory.Build.props");
|
|
95614
95743
|
const validatedPath = validateFile ? validateFile(unvalidatedPath) : unvalidatedPath;
|
|
95615
95744
|
if (validatedPath && validatedPath !== currentProject.validatedProjectPath) {
|
|
95616
95745
|
const directoryBuildPropsProject = await loadNuGetProjectOrTarget(
|
|
@@ -95631,7 +95760,7 @@ async function findDirectoryBuildPropsProjects(currentProject, mainProject, visi
|
|
|
95631
95760
|
async function findDirectoryPackagesPropsProject(currentProject, mainProject, visited, validateFile) {
|
|
95632
95761
|
let currentDir = dirname9(currentProject.validatedProjectPath);
|
|
95633
95762
|
while (currentDir.startsWith(currentProject.rootDir) && currentDir !== dirname9(currentDir)) {
|
|
95634
|
-
const unvalidatedPath =
|
|
95763
|
+
const unvalidatedPath = join12(currentDir, "Directory.Packages.props");
|
|
95635
95764
|
const validatedPath = validateFile ? validateFile(unvalidatedPath) : unvalidatedPath;
|
|
95636
95765
|
if (validatedPath) {
|
|
95637
95766
|
return validatedPath !== currentProject.validatedProjectPath ? await loadNuGetProjectOrTarget(currentProject.rootDir, unvalidatedPath, mainProject, visited, validateFile) : void 0;
|
|
@@ -95698,7 +95827,7 @@ async function handleImportElement(currentProject, importElement, mainProject, v
|
|
|
95698
95827
|
if (!importPath) return;
|
|
95699
95828
|
const resolvedPath = resolve8(dirname9(currentProject.validatedProjectPath), normalizeMSBuildPath(importPath));
|
|
95700
95829
|
const validatedPath = validateFile ? validateFile(resolvedPath) : resolvedPath;
|
|
95701
|
-
if (!validatedPath || !
|
|
95830
|
+
if (!validatedPath || !existsSync6(validatedPath)) return;
|
|
95702
95831
|
const importedProject = await loadNuGetProjectOrTarget(
|
|
95703
95832
|
currentProject.rootDir,
|
|
95704
95833
|
resolvedPath,
|
|
@@ -96037,7 +96166,7 @@ var DotnetCodeAwareVulnerabilityScanner = class _DotnetCodeAwareVulnerabilitySca
|
|
|
96037
96166
|
};
|
|
96038
96167
|
const inputFile = resolve9(tmpDir, "input.json");
|
|
96039
96168
|
const outputFile = resolve9(tmpDir, "output.json");
|
|
96040
|
-
await
|
|
96169
|
+
await writeFile5(inputFile, JSON.stringify(options));
|
|
96041
96170
|
const timeoutMs = Math.max(timeoutInSeconds * 1.5, timeoutInSeconds + 30) * 1e3;
|
|
96042
96171
|
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, killSignal: "SIGKILL", heartbeat: HEARTBEATS.dotnet });
|
|
96043
96172
|
if (result.error)
|
|
@@ -96046,7 +96175,7 @@ var DotnetCodeAwareVulnerabilityScanner = class _DotnetCodeAwareVulnerabilitySca
|
|
|
96046
96175
|
return packageIds?.map((packageId) => this.depIdToPurl.get(packageId)).filter((purl) => purl !== void 0).map((purl) => purl.name ?? "");
|
|
96047
96176
|
});
|
|
96048
96177
|
}
|
|
96049
|
-
async runAnalysis(vulnerabilities, heuristic, timeoutInSeconds, _experiment, telemetryHandler) {
|
|
96178
|
+
async runAnalysis(vulnerabilities, heuristic, timeoutInSeconds, _experiment, telemetryHandler, analyzerTelemetryHandler) {
|
|
96050
96179
|
try {
|
|
96051
96180
|
this.statusUpdater?.("Preparing code for analysis...");
|
|
96052
96181
|
const packagesToAnalyze = heuristic.getPackagesToAnalyze(vulnerabilities);
|
|
@@ -96055,12 +96184,12 @@ var DotnetCodeAwareVulnerabilityScanner = class _DotnetCodeAwareVulnerabilitySca
|
|
|
96055
96184
|
const purl = this.depIdToPurl.get(packageId);
|
|
96056
96185
|
return purl?.name && packagesToAnalyzeSet.has(purl.name);
|
|
96057
96186
|
}));
|
|
96058
|
-
return await this.actuallyRunAnalysis(vulnerabilities.flatMap((v) => v.vulnerabilityAccessPaths), timeoutInSeconds, filteredDeps, telemetryHandler);
|
|
96187
|
+
return await this.actuallyRunAnalysis(vulnerabilities.flatMap((v) => v.vulnerabilityAccessPaths), timeoutInSeconds, filteredDeps, telemetryHandler, analyzerTelemetryHandler);
|
|
96059
96188
|
} catch (e) {
|
|
96060
96189
|
return { type: "error", message: e.message };
|
|
96061
96190
|
}
|
|
96062
96191
|
}
|
|
96063
|
-
async actuallyRunAnalysis(vulnerabilityAccessPaths, timeoutInSeconds, filteredDeps, telemetryHandler) {
|
|
96192
|
+
async actuallyRunAnalysis(vulnerabilityAccessPaths, timeoutInSeconds, filteredDeps, telemetryHandler, analyzerTelemetryHandler) {
|
|
96064
96193
|
this.statusUpdater?.("Running analysis...");
|
|
96065
96194
|
return withTmpDirectory("dotnet-run-analysis", async (tmpDir) => {
|
|
96066
96195
|
try {
|
|
@@ -96076,9 +96205,9 @@ var DotnetCodeAwareVulnerabilityScanner = class _DotnetCodeAwareVulnerabilitySca
|
|
|
96076
96205
|
};
|
|
96077
96206
|
const inputFile = resolve9(tmpDir, "input.json");
|
|
96078
96207
|
const outputFile = resolve9(tmpDir, "output.json");
|
|
96079
|
-
await
|
|
96208
|
+
await writeFile5(inputFile, JSON.stringify(options));
|
|
96080
96209
|
const timeoutMs = Math.max(timeoutInSeconds * 1.5, timeoutInSeconds + 30) * 1e3;
|
|
96081
|
-
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, killSignal: "SIGKILL", heartbeat: HEARTBEATS.dotnet, telemetryHandler });
|
|
96210
|
+
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, killSignal: "SIGKILL", heartbeat: HEARTBEATS.dotnet, telemetryHandler, analyzerTelemetryHandler });
|
|
96082
96211
|
if (result.error)
|
|
96083
96212
|
return { type: "error", message: result.error.message ?? "unknown error" };
|
|
96084
96213
|
const { success, error, analysisDiagnostics: diagnostics, vulnerablePaths, reachablePackageIds } = JSON.parse(await readFile6(outputFile, "utf-8")).result;
|
|
@@ -96126,12 +96255,12 @@ var DotnetCodeAwareVulnerabilityScanner = class _DotnetCodeAwareVulnerabilitySca
|
|
|
96126
96255
|
};
|
|
96127
96256
|
}
|
|
96128
96257
|
getPackagesExcludedUnrelatedToHeuristic() {
|
|
96129
|
-
return Object.entries(this.deps).filter(([_, { src, bin }]) => !src?.length && (!bin || bin.some((f2) => !
|
|
96258
|
+
return Object.entries(this.deps).filter(([_, { src, bin }]) => !src?.length && (!bin || bin.some((f2) => !existsSync7(f2)))).map(([packageId]) => this.depIdToPurl.get(packageId)?.name).filter((name2) => name2 !== void 0).map((name2) => name2);
|
|
96130
96259
|
}
|
|
96131
96260
|
};
|
|
96132
96261
|
async function extractNugetPackage(nupkgFilePath, packageName, version3, tmpDir) {
|
|
96133
96262
|
const packageDir = resolve9(tmpDir, packageName.toLowerCase(), version3.toLowerCase());
|
|
96134
|
-
if (
|
|
96263
|
+
if (existsSync7(packageDir)) {
|
|
96135
96264
|
const dllMatcher = (0, import_picomatch.default)("**/*.dll");
|
|
96136
96265
|
try {
|
|
96137
96266
|
const allFiles = await getFiles(packageDir);
|
|
@@ -96153,7 +96282,7 @@ async function extractNugetPackage(nupkgFilePath, packageName, version3, tmpDir)
|
|
|
96153
96282
|
return;
|
|
96154
96283
|
const entryPath = resolve9(packageDir, entry.entryName);
|
|
96155
96284
|
await mkdir5(dirname10(entryPath), { recursive: true });
|
|
96156
|
-
await
|
|
96285
|
+
await writeFile5(entryPath, entry.getData());
|
|
96157
96286
|
if (extname3(entryPath) === ".dll") {
|
|
96158
96287
|
files.push(entryPath);
|
|
96159
96288
|
}
|
|
@@ -96165,7 +96294,7 @@ async function extractNugetPackage(nupkgFilePath, packageName, version3, tmpDir)
|
|
|
96165
96294
|
}
|
|
96166
96295
|
async function downloadAndExtractNugetPackage(packageName, version3, tmpDir) {
|
|
96167
96296
|
const packageFile = resolve9(tmpDir, `${packageName.toLowerCase()}.${version3.toLowerCase()}.nupkg`);
|
|
96168
|
-
if (!
|
|
96297
|
+
if (!existsSync7(packageFile)) {
|
|
96169
96298
|
const packageUrl = getUrlForPackage(packageName, version3);
|
|
96170
96299
|
const success = await downloadFile(packageUrl, packageFile);
|
|
96171
96300
|
if (!success) {
|
|
@@ -96194,7 +96323,7 @@ function getNuGetLocalRepositoryPaths() {
|
|
|
96194
96323
|
// macOS/Linux NuGet cache
|
|
96195
96324
|
resolve9(home, ".local", "share", "NuGet", "v3-cache")
|
|
96196
96325
|
];
|
|
96197
|
-
return repositories.filter((repo) =>
|
|
96326
|
+
return repositories.filter((repo) => existsSync7(repo));
|
|
96198
96327
|
}
|
|
96199
96328
|
async function findNuGetPackageInLocalRepo(repo, packageName, version3, tmpDir) {
|
|
96200
96329
|
const dllMatcher = (0, import_picomatch.default)("**/*.dll");
|
|
@@ -96230,8 +96359,8 @@ async function convertSocketArtifacts(artifacts, tmpDir) {
|
|
|
96230
96359
|
// dist/whole-program-code-aware-vulnerability-scanner/java/java-code-aware-vulnerability-scanner.js
|
|
96231
96360
|
var import_lodash8 = __toESM(require_lodash(), 1);
|
|
96232
96361
|
var import_adm_zip2 = __toESM(require_adm_zip(), 1);
|
|
96233
|
-
import { existsSync as
|
|
96234
|
-
import { mkdir as mkdir6, readFile as readFile7, writeFile as
|
|
96362
|
+
import { existsSync as existsSync9 } from "node:fs";
|
|
96363
|
+
import { mkdir as mkdir6, readFile as readFile7, writeFile as writeFile6 } from "node:fs/promises";
|
|
96235
96364
|
import { basename as basename8, dirname as dirname11, resolve as resolve10 } from "node:path";
|
|
96236
96365
|
|
|
96237
96366
|
// ../../node_modules/.pnpm/cheerio@1.0.0-rc.12/node_modules/cheerio/lib/esm/options.js
|
|
@@ -109733,8 +109862,8 @@ var { root: root2 } = static_exports;
|
|
|
109733
109862
|
|
|
109734
109863
|
// ../utils/src/maven-utils.ts
|
|
109735
109864
|
var import_lodash7 = __toESM(require_lodash(), 1);
|
|
109736
|
-
import { existsSync as
|
|
109737
|
-
import { join as
|
|
109865
|
+
import { existsSync as existsSync8, readdirSync as readdirSync4, statSync as statSync4 } from "fs";
|
|
109866
|
+
import { join as join13 } from "path";
|
|
109738
109867
|
var { memoize } = import_lodash7.default;
|
|
109739
109868
|
var memoizedParseShellArgs = memoize(parseShellArgs);
|
|
109740
109869
|
async function getMavenCLIOpts() {
|
|
@@ -109804,13 +109933,13 @@ function getUrlForArtifact(repository, groupId, artifactId, type, classifier, ve
|
|
|
109804
109933
|
).href;
|
|
109805
109934
|
}
|
|
109806
109935
|
function getPathToProject(repository, groupId, artifactId) {
|
|
109807
|
-
return
|
|
109936
|
+
return join13(repository, groupId.replaceAll(".", "/"), artifactId);
|
|
109808
109937
|
}
|
|
109809
109938
|
function getPathToPackage(repository, groupId, artifactId, version3) {
|
|
109810
|
-
return
|
|
109939
|
+
return join13(getPathToProject(repository, groupId, artifactId), version3);
|
|
109811
109940
|
}
|
|
109812
109941
|
function getPathToArtifact(repository, groupId, artifactId, type, classifier, version3) {
|
|
109813
|
-
return
|
|
109942
|
+
return join13(
|
|
109814
109943
|
repository,
|
|
109815
109944
|
groupId.replaceAll(".", "/"),
|
|
109816
109945
|
artifactId,
|
|
@@ -110013,7 +110142,7 @@ var JavaCodeAwareVulnerabilityScanner = class _JavaCodeAwareVulnerabilityScanner
|
|
|
110013
110142
|
};
|
|
110014
110143
|
const inputFile = resolve10(tmpDir, "input.json");
|
|
110015
110144
|
const outputFile = resolve10(tmpDir, "output.json");
|
|
110016
|
-
await
|
|
110145
|
+
await writeFile6(inputFile, JSON.stringify(options));
|
|
110017
110146
|
const timeoutMs = Math.max(timeoutInSeconds * 1.5, timeoutInSeconds + 30) * 1e3;
|
|
110018
110147
|
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, killSignal: "SIGKILL", heartbeat: HEARTBEATS.java });
|
|
110019
110148
|
if (result.error)
|
|
@@ -110022,7 +110151,7 @@ var JavaCodeAwareVulnerabilityScanner = class _JavaCodeAwareVulnerabilityScanner
|
|
|
110022
110151
|
return packageIds?.map((packageId) => this.depIdToPurl.get(packageId)).filter((purl) => purl !== void 0).map((purl) => `${purl.namespace}:${purl.name}}`);
|
|
110023
110152
|
});
|
|
110024
110153
|
}
|
|
110025
|
-
async runAnalysis(vulnerabilities, heuristic, timeoutInSeconds, _experiment, telemetryHandler) {
|
|
110154
|
+
async runAnalysis(vulnerabilities, heuristic, timeoutInSeconds, _experiment, telemetryHandler, analyzerTelemetryHandler) {
|
|
110026
110155
|
try {
|
|
110027
110156
|
this.statusUpdater?.("Preparing code for analysis...");
|
|
110028
110157
|
const packagesToAnalyze = heuristic.getPackagesToAnalyze(vulnerabilities);
|
|
@@ -110031,12 +110160,12 @@ var JavaCodeAwareVulnerabilityScanner = class _JavaCodeAwareVulnerabilityScanner
|
|
|
110031
110160
|
const purl = this.depIdToPurl.get(packageId);
|
|
110032
110161
|
return purl && packagesToAnalyzeSet.has(`${purl.namespace}:${purl.name}}`);
|
|
110033
110162
|
}));
|
|
110034
|
-
return await this.actuallyRunAnalysis(vulnerabilities.flatMap((v) => v.vulnerabilityAccessPaths), timeoutInSeconds, filteredDeps, telemetryHandler);
|
|
110163
|
+
return await this.actuallyRunAnalysis(vulnerabilities.flatMap((v) => v.vulnerabilityAccessPaths), timeoutInSeconds, filteredDeps, telemetryHandler, analyzerTelemetryHandler);
|
|
110035
110164
|
} catch (e) {
|
|
110036
110165
|
return { type: "error", message: e.message };
|
|
110037
110166
|
}
|
|
110038
110167
|
}
|
|
110039
|
-
async actuallyRunAnalysis(vulnerabilityAccessPaths, timeoutInSeconds, filteredDeps, telemetryHandler) {
|
|
110168
|
+
async actuallyRunAnalysis(vulnerabilityAccessPaths, timeoutInSeconds, filteredDeps, telemetryHandler, analyzerTelemetryHandler) {
|
|
110040
110169
|
this.statusUpdater?.("Running analysis...");
|
|
110041
110170
|
return withTmpDirectory("java-run-analysis", async (tmpDir) => {
|
|
110042
110171
|
try {
|
|
@@ -110052,9 +110181,9 @@ var JavaCodeAwareVulnerabilityScanner = class _JavaCodeAwareVulnerabilityScanner
|
|
|
110052
110181
|
};
|
|
110053
110182
|
const inputFile = resolve10(tmpDir, "input.json");
|
|
110054
110183
|
const outputFile = resolve10(tmpDir, "output.json");
|
|
110055
|
-
await
|
|
110184
|
+
await writeFile6(inputFile, JSON.stringify(options));
|
|
110056
110185
|
const timeoutMs = Math.max(timeoutInSeconds * 1.5, timeoutInSeconds + 30) * 1e3;
|
|
110057
|
-
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, killSignal: "SIGKILL", heartbeat: HEARTBEATS.java, telemetryHandler });
|
|
110186
|
+
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, killSignal: "SIGKILL", heartbeat: HEARTBEATS.java, telemetryHandler, analyzerTelemetryHandler });
|
|
110058
110187
|
if (result.error)
|
|
110059
110188
|
return { type: "error", message: result.error.message ?? "unknown error" };
|
|
110060
110189
|
const { success, error, analysisDiagnostics: diagnostics, vulnerablePaths, reachablePackageIds } = JSON.parse(await readFile7(outputFile, "utf-8")).result;
|
|
@@ -110102,7 +110231,7 @@ var JavaCodeAwareVulnerabilityScanner = class _JavaCodeAwareVulnerabilityScanner
|
|
|
110102
110231
|
};
|
|
110103
110232
|
}
|
|
110104
110233
|
getPackagesExcludedUnrelatedToHeuristic() {
|
|
110105
|
-
return Object.entries(this.deps).filter(([_, { src, bin }]) => !src?.length && (!bin || bin.some((f2) => !
|
|
110234
|
+
return Object.entries(this.deps).filter(([_, { src, bin }]) => !src?.length && (!bin || bin.some((f2) => !existsSync9(f2)))).map(([packageId]) => this.depIdToPurl.get(packageId)).filter((purl) => purl !== void 0).map((purl) => `${purl.namespace}:${purl.name}}`);
|
|
110106
110235
|
}
|
|
110107
110236
|
};
|
|
110108
110237
|
async function convertDependencyChain2(dependencyChain, tmpDir) {
|
|
@@ -110146,14 +110275,14 @@ function getLocalRepositoryPaths() {
|
|
|
110146
110275
|
async function convertSocketArtifacts2(rootDir, artifacts, tmpDir) {
|
|
110147
110276
|
const pomMatcher = (0, import_picomatch2.default)("{*-*.,}pom{.xml,}");
|
|
110148
110277
|
const mavenInstalled = await isMavenInstalled();
|
|
110149
|
-
const localRepositories = getLocalRepositoryPaths().filter((repo) =>
|
|
110278
|
+
const localRepositories = getLocalRepositoryPaths().filter((repo) => existsSync9(repo.path));
|
|
110150
110279
|
const mavenLocalRepo = await findLocalRepository() ?? resolve10(process.env.HOME ?? "~", ".m2", "repository");
|
|
110151
110280
|
async function resolveArtifact(groupId, artifactId, type, classifier, version3, pomFile) {
|
|
110152
110281
|
for (const repo of localRepositories) {
|
|
110153
110282
|
switch (repo.type) {
|
|
110154
110283
|
case "maven": {
|
|
110155
110284
|
const artifactPath = getPathToArtifact(repo.path, groupId, artifactId, type, classifier, version3);
|
|
110156
|
-
if (
|
|
110285
|
+
if (existsSync9(artifactPath))
|
|
110157
110286
|
return artifactPath;
|
|
110158
110287
|
break;
|
|
110159
110288
|
}
|
|
@@ -110176,7 +110305,7 @@ async function convertSocketArtifacts2(rootDir, artifacts, tmpDir) {
|
|
|
110176
110305
|
const dependencyGetCmd = cmdt`mvn -f=${basename8(resolve10(rootDir, pomFile))} dependency:get -DgroupId=${groupId} -DartifactId=${artifactId} -Dpackaging=${type} -Dclassifier${classifier} -Dversion=${version3} -Dtransitive=false`;
|
|
110177
110306
|
await execNeverFail2(dependencyGetCmd, dirname11(resolve10(rootDir, pomFile)));
|
|
110178
110307
|
const mavenArtifact = getPathToArtifact(mavenLocalRepo, groupId, artifactId, type, classifier, version3);
|
|
110179
|
-
if (
|
|
110308
|
+
if (existsSync9(mavenArtifact))
|
|
110180
110309
|
return mavenArtifact;
|
|
110181
110310
|
} catch {
|
|
110182
110311
|
}
|
|
@@ -110228,19 +110357,19 @@ async function extractArchivesIfNeeded(tmpDir, apps, deps) {
|
|
|
110228
110357
|
|
|
110229
110358
|
// dist/whole-program-code-aware-vulnerability-scanner/js/js-code-aware-vulnerability-scanner.js
|
|
110230
110359
|
import { mkdtempSync } from "fs";
|
|
110231
|
-
import { cp as cp5, mkdir as mkdir8, rm as rm3, writeFile as
|
|
110232
|
-
import { tmpdir as
|
|
110233
|
-
import { join as
|
|
110360
|
+
import { cp as cp5, mkdir as mkdir8, rm as rm3, writeFile as writeFile8 } from "fs/promises";
|
|
110361
|
+
import { tmpdir as tmpdir4 } from "os";
|
|
110362
|
+
import { join as join15 } from "path";
|
|
110234
110363
|
|
|
110235
110364
|
// dist/whole-program-code-aware-vulnerability-scanner/js/dependency-preparation.js
|
|
110236
|
-
import { existsSync as
|
|
110365
|
+
import { existsSync as existsSync10 } from "fs";
|
|
110237
110366
|
import { resolve as resolve12 } from "path";
|
|
110238
110367
|
|
|
110239
110368
|
// dist/whole-program-code-aware-vulnerability-scanner/js/setup-npm-dependencies-for-analysis.js
|
|
110240
110369
|
var import_lodash9 = __toESM(require_lodash(), 1);
|
|
110241
110370
|
import { link, mkdir as mkdir7 } from "fs/promises";
|
|
110242
110371
|
import { availableParallelism } from "os";
|
|
110243
|
-
import { dirname as dirname12, join as
|
|
110372
|
+
import { dirname as dirname12, join as join14, resolve as resolve11 } from "path";
|
|
110244
110373
|
var { chunk } = import_lodash9.default;
|
|
110245
110374
|
var ROOT_PACKAGE_METADATA_NAME = "UNIQUE_ROOT_PACKAGE_METADATA_NAME";
|
|
110246
110375
|
async function setupDependenciesForAnalysis(subprojectDir, workspaceDir, directDependencies, artifactIdToArtifact) {
|
|
@@ -110309,7 +110438,7 @@ async function hardlinkPackages(placements) {
|
|
|
110309
110438
|
const files = await getFiles(dir, ["node_modules"]);
|
|
110310
110439
|
for (const sourceFile of files) {
|
|
110311
110440
|
const relativePath = sourceFile.slice(dir.length + 1);
|
|
110312
|
-
const targetFile =
|
|
110441
|
+
const targetFile = join14(targetPath, relativePath);
|
|
110313
110442
|
await mkdir7(dirname12(targetFile), { recursive: true });
|
|
110314
110443
|
await link(sourceFile, targetFile);
|
|
110315
110444
|
}
|
|
@@ -110553,7 +110682,7 @@ function tarjanAndCondensation(packageMetadatas) {
|
|
|
110553
110682
|
|
|
110554
110683
|
// dist/whole-program-code-aware-vulnerability-scanner/js/dependency-preparation.js
|
|
110555
110684
|
async function prepareNpmDependencies(subprojectDir, workspaceDir, artifactIdToArtifact, directDependencies, packageNamesToInstall) {
|
|
110556
|
-
if (
|
|
110685
|
+
if (existsSync10(resolve12(subprojectDir, "node_modules")))
|
|
110557
110686
|
return { failedPackages: [], installedPackages: [] };
|
|
110558
110687
|
const artifactToOriginal = /* @__PURE__ */ new Map();
|
|
110559
110688
|
const transitiveDependenciesToInstall = Object.fromEntries(Object.entries(artifactIdToArtifact).filter(([_, dep]) => packageNamesToInstall.includes(getPackageName(dep))).map(([depId, dep]) => {
|
|
@@ -110638,11 +110767,11 @@ function computePackagesOnVulnPath(vulnerabilities, { includeLeafPackages = fals
|
|
|
110638
110767
|
// dist/whole-program-code-aware-vulnerability-scanner/js/jelly-runner.js
|
|
110639
110768
|
var import_lodash10 = __toESM(require_lodash(), 1);
|
|
110640
110769
|
import assert4 from "assert";
|
|
110641
|
-
import { readFile as readFile8, realpath as realpath2, rm as rm2, writeFile as
|
|
110770
|
+
import { readFile as readFile8, realpath as realpath2, rm as rm2, writeFile as writeFile7 } from "fs/promises";
|
|
110642
110771
|
import { relative as relative6, resolve as resolve13 } from "path";
|
|
110643
110772
|
var { map: map2, uniq: uniq4 } = import_lodash10.default;
|
|
110644
110773
|
var PRINT_JELLY_COMMAND = false;
|
|
110645
|
-
async function runJellyAnalysis(mainProjectRoot, projectRoot, jellyOptions, reachabilityAnalysisOptions, timeoutInSeconds, vulnerabilities, experiment, telemetryHandler) {
|
|
110774
|
+
async function runJellyAnalysis(mainProjectRoot, projectRoot, jellyOptions, reachabilityAnalysisOptions, timeoutInSeconds, vulnerabilities, experiment, telemetryHandler, analyzerTelemetryHandler) {
|
|
110646
110775
|
const tmpFolder = await createTmpDirectory("jelly-analysis");
|
|
110647
110776
|
try {
|
|
110648
110777
|
const filesToAnalyze = reachabilityAnalysisOptions.entryPoints ?? [projectRoot];
|
|
@@ -110660,7 +110789,7 @@ async function runJellyAnalysis(mainProjectRoot, projectRoot, jellyOptions, reac
|
|
|
110660
110789
|
const callStackFile = resolve13(tmpFolder, "call-stacks.json");
|
|
110661
110790
|
const affectedPackagesFile = resolve13(tmpFolder, "affected-packages.json");
|
|
110662
110791
|
const logFile = reachabilityAnalysisOptions.analysisLogFile ?? (reachabilityAnalysisOptions.printLogFile && resolve13(projectRoot, "js-analysis.log"));
|
|
110663
|
-
await
|
|
110792
|
+
await writeFile7(vulnerabilitiesFile, JSON.stringify(vulnerabilitiesInJellyFormat));
|
|
110664
110793
|
const useLazy = experiment === "LAZY_EXPERIMENT" || reachabilityAnalysisOptions.lazy;
|
|
110665
110794
|
const { includePackages } = jellyOptions;
|
|
110666
110795
|
const jellyCmd = cmdt`
|
|
@@ -110690,7 +110819,8 @@ async function runJellyAnalysis(mainProjectRoot, projectRoot, jellyOptions, reac
|
|
|
110690
110819
|
timeout: timeoutInSeconds * 1e3 * 1.5,
|
|
110691
110820
|
killSignal: "SIGKILL",
|
|
110692
110821
|
heartbeat: HEARTBEATS.js,
|
|
110693
|
-
telemetryHandler
|
|
110822
|
+
telemetryHandler,
|
|
110823
|
+
analyzerTelemetryHandler
|
|
110694
110824
|
}
|
|
110695
110825
|
);
|
|
110696
110826
|
if (reachabilityAnalysisOptions.printLogFile)
|
|
@@ -110724,7 +110854,7 @@ async function runJellyAnalysis(mainProjectRoot, projectRoot, jellyOptions, reac
|
|
|
110724
110854
|
await rm2(tmpFolder, { recursive: true });
|
|
110725
110855
|
}
|
|
110726
110856
|
}
|
|
110727
|
-
async function runJellyPhantomDependencyAnalysis(projectRoot, options, telemetryHandler) {
|
|
110857
|
+
async function runJellyPhantomDependencyAnalysis(projectRoot, options, telemetryHandler, analyzerTelemetryHandler) {
|
|
110728
110858
|
const tmpFolder = await createTmpDirectory("jelly-analysis");
|
|
110729
110859
|
try {
|
|
110730
110860
|
const jellyExecutable = ToolPathResolver.jellyPath;
|
|
@@ -110736,14 +110866,15 @@ async function runJellyPhantomDependencyAnalysis(projectRoot, options, telemetry
|
|
|
110736
110866
|
timeout: options.timeoutSeconds.allVulnRuns * 1e3,
|
|
110737
110867
|
killSignal: "SIGKILL",
|
|
110738
110868
|
heartbeat: HEARTBEATS.js,
|
|
110739
|
-
telemetryHandler
|
|
110869
|
+
telemetryHandler,
|
|
110870
|
+
analyzerTelemetryHandler
|
|
110740
110871
|
});
|
|
110741
110872
|
return JSON.parse(await readFile8(reachablePackagesFile, "utf-8")).packages;
|
|
110742
110873
|
} finally {
|
|
110743
110874
|
await rm2(tmpFolder, { recursive: true });
|
|
110744
110875
|
}
|
|
110745
110876
|
}
|
|
110746
|
-
async function runJellyImportReachabilityAnalysis(mainProjectRoot, projectRoot, vulnerabilities, options, telemetryHandler) {
|
|
110877
|
+
async function runJellyImportReachabilityAnalysis(mainProjectRoot, projectRoot, vulnerabilities, options, telemetryHandler, analyzerTelemetryHandler) {
|
|
110747
110878
|
const tmpFolder = await createTmpDirectory("jelly-analysis");
|
|
110748
110879
|
try {
|
|
110749
110880
|
const includePackages = computePackagesOnVulnPath(vulnerabilities, { includeLeafPackages: true });
|
|
@@ -110758,7 +110889,8 @@ async function runJellyImportReachabilityAnalysis(mainProjectRoot, projectRoot,
|
|
|
110758
110889
|
timeout: options.timeoutSeconds.allVulnRuns * 1e3,
|
|
110759
110890
|
killSignal: "SIGKILL",
|
|
110760
110891
|
heartbeat: HEARTBEATS.js,
|
|
110761
|
-
telemetryHandler
|
|
110892
|
+
telemetryHandler,
|
|
110893
|
+
analyzerTelemetryHandler
|
|
110762
110894
|
});
|
|
110763
110895
|
return JSON.parse(await readFile8(reachableModulesFile, "utf-8"));
|
|
110764
110896
|
} finally {
|
|
@@ -110813,11 +110945,11 @@ var JSCodeAwareVulnerabilityScanner = class _JSCodeAwareVulnerabilityScanner {
|
|
|
110813
110945
|
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);
|
|
110814
110946
|
this.packagesExcludedUnrelatedToHeuristic = failedPackages.map((p) => getPackageName(p));
|
|
110815
110947
|
}
|
|
110816
|
-
async runAnalysis(vulnerabilities, heuristic, timeoutInSeconds, experiment, telemetryHandler) {
|
|
110948
|
+
async runAnalysis(vulnerabilities, heuristic, timeoutInSeconds, experiment, telemetryHandler, analyzerTelemetryHandler) {
|
|
110817
110949
|
const analysisOptionsFromHeuristic = heuristic.getOptions(vulnerabilities);
|
|
110818
110950
|
try {
|
|
110819
110951
|
analysisOptionsFromHeuristic.approx = process.env.JELLY_APPROX === "true" || experiment === "JELLY_APPROX";
|
|
110820
|
-
const analysisRes = await runJellyAnalysis(this.mainProjectDir, this.projectDir, analysisOptionsFromHeuristic, this.options, timeoutInSeconds, vulnerabilities, experiment, telemetryHandler);
|
|
110952
|
+
const analysisRes = await runJellyAnalysis(this.mainProjectDir, this.projectDir, analysisOptionsFromHeuristic, this.options, timeoutInSeconds, vulnerabilities, experiment, telemetryHandler, analyzerTelemetryHandler);
|
|
110821
110953
|
const { analysisDiagnostics: diagnostics, matches } = analysisRes;
|
|
110822
110954
|
return {
|
|
110823
110955
|
type: "success",
|
|
@@ -110855,7 +110987,7 @@ var JSCodeAwareVulnerabilityScanner = class _JSCodeAwareVulnerabilityScanner {
|
|
|
110855
110987
|
}
|
|
110856
110988
|
static async runOnAlreadyDownloadedPackages(packages, vulnerability, reachabilityAnalysisOptions, baseHeuristic = heuristics.ALL_PACKAGES) {
|
|
110857
110989
|
return await withTmpDirectory("runOnAlreadyDownloadedPackagesNpm", async (tmpDir) => {
|
|
110858
|
-
const nodeModulesDir =
|
|
110990
|
+
const nodeModulesDir = join15(tmpDir, "node_modules");
|
|
110859
110991
|
await mkdir8(nodeModulesDir);
|
|
110860
110992
|
let firstPackageName;
|
|
110861
110993
|
const fileMappings = /* @__PURE__ */ new Map();
|
|
@@ -110871,14 +111003,14 @@ var JSCodeAwareVulnerabilityScanner = class _JSCodeAwareVulnerabilityScanner {
|
|
|
110871
111003
|
firstPackageName = nameFromPackageJson;
|
|
110872
111004
|
else
|
|
110873
111005
|
otherPackageNames.push(nameFromPackageJson);
|
|
110874
|
-
const targetDirectory =
|
|
111006
|
+
const targetDirectory = join15(nodeModulesDir, nameFromPackageJson);
|
|
110875
111007
|
logger.info(`Copying ${packagePath} to ${targetDirectory}`);
|
|
110876
111008
|
await cp5(packagePath, targetDirectory, { recursive: true });
|
|
110877
111009
|
fileMappings.set(targetDirectory, packagePath);
|
|
110878
111010
|
}
|
|
110879
111011
|
if (!firstPackageName)
|
|
110880
111012
|
throw new Error("No packages provided to run the analysis on");
|
|
110881
|
-
const projectDir =
|
|
111013
|
+
const projectDir = join15(tmpDir, "node_modules", firstPackageName);
|
|
110882
111014
|
const scanner = new _JSCodeAwareVulnerabilityScanner(projectDir, projectDir, reachabilityAnalysisOptions);
|
|
110883
111015
|
logger.info(`Started analysis of ${projectDir}`);
|
|
110884
111016
|
const result = await scanner.runAnalysis([vulnerability], heuristics.createIncludePackagesHeuristic(otherPackageNames, baseHeuristic.getOptions([vulnerability])), reachabilityAnalysisOptions.timeoutSeconds.allVulnRuns);
|
|
@@ -110898,12 +111030,12 @@ var JSCodeAwareVulnerabilityScanner = class _JSCodeAwareVulnerabilityScanner {
|
|
|
110898
111030
|
static async runOnDependencyChain(dependencyChain, vulnerability, reachabilityAnalysisOptions, baseHeuristic = heuristics.ALL_PACKAGES) {
|
|
110899
111031
|
const [first2, ...rest] = dependencyChain;
|
|
110900
111032
|
const packageJSONContent = buildPackageJSONForDependencyChain(first2, rest);
|
|
110901
|
-
const tmpDir = mkdtempSync(
|
|
110902
|
-
const packageJsonFileLoc =
|
|
110903
|
-
await
|
|
111033
|
+
const tmpDir = mkdtempSync(join15(tmpdir4(), "run-on-dependency-chain"));
|
|
111034
|
+
const packageJsonFileLoc = join15(tmpDir, "package.json");
|
|
111035
|
+
await writeFile8(packageJsonFileLoc, JSON.stringify(packageJSONContent));
|
|
110904
111036
|
await exec2("npm install -f --ignore-scripts", tmpDir);
|
|
110905
111037
|
const restWithoutLast = rest.slice(0, -1);
|
|
110906
|
-
const projectDir =
|
|
111038
|
+
const projectDir = join15(tmpDir, "node_modules", first2.packageName);
|
|
110907
111039
|
const scanner = new _JSCodeAwareVulnerabilityScanner(tmpDir, projectDir, reachabilityAnalysisOptions);
|
|
110908
111040
|
const result = await scanner.runAnalysis([vulnerability], heuristics.createIncludePackagesHeuristic(restWithoutLast.map((p) => p.packageName), baseHeuristic.getOptions([vulnerability])), reachabilityAnalysisOptions.timeoutSeconds.allVulnRuns);
|
|
110909
111041
|
await rm3(tmpDir, { recursive: true, force: true });
|
|
@@ -110949,7 +111081,7 @@ function transformSourceLocations(fileMappings, detectedOccurrences) {
|
|
|
110949
111081
|
const matchingFile = [...fileMappings.keys()].find((file) => call.sourceLocation.filename.includes(file));
|
|
110950
111082
|
if (!matchingFile)
|
|
110951
111083
|
return;
|
|
110952
|
-
const newFilePath =
|
|
111084
|
+
const newFilePath = join15(fileMappings.get(matchingFile), call.sourceLocation.filename.split(matchingFile)[1]);
|
|
110953
111085
|
call.sourceLocation.filename = newFilePath;
|
|
110954
111086
|
});
|
|
110955
111087
|
});
|
|
@@ -110959,10 +111091,10 @@ function transformSourceLocations(fileMappings, detectedOccurrences) {
|
|
|
110959
111091
|
// dist/whole-program-code-aware-vulnerability-scanner/go/go-code-aware-vulnerability-scanner.js
|
|
110960
111092
|
var import_lodash11 = __toESM(require_lodash(), 1);
|
|
110961
111093
|
import assert5 from "assert";
|
|
110962
|
-
import { existsSync as
|
|
111094
|
+
import { existsSync as existsSync11, createReadStream as createReadStream2, createWriteStream as createWriteStream3 } from "fs";
|
|
110963
111095
|
import { readFile as readFile9, rm as rm4, cp as cp6 } from "fs/promises";
|
|
110964
111096
|
import zlib2 from "zlib";
|
|
110965
|
-
import { join as
|
|
111097
|
+
import { join as join16, resolve as resolve14, sep as sep3 } from "path";
|
|
110966
111098
|
|
|
110967
111099
|
// dist/whole-program-code-aware-vulnerability-scanner/go/heuristics.js
|
|
110968
111100
|
var GoanaHeuristics = {
|
|
@@ -110996,22 +111128,22 @@ var GoCodeAwareVulnerabilityScanner = class {
|
|
|
110996
111128
|
this.projectDir = projectDir;
|
|
110997
111129
|
this.options = options;
|
|
110998
111130
|
}
|
|
110999
|
-
async runAnalysis(vulns, heuristic, timeoutInSeconds, _experiment, telemetryHandler) {
|
|
111131
|
+
async runAnalysis(vulns, heuristic, timeoutInSeconds, _experiment, telemetryHandler, analyzerTelemetryHandler) {
|
|
111000
111132
|
logger.info("Started instantiating Go code-aware analysis");
|
|
111001
|
-
if (!
|
|
111133
|
+
if (!existsSync11(join16(this.projectDir, "go.mod")))
|
|
111002
111134
|
throw new Error("go.mod file not found in the project directory");
|
|
111003
111135
|
const { memoryLimitInMB } = this.options;
|
|
111004
111136
|
const tmpDir = await createTmpDirectory("goana-output");
|
|
111005
|
-
const vulnsOutputFile =
|
|
111006
|
-
const diagnosticsOutputFile =
|
|
111007
|
-
const reachedModulesOutputFile =
|
|
111137
|
+
const vulnsOutputFile = join16(tmpDir, "vulns.json");
|
|
111138
|
+
const diagnosticsOutputFile = join16(tmpDir, "diagnostics.json");
|
|
111139
|
+
const reachedModulesOutputFile = join16(tmpDir, "reached-modules.json");
|
|
111008
111140
|
try {
|
|
111009
111141
|
const binaryPath = ToolPathResolver.getGoanaBinaryPath(process.platform, process.arch);
|
|
111010
111142
|
if (!await exists(binaryPath))
|
|
111011
111143
|
throw new Error(`goana binary not found at '${binaryPath}'`);
|
|
111012
|
-
await pipeline2(createReadStream2(binaryPath), zlib2.createGunzip(), createWriteStream3(
|
|
111144
|
+
await pipeline2(createReadStream2(binaryPath), zlib2.createGunzip(), createWriteStream3(join16(tmpDir, "goana"), { mode: 493 }));
|
|
111013
111145
|
const vulnAccPaths = uniq5(vulns.flatMap((v) => v.vulnerabilityAccessPaths));
|
|
111014
|
-
const { error, stderr } = await execNeverFail2(cmdt`${
|
|
111146
|
+
const { error, stderr } = await execNeverFail2(cmdt`${join16(tmpDir, "goana")}
|
|
111015
111147
|
-output-vulnerabilities ${vulnsOutputFile}
|
|
111016
111148
|
-output-diagnostics ${diagnosticsOutputFile}
|
|
111017
111149
|
-output-reached-modules ${reachedModulesOutputFile}
|
|
@@ -111021,7 +111153,8 @@ var GoCodeAwareVulnerabilityScanner = class {
|
|
|
111021
111153
|
killSignal: "SIGKILL",
|
|
111022
111154
|
env: memoryLimitInMB ? { ...process.env, GOMEMLIMIT: `${memoryLimitInMB}MiB` } : void 0,
|
|
111023
111155
|
heartbeat: HEARTBEATS.go,
|
|
111024
|
-
telemetryHandler
|
|
111156
|
+
telemetryHandler,
|
|
111157
|
+
analyzerTelemetryHandler
|
|
111025
111158
|
});
|
|
111026
111159
|
if (error) {
|
|
111027
111160
|
logger.error("Error running Go code-aware analysis", error);
|
|
@@ -111072,7 +111205,7 @@ ${stderr}`);
|
|
|
111072
111205
|
try {
|
|
111073
111206
|
await cp6(Dir, projectDir, { recursive: true });
|
|
111074
111207
|
const projGoMod = resolve14(projectDir, "go.mod");
|
|
111075
|
-
if (!
|
|
111208
|
+
if (!existsSync11(projGoMod))
|
|
111076
111209
|
await cp6(GoMod, projGoMod);
|
|
111077
111210
|
await exec2(cmdt`chmod --recursive +w ${projectDir}`);
|
|
111078
111211
|
await runGoModTidy(projectDir);
|
|
@@ -111100,7 +111233,7 @@ ${stderr}`);
|
|
|
111100
111233
|
}
|
|
111101
111234
|
static async runOnAlreadyDownloadedPackages(packages, vuln, options) {
|
|
111102
111235
|
for (const pkg of packages)
|
|
111103
|
-
assert5(
|
|
111236
|
+
assert5(existsSync11(join16(pkg, "go.mod")), `${pkg} does not contain a go.mod file`);
|
|
111104
111237
|
const [app, ...dependencies] = packages;
|
|
111105
111238
|
const projectDir = await createTmpDirectory("go-run-on-already-downloaded-packages-");
|
|
111106
111239
|
try {
|
|
@@ -111138,8 +111271,8 @@ ${stderr}`);
|
|
|
111138
111271
|
|
|
111139
111272
|
// dist/whole-program-code-aware-vulnerability-scanner/rust/rust-code-aware-vulnerability-scanner.js
|
|
111140
111273
|
var import_lodash12 = __toESM(require_lodash(), 1);
|
|
111141
|
-
import { existsSync as
|
|
111142
|
-
import { readFile as readFile10, writeFile as
|
|
111274
|
+
import { existsSync as existsSync12 } from "node:fs";
|
|
111275
|
+
import { readFile as readFile10, writeFile as writeFile9 } from "node:fs/promises";
|
|
111143
111276
|
import { basename as basename10, dirname as dirname14, resolve as resolve15 } from "node:path";
|
|
111144
111277
|
|
|
111145
111278
|
// dist/whole-program-code-aware-vulnerability-scanner/rust/heuristics.js
|
|
@@ -111239,7 +111372,7 @@ var RustCodeAwareVulnerabilityScanner = class _RustCodeAwareVulnerabilityScanner
|
|
|
111239
111372
|
let appCrateName;
|
|
111240
111373
|
const appSrc = [];
|
|
111241
111374
|
const dependencies = {};
|
|
111242
|
-
const appCrateInfo =
|
|
111375
|
+
const appCrateInfo = existsSync12(cargoTomlPath) ? await getCrateInfo(cargoTomlPath) : void 0;
|
|
111243
111376
|
if (appCrateInfo?.name) {
|
|
111244
111377
|
appSrc.push(...i([appCrateInfo.lib, ...appCrateInfo.examples ?? [], ...appCrateInfo.tests ?? []]));
|
|
111245
111378
|
appCrateName = appCrateInfo.name.replaceAll("-", "_");
|
|
@@ -111351,7 +111484,7 @@ var RustCodeAwareVulnerabilityScanner = class _RustCodeAwareVulnerabilityScanner
|
|
|
111351
111484
|
const appDependencies = {};
|
|
111352
111485
|
if (rustDependencyChain[0].src && rustDependencyChain[0].src.length > 0) {
|
|
111353
111486
|
const appCargoTomlPath = resolve15(rustDependencyChain[0].src[0], "..", "Cargo.toml");
|
|
111354
|
-
if (
|
|
111487
|
+
if (existsSync12(appCargoTomlPath)) {
|
|
111355
111488
|
const cargoTomlDeps = await extractDependenciesFromCargoToml(appCargoTomlPath);
|
|
111356
111489
|
for (const [packageName, names] of cargoTomlDeps.entries()) {
|
|
111357
111490
|
const depId = packageNameToId.get(packageName);
|
|
@@ -111378,7 +111511,7 @@ var RustCodeAwareVulnerabilityScanner = class _RustCodeAwareVulnerabilityScanner
|
|
|
111378
111511
|
const dependencies = {};
|
|
111379
111512
|
if (dep.src && dep.src.length > 0) {
|
|
111380
111513
|
const depCargoTomlPath = resolve15(dep.src[0], "..", "Cargo.toml");
|
|
111381
|
-
if (
|
|
111514
|
+
if (existsSync12(depCargoTomlPath)) {
|
|
111382
111515
|
const cargoTomlDeps = await extractDependenciesFromCargoToml(depCargoTomlPath);
|
|
111383
111516
|
for (const [packageName, names] of cargoTomlDeps.entries()) {
|
|
111384
111517
|
const transDepId = packageNameToId.get(packageName);
|
|
@@ -111418,7 +111551,7 @@ var RustCodeAwareVulnerabilityScanner = class _RustCodeAwareVulnerabilityScanner
|
|
|
111418
111551
|
};
|
|
111419
111552
|
const inputFile = resolve15(tmpDir, "input.json");
|
|
111420
111553
|
const outputFile = resolve15(tmpDir, "output.json");
|
|
111421
|
-
await
|
|
111554
|
+
await writeFile9(inputFile, JSON.stringify(options));
|
|
111422
111555
|
const timeoutMs = Math.max(timeoutInSeconds * 1.5, timeoutInSeconds + 30) * 1e3;
|
|
111423
111556
|
const result = await execNeverFail2(cmdt`${await getNodeExecutable(ToolPathResolver.nodeExecutablePath)} ${getClassGraphAnalysisCliPath()} runRustDirectDependencyAnalysis -i ${inputFile} -o ${outputFile} --tree-sitter-rust ${getTreeSitterRustPath()}`, void 0, { timeout: timeoutMs, killSignal: "SIGKILL", heartbeat: HEARTBEATS.rust });
|
|
111424
111557
|
if (result.error)
|
|
@@ -111427,7 +111560,7 @@ var RustCodeAwareVulnerabilityScanner = class _RustCodeAwareVulnerabilityScanner
|
|
|
111427
111560
|
return packageIds?.map((packageId) => this.depIdToPurl.get(packageId)?.name).filter((name2) => name2 !== void 0).map((name2) => name2);
|
|
111428
111561
|
});
|
|
111429
111562
|
}
|
|
111430
|
-
async runAnalysis(vulnerabilities, heuristic, timeoutInSeconds, _experiment, telemetryHandler) {
|
|
111563
|
+
async runAnalysis(vulnerabilities, heuristic, timeoutInSeconds, _experiment, telemetryHandler, analyzerTelemetryHandler) {
|
|
111431
111564
|
try {
|
|
111432
111565
|
this.statusUpdater?.("Preparing code for analysis...");
|
|
111433
111566
|
const packagesToAnalyze = heuristic.getPackagesToAnalyze(vulnerabilities);
|
|
@@ -111436,12 +111569,12 @@ var RustCodeAwareVulnerabilityScanner = class _RustCodeAwareVulnerabilityScanner
|
|
|
111436
111569
|
const purl = this.depIdToPurl.get(packageId);
|
|
111437
111570
|
return purl?.name && packagesToAnalyzeSet.has(purl.name);
|
|
111438
111571
|
}));
|
|
111439
|
-
return await this.actuallyRunAnalysis(vulnerabilities.flatMap((v) => v.vulnerabilityAccessPaths), timeoutInSeconds, filteredDeps, telemetryHandler);
|
|
111572
|
+
return await this.actuallyRunAnalysis(vulnerabilities.flatMap((v) => v.vulnerabilityAccessPaths), timeoutInSeconds, filteredDeps, telemetryHandler, analyzerTelemetryHandler);
|
|
111440
111573
|
} catch (e) {
|
|
111441
111574
|
return { type: "error", message: e.message };
|
|
111442
111575
|
}
|
|
111443
111576
|
}
|
|
111444
|
-
async actuallyRunAnalysis(vulnerabilityAccessPaths, timeoutInSeconds, filteredDeps, telemetryHandler) {
|
|
111577
|
+
async actuallyRunAnalysis(vulnerabilityAccessPaths, timeoutInSeconds, filteredDeps, telemetryHandler, analyzerTelemetryHandler) {
|
|
111445
111578
|
this.statusUpdater?.("Running analysis...");
|
|
111446
111579
|
return withTmpDirectory("rust-run-analysis", async (tmpDir) => {
|
|
111447
111580
|
const effectiveTimeout = timeoutInSeconds;
|
|
@@ -111454,9 +111587,9 @@ var RustCodeAwareVulnerabilityScanner = class _RustCodeAwareVulnerabilityScanner
|
|
|
111454
111587
|
};
|
|
111455
111588
|
const inputFile = resolve15(tmpDir, "input.json");
|
|
111456
111589
|
const outputFile = resolve15(tmpDir, "output.json");
|
|
111457
|
-
await
|
|
111590
|
+
await writeFile9(inputFile, JSON.stringify(options));
|
|
111458
111591
|
const timeoutMs = Math.max(effectiveTimeout * 1.5, effectiveTimeout + 30) * 1e3;
|
|
111459
|
-
const result = await execNeverFail2(cmdt`${await getNodeExecutable(ToolPathResolver.nodeExecutablePath)} ${getClassGraphAnalysisCliPath()} runRustReachabilityAnalysis -i ${inputFile} -o ${outputFile} --tree-sitter-rust ${getTreeSitterRustPath()}`, void 0, { timeout: timeoutMs, killSignal: "SIGKILL", heartbeat: HEARTBEATS.rust, telemetryHandler });
|
|
111592
|
+
const result = await execNeverFail2(cmdt`${await getNodeExecutable(ToolPathResolver.nodeExecutablePath)} ${getClassGraphAnalysisCliPath()} runRustReachabilityAnalysis -i ${inputFile} -o ${outputFile} --tree-sitter-rust ${getTreeSitterRustPath()}`, void 0, { timeout: timeoutMs, killSignal: "SIGKILL", heartbeat: HEARTBEATS.rust, telemetryHandler, analyzerTelemetryHandler });
|
|
111460
111593
|
if (result.error)
|
|
111461
111594
|
return { type: "error", message: result.error.message ?? "unknown error" };
|
|
111462
111595
|
const { success, error, analysisDiagnostics: diagnostics, vulnerablePaths, reachablePackageIds } = JSON.parse(await readFile10(outputFile, "utf-8")).result;
|
|
@@ -111507,7 +111640,7 @@ var RustCodeAwareVulnerabilityScanner = class _RustCodeAwareVulnerabilityScanner
|
|
|
111507
111640
|
};
|
|
111508
111641
|
}
|
|
111509
111642
|
getPackagesExcludedUnrelatedToHeuristic() {
|
|
111510
|
-
return Object.entries(this.deps).filter(([_, { src, bin }]) => !src?.length && (!bin || bin.some((f2) => !
|
|
111643
|
+
return Object.entries(this.deps).filter(([_, { src, bin }]) => !src?.length && (!bin || bin.some((f2) => !existsSync12(f2)))).map(([packageId]) => this.depIdToPurl.get(packageId)?.name).filter((name2) => name2 !== void 0).map((name2) => name2);
|
|
111511
111644
|
}
|
|
111512
111645
|
};
|
|
111513
111646
|
async function convertDependencyChain3(dependencyChain, tmpDir) {
|
|
@@ -111539,7 +111672,7 @@ function getCargoLocalRepositoryPaths() {
|
|
|
111539
111672
|
// Cargo git dependencies
|
|
111540
111673
|
{ path: resolve15(cargoHome, "git", "checkouts"), type: "git" }
|
|
111541
111674
|
];
|
|
111542
|
-
return repositories.filter((repo) =>
|
|
111675
|
+
return repositories.filter((repo) => existsSync12(repo.path));
|
|
111543
111676
|
}
|
|
111544
111677
|
async function findCargoPackageInLocalRepo(repo, packageName, version3, tmpDir) {
|
|
111545
111678
|
try {
|
|
@@ -111579,10 +111712,10 @@ async function findCargoPackageInLocalRepo(repo, packageName, version3, tmpDir)
|
|
|
111579
111712
|
}
|
|
111580
111713
|
async function extractCargoCrate(crateFilePath, packageName, version3, tmpDir) {
|
|
111581
111714
|
const packageDir = resolve15(tmpDir, `${packageName}-${version3}`);
|
|
111582
|
-
if (
|
|
111715
|
+
if (existsSync12(packageDir)) {
|
|
111583
111716
|
try {
|
|
111584
111717
|
const cargoTomlPath = resolve15(packageDir, "Cargo.toml");
|
|
111585
|
-
if (
|
|
111718
|
+
if (existsSync12(cargoTomlPath)) {
|
|
111586
111719
|
const depCrateInfo = await getCrateInfo(cargoTomlPath);
|
|
111587
111720
|
return [depCrateInfo.lib];
|
|
111588
111721
|
}
|
|
@@ -111602,7 +111735,7 @@ async function extractCargoCrate(crateFilePath, packageName, version3, tmpDir) {
|
|
|
111602
111735
|
}
|
|
111603
111736
|
async function downloadAndExtractCargoCrate(packageName, version3, tmpDir) {
|
|
111604
111737
|
const packageFile = resolve15(tmpDir, `${packageName}-${version3}.crate`);
|
|
111605
|
-
if (!
|
|
111738
|
+
if (!existsSync12(packageFile)) {
|
|
111606
111739
|
const packageUrl = getUrlForCrate(packageName, version3);
|
|
111607
111740
|
const success = await downloadFile(packageUrl, packageFile);
|
|
111608
111741
|
if (!success) {
|
|
@@ -111635,7 +111768,7 @@ async function convertSocketArtifacts3(artifacts, tmpDir, artifactNameToId) {
|
|
|
111635
111768
|
const dependencies = {};
|
|
111636
111769
|
if (src && src.length > 0) {
|
|
111637
111770
|
const cargoTomlPath = resolve15(dirname14(src[0]), "Cargo.toml");
|
|
111638
|
-
if (
|
|
111771
|
+
if (existsSync12(cargoTomlPath)) {
|
|
111639
111772
|
const cargoTomlDeps = await extractDependenciesFromCargoToml(cargoTomlPath);
|
|
111640
111773
|
for (const [packageName, names] of cargoTomlDeps.entries()) {
|
|
111641
111774
|
const depArtifactId = artifactNameToId.get(packageName);
|
|
@@ -111846,7 +111979,7 @@ async function runWithJSHeuristics(cb) {
|
|
|
111846
111979
|
function getCurrentCommitHash(project) {
|
|
111847
111980
|
const headShaPath = resolve16(COANA_REPOS_PATH(), project, "HEAD_SHA");
|
|
111848
111981
|
try {
|
|
111849
|
-
const content =
|
|
111982
|
+
const content = readFileSync4(headShaPath, "utf-8").trim();
|
|
111850
111983
|
const colonIndex = content.indexOf(":");
|
|
111851
111984
|
return colonIndex !== -1 ? content.slice(colonIndex + 1) : content;
|
|
111852
111985
|
} catch {
|
|
@@ -111927,7 +112060,7 @@ var PythonCodeAwareVulnerabilityScanner = class {
|
|
|
111927
112060
|
logger.info("Done setting up virtual environment");
|
|
111928
112061
|
}
|
|
111929
112062
|
}
|
|
111930
|
-
async runAnalysis(vulns, heuristic, timeoutInSeconds, _experiment, telemetryHandler) {
|
|
112063
|
+
async runAnalysis(vulns, heuristic, timeoutInSeconds, _experiment, telemetryHandler, analyzerTelemetryHandler) {
|
|
111931
112064
|
if (!this.virtualEnvInfo)
|
|
111932
112065
|
throw new Error("Virtual environment not set up");
|
|
111933
112066
|
this.mambaladeVenvPath ??= await setupMambalade();
|
|
@@ -111954,10 +112087,10 @@ var PythonCodeAwareVulnerabilityScanner = class {
|
|
|
111954
112087
|
const packagesToExclude = heuristic.getPackagesToExcludeFromAnalysis?.(vulns);
|
|
111955
112088
|
const vulnAccPaths = sortedUniq(vulns.flatMap((v) => v.vulnerabilityAccessPaths).sort());
|
|
111956
112089
|
const tmpDir = await createTmpDirectory("coana-mambalade-output");
|
|
111957
|
-
const vulnsOutputFile =
|
|
111958
|
-
const diagnosticsOutputFile =
|
|
111959
|
-
const reachedPackagesOutputFile =
|
|
111960
|
-
const pythonExecutable =
|
|
112090
|
+
const vulnsOutputFile = join17(tmpDir, "vulns.json");
|
|
112091
|
+
const diagnosticsOutputFile = join17(tmpDir, "diagnostics.json");
|
|
112092
|
+
const reachedPackagesOutputFile = join17(tmpDir, "reached-packages.json");
|
|
112093
|
+
const pythonExecutable = join17(this.mambaladeVenvPath, "bin", "python");
|
|
111961
112094
|
const mambaladeArgs = cmdt`\
|
|
111962
112095
|
${pythonExecutable} - ${reachabilityAnalysisOptions.memoryLimitInMB ?? 0}
|
|
111963
112096
|
--vulnerabilities ${vulnAccPaths}
|
|
@@ -111982,7 +112115,8 @@ var PythonCodeAwareVulnerabilityScanner = class {
|
|
|
111982
112115
|
timeout: (timeoutInSeconds * 1.5 + 15) * 1e3,
|
|
111983
112116
|
killSignal: "SIGKILL",
|
|
111984
112117
|
heartbeat: HEARTBEATS.python,
|
|
111985
|
-
telemetryHandler
|
|
112118
|
+
telemetryHandler,
|
|
112119
|
+
analyzerTelemetryHandler
|
|
111986
112120
|
});
|
|
111987
112121
|
logger.debug("Done running mambalade");
|
|
111988
112122
|
const errors = stderr.split("\n").filter((line) => line.startsWith("ERROR:") && !/^ERROR: Excluded distribution/.test(line));
|
|
@@ -112059,7 +112193,7 @@ ${msg}`;
|
|
|
112059
112193
|
static async runOnAlreadyDownloadedPackages([app, ...dependencies], vuln, options) {
|
|
112060
112194
|
return await withTmpDirectory("runOnAlreadyDownloadedPackagesPIP", async (projectTmpDir) => {
|
|
112061
112195
|
const fileMappings = /* @__PURE__ */ new Map();
|
|
112062
|
-
const projectDir =
|
|
112196
|
+
const projectDir = join17(projectTmpDir, basename11(app));
|
|
112063
112197
|
logger.info(`Copying ${app} to ${projectDir}`);
|
|
112064
112198
|
await cp7(app, projectDir, { recursive: true });
|
|
112065
112199
|
fileMappings.set(projectDir, app);
|
|
@@ -112071,7 +112205,7 @@ ${msg}`;
|
|
|
112071
112205
|
await scanner.prepareVirtualEnv([]);
|
|
112072
112206
|
const sitePackagesDir = scanner.virtualEnvInfo.virtualEnvPathToSitePackages;
|
|
112073
112207
|
for (const dep of dependencies) {
|
|
112074
|
-
const dependencyDir =
|
|
112208
|
+
const dependencyDir = join17(sitePackagesDir, basename11(dep));
|
|
112075
112209
|
logger.info(`Copying ${dep} to ${dependencyDir}`);
|
|
112076
112210
|
await cp7(dep, dependencyDir, { recursive: true });
|
|
112077
112211
|
fileMappings.set(dependencyDir, dep);
|
|
@@ -112108,7 +112242,7 @@ ${msg}`;
|
|
|
112108
112242
|
const candidate = findBestWheel(packageName, version3, meta);
|
|
112109
112243
|
if (candidate) {
|
|
112110
112244
|
const filename = candidate.url.split("/").at(-1);
|
|
112111
|
-
if (await downloadFile(candidate.url,
|
|
112245
|
+
if (await downloadFile(candidate.url, join17(tmpDir, filename)) && await execAndLogOnFailure2(["unzip", filename], tmpDir, void 0, "debug"))
|
|
112112
112246
|
return;
|
|
112113
112247
|
}
|
|
112114
112248
|
await execUvPipInstall(cmdt`${uvCommand} pip install --python-platform ${uvPythonPlatform} --target ${tmpDir} --no-deps ${packageName}==${version3}`);
|
|
@@ -112134,7 +112268,7 @@ ${msg}`;
|
|
|
112134
112268
|
// public for testing only
|
|
112135
112269
|
async tryUsingPreinstalledVirtualEnv(packages) {
|
|
112136
112270
|
const preinstallVirtualEnvPath = resolve17(this.projectDir, ".venv");
|
|
112137
|
-
if (!
|
|
112271
|
+
if (!existsSync13(preinstallVirtualEnvPath))
|
|
112138
112272
|
return false;
|
|
112139
112273
|
logger.info(`Checking preinstalled virtual environment at ${preinstallVirtualEnvPath}`);
|
|
112140
112274
|
try {
|
|
@@ -112161,7 +112295,7 @@ ${msg}`;
|
|
|
112161
112295
|
if (!await hasUv())
|
|
112162
112296
|
throw new Error("uv (https://docs.astral.sh/uv/) is missing, but is required for Python analysis");
|
|
112163
112297
|
const tmpDir = await createTmpDirectory("coana-python-analysis-venv");
|
|
112164
|
-
const virtualEnvFolder =
|
|
112298
|
+
const virtualEnvFolder = join17(tmpDir, ".venv");
|
|
112165
112299
|
const pythonExecutable = await this.vm.getPythonExecutableForWorkspace(this.projectDir, false);
|
|
112166
112300
|
await exec2(cmdt`${uvCommand} venv --python ${pythonExecutable} .venv`, tmpDir);
|
|
112167
112301
|
logger.debug("Virtual environment created at", virtualEnvFolder);
|
|
@@ -112196,7 +112330,7 @@ ${msg}`;
|
|
|
112196
112330
|
if (!candidate)
|
|
112197
112331
|
return true;
|
|
112198
112332
|
const filename = candidate.url.split("/").at(-1);
|
|
112199
|
-
if (await downloadFile(candidate.url,
|
|
112333
|
+
if (await downloadFile(candidate.url, join17(tmpDir, filename)) && await execAndLogOnFailure2(cmdt`${uvTool(pythonExecutable)} --from installer==0.7.0 python -m installer
|
|
112200
112334
|
--no-compile-bytecode --prefix .venv ${filename}`, tmpDir, void 0, "debug")) {
|
|
112201
112335
|
installStats.installedUsingSpecializedInstallCommand.push(packageName);
|
|
112202
112336
|
return false;
|
|
@@ -112233,7 +112367,7 @@ ${msg}`;
|
|
|
112233
112367
|
await this.updateVirtualEnvInfo(tmpDir, installStats);
|
|
112234
112368
|
}
|
|
112235
112369
|
async updateVirtualEnvInfo(virtualEnvFolder, packageInstallationStats) {
|
|
112236
|
-
const entries = await readdir4(
|
|
112370
|
+
const entries = await readdir4(join17(virtualEnvFolder, ".venv", "lib"));
|
|
112237
112371
|
const pydir = entries.find((entry) => entry.startsWith("python"));
|
|
112238
112372
|
assert6(pydir, `No python* directory found in virtual environment: ${util5.inspect(entries)}`);
|
|
112239
112373
|
this.virtualEnvInfo = {
|
|
@@ -112291,13 +112425,13 @@ function transformSourceLocations2(appPath, fileMappings, detectedOccurrences) {
|
|
|
112291
112425
|
for (const stack of detectedOccurrences.stacks)
|
|
112292
112426
|
for (const call of stack) {
|
|
112293
112427
|
if (call.package === ROOT_NODE_STR) {
|
|
112294
|
-
call.sourceLocation.filename =
|
|
112428
|
+
call.sourceLocation.filename = join17(dirname15(appPath), call.sourceLocation.filename);
|
|
112295
112429
|
continue;
|
|
112296
112430
|
}
|
|
112297
112431
|
const entry = entries.find(([file]) => call.sourceLocation.filename.includes(file));
|
|
112298
112432
|
if (entry) {
|
|
112299
112433
|
const [oldFile, newFile] = entry;
|
|
112300
|
-
const newFilePath =
|
|
112434
|
+
const newFilePath = join17(newFile, call.sourceLocation.filename.split(oldFile)[1]);
|
|
112301
112435
|
call.sourceLocation.filename = newFilePath;
|
|
112302
112436
|
}
|
|
112303
112437
|
}
|
|
@@ -112330,7 +112464,7 @@ async function setupMambalade() {
|
|
|
112330
112464
|
logger.debug(`Using Python interpreter: ${python}`);
|
|
112331
112465
|
await exec2(cmdt`${uvCommand} venv --python=${python} ${venvDir}`);
|
|
112332
112466
|
const mambaladeWheelsPath = ToolPathResolver.mambaladeDistPath;
|
|
112333
|
-
const mambaladeWheels = (await readdir4(mambaladeWheelsPath)).filter((f2) => f2.endsWith(".whl")).map((f2) =>
|
|
112467
|
+
const mambaladeWheels = (await readdir4(mambaladeWheelsPath)).filter((f2) => f2.endsWith(".whl")).map((f2) => join17(mambaladeWheelsPath, f2));
|
|
112334
112468
|
if (!mambaladeWheels.length)
|
|
112335
112469
|
throw new Error(`No mambalade wheel files found in ${mambaladeWheelsPath}`);
|
|
112336
112470
|
logger.debug(`Installing mambalade wheels: ${mambaladeWheels.join(", ")}`);
|
|
@@ -112753,7 +112887,7 @@ async function analyzeWithHeuristics(state, vulns, heuristicsInOrder, doNotRecom
|
|
|
112753
112887
|
const initialBucketContainingAllVulns = buckets.length === 1 && buckets[0] === bucket;
|
|
112754
112888
|
const timeoutInSeconds = initialBucketContainingAllVulns ? state.reachabilityAnalysisOptions.timeoutSeconds.allVulnRuns : state.reachabilityAnalysisOptions.timeoutSeconds.bucketedRuns;
|
|
112755
112889
|
logger.info(`Running full reachability analysis for ${vulnsForBucket.length}/${vulnerabilities.length} vulnerabilities.`);
|
|
112756
|
-
const result = await codeAwareScanner.runAnalysis(vulnsForBucket, bucket.heuristic, timeoutInSeconds, experiment, createTelemetryHandler(dashboardAPI, analysisMetadataId));
|
|
112890
|
+
const result = await codeAwareScanner.runAnalysis(vulnsForBucket, bucket.heuristic, timeoutInSeconds, experiment, createTelemetryHandler(dashboardAPI, analysisMetadataId), createAnalyzerTelemetryHandler(dashboardAPI, analysisMetadataId));
|
|
112757
112891
|
const allowSplitInBuckets = !disableBucketing && bucket.heuristic.splitAnalysisInBuckets && !state.otherAnalysisOptions.disableBucketing && vulnDepIdentifiers.length > 1 && (result.type === "error" || result.reachedDependencies);
|
|
112758
112892
|
if (result.type === "success") {
|
|
112759
112893
|
result.diagnostics.timings ??= {};
|
|
@@ -113117,7 +113251,7 @@ var MavenAnalyzer = class {
|
|
|
113117
113251
|
// dist/analyzers/npm-analyzer.js
|
|
113118
113252
|
var import_lodash19 = __toESM(require_lodash(), 1);
|
|
113119
113253
|
var import_picomatch4 = __toESM(require_picomatch2(), 1);
|
|
113120
|
-
import { existsSync as
|
|
113254
|
+
import { existsSync as existsSync14 } from "fs";
|
|
113121
113255
|
import { rm as rm6 } from "fs/promises";
|
|
113122
113256
|
import { relative as relative8, resolve as resolve20 } from "path";
|
|
113123
113257
|
|
|
@@ -113153,7 +113287,7 @@ var NpmAnalyzer = class {
|
|
|
113153
113287
|
}
|
|
113154
113288
|
async runReachabilityAnalysis(vulns, analysisMetadataCollector, statusUpdater) {
|
|
113155
113289
|
const heuristicsInOrder = this.state.otherAnalysisOptions.lightweightReachability ? [heuristics.IGNORE_DEPENDENCIES_AND_MAX_ROUNDS_3] : [heuristics.ONLY_VULN_PATH_PACKAGES_EXCEPT_VULNERABLE_PACKAGE];
|
|
113156
|
-
const nodeModulesAlreadyExisted =
|
|
113290
|
+
const nodeModulesAlreadyExisted = existsSync14(resolve20(this.state.subprojectDir, "node_modules"));
|
|
113157
113291
|
this.preinstalledDependencies = nodeModulesAlreadyExisted ? "YES" : "NO";
|
|
113158
113292
|
const wrappedCollector = (metadata) => {
|
|
113159
113293
|
const jellyDiagnostics = metadata.analysisDiagnostics;
|
|
@@ -113176,7 +113310,7 @@ var NpmAnalyzer = class {
|
|
|
113176
113310
|
try {
|
|
113177
113311
|
statusUpdater?.("Running import reachability analysis");
|
|
113178
113312
|
logger.debug("Starting jelly import reachability analysis");
|
|
113179
|
-
reachable = await runJellyImportReachabilityAnalysis(this.state.rootWorkingDir, this.projectDir, vulns, this.state.reachabilityAnalysisOptions, createTelemetryHandler(dashboardAPI2, importAnalysisMetadataId));
|
|
113313
|
+
reachable = await runJellyImportReachabilityAnalysis(this.state.rootWorkingDir, this.projectDir, vulns, this.state.reachabilityAnalysisOptions, createTelemetryHandler(dashboardAPI2, importAnalysisMetadataId), createAnalyzerTelemetryHandler(dashboardAPI2, importAnalysisMetadataId));
|
|
113180
113314
|
dashboardAPI2.registerDiagnosticsToAnalysisMetadata(importAnalysisMetadataId, {
|
|
113181
113315
|
analysisDiagnostics: {
|
|
113182
113316
|
timeout: false,
|
|
@@ -113270,9 +113404,9 @@ ${e.stack}` : String(e),
|
|
|
113270
113404
|
return res;
|
|
113271
113405
|
} finally {
|
|
113272
113406
|
if (!nodeModulesAlreadyExisted) {
|
|
113273
|
-
if (
|
|
113407
|
+
if (existsSync14(resolve20(this.state.subprojectDir, "node_modules")))
|
|
113274
113408
|
await rm6(resolve20(this.state.subprojectDir, "node_modules"), { recursive: true });
|
|
113275
|
-
if (
|
|
113409
|
+
if (existsSync14(resolve20(this.projectDir, "node_modules")))
|
|
113276
113410
|
await rm6(resolve20(this.projectDir, "node_modules"), { recursive: true });
|
|
113277
113411
|
}
|
|
113278
113412
|
}
|
|
@@ -113359,14 +113493,14 @@ var NugetAnalyzer = class {
|
|
|
113359
113493
|
|
|
113360
113494
|
// dist/analyzers/ruby-analyzer.js
|
|
113361
113495
|
var import_lodash21 = __toESM(require_lodash(), 1);
|
|
113362
|
-
import { existsSync as
|
|
113496
|
+
import { existsSync as existsSync16 } from "fs";
|
|
113363
113497
|
import { resolve as resolve21 } from "path";
|
|
113364
113498
|
|
|
113365
113499
|
// dist/whole-program-code-aware-vulnerability-scanner/ruby/ruby-code-aware-vulnerability-scanner.js
|
|
113366
113500
|
var import_lodash20 = __toESM(require_lodash(), 1);
|
|
113367
|
-
import { createWriteStream as createWriteStream4, existsSync as
|
|
113501
|
+
import { createWriteStream as createWriteStream4, existsSync as existsSync15 } from "fs";
|
|
113368
113502
|
import { mkdir as mkdir9, readdir as readdir5, readFile as readFile12, rm as rm7 } from "fs/promises";
|
|
113369
|
-
import { join as
|
|
113503
|
+
import { join as join18, relative as relative9 } from "path";
|
|
113370
113504
|
import { pipeline as pipeline3 } from "stream/promises";
|
|
113371
113505
|
var PRINT_ANALYSIS_COMMAND = false;
|
|
113372
113506
|
var { uniqBy: uniqBy2, sortedUniq: sortedUniq2 } = import_lodash20.default;
|
|
@@ -113383,8 +113517,8 @@ var RubyCodeAwareVulnerabilityScanner = class {
|
|
|
113383
113517
|
this.options = options;
|
|
113384
113518
|
}
|
|
113385
113519
|
async prepareDependencies(preInstalledDepInfos, vulns, heuristic) {
|
|
113386
|
-
const vendorDir =
|
|
113387
|
-
if (
|
|
113520
|
+
const vendorDir = join18(this.projectDir, "vendor");
|
|
113521
|
+
if (existsSync15(vendorDir)) {
|
|
113388
113522
|
logger.info(`Vendor directory already exists at ${vendorDir}, skipping gem installation`);
|
|
113389
113523
|
this.vendorDir = vendorDir;
|
|
113390
113524
|
this.vendorDirWasCreated = false;
|
|
@@ -113418,12 +113552,12 @@ var RubyCodeAwareVulnerabilityScanner = class {
|
|
|
113418
113552
|
if (!this.vendorDir)
|
|
113419
113553
|
throw new Error("Assertion error: The vendor directory is not correctly initialized");
|
|
113420
113554
|
const analyzerPath = ToolPathResolver.callgraphReachabilityAnalyzersCliPath;
|
|
113421
|
-
if (!
|
|
113555
|
+
if (!existsSync15(analyzerPath))
|
|
113422
113556
|
throw new Error(`callgraph-reachability-analyzers CLI not found at ${analyzerPath}`);
|
|
113423
113557
|
const vulnAccPaths = sortedUniq2(vulns.flatMap((v) => v.vulnerabilityAccessPaths).sort());
|
|
113424
|
-
const vulnsOutputFile =
|
|
113425
|
-
const reachedPackagesOutputFile =
|
|
113426
|
-
const diagnosticsOutputFile =
|
|
113558
|
+
const vulnsOutputFile = join18(tmpDir, "vulns.json");
|
|
113559
|
+
const reachedPackagesOutputFile = join18(tmpDir, "reached-packages.json");
|
|
113560
|
+
const diagnosticsOutputFile = join18(tmpDir, "diagnostics.json");
|
|
113427
113561
|
const packagesToAnalyze = heuristic.getPackagesToIncludeInAnalysis?.(vulns);
|
|
113428
113562
|
const { loadPathsToPackageNames, failedToFindLoadPath } = await this.computeLoadPath(packagesToAnalyze ?? []);
|
|
113429
113563
|
const loadPaths = Array.from(loadPathsToPackageNames.keys());
|
|
@@ -113458,7 +113592,7 @@ var RubyCodeAwareVulnerabilityScanner = class {
|
|
|
113458
113592
|
telemetryHandler
|
|
113459
113593
|
});
|
|
113460
113594
|
const result = JSON.parse(await readFile12(vulnsOutputFile, "utf-8"));
|
|
113461
|
-
const relativeLoadPathsToPackageNames = new Map([...loadPathsToPackageNames.entries()].map(([k, v]) => [
|
|
113595
|
+
const relativeLoadPathsToPackageNames = new Map([...loadPathsToPackageNames.entries()].map(([k, v]) => [join18("vendor", relative9(this.vendorDir, k)), v]));
|
|
113462
113596
|
const { timedOut, ...diagnostics } = JSON.parse(await readFile12(diagnosticsOutputFile, "utf-8"));
|
|
113463
113597
|
const reachedPackages = JSON.parse(await readFile12(reachedPackagesOutputFile, "utf-8"));
|
|
113464
113598
|
logger.debug("Reached packages: %O", reachedPackages);
|
|
@@ -113491,7 +113625,7 @@ var RubyCodeAwareVulnerabilityScanner = class {
|
|
|
113491
113625
|
return this.packagesExcludedUnrelatedToHeuristic;
|
|
113492
113626
|
}
|
|
113493
113627
|
async cleanup() {
|
|
113494
|
-
if (this.vendorDirWasCreated && this.vendorDir &&
|
|
113628
|
+
if (this.vendorDirWasCreated && this.vendorDir && existsSync15(this.vendorDir)) {
|
|
113495
113629
|
logger.info(`Deleting auto-generated vendor directory at ${this.vendorDir}`);
|
|
113496
113630
|
await rm7(this.vendorDir, { recursive: true, force: true }).catch(() => {
|
|
113497
113631
|
});
|
|
@@ -113506,20 +113640,20 @@ var RubyCodeAwareVulnerabilityScanner = class {
|
|
|
113506
113640
|
const failedToFindLoadPath = [];
|
|
113507
113641
|
if (this.vendorDirWasCreated) {
|
|
113508
113642
|
for (const pkg of packagesToAnalyze) {
|
|
113509
|
-
const libPath =
|
|
113510
|
-
if (
|
|
113643
|
+
const libPath = join18(this.vendorDir, `${pkg.packageName}-${pkg.version}`, "lib");
|
|
113644
|
+
if (existsSync15(libPath))
|
|
113511
113645
|
loadPathsToPackageNames.set(libPath, `${pkg.packageName}@${pkg.version}`);
|
|
113512
113646
|
else
|
|
113513
113647
|
failedToFindLoadPath.push(pkg);
|
|
113514
113648
|
}
|
|
113515
113649
|
return { loadPathsToPackageNames, failedToFindLoadPath };
|
|
113516
113650
|
}
|
|
113517
|
-
const bundlerGemsDir =
|
|
113518
|
-
if (
|
|
113651
|
+
const bundlerGemsDir = join18(this.vendorDir, "bundle", "ruby");
|
|
113652
|
+
if (existsSync15(bundlerGemsDir)) {
|
|
113519
113653
|
const rubyVersions = await readdir5(bundlerGemsDir);
|
|
113520
113654
|
for (const rubyVersion of rubyVersions) {
|
|
113521
|
-
const gemsDir =
|
|
113522
|
-
if (
|
|
113655
|
+
const gemsDir = join18(bundlerGemsDir, rubyVersion, "gems");
|
|
113656
|
+
if (existsSync15(gemsDir)) {
|
|
113523
113657
|
const nameToEntry = /* @__PURE__ */ new Map();
|
|
113524
113658
|
for (const entry of await readdir5(gemsDir, { withFileTypes: true }))
|
|
113525
113659
|
if (entry.isDirectory()) {
|
|
@@ -113531,8 +113665,8 @@ var RubyCodeAwareVulnerabilityScanner = class {
|
|
|
113531
113665
|
const entry = nameToEntry.get(`${pkg.packageName}-${pkg.version}`);
|
|
113532
113666
|
if (!entry)
|
|
113533
113667
|
continue;
|
|
113534
|
-
const libDir =
|
|
113535
|
-
if (
|
|
113668
|
+
const libDir = join18(gemsDir, entry, "lib");
|
|
113669
|
+
if (existsSync15(libDir))
|
|
113536
113670
|
loadPathsToPackageNames.set(libDir, `${pkg.packageName}@${pkg.version}`);
|
|
113537
113671
|
else
|
|
113538
113672
|
failedToFindLoadPath.push(pkg);
|
|
@@ -113541,8 +113675,8 @@ var RubyCodeAwareVulnerabilityScanner = class {
|
|
|
113541
113675
|
}
|
|
113542
113676
|
} else
|
|
113543
113677
|
for (const pkg of packagesToAnalyze) {
|
|
113544
|
-
const libPath =
|
|
113545
|
-
if (
|
|
113678
|
+
const libPath = join18(this.vendorDir, `${pkg.packageName}-${pkg.version}`, "lib");
|
|
113679
|
+
if (existsSync15(libPath))
|
|
113546
113680
|
loadPathsToPackageNames.set(libPath, `${pkg.packageName}@${pkg.version}`);
|
|
113547
113681
|
else
|
|
113548
113682
|
failedToFindLoadPath.push(pkg);
|
|
@@ -113551,12 +113685,12 @@ var RubyCodeAwareVulnerabilityScanner = class {
|
|
|
113551
113685
|
}
|
|
113552
113686
|
};
|
|
113553
113687
|
async function downloadAndExtractGem(gemName, version3, vendorDir) {
|
|
113554
|
-
const gemDir =
|
|
113555
|
-
if (
|
|
113688
|
+
const gemDir = join18(vendorDir, `${gemName}-${version3}`);
|
|
113689
|
+
if (existsSync15(gemDir)) {
|
|
113556
113690
|
logger.debug(`Gem ${gemName}@${version3} already extracted`);
|
|
113557
113691
|
return;
|
|
113558
113692
|
}
|
|
113559
|
-
const tempGemFile =
|
|
113693
|
+
const tempGemFile = join18(vendorDir, `${gemName}-${version3}.gem`);
|
|
113560
113694
|
const downloadAndExtract = async (platform7) => {
|
|
113561
113695
|
logger.debug(`Downloading gem ${gemName}@${version3}`);
|
|
113562
113696
|
const response = await fetch(`https://rubygems.org/gems/${gemName}-${version3}${platform7 ? `-${platform7}` : ""}.gem`);
|
|
@@ -113569,8 +113703,8 @@ async function downloadAndExtractGem(gemName, version3, vendorDir) {
|
|
|
113569
113703
|
logger.debug(`Extracting gem ${gemName}@${version3}`);
|
|
113570
113704
|
await exec2(["tar", "-xf", tempGemFile, "data.tar.gz"], gemDir);
|
|
113571
113705
|
await exec2(["tar", "-xzf", "data.tar.gz"], gemDir);
|
|
113572
|
-
await rm7(
|
|
113573
|
-
const hasValidStructure = [`${gemName}.gemspec`, "Rakefile", "lib"].some((f2) =>
|
|
113706
|
+
await rm7(join18(gemDir, "data.tar.gz"));
|
|
113707
|
+
const hasValidStructure = [`${gemName}.gemspec`, "Rakefile", "lib"].some((f2) => existsSync15(join18(gemDir, f2)));
|
|
113574
113708
|
if (!hasValidStructure)
|
|
113575
113709
|
throw new Error(`Invalid gem structure: Could not find ${gemName}.gemspec or Rakefile or lib`);
|
|
113576
113710
|
await rm7(tempGemFile, { force: true });
|
|
@@ -113621,7 +113755,7 @@ var RubyGemsAnalyzer = class {
|
|
|
113621
113755
|
}
|
|
113622
113756
|
analysisMetadataCollector?.(metadata);
|
|
113623
113757
|
};
|
|
113624
|
-
this.preinstalledDependencies =
|
|
113758
|
+
this.preinstalledDependencies = existsSync16(resolve21(this.projectDir, "vendor")) ? "YES" : "NO";
|
|
113625
113759
|
try {
|
|
113626
113760
|
return await analyzeWithHeuristics(this.state, vulns, [RubyHeuristics.ONLY_VULN_PATH_PACKAGES], false, await this.prepareScanner(), wrappedCollector, statusUpdater);
|
|
113627
113761
|
} finally {
|
|
@@ -113774,7 +113908,7 @@ var runReachabilityAnalysisCmd = new Command().name("runReachabilityAnalysis").a
|
|
|
113774
113908
|
const result = await runReachabilityAnalysis(state);
|
|
113775
113909
|
if (options.outputFile) {
|
|
113776
113910
|
logger.debug("Writing result to file", options.outputFile);
|
|
113777
|
-
await
|
|
113911
|
+
await writeFile10(options.outputFile, JSON.stringify({ result }));
|
|
113778
113912
|
} else {
|
|
113779
113913
|
logger.info("Result:", JSON.stringify(result, null, 2));
|
|
113780
113914
|
}
|
|
@@ -113788,7 +113922,7 @@ var runOnDependencyChainCmd = new Command().name("runOnDependencyChain").option(
|
|
|
113788
113922
|
const result = await analyzePackages(ecosystem, deserializeDependencyChain(ecosystem, dependencyChain), vulnerability, defaultOptions2);
|
|
113789
113923
|
if (options.outputFile) {
|
|
113790
113924
|
logger.debug("Writing result to file", options.outputFile);
|
|
113791
|
-
await
|
|
113925
|
+
await writeFile10(options.outputFile, JSON.stringify({ result }));
|
|
113792
113926
|
} else {
|
|
113793
113927
|
logger.info("Result:", JSON.stringify(result, null, 2));
|
|
113794
113928
|
}
|
|
@@ -113821,7 +113955,7 @@ var runOnPackageRegistryPackageCmd = new Command().name("runOnPackageRegistryPac
|
|
|
113821
113955
|
const result = isFile3 ? 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);
|
|
113822
113956
|
if (options.outputFile) {
|
|
113823
113957
|
logger.info("Writing result to file", options.outputFile);
|
|
113824
|
-
await
|
|
113958
|
+
await writeFile10(options.outputFile, JSON.stringify(result, null, 2));
|
|
113825
113959
|
} else {
|
|
113826
113960
|
logger.info("Result:", JSON.stringify(result, null, 2));
|
|
113827
113961
|
}
|