@coana-tech/cli 14.11.12 → 14.11.14
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 +8 -3
- package/coana-repos/goana/bin/goana-darwin-amd64.gz +0 -0
- package/coana-repos/goana/bin/goana-darwin-arm64.gz +0 -0
- package/coana-repos/goana/bin/goana-linux-amd64.gz +0 -0
- package/coana-repos/goana/bin/goana-linux-arm64.gz +0 -0
- package/package.json +1 -1
- package/reachability-analyzers-cli.mjs +80 -61
package/cli.mjs
CHANGED
|
@@ -210065,7 +210065,7 @@ function inferWorkspaceFromManifestPath(ecosystem, manifestPath, properPythonPro
|
|
|
210065
210065
|
case "NPM": {
|
|
210066
210066
|
const base = basename7(manifestPath);
|
|
210067
210067
|
const dir = dirname8(manifestPath);
|
|
210068
|
-
return base === "package.json" ? dir
|
|
210068
|
+
return base === "package.json" ? dir || "." : void 0;
|
|
210069
210069
|
}
|
|
210070
210070
|
case "MAVEN": {
|
|
210071
210071
|
return ".";
|
|
@@ -210096,6 +210096,11 @@ function inferWorkspaceFromManifestPath(ecosystem, manifestPath, properPythonPro
|
|
|
210096
210096
|
case "RUST": {
|
|
210097
210097
|
return dirname8(manifestPath) || ".";
|
|
210098
210098
|
}
|
|
210099
|
+
case "GO": {
|
|
210100
|
+
const base = basename7(manifestPath);
|
|
210101
|
+
const dir = dirname8(manifestPath);
|
|
210102
|
+
return base === "go.mod" ? dir || "." : void 0;
|
|
210103
|
+
}
|
|
210099
210104
|
default: {
|
|
210100
210105
|
return ".";
|
|
210101
210106
|
}
|
|
@@ -225392,7 +225397,7 @@ async function onlineScan(dependencyTree, apiKey, timeout) {
|
|
|
225392
225397
|
}
|
|
225393
225398
|
|
|
225394
225399
|
// dist/version.js
|
|
225395
|
-
var version2 = "14.11.
|
|
225400
|
+
var version2 = "14.11.14";
|
|
225396
225401
|
|
|
225397
225402
|
// dist/cli-core.js
|
|
225398
225403
|
var { mapValues, omit, partition, pick } = import_lodash15.default;
|
|
@@ -225572,7 +225577,7 @@ var CliCore = class {
|
|
|
225572
225577
|
otherModulesCommunicator,
|
|
225573
225578
|
this.rootWorkingDirectory,
|
|
225574
225579
|
ecosystem,
|
|
225575
|
-
["NPM", "PIP"].includes(ecosystem) && isEcosystemToAnalyze
|
|
225580
|
+
["NPM", "PIP", "GO"].includes(ecosystem) && isEcosystemToAnalyze
|
|
225576
225581
|
)).flat());
|
|
225577
225582
|
this.sendProgress("RUN_ON_SUBPROJECT", false, this.rootWorkingDirectory);
|
|
225578
225583
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -9234,7 +9234,7 @@ var require_pipeline = __commonJS({
|
|
|
9234
9234
|
if (typeof streams[streams.length - 1] !== "function") return noop4;
|
|
9235
9235
|
return streams.pop();
|
|
9236
9236
|
}
|
|
9237
|
-
function
|
|
9237
|
+
function pipeline2() {
|
|
9238
9238
|
for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
9239
9239
|
streams[_key] = arguments[_key];
|
|
9240
9240
|
}
|
|
@@ -9257,7 +9257,7 @@ var require_pipeline = __commonJS({
|
|
|
9257
9257
|
});
|
|
9258
9258
|
return streams.reduce(pipe);
|
|
9259
9259
|
}
|
|
9260
|
-
module.exports =
|
|
9260
|
+
module.exports = pipeline2;
|
|
9261
9261
|
}
|
|
9262
9262
|
});
|
|
9263
9263
|
|
|
@@ -11444,7 +11444,7 @@ var require_file = __commonJS({
|
|
|
11444
11444
|
var fs12 = __require("fs");
|
|
11445
11445
|
var path9 = __require("path");
|
|
11446
11446
|
var asyncSeries = require_series();
|
|
11447
|
-
var
|
|
11447
|
+
var zlib3 = __require("zlib");
|
|
11448
11448
|
var { MESSAGE } = require_triple_beam();
|
|
11449
11449
|
var { Stream: Stream2, PassThrough } = require_readable();
|
|
11450
11450
|
var TransportStream = require_winston_transport();
|
|
@@ -12013,7 +12013,7 @@ var require_file = __commonJS({
|
|
|
12013
12013
|
if (err) {
|
|
12014
12014
|
return callback();
|
|
12015
12015
|
}
|
|
12016
|
-
var gzip =
|
|
12016
|
+
var gzip = zlib3.createGzip();
|
|
12017
12017
|
var inp = fs12.createReadStream(src);
|
|
12018
12018
|
var out = fs12.createWriteStream(dest);
|
|
12019
12019
|
out.on("finish", () => {
|
|
@@ -43748,7 +43748,7 @@ var require_client = __commonJS({
|
|
|
43748
43748
|
var assert9 = __require("assert");
|
|
43749
43749
|
var net = __require("net");
|
|
43750
43750
|
var http2 = __require("http");
|
|
43751
|
-
var { pipeline } = __require("stream");
|
|
43751
|
+
var { pipeline: pipeline2 } = __require("stream");
|
|
43752
43752
|
var util6 = require_util2();
|
|
43753
43753
|
var timers = require_timers();
|
|
43754
43754
|
var Request2 = require_request();
|
|
@@ -45166,7 +45166,7 @@ upgrade: ${upgrade}\r
|
|
|
45166
45166
|
let onPipeData = function(chunk2) {
|
|
45167
45167
|
request.onBodySent(chunk2);
|
|
45168
45168
|
};
|
|
45169
|
-
const pipe =
|
|
45169
|
+
const pipe = pipeline2(
|
|
45170
45170
|
body,
|
|
45171
45171
|
h2stream,
|
|
45172
45172
|
(err) => {
|
|
@@ -46926,7 +46926,7 @@ var require_api_pipeline = __commonJS({
|
|
|
46926
46926
|
util6.destroy(ret, err);
|
|
46927
46927
|
}
|
|
46928
46928
|
};
|
|
46929
|
-
function
|
|
46929
|
+
function pipeline2(opts, handler) {
|
|
46930
46930
|
try {
|
|
46931
46931
|
const pipelineHandler = new PipelineHandler(opts, handler);
|
|
46932
46932
|
this.dispatch({ ...opts, body: pipelineHandler.req }, pipelineHandler);
|
|
@@ -46935,7 +46935,7 @@ var require_api_pipeline = __commonJS({
|
|
|
46935
46935
|
return new PassThrough().destroy(err);
|
|
46936
46936
|
}
|
|
46937
46937
|
}
|
|
46938
|
-
module.exports =
|
|
46938
|
+
module.exports = pipeline2;
|
|
46939
46939
|
}
|
|
46940
46940
|
});
|
|
46941
46941
|
|
|
@@ -49832,7 +49832,7 @@ var require_fetch = __commonJS({
|
|
|
49832
49832
|
} = require_response();
|
|
49833
49833
|
var { Headers } = require_headers();
|
|
49834
49834
|
var { Request: Request2, makeRequest } = require_request2();
|
|
49835
|
-
var
|
|
49835
|
+
var zlib3 = __require("zlib");
|
|
49836
49836
|
var {
|
|
49837
49837
|
bytesMatch,
|
|
49838
49838
|
makePolicyContainer,
|
|
@@ -49876,7 +49876,7 @@ var require_fetch = __commonJS({
|
|
|
49876
49876
|
} = require_constants3();
|
|
49877
49877
|
var { kHeadersList } = require_symbols();
|
|
49878
49878
|
var EE3 = __require("events");
|
|
49879
|
-
var { Readable: Readable2, pipeline } = __require("stream");
|
|
49879
|
+
var { Readable: Readable2, pipeline: pipeline2 } = __require("stream");
|
|
49880
49880
|
var { addAbortListener, isErrored, isReadable: isReadable2, nodeMajor, nodeMinor } = require_util2();
|
|
49881
49881
|
var { dataURLProcessor, serializeAMimeType } = require_dataURL();
|
|
49882
49882
|
var { TransformStream } = __require("stream/web");
|
|
@@ -50773,18 +50773,18 @@ var require_fetch = __commonJS({
|
|
|
50773
50773
|
if (request.method !== "HEAD" && request.method !== "CONNECT" && !nullBodyStatus.includes(status) && !willFollow) {
|
|
50774
50774
|
for (const coding of codings) {
|
|
50775
50775
|
if (coding === "x-gzip" || coding === "gzip") {
|
|
50776
|
-
decoders.push(
|
|
50776
|
+
decoders.push(zlib3.createGunzip({
|
|
50777
50777
|
// Be less strict when decoding compressed responses, since sometimes
|
|
50778
50778
|
// servers send slightly invalid responses that are still accepted
|
|
50779
50779
|
// by common browsers.
|
|
50780
50780
|
// Always using Z_SYNC_FLUSH is what cURL does.
|
|
50781
|
-
flush:
|
|
50782
|
-
finishFlush:
|
|
50781
|
+
flush: zlib3.constants.Z_SYNC_FLUSH,
|
|
50782
|
+
finishFlush: zlib3.constants.Z_SYNC_FLUSH
|
|
50783
50783
|
}));
|
|
50784
50784
|
} else if (coding === "deflate") {
|
|
50785
|
-
decoders.push(
|
|
50785
|
+
decoders.push(zlib3.createInflate());
|
|
50786
50786
|
} else if (coding === "br") {
|
|
50787
|
-
decoders.push(
|
|
50787
|
+
decoders.push(zlib3.createBrotliDecompress());
|
|
50788
50788
|
} else {
|
|
50789
50789
|
decoders.length = 0;
|
|
50790
50790
|
break;
|
|
@@ -50795,7 +50795,7 @@ var require_fetch = __commonJS({
|
|
|
50795
50795
|
status,
|
|
50796
50796
|
statusText,
|
|
50797
50797
|
headersList: headers[kHeadersList],
|
|
50798
|
-
body: decoders.length ?
|
|
50798
|
+
body: decoders.length ? pipeline2(this.body, ...decoders, () => {
|
|
50799
50799
|
}) : this.body.on("error", () => {
|
|
50800
50800
|
})
|
|
50801
50801
|
});
|
|
@@ -59413,7 +59413,7 @@ var require_upload_gzip = __commonJS({
|
|
|
59413
59413
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59414
59414
|
exports.createGZipFileInBuffer = exports.createGZipFileOnDisk = void 0;
|
|
59415
59415
|
var fs12 = __importStar(__require("fs"));
|
|
59416
|
-
var
|
|
59416
|
+
var zlib3 = __importStar(__require("zlib"));
|
|
59417
59417
|
var util_1 = __require("util");
|
|
59418
59418
|
var stat3 = (0, util_1.promisify)(fs12.stat);
|
|
59419
59419
|
var gzipExemptFileExtensions = [
|
|
@@ -59449,7 +59449,7 @@ var require_upload_gzip = __commonJS({
|
|
|
59449
59449
|
}
|
|
59450
59450
|
return new Promise((resolve17, reject) => {
|
|
59451
59451
|
const inputStream = fs12.createReadStream(originalFilePath);
|
|
59452
|
-
const gzip =
|
|
59452
|
+
const gzip = zlib3.createGzip();
|
|
59453
59453
|
const outputStream = fs12.createWriteStream(tempFilePath);
|
|
59454
59454
|
inputStream.pipe(gzip).pipe(outputStream);
|
|
59455
59455
|
outputStream.on("finish", () => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -59469,7 +59469,7 @@ var require_upload_gzip = __commonJS({
|
|
|
59469
59469
|
return new Promise((resolve17) => __awaiter(this, void 0, void 0, function* () {
|
|
59470
59470
|
var _a2, e_1, _b, _c;
|
|
59471
59471
|
const inputStream = fs12.createReadStream(originalFilePath);
|
|
59472
|
-
const gzip =
|
|
59472
|
+
const gzip = zlib3.createGzip();
|
|
59473
59473
|
inputStream.pipe(gzip);
|
|
59474
59474
|
const chunks = [];
|
|
59475
59475
|
try {
|
|
@@ -60071,7 +60071,7 @@ var require_download_http_client = __commonJS({
|
|
|
60071
60071
|
exports.DownloadHttpClient = void 0;
|
|
60072
60072
|
var fs12 = __importStar(__require("fs"));
|
|
60073
60073
|
var core = __importStar(require_core());
|
|
60074
|
-
var
|
|
60074
|
+
var zlib3 = __importStar(__require("zlib"));
|
|
60075
60075
|
var utils_1 = require_utils3();
|
|
60076
60076
|
var url_1 = __require("url");
|
|
60077
60077
|
var status_reporter_1 = require_status_reporter();
|
|
@@ -60249,7 +60249,7 @@ var require_download_http_client = __commonJS({
|
|
|
60249
60249
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60250
60250
|
yield new Promise((resolve17, reject) => {
|
|
60251
60251
|
if (isGzip) {
|
|
60252
|
-
const gunzip =
|
|
60252
|
+
const gunzip = zlib3.createGunzip();
|
|
60253
60253
|
response.message.on("error", (error) => {
|
|
60254
60254
|
core.info(`An error occurred while attempting to read the response stream`);
|
|
60255
60255
|
gunzip.close();
|
|
@@ -66504,14 +66504,14 @@ var require_headers2 = __commonJS({
|
|
|
66504
66504
|
var require_deflater = __commonJS({
|
|
66505
66505
|
"../../node_modules/.pnpm/adm-zip@0.5.16/node_modules/adm-zip/methods/deflater.js"(exports, module) {
|
|
66506
66506
|
module.exports = function(inbuf) {
|
|
66507
|
-
var
|
|
66507
|
+
var zlib3 = __require("zlib");
|
|
66508
66508
|
var opts = { chunkSize: (parseInt(inbuf.length / 1024) + 1) * 1024 };
|
|
66509
66509
|
return {
|
|
66510
66510
|
deflate: function() {
|
|
66511
|
-
return
|
|
66511
|
+
return zlib3.deflateRawSync(inbuf, opts);
|
|
66512
66512
|
},
|
|
66513
66513
|
deflateAsync: function(callback) {
|
|
66514
|
-
var tmp =
|
|
66514
|
+
var tmp = zlib3.createDeflateRaw(opts), parts = [], total = 0;
|
|
66515
66515
|
tmp.on("data", function(data2) {
|
|
66516
66516
|
parts.push(data2);
|
|
66517
66517
|
total += data2.length;
|
|
@@ -66538,14 +66538,14 @@ var require_inflater = __commonJS({
|
|
|
66538
66538
|
"../../node_modules/.pnpm/adm-zip@0.5.16/node_modules/adm-zip/methods/inflater.js"(exports, module) {
|
|
66539
66539
|
var version3 = +(process.versions ? process.versions.node : "").split(".")[0] || 0;
|
|
66540
66540
|
module.exports = function(inbuf, expectedLength) {
|
|
66541
|
-
var
|
|
66541
|
+
var zlib3 = __require("zlib");
|
|
66542
66542
|
const option = version3 >= 15 && expectedLength > 0 ? { maxOutputLength: expectedLength } : {};
|
|
66543
66543
|
return {
|
|
66544
66544
|
inflate: function() {
|
|
66545
|
-
return
|
|
66545
|
+
return zlib3.inflateRawSync(inbuf, option);
|
|
66546
66546
|
},
|
|
66547
66547
|
inflateAsync: function(callback) {
|
|
66548
|
-
var tmp =
|
|
66548
|
+
var tmp = zlib3.createInflateRaw(option), parts = [], total = 0;
|
|
66549
66549
|
tmp.on("data", function(data2) {
|
|
66550
66550
|
parts.push(data2);
|
|
66551
66551
|
total += data2.length;
|
|
@@ -94983,32 +94983,48 @@ function transformSourceLocations(fileMappings, detectedOccurrences) {
|
|
|
94983
94983
|
// dist/whole-program-code-aware-vulnerability-scanner/go/go-code-aware-vulnerability-scanner.js
|
|
94984
94984
|
var import_lodash11 = __toESM(require_lodash(), 1);
|
|
94985
94985
|
import assert4 from "assert";
|
|
94986
|
-
import { existsSync as existsSync9 } from "fs";
|
|
94986
|
+
import { existsSync as existsSync9, createReadStream, createWriteStream as createWriteStream2 } from "fs";
|
|
94987
94987
|
import { readFile as readFile7, rm as rm4, cp as cp4 } from "fs/promises";
|
|
94988
|
+
import zlib2 from "zlib";
|
|
94988
94989
|
import { join as join13, resolve as resolve10, sep } from "path";
|
|
94990
|
+
import { pipeline } from "stream/promises";
|
|
94989
94991
|
var { uniq: uniq5 } = import_lodash11.default;
|
|
94990
94992
|
var GoCodeAwareVulnerabilityScanner = class {
|
|
94991
94993
|
projectDir;
|
|
94992
|
-
|
|
94994
|
+
options;
|
|
94993
94995
|
name = "GOANA";
|
|
94994
|
-
constructor(projectDir,
|
|
94996
|
+
constructor(projectDir, options = {}) {
|
|
94995
94997
|
this.projectDir = projectDir;
|
|
94996
|
-
this.
|
|
94998
|
+
this.options = options;
|
|
94999
|
+
}
|
|
95000
|
+
get compressedGoanaBinaryName() {
|
|
95001
|
+
const { platform: platform6, arch } = process;
|
|
95002
|
+
const rarch = arch === "arm" ? "arm64" : arch === "x64" ? "amd64" : arch;
|
|
95003
|
+
return `goana-${platform6}-${rarch}.gz`;
|
|
94997
95004
|
}
|
|
94998
95005
|
async runAnalysis(vulns, heuristic, _analyzesAllVulns) {
|
|
94999
95006
|
logger.info("Started instantiating Go code-aware analysis");
|
|
95000
95007
|
if (!existsSync9(join13(this.projectDir, "go.mod")))
|
|
95001
95008
|
throw new Error("go.mod file not found in the project directory");
|
|
95009
|
+
const { timeoutInSeconds, memoryLimitInMB } = this.options;
|
|
95002
95010
|
const tmpDir = await createTmpDirectory("goana-output");
|
|
95003
95011
|
const vulnsOutputFile = join13(tmpDir, "vulns.json");
|
|
95004
95012
|
const diagnosticsOutputFile = join13(tmpDir, "diagnostics.json");
|
|
95005
95013
|
try {
|
|
95014
|
+
const binaryName = this.compressedGoanaBinaryName;
|
|
95015
|
+
const binaryPath = join13(COANA_REPOS_PATH(), "goana/bin", binaryName);
|
|
95016
|
+
if (!await exists(binaryPath))
|
|
95017
|
+
throw new Error(`goana binary '${binaryName}' not found`);
|
|
95018
|
+
await pipeline(createReadStream(binaryPath), zlib2.createGunzip(), createWriteStream2(join13(tmpDir, "goana"), { mode: 493 }));
|
|
95006
95019
|
const vulnAccPaths = uniq5(vulns.flatMap((v) => v.vulnerabilityAccessPaths));
|
|
95007
|
-
const { error, stderr } = await execNeverFail(cmdt`${
|
|
95020
|
+
const { error, stderr } = await execNeverFail(cmdt`${join13(tmpDir, "goana")}
|
|
95008
95021
|
-output-vulnerabilities ${vulnsOutputFile}
|
|
95009
95022
|
-output-diagnostics ${diagnosticsOutputFile}
|
|
95010
95023
|
-topk=4 ${heuristic.includeTests && "-tests"}
|
|
95011
|
-
${this.projectDir} ${vulnAccPaths}`, void 0, {
|
|
95024
|
+
${this.projectDir} ${vulnAccPaths}`, void 0, {
|
|
95025
|
+
timeout: timeoutInSeconds ? timeoutInSeconds * 1e3 : void 0,
|
|
95026
|
+
env: memoryLimitInMB ? { ...process.env, GOMEMLIMIT: `${memoryLimitInMB}MiB` } : void 0
|
|
95027
|
+
});
|
|
95012
95028
|
if (error) {
|
|
95013
95029
|
logger.error("Error running Go code-aware analysis", error);
|
|
95014
95030
|
const timeout = !!error.killed;
|
|
@@ -95045,7 +95061,7 @@ ${stderr}`);
|
|
|
95045
95061
|
await rm4(tmpDir, { recursive: true, force: true });
|
|
95046
95062
|
}
|
|
95047
95063
|
}
|
|
95048
|
-
static async runOnDependencyChain([first2, ...rest], vuln,
|
|
95064
|
+
static async runOnDependencyChain([first2, ...rest], vuln, options = {}) {
|
|
95049
95065
|
assert4(first2.version);
|
|
95050
95066
|
const { Dir, GoMod } = JSON.parse(await runCommandResolveStdOut(cmdt`go mod download -json ${first2.packageName}@v${first2.version}`));
|
|
95051
95067
|
const projectDir = await createTmpDirectory("go-run-on-dependency-chain-");
|
|
@@ -95062,7 +95078,7 @@ ${stderr}`);
|
|
|
95062
95078
|
await runGoModTidy(projectDir);
|
|
95063
95079
|
}
|
|
95064
95080
|
const heuristic = GoanaHeuristics.NO_TESTS;
|
|
95065
|
-
const result = await new this(projectDir,
|
|
95081
|
+
const result = await new this(projectDir, options).runAnalysis([vuln], heuristic, true);
|
|
95066
95082
|
if (result.type === "error")
|
|
95067
95083
|
return {
|
|
95068
95084
|
error: result.message,
|
|
@@ -95078,7 +95094,7 @@ ${stderr}`);
|
|
|
95078
95094
|
await rm4(projectDir, { recursive: true, force: true });
|
|
95079
95095
|
}
|
|
95080
95096
|
}
|
|
95081
|
-
static async runOnAlreadyDownloadedPackages(packages, vuln,
|
|
95097
|
+
static async runOnAlreadyDownloadedPackages(packages, vuln, options = {}) {
|
|
95082
95098
|
for (const pkg of packages)
|
|
95083
95099
|
assert4(existsSync9(join13(pkg, "go.mod")), `${pkg} does not contain a go.mod file`);
|
|
95084
95100
|
const [app, ...dependencies] = packages;
|
|
@@ -95095,7 +95111,7 @@ ${stderr}`);
|
|
|
95095
95111
|
await runGoModTidy(projectDir);
|
|
95096
95112
|
}
|
|
95097
95113
|
const heuristic = GoanaHeuristics.NO_TESTS;
|
|
95098
|
-
const result = await new this(projectDir,
|
|
95114
|
+
const result = await new this(projectDir, options).runAnalysis([vuln], heuristic, true);
|
|
95099
95115
|
if (result.type === "error")
|
|
95100
95116
|
return {
|
|
95101
95117
|
error: result.message,
|
|
@@ -96170,7 +96186,10 @@ async function analyzePackages(ecosystem, packages, vulnerability, options) {
|
|
|
96170
96186
|
break;
|
|
96171
96187
|
case "GO":
|
|
96172
96188
|
analysisName = "Goana";
|
|
96173
|
-
result = await GoCodeAwareVulnerabilityScanner.runOnDependencyChain(packages, vulnerability,
|
|
96189
|
+
result = await GoCodeAwareVulnerabilityScanner.runOnDependencyChain(packages, vulnerability, {
|
|
96190
|
+
timeoutInSeconds: options?.timeoutInSeconds ?? 60,
|
|
96191
|
+
memoryLimitInMB: options?.memoryLimitInMB ?? 16384
|
|
96192
|
+
});
|
|
96174
96193
|
break;
|
|
96175
96194
|
case "RUST":
|
|
96176
96195
|
analysisName = "Rustica";
|
|
@@ -96215,7 +96234,10 @@ async function analyzeAlreadyInstalledPackages(ecosystem, packages, vulnerabilit
|
|
|
96215
96234
|
break;
|
|
96216
96235
|
case "GO":
|
|
96217
96236
|
analysisName = "Goana";
|
|
96218
|
-
result = await GoCodeAwareVulnerabilityScanner.runOnAlreadyDownloadedPackages(packages, vulnerability,
|
|
96237
|
+
result = await GoCodeAwareVulnerabilityScanner.runOnAlreadyDownloadedPackages(packages, vulnerability, {
|
|
96238
|
+
timeoutInSeconds: options?.timeoutInSeconds ?? 60,
|
|
96239
|
+
memoryLimitInMB: options?.memoryLimitInMB ?? 16384
|
|
96240
|
+
});
|
|
96219
96241
|
break;
|
|
96220
96242
|
case "RUST":
|
|
96221
96243
|
analysisName = "Rustica";
|
|
@@ -96270,7 +96292,7 @@ async function getVersion(analysisName) {
|
|
|
96270
96292
|
// dist/whole-program-code-aware-vulnerability-scanner/python/python-code-aware-vulnerability-scanner.js
|
|
96271
96293
|
var import_semver2 = __toESM(require_semver2(), 1);
|
|
96272
96294
|
var { omit, once: once3, pick, sortedUniq, uniqBy } = import_lodash14.default;
|
|
96273
|
-
var PythonCodeAwareVulnerabilityScanner = class
|
|
96295
|
+
var PythonCodeAwareVulnerabilityScanner = class {
|
|
96274
96296
|
state;
|
|
96275
96297
|
projectDir;
|
|
96276
96298
|
name = "MAMBALADE";
|
|
@@ -96295,9 +96317,7 @@ var PythonCodeAwareVulnerabilityScanner = class _PythonCodeAwareVulnerabilitySca
|
|
|
96295
96317
|
async runAnalysis(vulns, heuristic, analyzesAllVulns) {
|
|
96296
96318
|
if (!this.virtualEnvInfo)
|
|
96297
96319
|
throw new Error("Virtual environment not set up");
|
|
96298
|
-
|
|
96299
|
-
await this.setupMambalade();
|
|
96300
|
-
}
|
|
96320
|
+
this.mambaladeVenvPath ??= await setupMambalade();
|
|
96301
96321
|
logger.info("Started instantiating Python code-aware analysis");
|
|
96302
96322
|
logger.debug(`Trying to find files to analyze from projectDir: ${this.projectDir}`);
|
|
96303
96323
|
const { rootWorkingDir, reachabilityAnalysisOptions } = this.state;
|
|
@@ -96429,7 +96449,7 @@ ${msg}`;
|
|
|
96429
96449
|
logger.info(`Copying ${app} to ${projectDir}`);
|
|
96430
96450
|
await cp5(app, projectDir, { recursive: true });
|
|
96431
96451
|
fileMappings.set(projectDir, app);
|
|
96432
|
-
const scanner = new
|
|
96452
|
+
const scanner = new this({
|
|
96433
96453
|
rootWorkingDir: projectTmpDir,
|
|
96434
96454
|
reachabilityAnalysisOptions: options
|
|
96435
96455
|
}, projectTmpDir);
|
|
@@ -96608,22 +96628,6 @@ ${msg}`;
|
|
|
96608
96628
|
getVirtualEnvInfo() {
|
|
96609
96629
|
return this.virtualEnvInfo;
|
|
96610
96630
|
}
|
|
96611
|
-
async setupMambalade() {
|
|
96612
|
-
const venvDir = await createTmpDirectory("mambalade-venv");
|
|
96613
|
-
logger.info("Creating Mambalade virtual environment");
|
|
96614
|
-
const pythonInterpreter = await getPythonInterpreter();
|
|
96615
|
-
await exec(cmdt`${pythonInterpreter} -SIm venv ${venvDir}`);
|
|
96616
|
-
const mambaladeWheelsPath = join15(COANA_REPOS_PATH(), "mambalade", "dist");
|
|
96617
|
-
const wheelFiles = await readdir3(mambaladeWheelsPath);
|
|
96618
|
-
const mambaladeWheels = wheelFiles.filter((f2) => f2.endsWith(".whl")).map((f2) => join15(mambaladeWheelsPath, f2));
|
|
96619
|
-
if (mambaladeWheels.length === 0) {
|
|
96620
|
-
throw new Error(`No mambalade wheel files found in ${mambaladeWheelsPath}`);
|
|
96621
|
-
}
|
|
96622
|
-
logger.info(`Installing mambalade wheels: ${mambaladeWheels.join(", ")}`);
|
|
96623
|
-
await exec(cmdt`${venvDir}/bin/pip install --no-deps ${mambaladeWheels}`);
|
|
96624
|
-
this.mambaladeVenvPath = venvDir;
|
|
96625
|
-
logger.info("Mambalade virtual environment setup complete");
|
|
96626
|
-
}
|
|
96627
96631
|
// async [Symbol.asyncDispose]() {
|
|
96628
96632
|
async cleanup() {
|
|
96629
96633
|
if (this.virtualEnvInfo?.temporary) {
|
|
@@ -96684,6 +96688,21 @@ async function getPythonInterpreter() {
|
|
|
96684
96688
|
return "python3";
|
|
96685
96689
|
throw new Error(`No Python ${pythonVersionRequired} interpreter found`);
|
|
96686
96690
|
}
|
|
96691
|
+
async function setupMambalade() {
|
|
96692
|
+
const venvDir = await createTmpDirectory("mambalade-venv");
|
|
96693
|
+
logger.info("Creating Mambalade virtual environment");
|
|
96694
|
+
const pythonInterpreter = await getPythonInterpreter();
|
|
96695
|
+
await exec(cmdt`${pythonInterpreter} -SIm venv ${venvDir}`);
|
|
96696
|
+
const mambaladeWheelsPath = join15(COANA_REPOS_PATH(), "mambalade", "dist");
|
|
96697
|
+
const wheelFiles = await readdir3(mambaladeWheelsPath);
|
|
96698
|
+
const mambaladeWheels = wheelFiles.filter((f2) => f2.endsWith(".whl")).map((f2) => join15(mambaladeWheelsPath, f2));
|
|
96699
|
+
if (!mambaladeWheels.length)
|
|
96700
|
+
throw new Error(`No mambalade wheel files found in ${mambaladeWheelsPath}`);
|
|
96701
|
+
logger.info(`Installing mambalade wheels: ${mambaladeWheels.join(", ")}`);
|
|
96702
|
+
await exec(cmdt`${venvDir}/bin/pip install --no-deps ${mambaladeWheels}`);
|
|
96703
|
+
logger.info("Mambalade virtual environment setup complete");
|
|
96704
|
+
return venvDir;
|
|
96705
|
+
}
|
|
96687
96706
|
|
|
96688
96707
|
// dist/whole-program-code-aware-vulnerability-scanner/python/phantom-deps.js
|
|
96689
96708
|
var { uniq: uniq8 } = import_lodash15.default;
|
|
@@ -97208,7 +97227,7 @@ var GoAnalyzer = class {
|
|
|
97208
97227
|
const vulnerablePackages = uniq9(vulns.flatMap((v) => v.vulnerabilityAccessPaths.map((vap) => vap.split(":")[0])));
|
|
97209
97228
|
const irrelevantPackages = new Set(await getIrrelevantPackages(this.projectDir, vulnerablePackages));
|
|
97210
97229
|
const [unreachableVulns, otherVulns] = partition2(vulns, (v) => v.vulnerabilityAccessPaths.every((vap) => irrelevantPackages.has(vap.split(":")[0])));
|
|
97211
|
-
const res = otherVulns.length ? await analyzeWithHeuristics(this.state, otherVulns, [GoanaHeuristics.DEFAULT], false, new GoCodeAwareVulnerabilityScanner(this.projectDir, this.state.reachabilityAnalysisOptions
|
|
97230
|
+
const res = otherVulns.length ? await analyzeWithHeuristics(this.state, otherVulns, [GoanaHeuristics.DEFAULT], false, new GoCodeAwareVulnerabilityScanner(this.projectDir, this.state.reachabilityAnalysisOptions), analysisMetadataCollector, statusUpdater) : [];
|
|
97212
97231
|
if (unreachableVulns.length) {
|
|
97213
97232
|
const heuristicName = GoanaHeuristics.IMPORT_REACHABILITY.name;
|
|
97214
97233
|
const detectedOccurrences = {
|