@coana-tech/cli 14.10.5 → 14.10.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.mjs +29 -29
- package/package.json +1 -1
package/cli.mjs
CHANGED
|
@@ -207551,18 +207551,16 @@ var MavenSocketUpgradeManager = class {
|
|
|
207551
207551
|
|
|
207552
207552
|
// ../fixing-management/src/fixing-management/npm/npm-ecosystem-socket-fixing-manager.ts
|
|
207553
207553
|
import { dirname as dirname5, join as join9, relative as relative6 } from "path";
|
|
207554
|
+
import { existsSync as existsSync10 } from "fs";
|
|
207554
207555
|
var NpmSocketUpgradeManager = class {
|
|
207555
207556
|
constructor(rootDir) {
|
|
207556
207557
|
this.rootDir = rootDir;
|
|
207557
207558
|
}
|
|
207558
207559
|
async applySocketArtifactUpgrades(upgrades, artifacts) {
|
|
207559
|
-
const
|
|
207560
|
-
upgrades,
|
|
207561
|
-
artifacts
|
|
207562
|
-
);
|
|
207560
|
+
const subprojectToUpgrade = await this.groupUpgradesBySubprojectAndWorkspace(upgrades, artifacts);
|
|
207563
207561
|
for (const [subprojectDir, workspaceToUpgrade] of subprojectToUpgrade) {
|
|
207564
207562
|
const fixingManager = getFixingManagerFromPackageManager(
|
|
207565
|
-
|
|
207563
|
+
getPackageMangerForDirectory(subprojectDir),
|
|
207566
207564
|
this.rootDir,
|
|
207567
207565
|
subprojectDir
|
|
207568
207566
|
);
|
|
@@ -207572,7 +207570,6 @@ var NpmSocketUpgradeManager = class {
|
|
|
207572
207570
|
async groupUpgradesBySubprojectAndWorkspace(upgrades, artifacts) {
|
|
207573
207571
|
const subprojectToUpgrade = /* @__PURE__ */ new Map();
|
|
207574
207572
|
const workspaceToSubproject = /* @__PURE__ */ new Map();
|
|
207575
|
-
const workspaceToPackageManager = /* @__PURE__ */ new Map();
|
|
207576
207573
|
for (const upgrade of upgrades) {
|
|
207577
207574
|
const artifact = artifacts[upgrade.idx];
|
|
207578
207575
|
const lockFiles = artifact.manifestFiles?.filter(
|
|
@@ -207586,10 +207583,6 @@ var NpmSocketUpgradeManager = class {
|
|
|
207586
207583
|
const workspaces = isPnpmLockFile ? await getWorkspacePathsFromPnpmLockFile(subprojectDir, true) : await getWorkspacePathsFromPackageJSON(subprojectDir, true);
|
|
207587
207584
|
for (const workspace of workspaces) {
|
|
207588
207585
|
workspaceToSubproject.set(join9(subprojectDir, workspace), subprojectDir);
|
|
207589
|
-
workspaceToPackageManager.set(
|
|
207590
|
-
join9(subprojectDir, workspace),
|
|
207591
|
-
isPnpmLockFile ? "PNPM" : lockFile.file.endsWith("yarn.lock") ? "YARN" : "NPM"
|
|
207592
|
-
);
|
|
207593
207586
|
}
|
|
207594
207587
|
}
|
|
207595
207588
|
const packageJsonFiles = artifact.manifestFiles?.filter((a4) => a4.file.endsWith("package.json"));
|
|
@@ -207606,7 +207599,7 @@ var NpmSocketUpgradeManager = class {
|
|
|
207606
207599
|
subprojectToUpgrade.get(subprojectDir)?.get(workspacePath)?.push(upgrade);
|
|
207607
207600
|
}
|
|
207608
207601
|
}
|
|
207609
|
-
return
|
|
207602
|
+
return subprojectToUpgrade;
|
|
207610
207603
|
}
|
|
207611
207604
|
async applySecurityFixesForSocketArtifacts(fixingManager, artifacts, workspaceTofixes) {
|
|
207612
207605
|
for (const [workspacePath, upgrades] of workspaceTofixes.entries()) {
|
|
@@ -207643,6 +207636,15 @@ function getFixingManagerFromPackageManager(packageManager, rootDir, subprojectP
|
|
|
207643
207636
|
return new YarnFixingManager(rootDir, subprojectPath);
|
|
207644
207637
|
}
|
|
207645
207638
|
}
|
|
207639
|
+
function getPackageMangerForDirectory(directory) {
|
|
207640
|
+
if (existsSync10(join9(directory, "pnpm-lock.yaml")) || existsSync10(join9(directory, "pnpm-lock.yml"))) {
|
|
207641
|
+
return "PNPM";
|
|
207642
|
+
} else if (existsSync10(join9(directory, "yarn.lock"))) {
|
|
207643
|
+
return "YARN";
|
|
207644
|
+
} else {
|
|
207645
|
+
return "NPM";
|
|
207646
|
+
}
|
|
207647
|
+
}
|
|
207646
207648
|
|
|
207647
207649
|
// ../fixing-management/src/main.ts
|
|
207648
207650
|
var fixingManagerConstructors = {
|
|
@@ -207688,7 +207690,7 @@ async function applySocketUpgrades(ecosystem, rootDir, upgrades, artifacts) {
|
|
|
207688
207690
|
|
|
207689
207691
|
// dist/cli-apply-fix.js
|
|
207690
207692
|
var import_lodash12 = __toESM(require_lodash(), 1);
|
|
207691
|
-
import { existsSync as
|
|
207693
|
+
import { existsSync as existsSync13 } from "fs";
|
|
207692
207694
|
|
|
207693
207695
|
// ../other-modules-communicator/src/other-modules-communicator.ts
|
|
207694
207696
|
import { execFileSync } from "child_process";
|
|
@@ -208434,7 +208436,7 @@ async function detectVariantMaven(projectDir) {
|
|
|
208434
208436
|
}
|
|
208435
208437
|
|
|
208436
208438
|
// ../docker-management/src/maven/gradle-version-detector.ts
|
|
208437
|
-
import { existsSync as
|
|
208439
|
+
import { existsSync as existsSync11 } from "fs";
|
|
208438
208440
|
import { join as join12 } from "path";
|
|
208439
208441
|
import { readFile as readFile14 } from "fs/promises";
|
|
208440
208442
|
async function detectVariantGradle(projectDir) {
|
|
@@ -208442,7 +208444,7 @@ async function detectVariantGradle(projectDir) {
|
|
|
208442
208444
|
}
|
|
208443
208445
|
async function detect(projectDir) {
|
|
208444
208446
|
const gradleWrapperPropertiesPath = join12(projectDir, "gradle", "wrapper", "gradle-wrapper.properties");
|
|
208445
|
-
const gradleWrapperProperties =
|
|
208447
|
+
const gradleWrapperProperties = existsSync11(gradleWrapperPropertiesPath) ? (await readFile14(gradleWrapperPropertiesPath, "utf-8")).split("\n").map((line) => line.trim()).filter((line) => !line.startsWith("#")).filter((line) => line) : void 0;
|
|
208446
208448
|
if (!gradleWrapperProperties) return void 0;
|
|
208447
208449
|
const distributionUrlRegex = /.*gradle-(\d+(\.\d+(\.\d+)?)?)/;
|
|
208448
208450
|
for (const prop2 of gradleWrapperProperties) {
|
|
@@ -208456,7 +208458,7 @@ async function detect(projectDir) {
|
|
|
208456
208458
|
}
|
|
208457
208459
|
|
|
208458
208460
|
// ../docker-management/src/maven/sbt-version-detector.ts
|
|
208459
|
-
import { existsSync as
|
|
208461
|
+
import { existsSync as existsSync12 } from "fs";
|
|
208460
208462
|
import { join as join13 } from "path";
|
|
208461
208463
|
import { readFile as readFile15 } from "fs/promises";
|
|
208462
208464
|
async function detectVariantSbt(projectDir) {
|
|
@@ -208464,7 +208466,7 @@ async function detectVariantSbt(projectDir) {
|
|
|
208464
208466
|
}
|
|
208465
208467
|
async function detect2(projectDir) {
|
|
208466
208468
|
const sbtBuildPropertiesPath = join13(projectDir, "project", "build.properties");
|
|
208467
|
-
const sbtBuildProperties =
|
|
208469
|
+
const sbtBuildProperties = existsSync12(sbtBuildPropertiesPath) ? (await readFile15(sbtBuildPropertiesPath, "utf-8")).split("\n").map((line) => line.trim()).filter((line) => !line.startsWith("#")).filter((line) => line) : void 0;
|
|
208468
208470
|
if (!sbtBuildProperties) return void 0;
|
|
208469
208471
|
for (const prop2 of sbtBuildProperties) {
|
|
208470
208472
|
const [key, value] = prop2.split("=");
|
|
@@ -209881,7 +209883,7 @@ async function verifyFixes(fixes, otherModulesCommunicator, rootPath) {
|
|
|
209881
209883
|
if (pathsForEachFixIdData.length !== new Set(pathsForEachFixIdData).size) {
|
|
209882
209884
|
throw new Error("Multiple fix IDs found for the same subproject, workspace and ecosystem");
|
|
209883
209885
|
}
|
|
209884
|
-
const subprojectsNotFound = uniq3(fixes.filter(({ vulnerabilityInstance: v }) => !
|
|
209886
|
+
const subprojectsNotFound = uniq3(fixes.filter(({ vulnerabilityInstance: v }) => !existsSync13(resolve19(rootPath, v.subprojectPath))).map(({ vulnerabilityInstance: v }) => `${v.subprojectPath}:${v.ecosystem}`));
|
|
209885
209887
|
if (subprojectsNotFound.length > 0) {
|
|
209886
209888
|
throw new Error(`Cannot find the following subprojects: ${subprojectsNotFound.join(", ")}`);
|
|
209887
209889
|
}
|
|
@@ -210805,12 +210807,12 @@ import { readdir as readdir7 } from "fs/promises";
|
|
|
210805
210807
|
import { join as join19, relative as relative10, resolve as resolve22 } from "path";
|
|
210806
210808
|
|
|
210807
210809
|
// ../project-management/src/project-management/ecosystem-management/ecosystem-specs.ts
|
|
210808
|
-
import { existsSync as
|
|
210810
|
+
import { existsSync as existsSync15 } from "fs";
|
|
210809
210811
|
import { readdir as readdir6, readFile as readFile19 } from "fs/promises";
|
|
210810
210812
|
import { join as join18, sep as sep4 } from "path";
|
|
210811
210813
|
|
|
210812
210814
|
// ../utils/src/pip-utils.ts
|
|
210813
|
-
import { existsSync as
|
|
210815
|
+
import { existsSync as existsSync14 } from "fs";
|
|
210814
210816
|
import { readFile as readFile18 } from "fs/promises";
|
|
210815
210817
|
import { resolve as resolve21 } from "path";
|
|
210816
210818
|
import util6 from "util";
|
|
@@ -210907,7 +210909,7 @@ function getEcosystemSpecs(ecosystems) {
|
|
|
210907
210909
|
}
|
|
210908
210910
|
function packageManagerIfPackageJSONExistsAndValid(packageManager) {
|
|
210909
210911
|
return async (projectDir) => {
|
|
210910
|
-
if (!
|
|
210912
|
+
if (!existsSync15(join18(projectDir, "package.json"))) return void 0;
|
|
210911
210913
|
const packageJSONPath = join18(projectDir, "package.json");
|
|
210912
210914
|
try {
|
|
210913
210915
|
JSON.parse(await readFile19(packageJSONPath, "utf-8"));
|
|
@@ -211379,16 +211381,16 @@ function isVulnChainWithParentsMap(v) {
|
|
|
211379
211381
|
var DEFAULT_REPORT_FILENAME_BASE = "coana-report";
|
|
211380
211382
|
|
|
211381
211383
|
// dist/internal/exclude-dirs-from-configuration-files.js
|
|
211382
|
-
import { existsSync as
|
|
211384
|
+
import { existsSync as existsSync16 } from "fs";
|
|
211383
211385
|
import { readFile as readFile20 } from "fs/promises";
|
|
211384
211386
|
import { basename as basename5, resolve as resolve24 } from "path";
|
|
211385
211387
|
var import_yaml2 = __toESM(require_dist11(), 1);
|
|
211386
211388
|
async function inferExcludeDirsFromConfigurationFiles(rootWorkingDir) {
|
|
211387
211389
|
const socketYmlConfigFile = resolve24(rootWorkingDir, "socket.yml");
|
|
211388
|
-
if (
|
|
211390
|
+
if (existsSync16(socketYmlConfigFile))
|
|
211389
211391
|
return inferExcludeDirsFromSocketConfig(socketYmlConfigFile);
|
|
211390
211392
|
const socketYamlConfigFile = resolve24(rootWorkingDir, "socket.yaml");
|
|
211391
|
-
if (
|
|
211393
|
+
if (existsSync16(socketYamlConfigFile))
|
|
211392
211394
|
return inferExcludeDirsFromSocketConfig(socketYamlConfigFile);
|
|
211393
211395
|
return void 0;
|
|
211394
211396
|
}
|
|
@@ -224924,7 +224926,7 @@ var { root: root2 } = static_exports;
|
|
|
224924
224926
|
|
|
224925
224927
|
// ../utils/src/maven-utils.ts
|
|
224926
224928
|
var import_lodash14 = __toESM(require_lodash(), 1);
|
|
224927
|
-
import { existsSync as
|
|
224929
|
+
import { existsSync as existsSync17, readdirSync as readdirSync4, statSync as statSync4 } from "fs";
|
|
224928
224930
|
import { join as join20 } from "path";
|
|
224929
224931
|
var { memoize: memoize3 } = import_lodash14.default;
|
|
224930
224932
|
var memoizedParseShellArgs = memoize3(parseShellArgs);
|
|
@@ -226296,7 +226298,7 @@ async function onlineScan(dependencyTree, apiKey, timeout) {
|
|
|
226296
226298
|
}
|
|
226297
226299
|
|
|
226298
226300
|
// dist/version.js
|
|
226299
|
-
var version2 = "14.10.
|
|
226301
|
+
var version2 = "14.10.6";
|
|
226300
226302
|
|
|
226301
226303
|
// ../../node_modules/.pnpm/axios@1.9.0/node_modules/axios/lib/helpers/bind.js
|
|
226302
226304
|
function bind3(fn2, thisArg) {
|
|
@@ -230826,9 +230828,7 @@ async function computeFixesAndUpgradePurls(path2, options) {
|
|
|
230826
230828
|
logger.info("Run again with --apply-fixes-to GHSA_IDS to fix those vulnerabilities by computing packages to upgrade and apply them");
|
|
230827
230829
|
return;
|
|
230828
230830
|
}
|
|
230829
|
-
const vulnerableArtifactIdsForGhsas = options.applyFixesTo.flatMap((ghsa) => [
|
|
230830
|
-
...vulnerableArtifactIdsPerVulnerability.get(ghsa)?.values() ?? []
|
|
230831
|
-
]);
|
|
230831
|
+
const vulnerableArtifactIdsForGhsas = options.applyFixesTo.includes("all") ? Array.from(vulnerableArtifactIdsPerVulnerability.values()).flatMap((ids) => Array.from(ids)) : options.applyFixesTo.flatMap((ghsa) => [...vulnerableArtifactIdsPerVulnerability.get(ghsa)?.values() ?? []]);
|
|
230832
230832
|
const computedFix = await useSocketComputeFixEndpoint(artifacts, vulnerableArtifactIdsForGhsas);
|
|
230833
230833
|
if (computedFix.type !== "success") {
|
|
230834
230834
|
throw new Error(`No fix found for the given vulnerabilities`);
|
|
@@ -231009,7 +231009,7 @@ upgradePurls.name("upgrade-purls").argument("<path>", "File system path to the f
|
|
|
231009
231009
|
await upgradePurl(path2, upgradeSpecs, options);
|
|
231010
231010
|
}).configureHelp({ sortOptions: true });
|
|
231011
231011
|
var computeFixesAndUpgradePurlsCmd = new Command();
|
|
231012
|
-
computeFixesAndUpgradePurlsCmd.name("compute-fixes-and-upgrade-purls").argument("<path>", "File system path to the folder containing the project").option("-a, --apply-fixes-to <ghsas...>",
|
|
231012
|
+
computeFixesAndUpgradePurlsCmd.name("compute-fixes-and-upgrade-purls").argument("<path>", "File system path to the folder containing the project").option("-a, --apply-fixes-to <ghsas...>", 'GHSA IDs to compute fixes for. Use "all" to compute fixes for all vulnerabilities.', []).option("--dry-run", "Show what changes would be made without actually making them", false).option("-g, --glob <pattern>", "Glob pattern to filter workspaces by absolute file path").option("-d, --debug", "Enable debug logging", false).option("-s, --silent", "Silence all debug/warning output", false).addOption(new Option("--run-without-docker", "Run package managers without using docker").default(process.env.RUN_WITHOUT_DOCKER === "true").hideHelp()).addOption(new Option("--manifests-tar-hash <hash>", "Hash of the tarball containing all manifest files already uploaded to Socket. If provided, Socket will be used for computing dependency trees.").hideHelp()).version(version2).action(async (path2, options) => {
|
|
231013
231013
|
process.env.DOCKER_IMAGE_TAG ??= version2;
|
|
231014
231014
|
await computeFixesAndUpgradePurls(path2, options);
|
|
231015
231015
|
}).configureHelp({ sortOptions: true });
|