@coana-tech/cli 14.12.20 → 14.12.22
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 +210 -139
- package/package.json +1 -1
- package/repos/coana-tech/alucard/alucard.jar +0 -0
- 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/mambalade/dist/mambalade-0.3.12-py3-none-any.whl +0 -0
package/cli.mjs
CHANGED
|
@@ -191180,12 +191180,18 @@ var GoFixingManager = class {
|
|
|
191180
191180
|
await applySeries(Object.entries(fixes), async ([workspacePath, fixesWithId]) => {
|
|
191181
191181
|
const dependencyTree = fixingInfo.dependencyTrees[workspacePath];
|
|
191182
191182
|
await applySeries(fixesWithId, async ({ fixId, vulnerabilityFixes }) => {
|
|
191183
|
-
await this.applySecurityFixesForWorkspace(
|
|
191183
|
+
await this.applySecurityFixesForWorkspace(
|
|
191184
|
+
workspacePath,
|
|
191185
|
+
vulnerabilityFixes,
|
|
191186
|
+
Object.fromEntries(
|
|
191187
|
+
Object.entries(dependencyTree.transitiveDependencies).map(([key, value]) => [key, value.version])
|
|
191188
|
+
)
|
|
191189
|
+
);
|
|
191184
191190
|
signalFixApplied2?.(fixId, this.subprojectPath, workspacePath, vulnerabilityFixes);
|
|
191185
191191
|
});
|
|
191186
191192
|
});
|
|
191187
191193
|
}
|
|
191188
|
-
async applySecurityFixesForWorkspace(workspacePath, fixes,
|
|
191194
|
+
async applySecurityFixesForWorkspace(workspacePath, fixes, dependencyNameToVersion) {
|
|
191189
191195
|
const subprojectPath = resolve(this.rootDir, this.subprojectPath, workspacePath);
|
|
191190
191196
|
const runGoGetCmd = async (projectPath, oldModule, newModule) => {
|
|
191191
191197
|
const success = await execAndLogOnFailure(["go", "get", newModule], projectPath);
|
|
@@ -191204,14 +191210,171 @@ var GoFixingManager = class {
|
|
|
191204
191210
|
for (const fix of fixes) {
|
|
191205
191211
|
const fixedRelease = `${fix.dependencyName}@v${fix.fixedVersion}`;
|
|
191206
191212
|
const currentRelease = `${fix.dependencyName}@v${fix.currentVersion}`;
|
|
191207
|
-
const
|
|
191208
|
-
if (
|
|
191213
|
+
const version3 = dependencyNameToVersion[fix.dependencyName];
|
|
191214
|
+
if (version3 !== fix.currentVersion) return;
|
|
191209
191215
|
await runGoGetCmd(subprojectPath, currentRelease, fixedRelease);
|
|
191210
191216
|
await excludeDowngraded(subprojectPath, fix);
|
|
191211
191217
|
}
|
|
191212
191218
|
}
|
|
191213
191219
|
};
|
|
191214
191220
|
|
|
191221
|
+
// ../fixing-management/src/fixing-management/go/go-socket-upgrade-manager.ts
|
|
191222
|
+
import { dirname } from "path";
|
|
191223
|
+
|
|
191224
|
+
// ../web-compat-utils/src/purl-utils.ts
|
|
191225
|
+
function getPurlType(ecosystem) {
|
|
191226
|
+
switch (ecosystem) {
|
|
191227
|
+
case "NPM":
|
|
191228
|
+
return "npm" /* NPM */;
|
|
191229
|
+
case "MAVEN":
|
|
191230
|
+
return "maven" /* MAVEN */;
|
|
191231
|
+
case "PIP":
|
|
191232
|
+
return "pypi" /* PYPI */;
|
|
191233
|
+
case "NUGET":
|
|
191234
|
+
return "nuget" /* NUGET */;
|
|
191235
|
+
case "GO":
|
|
191236
|
+
return "golang" /* GOLANG */;
|
|
191237
|
+
case "RUST":
|
|
191238
|
+
return "cargo" /* CARGO */;
|
|
191239
|
+
case "RUBYGEMS":
|
|
191240
|
+
return "gem" /* GEM */;
|
|
191241
|
+
default:
|
|
191242
|
+
throw Error(`Unsupported ecosystem: ${ecosystem}`);
|
|
191243
|
+
}
|
|
191244
|
+
}
|
|
191245
|
+
function getAdvisoryEcosystemFromPurl(purl) {
|
|
191246
|
+
const [purlSceme, rest] = purl.split(":");
|
|
191247
|
+
if (purlSceme !== "pkg") throw Error(`Upsupported purl scheme: ${purlSceme}`);
|
|
191248
|
+
const [purlType] = rest.split("/");
|
|
191249
|
+
return getAdvisoryEcosystemFromPurlType(purlType);
|
|
191250
|
+
}
|
|
191251
|
+
function getAdvisoryEcosystemFromPurlType(purlType) {
|
|
191252
|
+
switch (purlType) {
|
|
191253
|
+
case "npm" /* NPM */:
|
|
191254
|
+
return "NPM";
|
|
191255
|
+
case "maven" /* MAVEN */:
|
|
191256
|
+
return "MAVEN";
|
|
191257
|
+
case "pypi" /* PYPI */:
|
|
191258
|
+
return "PIP";
|
|
191259
|
+
case "nuget" /* NUGET */:
|
|
191260
|
+
return "NUGET";
|
|
191261
|
+
case "golang" /* GOLANG */:
|
|
191262
|
+
return "GO";
|
|
191263
|
+
case "cargo" /* CARGO */:
|
|
191264
|
+
return "RUST";
|
|
191265
|
+
case "gem" /* GEM */:
|
|
191266
|
+
return "RUBYGEMS";
|
|
191267
|
+
default:
|
|
191268
|
+
throw Error(`Unsupported purl type: ${purlType}`);
|
|
191269
|
+
}
|
|
191270
|
+
}
|
|
191271
|
+
function getPurlStrings(dependencyTree) {
|
|
191272
|
+
const res = {};
|
|
191273
|
+
for (const [depId, node] of Object.entries(dependencyTree.transitiveDependencies)) {
|
|
191274
|
+
const type = getPurlType(dependencyTree.ecosystem ?? "NPM");
|
|
191275
|
+
const { namespace: namespace2, name } = getNamespaceAndName(dependencyTree.ecosystem, node.packageName);
|
|
191276
|
+
const version3 = node.version;
|
|
191277
|
+
const purl = simplePurl(type, namespace2, name, version3);
|
|
191278
|
+
if (!res[purl]) res[purl] = /* @__PURE__ */ new Set();
|
|
191279
|
+
res[purl].add(depId);
|
|
191280
|
+
}
|
|
191281
|
+
return res;
|
|
191282
|
+
}
|
|
191283
|
+
function simplePurl(type, namespace2, name, version3) {
|
|
191284
|
+
return `pkg:${type}${namespace2 ? `/${namespace2}` : ""}/${name}${version3 ? `@${version3}` : ""}`;
|
|
191285
|
+
}
|
|
191286
|
+
function getNamespaceAndName(ecosystem, packageName) {
|
|
191287
|
+
let namespace2 = "";
|
|
191288
|
+
let name = "";
|
|
191289
|
+
switch (ecosystem) {
|
|
191290
|
+
case "NPM":
|
|
191291
|
+
if (packageName.includes("/")) [namespace2, name] = packageName.split("/", 2);
|
|
191292
|
+
else name = packageName;
|
|
191293
|
+
break;
|
|
191294
|
+
case "MAVEN":
|
|
191295
|
+
if (packageName.includes(":")) [namespace2, name] = packageName.split(":", 2);
|
|
191296
|
+
else name = packageName;
|
|
191297
|
+
break;
|
|
191298
|
+
case "PIP":
|
|
191299
|
+
name = packageName;
|
|
191300
|
+
break;
|
|
191301
|
+
default:
|
|
191302
|
+
name = packageName;
|
|
191303
|
+
}
|
|
191304
|
+
return { namespace: namespace2, name };
|
|
191305
|
+
}
|
|
191306
|
+
function getNameFromNamespaceAndName(purlType, namespace2, name) {
|
|
191307
|
+
if (!name) return "";
|
|
191308
|
+
switch (purlType) {
|
|
191309
|
+
case "npm" /* NPM */:
|
|
191310
|
+
return namespace2 ? `${namespace2}/${name}` : name;
|
|
191311
|
+
case "maven" /* MAVEN */:
|
|
191312
|
+
return namespace2 ? `${namespace2}:${name}` : name;
|
|
191313
|
+
case "pypi" /* PYPI */:
|
|
191314
|
+
return name;
|
|
191315
|
+
case "golang" /* GOLANG */:
|
|
191316
|
+
return namespace2 ? `${namespace2}/${name}` : name;
|
|
191317
|
+
default:
|
|
191318
|
+
return name;
|
|
191319
|
+
}
|
|
191320
|
+
}
|
|
191321
|
+
|
|
191322
|
+
// ../fixing-management/src/fixing-management/go/go-socket-upgrade-manager.ts
|
|
191323
|
+
var GoSocketUpgradeManager = class {
|
|
191324
|
+
constructor(rootDir) {
|
|
191325
|
+
this.rootDir = rootDir;
|
|
191326
|
+
}
|
|
191327
|
+
async applySocketArtifactUpgrades(_manifestFiles, upgrades, artifacts, rangeStyle) {
|
|
191328
|
+
const subprojectsToUpgrade = await this.groupUpgradesBySubproject(upgrades, artifacts);
|
|
191329
|
+
for (const [subprojectDir, upgradesForSubproject] of subprojectsToUpgrade) {
|
|
191330
|
+
const fixingManager = new GoFixingManager(this.rootDir, subprojectDir);
|
|
191331
|
+
await this.applySecurityFixesForSocketArtifacts(fixingManager, artifacts, upgradesForSubproject, rangeStyle);
|
|
191332
|
+
}
|
|
191333
|
+
}
|
|
191334
|
+
async groupUpgradesBySubproject(upgrades, artifacts) {
|
|
191335
|
+
const subprojectToUpgrade = /* @__PURE__ */ new Map();
|
|
191336
|
+
for (const upgrade of upgrades) {
|
|
191337
|
+
const artifact = artifacts[upgrade.idx];
|
|
191338
|
+
const goModFiles = artifact.manifestFiles?.filter((a5) => a5.file.endsWith("go.mod")) ?? [];
|
|
191339
|
+
artifact.toplevelAncestors?.forEach((ancestorId) => {
|
|
191340
|
+
const ancestor = artifacts.find((a5) => a5.id === ancestorId);
|
|
191341
|
+
if (ancestor) {
|
|
191342
|
+
const ancestorGoModFiles = ancestor.manifestFiles?.filter((a5) => a5.file.endsWith("go.mod")) ?? [];
|
|
191343
|
+
goModFiles.push(...ancestorGoModFiles);
|
|
191344
|
+
}
|
|
191345
|
+
});
|
|
191346
|
+
if (goModFiles.length === 0) {
|
|
191347
|
+
throw new Error("Failed to find go.mod file for artifact");
|
|
191348
|
+
}
|
|
191349
|
+
for (const goModFile of goModFiles) {
|
|
191350
|
+
const subprojectDir = dirname(goModFile.file);
|
|
191351
|
+
if (!subprojectToUpgrade.has(subprojectDir)) {
|
|
191352
|
+
subprojectToUpgrade.set(subprojectDir, []);
|
|
191353
|
+
}
|
|
191354
|
+
subprojectToUpgrade.get(subprojectDir).push(upgrade);
|
|
191355
|
+
}
|
|
191356
|
+
}
|
|
191357
|
+
return subprojectToUpgrade;
|
|
191358
|
+
}
|
|
191359
|
+
async applySecurityFixesForSocketArtifacts(fixingManager, artifacts, upgrades, _rangeStyle) {
|
|
191360
|
+
const normalizeVersion = (version3) => version3.startsWith("v") ? version3.slice(1) : version3;
|
|
191361
|
+
const upgradesTransformed = upgrades.map((upgrade) => ({
|
|
191362
|
+
dependencyName: getNameFromNamespaceAndName(
|
|
191363
|
+
"golang" /* GOLANG */,
|
|
191364
|
+
artifacts[upgrade.idx].namespace,
|
|
191365
|
+
artifacts[upgrade.idx].name
|
|
191366
|
+
),
|
|
191367
|
+
currentVersion: normalizeVersion(artifacts[upgrade.idx].version ?? ""),
|
|
191368
|
+
dependencyIdentifier: "" + upgrade.idx,
|
|
191369
|
+
fixedVersion: normalizeVersion(upgrade.upgradeVersion)
|
|
191370
|
+
}));
|
|
191371
|
+
const dependencies = Object.fromEntries(
|
|
191372
|
+
upgradesTransformed.map((fix) => [fix.dependencyName, fix.currentVersion])
|
|
191373
|
+
);
|
|
191374
|
+
await fixingManager.applySecurityFixesForWorkspace(".", upgradesTransformed, dependencies);
|
|
191375
|
+
}
|
|
191376
|
+
};
|
|
191377
|
+
|
|
191215
191378
|
// ../fixing-management/src/fixing-management/maven/gradle-fixing-manager.ts
|
|
191216
191379
|
import { existsSync as existsSync3 } from "node:fs";
|
|
191217
191380
|
import { readFile as readFile5 } from "node:fs/promises";
|
|
@@ -193615,7 +193778,7 @@ import { resolve as resolve6 } from "node:path";
|
|
|
193615
193778
|
var import_parse_xml2 = __toESM(require_dist(), 1);
|
|
193616
193779
|
import { readFile as readFile6 } from "node:fs/promises";
|
|
193617
193780
|
import { existsSync as existsSync4 } from "node:fs";
|
|
193618
|
-
import { resolve as resolve5, join as join4, relative as relative2, dirname } from "node:path";
|
|
193781
|
+
import { resolve as resolve5, join as join4, relative as relative2, dirname as dirname2 } from "node:path";
|
|
193619
193782
|
|
|
193620
193783
|
// ../fixing-management/src/fixing-management/utils/xml-utils.ts
|
|
193621
193784
|
var import_parse_xml = __toESM(require_dist(), 1);
|
|
@@ -194103,7 +194266,7 @@ function getParentPomPath(pom) {
|
|
|
194103
194266
|
if (!parentElement) return void 0;
|
|
194104
194267
|
const relativePathElement = parentElement.children.filter((child) => child instanceof import_parse_xml2.XmlElement).find((child) => child.name === "relativePath");
|
|
194105
194268
|
const relativePath = relativePathElement?.text ?? join4("..", "pom.xml");
|
|
194106
|
-
return relativePath ? resolve5(
|
|
194269
|
+
return relativePath ? resolve5(dirname2(pom.validatedPomFile), relativePath) : void 0;
|
|
194107
194270
|
}
|
|
194108
194271
|
|
|
194109
194272
|
// ../fixing-management/src/fixing-management/maven/maven-fixing-manager.ts
|
|
@@ -194455,7 +194618,7 @@ var MavenFixingManager = class {
|
|
|
194455
194618
|
|
|
194456
194619
|
// ../fixing-management/src/fixing-management/maven/maven-socket-upgrade-manager.ts
|
|
194457
194620
|
var import_picomatch = __toESM(require_picomatch2(), 1);
|
|
194458
|
-
import { basename, dirname as
|
|
194621
|
+
import { basename, dirname as dirname3, relative as relative4, resolve as resolve10 } from "node:path";
|
|
194459
194622
|
|
|
194460
194623
|
// ../fixing-management/src/fixing-management/utils/socket-patch-application.ts
|
|
194461
194624
|
import { existsSync as existsSync5 } from "node:fs";
|
|
@@ -194549,102 +194712,6 @@ async function applySocketPatchResults(ecosystem, rootDir, patchResults) {
|
|
|
194549
194712
|
}
|
|
194550
194713
|
}
|
|
194551
194714
|
|
|
194552
|
-
// ../web-compat-utils/src/purl-utils.ts
|
|
194553
|
-
function getPurlType(ecosystem) {
|
|
194554
|
-
switch (ecosystem) {
|
|
194555
|
-
case "NPM":
|
|
194556
|
-
return "npm" /* NPM */;
|
|
194557
|
-
case "MAVEN":
|
|
194558
|
-
return "maven" /* MAVEN */;
|
|
194559
|
-
case "PIP":
|
|
194560
|
-
return "pypi" /* PYPI */;
|
|
194561
|
-
case "NUGET":
|
|
194562
|
-
return "nuget" /* NUGET */;
|
|
194563
|
-
case "GO":
|
|
194564
|
-
return "golang" /* GOLANG */;
|
|
194565
|
-
case "RUST":
|
|
194566
|
-
return "cargo" /* CARGO */;
|
|
194567
|
-
case "RUBYGEMS":
|
|
194568
|
-
return "gem" /* GEM */;
|
|
194569
|
-
default:
|
|
194570
|
-
throw Error(`Unsupported ecosystem: ${ecosystem}`);
|
|
194571
|
-
}
|
|
194572
|
-
}
|
|
194573
|
-
function getAdvisoryEcosystemFromPurl(purl) {
|
|
194574
|
-
const [purlSceme, rest] = purl.split(":");
|
|
194575
|
-
if (purlSceme !== "pkg") throw Error(`Upsupported purl scheme: ${purlSceme}`);
|
|
194576
|
-
const [purlType] = rest.split("/");
|
|
194577
|
-
return getAdvisoryEcosystemFromPurlType(purlType);
|
|
194578
|
-
}
|
|
194579
|
-
function getAdvisoryEcosystemFromPurlType(purlType) {
|
|
194580
|
-
switch (purlType) {
|
|
194581
|
-
case "npm" /* NPM */:
|
|
194582
|
-
return "NPM";
|
|
194583
|
-
case "maven" /* MAVEN */:
|
|
194584
|
-
return "MAVEN";
|
|
194585
|
-
case "pypi" /* PYPI */:
|
|
194586
|
-
return "PIP";
|
|
194587
|
-
case "nuget" /* NUGET */:
|
|
194588
|
-
return "NUGET";
|
|
194589
|
-
case "golang" /* GOLANG */:
|
|
194590
|
-
return "GO";
|
|
194591
|
-
case "cargo" /* CARGO */:
|
|
194592
|
-
return "RUST";
|
|
194593
|
-
case "gem" /* GEM */:
|
|
194594
|
-
return "RUBYGEMS";
|
|
194595
|
-
default:
|
|
194596
|
-
throw Error(`Unsupported purl type: ${purlType}`);
|
|
194597
|
-
}
|
|
194598
|
-
}
|
|
194599
|
-
function getPurlStrings(dependencyTree) {
|
|
194600
|
-
const res = {};
|
|
194601
|
-
for (const [depId, node] of Object.entries(dependencyTree.transitiveDependencies)) {
|
|
194602
|
-
const type = getPurlType(dependencyTree.ecosystem ?? "NPM");
|
|
194603
|
-
const { namespace: namespace2, name } = getNamespaceAndName(dependencyTree.ecosystem, node.packageName);
|
|
194604
|
-
const version3 = node.version;
|
|
194605
|
-
const purl = simplePurl(type, namespace2, name, version3);
|
|
194606
|
-
if (!res[purl]) res[purl] = /* @__PURE__ */ new Set();
|
|
194607
|
-
res[purl].add(depId);
|
|
194608
|
-
}
|
|
194609
|
-
return res;
|
|
194610
|
-
}
|
|
194611
|
-
function simplePurl(type, namespace2, name, version3) {
|
|
194612
|
-
return `pkg:${type}${namespace2 ? `/${namespace2}` : ""}/${name}${version3 ? `@${version3}` : ""}`;
|
|
194613
|
-
}
|
|
194614
|
-
function getNamespaceAndName(ecosystem, packageName) {
|
|
194615
|
-
let namespace2 = "";
|
|
194616
|
-
let name = "";
|
|
194617
|
-
switch (ecosystem) {
|
|
194618
|
-
case "NPM":
|
|
194619
|
-
if (packageName.includes("/")) [namespace2, name] = packageName.split("/", 2);
|
|
194620
|
-
else name = packageName;
|
|
194621
|
-
break;
|
|
194622
|
-
case "MAVEN":
|
|
194623
|
-
if (packageName.includes(":")) [namespace2, name] = packageName.split(":", 2);
|
|
194624
|
-
else name = packageName;
|
|
194625
|
-
break;
|
|
194626
|
-
case "PIP":
|
|
194627
|
-
name = packageName;
|
|
194628
|
-
break;
|
|
194629
|
-
default:
|
|
194630
|
-
name = packageName;
|
|
194631
|
-
}
|
|
194632
|
-
return { namespace: namespace2, name };
|
|
194633
|
-
}
|
|
194634
|
-
function getNameFromNamespaceAndName(purlType, namespace2, name) {
|
|
194635
|
-
if (!name) return "";
|
|
194636
|
-
switch (purlType) {
|
|
194637
|
-
case "npm" /* NPM */:
|
|
194638
|
-
return namespace2 ? `${namespace2}/${name}` : name;
|
|
194639
|
-
case "maven" /* MAVEN */:
|
|
194640
|
-
return namespace2 ? `${namespace2}:${name}` : name;
|
|
194641
|
-
case "pypi" /* PYPI */:
|
|
194642
|
-
return name;
|
|
194643
|
-
default:
|
|
194644
|
-
return name;
|
|
194645
|
-
}
|
|
194646
|
-
}
|
|
194647
|
-
|
|
194648
194715
|
// ../fixing-management/src/fixing-management/utils/socket-required-upgrade-helper.ts
|
|
194649
194716
|
function collectRequiredSocketUpgradesByIndex(ecosystem, upgrades, originalArtifacts, recomputedArtifacts) {
|
|
194650
194717
|
const requiredUpgrades = [];
|
|
@@ -198408,13 +198475,14 @@ async function getLatestBucketsSocket(subprojectPath, workspacePath) {
|
|
|
198408
198475
|
return void 0;
|
|
198409
198476
|
}
|
|
198410
198477
|
}
|
|
198411
|
-
async function useSocketComputeFixEndpoint(autofixRunId, artifacts, vulnerableArtifactIdsForGhsas) {
|
|
198478
|
+
async function useSocketComputeFixEndpoint(autofixRunId, artifacts, vulnerableArtifactIdsForGhsas, config3) {
|
|
198412
198479
|
try {
|
|
198413
198480
|
const url2 = getSocketApiUrl("fixes/compute-fixes");
|
|
198414
198481
|
const data2 = {
|
|
198415
198482
|
autofixRunId,
|
|
198416
198483
|
artifacts,
|
|
198417
|
-
vulnerableArtifactIndexes: vulnerableArtifactIdsForGhsas
|
|
198484
|
+
vulnerableArtifactIndexes: vulnerableArtifactIdsForGhsas,
|
|
198485
|
+
config: config3
|
|
198418
198486
|
};
|
|
198419
198487
|
return (await axios2.post(url2, data2, { headers: getAuthHeaders() })).data;
|
|
198420
198488
|
} catch (error) {
|
|
@@ -198567,8 +198635,8 @@ var MavenSocketUpgradeManager = class {
|
|
|
198567
198635
|
const manifestFileSet = /* @__PURE__ */ new Set();
|
|
198568
198636
|
for (const manifestFile of manifestFiles) {
|
|
198569
198637
|
let shouldAdd = true;
|
|
198570
|
-
let curr =
|
|
198571
|
-
while (shouldAdd && curr !==
|
|
198638
|
+
let curr = dirname3(manifestFile);
|
|
198639
|
+
while (shouldAdd && curr !== dirname3(curr)) {
|
|
198572
198640
|
const dirName3 = basename(curr);
|
|
198573
198641
|
if (dirName3 === "target" || dirName3 === "build") {
|
|
198574
198642
|
shouldAdd = false;
|
|
@@ -198577,7 +198645,7 @@ var MavenSocketUpgradeManager = class {
|
|
|
198577
198645
|
`Skipping manifest file ${manifestFile} - appears to be generated by ${buildSystem} (found in ${dirName3}/)`
|
|
198578
198646
|
);
|
|
198579
198647
|
}
|
|
198580
|
-
curr =
|
|
198648
|
+
curr = dirname3(curr);
|
|
198581
198649
|
}
|
|
198582
198650
|
if (shouldAdd) manifestFileSet.add(resolve10(this.rootDir, manifestFile));
|
|
198583
198651
|
}
|
|
@@ -205797,7 +205865,7 @@ glob.glob = glob;
|
|
|
205797
205865
|
// ../utils/src/npm-utils.ts
|
|
205798
205866
|
var import_lodash4 = __toESM(require_lodash(), 1);
|
|
205799
205867
|
var import_lockfile_file = __toESM(require_lib25(), 1);
|
|
205800
|
-
import { dirname as
|
|
205868
|
+
import { dirname as dirname5, relative as relative6, resolve as resolve12, sep as sep2 } from "path";
|
|
205801
205869
|
|
|
205802
205870
|
// ../utils/dist/command-utils.js
|
|
205803
205871
|
import assert4 from "assert";
|
|
@@ -206030,7 +206098,7 @@ function argt2(statics, ...values) {
|
|
|
206030
206098
|
}
|
|
206031
206099
|
|
|
206032
206100
|
// ../utils/dist/package-utils.js
|
|
206033
|
-
import { parse, join as join7, resolve as resolve11, normalize as normalize2, dirname as
|
|
206101
|
+
import { parse, join as join7, resolve as resolve11, normalize as normalize2, dirname as dirname4, basename as basename2, relative as relative5 } from "path";
|
|
206034
206102
|
import { existsSync as existsSync7, readFileSync, readdirSync as readdirSync2, statSync, writeFileSync } from "fs";
|
|
206035
206103
|
function getPackageJsonObject(workspaceRoot) {
|
|
206036
206104
|
const packageJSONContent = getPackageJsonContent(workspaceRoot);
|
|
@@ -206098,7 +206166,7 @@ async function getWorkspacePathsFromPackageJSON(projectFolder, useDotWhenNoWorks
|
|
|
206098
206166
|
const workspacePaths = [];
|
|
206099
206167
|
await asyncForEach(workspaceGlobPatternsArray, async (workspace) => {
|
|
206100
206168
|
workspacePaths.push(
|
|
206101
|
-
...(await glob(resolve12(projectFolder, workspace, "package.json"))).map((path2) => relative6(projectFolder,
|
|
206169
|
+
...(await glob(resolve12(projectFolder, workspace, "package.json"))).map((path2) => relative6(projectFolder, dirname5(path2))).filter((path2) => !path2.includes(`${sep2}node_modules${sep2}`))
|
|
206102
206170
|
);
|
|
206103
206171
|
});
|
|
206104
206172
|
return workspacePaths;
|
|
@@ -206378,7 +206446,7 @@ import { readFile as readFile14, writeFile as writeFile5 } from "fs/promises";
|
|
|
206378
206446
|
import { resolve as resolve16 } from "path";
|
|
206379
206447
|
|
|
206380
206448
|
// ../utils/src/package-utils.ts
|
|
206381
|
-
import { parse as parse2, join as join8, resolve as resolve15, normalize as normalize3, dirname as
|
|
206449
|
+
import { parse as parse2, join as join8, resolve as resolve15, normalize as normalize3, dirname as dirname6, basename as basename3, relative as relative7 } from "path";
|
|
206382
206450
|
import { existsSync as existsSync9, readFileSync as readFileSync2, readdirSync as readdirSync3, statSync as statSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
206383
206451
|
function setFieldInPackageJson(workspaceRoot, field, value) {
|
|
206384
206452
|
const packageJSONContentObj = getPackageJsonObject2(workspaceRoot);
|
|
@@ -206633,7 +206701,7 @@ var YarnFixingManager = class extends NpmEcosystemFixingManager {
|
|
|
206633
206701
|
};
|
|
206634
206702
|
|
|
206635
206703
|
// ../fixing-management/src/fixing-management/npm/npm-ecosystem-socket-fixing-manager.ts
|
|
206636
|
-
import { dirname as
|
|
206704
|
+
import { dirname as dirname7, join as join9, relative as relative8 } from "path";
|
|
206637
206705
|
import { existsSync as existsSync10 } from "fs";
|
|
206638
206706
|
import { readFile as readFile15, writeFile as writeFile6 } from "fs/promises";
|
|
206639
206707
|
function applyUpgradesToPackageJson(packageJsonContent, upgrades, rangeStyle) {
|
|
@@ -206703,7 +206771,7 @@ var NpmSocketUpgradeManager = class {
|
|
|
206703
206771
|
)
|
|
206704
206772
|
);
|
|
206705
206773
|
for (const lockFile of lockFiles ?? []) {
|
|
206706
|
-
const subprojectDir =
|
|
206774
|
+
const subprojectDir = dirname7(lockFile.file);
|
|
206707
206775
|
const isPnpmLockFile = lockFile.file.endsWith("pnpm-lock.yaml") || lockFile.file.endsWith("pnpm-lock.yml");
|
|
206708
206776
|
const workspaces = isPnpmLockFile ? await getWorkspacePathsFromPnpmLockFile(subprojectDir, true) : await getWorkspacePathsFromPackageJSON(subprojectDir, true);
|
|
206709
206777
|
for (const workspace of workspaces) {
|
|
@@ -206712,13 +206780,13 @@ var NpmSocketUpgradeManager = class {
|
|
|
206712
206780
|
}
|
|
206713
206781
|
const packageJsonFiles = artifact.manifestFiles?.filter((a5) => a5.file.endsWith("package.json")) ?? [];
|
|
206714
206782
|
for (const lockFile of lockFiles ?? []) {
|
|
206715
|
-
const correspondingPackageJsonFile = join9(
|
|
206783
|
+
const correspondingPackageJsonFile = join9(dirname7(lockFile.file), "package.json");
|
|
206716
206784
|
if (!packageJsonFiles.some((p3) => p3.file === correspondingPackageJsonFile) && existsSync10(correspondingPackageJsonFile)) {
|
|
206717
206785
|
packageJsonFiles.push({ file: correspondingPackageJsonFile });
|
|
206718
206786
|
}
|
|
206719
206787
|
}
|
|
206720
206788
|
for (const packageJsonFile of packageJsonFiles ?? []) {
|
|
206721
|
-
const packageJsonDir =
|
|
206789
|
+
const packageJsonDir = dirname7(packageJsonFile.file);
|
|
206722
206790
|
const subprojectDir = workspaceToSubproject.get(packageJsonDir) ?? packageJsonDir;
|
|
206723
206791
|
if (!subprojectToUpgrade.has(subprojectDir)) {
|
|
206724
206792
|
subprojectToUpgrade.set(subprojectDir, /* @__PURE__ */ new Map());
|
|
@@ -207104,7 +207172,7 @@ import { basename as basename4, relative as relative10, resolve as resolve18 } f
|
|
|
207104
207172
|
// ../fixing-management/src/fixing-management/nuget/nuget-project-utils.ts
|
|
207105
207173
|
var import_parse_xml3 = __toESM(require_dist(), 1);
|
|
207106
207174
|
import { readFile as readFile17 } from "node:fs/promises";
|
|
207107
|
-
import { dirname as
|
|
207175
|
+
import { dirname as dirname8, join as join12, relative as relative9, resolve as resolve17 } from "node:path";
|
|
207108
207176
|
import { existsSync as existsSync11 } from "node:fs";
|
|
207109
207177
|
function normalizeMSBuildPath(path2) {
|
|
207110
207178
|
return path2.replace(/\\/g, "/");
|
|
@@ -207196,8 +207264,8 @@ function extractPackagesFromXml(xmlDoc, fileContent) {
|
|
|
207196
207264
|
}
|
|
207197
207265
|
async function findDirectoryBuildPropsProjects(project, validateFile) {
|
|
207198
207266
|
const projectsReverse = [];
|
|
207199
|
-
let currentDir =
|
|
207200
|
-
while (currentDir.startsWith(project.rootDir) && currentDir !==
|
|
207267
|
+
let currentDir = dirname8(project.validatedProjectPath);
|
|
207268
|
+
while (currentDir.startsWith(project.rootDir) && currentDir !== dirname8(currentDir)) {
|
|
207201
207269
|
const unvalidatedPath = join12(currentDir, "Directory.Build.props");
|
|
207202
207270
|
const validatedPath = validateFile(unvalidatedPath);
|
|
207203
207271
|
if (validatedPath && validatedPath !== project.validatedProjectPath) {
|
|
@@ -207211,19 +207279,19 @@ async function findDirectoryBuildPropsProjects(project, validateFile) {
|
|
|
207211
207279
|
projectsReverse.push(directoryBuildPropsProject);
|
|
207212
207280
|
}
|
|
207213
207281
|
}
|
|
207214
|
-
currentDir =
|
|
207282
|
+
currentDir = dirname8(currentDir);
|
|
207215
207283
|
}
|
|
207216
207284
|
return projectsReverse.reverse();
|
|
207217
207285
|
}
|
|
207218
207286
|
async function findDirectoryPackagesPropsProjects(project, validateFile) {
|
|
207219
|
-
let currentDir =
|
|
207220
|
-
while (currentDir.startsWith(project.rootDir) && currentDir !==
|
|
207287
|
+
let currentDir = dirname8(project.validatedProjectPath);
|
|
207288
|
+
while (currentDir.startsWith(project.rootDir) && currentDir !== dirname8(currentDir)) {
|
|
207221
207289
|
const unvalidatedPath = join12(currentDir, "Directory.Packages.props");
|
|
207222
207290
|
const validatedPath = validateFile(unvalidatedPath);
|
|
207223
207291
|
if (validatedPath) {
|
|
207224
207292
|
return validatedPath !== project.validatedProjectPath ? await loadNuGetProject(project.rootDir, unvalidatedPath, validateFile, project.visited) : void 0;
|
|
207225
207293
|
}
|
|
207226
|
-
currentDir =
|
|
207294
|
+
currentDir = dirname8(currentDir);
|
|
207227
207295
|
}
|
|
207228
207296
|
return void 0;
|
|
207229
207297
|
}
|
|
@@ -207249,7 +207317,7 @@ async function handleImportElement(project, importElement, validateFile) {
|
|
|
207249
207317
|
if (!projectValue) return;
|
|
207250
207318
|
const importPath = evaluate2(projectValue.text, project);
|
|
207251
207319
|
if (!importPath) return;
|
|
207252
|
-
const resolvedPath = resolve17(
|
|
207320
|
+
const resolvedPath = resolve17(dirname8(project.validatedProjectPath), normalizeMSBuildPath(importPath));
|
|
207253
207321
|
const validatedPath = validateFile(resolvedPath);
|
|
207254
207322
|
if (!validatedPath || !existsSync11(validatedPath)) return;
|
|
207255
207323
|
const importedProject = await loadNuGetProject(project.rootDir, resolvedPath, validateFile, project.visited);
|
|
@@ -207990,6 +208058,7 @@ var fixingManagerConstructors = {
|
|
|
207990
208058
|
}
|
|
207991
208059
|
};
|
|
207992
208060
|
var socketUpgradeManagerConstructors = {
|
|
208061
|
+
GO: GoSocketUpgradeManager,
|
|
207993
208062
|
MAVEN: MavenSocketUpgradeManager,
|
|
207994
208063
|
NPM: NpmSocketUpgradeManager,
|
|
207995
208064
|
NUGET: NuGetSocketUpgradeManager
|
|
@@ -208027,7 +208096,7 @@ import { resolve as resolve20 } from "path";
|
|
|
208027
208096
|
|
|
208028
208097
|
// ../utils/dist/constants.js
|
|
208029
208098
|
var import_lodash6 = __toESM(require_lodash(), 1);
|
|
208030
|
-
import { dirname as
|
|
208099
|
+
import { dirname as dirname9, join as join14 } from "node:path";
|
|
208031
208100
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
208032
208101
|
|
|
208033
208102
|
// ../utils/dist/file-utils.js
|
|
@@ -208055,7 +208124,7 @@ function findParent(dir, predicate, wholePath) {
|
|
|
208055
208124
|
// ../utils/dist/constants.js
|
|
208056
208125
|
var { once: once2 } = import_lodash6.default;
|
|
208057
208126
|
var fileName = fileURLToPath3(import.meta.url);
|
|
208058
|
-
var dirName =
|
|
208127
|
+
var dirName = dirname9(fileName);
|
|
208059
208128
|
var COANA_ROOT = once2(() => {
|
|
208060
208129
|
const coanaRoot = process.env.COANA_ROOT ?? findParent(dirName, (d3) => ["coana-package-manager", "coana"].includes(d3));
|
|
208061
208130
|
if (!coanaRoot) {
|
|
@@ -209179,11 +209248,11 @@ import { resolve as resolve22 } from "path";
|
|
|
209179
209248
|
|
|
209180
209249
|
// ../utils/src/constants.ts
|
|
209181
209250
|
var import_lodash9 = __toESM(require_lodash(), 1);
|
|
209182
|
-
import { dirname as
|
|
209251
|
+
import { dirname as dirname10, join as join19 } from "node:path";
|
|
209183
209252
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
209184
209253
|
var { once: once4 } = import_lodash9.default;
|
|
209185
209254
|
var fileName2 = fileURLToPath4(import.meta.url);
|
|
209186
|
-
var dirName2 =
|
|
209255
|
+
var dirName2 = dirname10(fileName2);
|
|
209187
209256
|
var COANA_ROOT2 = once4(() => {
|
|
209188
209257
|
const coanaRoot = process.env.COANA_ROOT ?? findParent2(dirName2, (d3) => ["coana-package-manager", "coana"].includes(d3));
|
|
209189
209258
|
if (!coanaRoot) {
|
|
@@ -211799,13 +211868,13 @@ function transformToVulnChainNode(dependencyTree) {
|
|
|
211799
211868
|
// dist/internal/socket-mode-helpers-socket-dependency-trees.js
|
|
211800
211869
|
var import_packageurl_js = __toESM(require_packageurl_js(), 1);
|
|
211801
211870
|
var import_picomatch3 = __toESM(require_picomatch2(), 1);
|
|
211802
|
-
import { basename as basename8, dirname as
|
|
211871
|
+
import { basename as basename8, dirname as dirname11, join as join24, sep as sep5 } from "path";
|
|
211803
211872
|
var REQUIREMENTS_FILES_SEARCH_DEPTH2 = 3;
|
|
211804
211873
|
function inferWorkspaceFromManifestPath(ecosystem, manifestPath, properPythonProjects) {
|
|
211805
211874
|
switch (ecosystem) {
|
|
211806
211875
|
case "NPM": {
|
|
211807
211876
|
const base = basename8(manifestPath);
|
|
211808
|
-
const dir =
|
|
211877
|
+
const dir = dirname11(manifestPath);
|
|
211809
211878
|
return base === "package.json" ? dir || "." : void 0;
|
|
211810
211879
|
}
|
|
211811
211880
|
case "MAVEN": {
|
|
@@ -211813,7 +211882,7 @@ function inferWorkspaceFromManifestPath(ecosystem, manifestPath, properPythonPro
|
|
|
211813
211882
|
}
|
|
211814
211883
|
case "PIP": {
|
|
211815
211884
|
const base = basename8(manifestPath);
|
|
211816
|
-
const dir =
|
|
211885
|
+
const dir = dirname11(manifestPath);
|
|
211817
211886
|
const workspaceDir = dir === "" ? "." : dir;
|
|
211818
211887
|
if (properPythonProjects.includes(workspaceDir)) {
|
|
211819
211888
|
return workspaceDir;
|
|
@@ -211835,11 +211904,11 @@ function inferWorkspaceFromManifestPath(ecosystem, manifestPath, properPythonPro
|
|
|
211835
211904
|
return ".";
|
|
211836
211905
|
}
|
|
211837
211906
|
case "RUST": {
|
|
211838
|
-
return
|
|
211907
|
+
return dirname11(manifestPath) || ".";
|
|
211839
211908
|
}
|
|
211840
211909
|
case "GO": {
|
|
211841
211910
|
const base = basename8(manifestPath);
|
|
211842
|
-
const dir =
|
|
211911
|
+
const dir = dirname11(manifestPath);
|
|
211843
211912
|
return base === "go.mod" ? dir || "." : void 0;
|
|
211844
211913
|
}
|
|
211845
211914
|
default: {
|
|
@@ -211852,7 +211921,7 @@ function inferProjectFromManifestPath(ecosystem, manifestPath) {
|
|
|
211852
211921
|
case "NPM": {
|
|
211853
211922
|
const filename = basename8(manifestPath);
|
|
211854
211923
|
if (["package-lock.json", "pnpm-lock.yaml", "pnpm-lock.yml", "yarn.lock"].includes(filename)) {
|
|
211855
|
-
return
|
|
211924
|
+
return dirname11(manifestPath) || ".";
|
|
211856
211925
|
}
|
|
211857
211926
|
return void 0;
|
|
211858
211927
|
}
|
|
@@ -211917,7 +211986,7 @@ async function fetchArtifactsFromSocket(rootWorkingDirectory, manifestsTarHash,
|
|
|
211917
211986
|
const allFiles = await getFilesRelative(rootWorkingDirectory, venvExcludes);
|
|
211918
211987
|
for (const file of allFiles) {
|
|
211919
211988
|
const base = basename8(file);
|
|
211920
|
-
const workspaceDir =
|
|
211989
|
+
const workspaceDir = dirname11(file) || ".";
|
|
211921
211990
|
if (base === "pyproject.toml" || base === "setup.py" && await isSetupPySetuptools(join24(rootWorkingDirectory, file))) {
|
|
211922
211991
|
if (!properPythonProjects.includes(workspaceDir)) {
|
|
211923
211992
|
properPythonProjects.push(workspaceDir);
|
|
@@ -227145,7 +227214,7 @@ async function onlineScan(dependencyTree, apiKey, timeout) {
|
|
|
227145
227214
|
}
|
|
227146
227215
|
|
|
227147
227216
|
// dist/version.js
|
|
227148
|
-
var version2 = "14.12.
|
|
227217
|
+
var version2 = "14.12.22";
|
|
227149
227218
|
|
|
227150
227219
|
// dist/cli-core.js
|
|
227151
227220
|
var { mapValues, omit, partition, pick } = import_lodash15.default;
|
|
@@ -227831,7 +227900,7 @@ async function getGitDataToMetadataIfAvailable(rootWorkingDirectory) {
|
|
|
227831
227900
|
// dist/cli-upgrade-purl.js
|
|
227832
227901
|
import { join as join27, relative as relative17 } from "node:path";
|
|
227833
227902
|
var import_packageurl_js2 = __toESM(require_packageurl_js(), 1);
|
|
227834
|
-
var ECOSYSTEMS_WITH_SOCKET_UPGRADES = ["NPM", "MAVEN", "NUGET"];
|
|
227903
|
+
var ECOSYSTEMS_WITH_SOCKET_UPGRADES = ["NPM", "MAVEN", "NUGET", "GO"];
|
|
227835
227904
|
async function upgradePurl(path2, upgrades, options, logFile, cliFixRunId) {
|
|
227836
227905
|
if (options.rangeStyle && options.rangeStyle !== "pin") {
|
|
227837
227906
|
throw new Error('Range style must be "pin"');
|
|
@@ -227989,7 +228058,9 @@ async function computeFixesAndUpgradePurls(path2, options, logFile) {
|
|
|
227989
228058
|
return;
|
|
227990
228059
|
}
|
|
227991
228060
|
const ghsaToVulnerableArtifactIdsToApply = options.applyFixesTo.includes("all") ? ghsaToVulnerableArtifactIds : Object.fromEntries(Object.entries(ghsaToVulnerableArtifactIds).filter(([ghsa]) => options.applyFixesTo.includes(ghsa)));
|
|
227992
|
-
const computedFix = await useSocketComputeFixEndpoint(autofixRunId, artifacts, ghsaToVulnerableArtifactIdsToApply
|
|
228061
|
+
const computedFix = await useSocketComputeFixEndpoint(autofixRunId, artifacts, ghsaToVulnerableArtifactIdsToApply, {
|
|
228062
|
+
noMajorUpdates: options.disableMajorUpdates
|
|
228063
|
+
});
|
|
227993
228064
|
if (computedFix.type !== "success") {
|
|
227994
228065
|
throw new Error(`No fix found for the given vulnerabilities`);
|
|
227995
228066
|
}
|
|
@@ -228163,7 +228234,7 @@ upgradePurls.name("upgrade-purls").argument("<path>", "File system path to the f
|
|
|
228163
228234
|
});
|
|
228164
228235
|
}).configureHelp({ sortOptions: true });
|
|
228165
228236
|
var computeFixesAndUpgradePurlsCmd = new Command();
|
|
228166
|
-
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).option("--range-style <style>", 'Range style to use for the output. Currently only "pin" is supported and it only works for npm.').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) => {
|
|
228237
|
+
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).option("--range-style <style>", 'Range style to use for the output. Currently only "pin" is supported and it only works for npm.').option("--disable-major-updates", "Do not suggest major updates. If only major update are available, the fix will not be applied.", 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) => {
|
|
228167
228238
|
process.env.DOCKER_IMAGE_TAG ??= version2;
|
|
228168
228239
|
if (options.rangeStyle && options.rangeStyle === "preserve") {
|
|
228169
228240
|
options.rangeStyle = void 0;
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|