@coana-tech/cli 14.9.19 → 14.9.21
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 +151 -63
- package/package.json +1 -1
package/cli.mjs
CHANGED
|
@@ -212320,7 +212320,7 @@ async function onlineScan(dependencyTree, apiKey, timeout) {
|
|
|
212320
212320
|
}
|
|
212321
212321
|
|
|
212322
212322
|
// dist/version.js
|
|
212323
|
-
var version2 = "14.9.
|
|
212323
|
+
var version2 = "14.9.21";
|
|
212324
212324
|
|
|
212325
212325
|
// ../../node_modules/.pnpm/axios@1.9.0/node_modules/axios/lib/helpers/bind.js
|
|
212326
212326
|
function bind2(fn2, thisArg) {
|
|
@@ -215677,22 +215677,36 @@ async function scanForVulnerabilitiesSocketMode(dependencyTree) {
|
|
|
215677
215677
|
let simplePurlForComponent = simplePurl(c3.purl_type, c3.namespace, c3.name, c3.version);
|
|
215678
215678
|
if (!(simplePurlForComponent in purlStringsToIdentifier))
|
|
215679
215679
|
simplePurlForComponent = simplePurl(c3.purl_type, c3.namespace, c3.name, null);
|
|
215680
|
-
const
|
|
215681
|
-
|
|
215682
|
-
|
|
215683
|
-
|
|
215684
|
-
|
|
215685
|
-
|
|
215686
|
-
|
|
215687
|
-
|
|
215688
|
-
|
|
215689
|
-
|
|
215690
|
-
|
|
215691
|
-
|
|
215692
|
-
|
|
215693
|
-
|
|
215694
|
-
|
|
215695
|
-
|
|
215680
|
+
const dependencyIdentifiers = purlStringsToIdentifier[simplePurlForComponent];
|
|
215681
|
+
for (const dependencyIdentifier of dependencyIdentifiers) {
|
|
215682
|
+
dependencyIdentifiersNotFound.delete(dependencyIdentifier);
|
|
215683
|
+
const dependencyTreeNode = dependencyTree.transitiveDependencies[dependencyIdentifier];
|
|
215684
|
+
if (!dependencyTreeNode)
|
|
215685
|
+
throw new Error(`Dependency tree does not contain dependency ${simplePurlForComponent}`);
|
|
215686
|
+
dependencyTreeNode.purlObj = {
|
|
215687
|
+
type: c3.purl_type,
|
|
215688
|
+
namespace: c3.namespace ?? void 0,
|
|
215689
|
+
name: c3.name,
|
|
215690
|
+
version: c3.version ?? void 0,
|
|
215691
|
+
subpath: c3.subpath ?? void 0,
|
|
215692
|
+
artifactId: c3.artifactId ?? void 0,
|
|
215693
|
+
artifact_id: c3.artifact_id ?? void 0,
|
|
215694
|
+
qualifiers: c3.qualifiers ?? void 0,
|
|
215695
|
+
purlString: c3.purl
|
|
215696
|
+
};
|
|
215697
|
+
for (const vulnerability of c3.vulnerabilities) {
|
|
215698
|
+
vulnerabilities.push({
|
|
215699
|
+
url: vulnerability.ghsaId,
|
|
215700
|
+
purl: c3.purl,
|
|
215701
|
+
purlType: c3.purl_type,
|
|
215702
|
+
range: vulnerability.range,
|
|
215703
|
+
name: dependencyTreeNode.packageName,
|
|
215704
|
+
dependency: dependencyTreeNode.packageName,
|
|
215705
|
+
vulnChainDetails: computeVulnChainDetails(dependencyTree, dependencyIdentifier, parentsMap),
|
|
215706
|
+
vulnerabilityAccessPaths: vulnerability.reachabilityData?.pattern,
|
|
215707
|
+
ecosystem: dependencyTree.ecosystem
|
|
215708
|
+
});
|
|
215709
|
+
}
|
|
215696
215710
|
}
|
|
215697
215711
|
}
|
|
215698
215712
|
for (const dependencyIdentifier of dependencyIdentifiersNotFound) {
|
|
@@ -215707,7 +215721,9 @@ function getPurlStrings(dependencyTree) {
|
|
|
215707
215721
|
const { namespace: namespace2, name } = getNamespaceAndName(dependencyTree.ecosystem, node.packageName);
|
|
215708
215722
|
const version3 = node.version;
|
|
215709
215723
|
const purl = simplePurl(type, namespace2, name, version3);
|
|
215710
|
-
res[purl]
|
|
215724
|
+
if (!res[purl])
|
|
215725
|
+
res[purl] = /* @__PURE__ */ new Set();
|
|
215726
|
+
res[purl].add(depId);
|
|
215711
215727
|
}
|
|
215712
215728
|
return res;
|
|
215713
215729
|
}
|
|
@@ -215753,19 +215769,19 @@ function transformToVulnChainNode(dependencyTree) {
|
|
|
215753
215769
|
function getPurlType(ecosystem) {
|
|
215754
215770
|
switch (ecosystem) {
|
|
215755
215771
|
case "NPM":
|
|
215756
|
-
return
|
|
215772
|
+
return "npm" /* NPM */;
|
|
215757
215773
|
case "MAVEN":
|
|
215758
|
-
return
|
|
215774
|
+
return "maven" /* MAVEN */;
|
|
215759
215775
|
case "PIP":
|
|
215760
|
-
return
|
|
215776
|
+
return "pypi" /* PYPI */;
|
|
215761
215777
|
case "NUGET":
|
|
215762
|
-
return
|
|
215778
|
+
return "nuget" /* NUGET */;
|
|
215763
215779
|
case "GO":
|
|
215764
|
-
return
|
|
215780
|
+
return "golang" /* GOLANG */;
|
|
215765
215781
|
case "RUST":
|
|
215766
|
-
return
|
|
215782
|
+
return "cargo" /* CARGO */;
|
|
215767
215783
|
case "RUBYGEMS":
|
|
215768
|
-
return
|
|
215784
|
+
return "gem" /* GEM */;
|
|
215769
215785
|
default:
|
|
215770
215786
|
throw new Error(`Unsupported ecosystem: ${ecosystem}`);
|
|
215771
215787
|
}
|
|
@@ -215794,39 +215810,112 @@ function getNamespaceAndName(ecosystem, packageName) {
|
|
|
215794
215810
|
}
|
|
215795
215811
|
return { namespace: namespace2, name };
|
|
215796
215812
|
}
|
|
215797
|
-
|
|
215798
|
-
|
|
215799
|
-
|
|
215800
|
-
|
|
215801
|
-
|
|
215802
|
-
|
|
215803
|
-
|
|
215804
|
-
|
|
215805
|
-
|
|
215806
|
-
|
|
215807
|
-
|
|
215808
|
-
|
|
215809
|
-
|
|
215810
|
-
|
|
215811
|
-
|
|
215812
|
-
|
|
215813
|
-
|
|
215814
|
-
|
|
215815
|
-
|
|
215816
|
-
|
|
215817
|
-
|
|
215818
|
-
|
|
215819
|
-
|
|
215820
|
-
|
|
215821
|
-
|
|
215822
|
-
|
|
215823
|
-
|
|
215824
|
-
|
|
215825
|
-
|
|
215826
|
-
|
|
215827
|
-
|
|
215828
|
-
|
|
215829
|
-
|
|
215813
|
+
|
|
215814
|
+
// dist/internal/socket-report.js
|
|
215815
|
+
function toSocketFacts(report, dependencyTrees) {
|
|
215816
|
+
const components = [];
|
|
215817
|
+
const purlToIndex = /* @__PURE__ */ new Map();
|
|
215818
|
+
for (const dependencyTree of dependencyTrees) {
|
|
215819
|
+
const depIdentifierToPurl = Object.fromEntries(Object.entries(dependencyTree.dependencyTree.transitiveDependencies).map(([depIdentifier, dep]) => {
|
|
215820
|
+
const purl = dep.purlObj.purlString;
|
|
215821
|
+
if (purl && !purlToIndex.has(purl)) {
|
|
215822
|
+
purlToIndex.set(purl, components.length);
|
|
215823
|
+
const depTreeNode = dependencyTree.dependencyTree.transitiveDependencies[depIdentifier];
|
|
215824
|
+
components[purlToIndex.get(purl)] = {
|
|
215825
|
+
id: purlToIndex.get(purl).toString(),
|
|
215826
|
+
type: depTreeNode.purlObj.type,
|
|
215827
|
+
name: depTreeNode.purlObj.name,
|
|
215828
|
+
version: depTreeNode.purlObj.version,
|
|
215829
|
+
namespace: depTreeNode.purlObj.namespace,
|
|
215830
|
+
subpath: depTreeNode.purlObj.subpath,
|
|
215831
|
+
artifact_id: depTreeNode.purlObj.artifact_id,
|
|
215832
|
+
artifactId: depTreeNode.purlObj.artifactId,
|
|
215833
|
+
qualifiers: depTreeNode.purlObj.qualifiers,
|
|
215834
|
+
// direct: false, // TODO: add direct flag
|
|
215835
|
+
// dev: false, // TODO: add dev flag
|
|
215836
|
+
dependencies: []
|
|
215837
|
+
};
|
|
215838
|
+
}
|
|
215839
|
+
return [depIdentifier, purl];
|
|
215840
|
+
}));
|
|
215841
|
+
for (const [depIdentifier, purl] of Object.entries(depIdentifierToPurl)) {
|
|
215842
|
+
const depTreeNode = dependencyTree.dependencyTree.transitiveDependencies[depIdentifier];
|
|
215843
|
+
const component = components[purlToIndex.get(purl)];
|
|
215844
|
+
depTreeNode.dependencies?.forEach((dep) => {
|
|
215845
|
+
const depPurl = depIdentifierToPurl[dep];
|
|
215846
|
+
const depIndex = purlToIndex.get(depPurl);
|
|
215847
|
+
if (!component.dependencies?.includes(depIndex.toString())) {
|
|
215848
|
+
component.dependencies.push(depIndex.toString());
|
|
215849
|
+
}
|
|
215850
|
+
});
|
|
215851
|
+
}
|
|
215852
|
+
}
|
|
215853
|
+
for (const vulnerability of report.vulnerabilities) {
|
|
215854
|
+
const component = components[purlToIndex.get(vulnerability.purl)];
|
|
215855
|
+
if (!component) {
|
|
215856
|
+
throw new Error(`Component not found for vulnerability ${vulnerability.purl}`);
|
|
215857
|
+
}
|
|
215858
|
+
if (!component.reachability) {
|
|
215859
|
+
component.reachability = [];
|
|
215860
|
+
}
|
|
215861
|
+
let reachabilityForGHSA = component.reachability?.find((r2) => r2.ghsa_id === vulnerability.vulnerabilityUrl.replace("https://github.com/advisories/", ""));
|
|
215862
|
+
if (!reachabilityForGHSA) {
|
|
215863
|
+
reachabilityForGHSA = {
|
|
215864
|
+
ghsa_id: vulnerability.vulnerabilityUrl.replace("https://github.com/advisories/", ""),
|
|
215865
|
+
reachability: []
|
|
215866
|
+
};
|
|
215867
|
+
component.reachability.push(reachabilityForGHSA);
|
|
215868
|
+
}
|
|
215869
|
+
reachabilityForGHSA.reachability.push({
|
|
215870
|
+
...toSocketReachabilitySchema(vulnerability),
|
|
215871
|
+
workspacePath: vulnerability.workspacePath,
|
|
215872
|
+
subprojectPath: vulnerability.subprojectPath
|
|
215873
|
+
});
|
|
215874
|
+
}
|
|
215875
|
+
return {
|
|
215876
|
+
components
|
|
215877
|
+
};
|
|
215878
|
+
}
|
|
215879
|
+
function toSocketReachabilitySchema(vulnerability) {
|
|
215880
|
+
if (vulnerability.codeAwareScanResult.type === "missingVulnerabilityPattern") {
|
|
215881
|
+
return { type: "missing_support" };
|
|
215882
|
+
}
|
|
215883
|
+
if (vulnerability.codeAwareScanResult.type === "noAnalysisCheck") {
|
|
215884
|
+
return { type: "undeterminable_reachability" };
|
|
215885
|
+
}
|
|
215886
|
+
if (vulnerability.codeAwareScanResult.type === "analysisError") {
|
|
215887
|
+
return { type: "error", error: vulnerability.codeAwareScanResult.message };
|
|
215888
|
+
}
|
|
215889
|
+
if (vulnerability.codeAwareScanResult.type === "otherError") {
|
|
215890
|
+
return { type: "error", error: vulnerability.codeAwareScanResult.message };
|
|
215891
|
+
}
|
|
215892
|
+
if (vulnerability.codeAwareScanResult.type === "success") {
|
|
215893
|
+
if (Array.isArray(vulnerability.codeAwareScanResult.detectedOccurrences)) {
|
|
215894
|
+
if (vulnerability.codeAwareScanResult.detectedOccurrences.length === 0) {
|
|
215895
|
+
return { type: "unreachable" };
|
|
215896
|
+
}
|
|
215897
|
+
throw new Error("Detected occurrences is an array with elements. This is a bug.");
|
|
215898
|
+
}
|
|
215899
|
+
const detOccWithStacks = vulnerability.codeAwareScanResult.detectedOccurrences;
|
|
215900
|
+
if (detOccWithStacks.stacks.length === 0) {
|
|
215901
|
+
return { type: "unreachable" };
|
|
215902
|
+
}
|
|
215903
|
+
if (detOccWithStacks.analysisLevel === "function-level") {
|
|
215904
|
+
return {
|
|
215905
|
+
type: "reachable",
|
|
215906
|
+
analysisLevel: detOccWithStacks.analysisLevel,
|
|
215907
|
+
matches: detOccWithStacks.stacks
|
|
215908
|
+
};
|
|
215909
|
+
} else if (detOccWithStacks.analysisLevel === "class-level") {
|
|
215910
|
+
return {
|
|
215911
|
+
type: "reachable",
|
|
215912
|
+
analysisLevel: detOccWithStacks.analysisLevel,
|
|
215913
|
+
matches: detOccWithStacks.stacks
|
|
215914
|
+
};
|
|
215915
|
+
}
|
|
215916
|
+
}
|
|
215917
|
+
throw new Error("Unknown codeAwareScanResult type");
|
|
215918
|
+
}
|
|
215830
215919
|
|
|
215831
215920
|
// dist/cli-core.js
|
|
215832
215921
|
var { omit, partition, pick } = import_lodash15.default;
|
|
@@ -215963,10 +216052,7 @@ var CliCore = class {
|
|
|
215963
216052
|
if (!this.reportDependencyTrees) {
|
|
215964
216053
|
throw new Error("Dependency trees should be available when using --socket-mode");
|
|
215965
216054
|
}
|
|
215966
|
-
const socketReport =
|
|
215967
|
-
...report,
|
|
215968
|
-
dependencyTrees: this.reportDependencyTrees
|
|
215969
|
-
};
|
|
216055
|
+
const socketReport = toSocketFacts(report, this.reportDependencyTrees);
|
|
215970
216056
|
const outputFile = resolve24(this.options.socketMode);
|
|
215971
216057
|
await writeFile10(outputFile, JSON.stringify(socketReport, null, 2));
|
|
215972
216058
|
logger.info(kleur_default.green(`Socket report written to: ${outputFile}`));
|
|
@@ -216305,7 +216391,9 @@ var CliCore = class {
|
|
|
216305
216391
|
packageVersion: vulnerableNode.version ?? "",
|
|
216306
216392
|
ecosystem: v.ecosystem ?? "NPM",
|
|
216307
216393
|
dependencyType,
|
|
216308
|
-
reachability
|
|
216394
|
+
reachability,
|
|
216395
|
+
purl: v.purl,
|
|
216396
|
+
purlType: v.purlType
|
|
216309
216397
|
};
|
|
216310
216398
|
});
|
|
216311
216399
|
}
|