snyk 1.1072.0 → 1.1074.0
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/dist/cli/784.index.js
CHANGED
|
@@ -1098,7 +1098,7 @@ async function fetchIssues(start_time, dep_graph_data, component_details, target
|
|
|
1098
1098
|
};
|
|
1099
1099
|
}
|
|
1100
1100
|
async function resolveAndTestFactsUnmanagedDeps(scans, options) {
|
|
1101
|
-
var _a, _b, _c, _d;
|
|
1101
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1102
1102
|
const results = [];
|
|
1103
1103
|
const errors = [];
|
|
1104
1104
|
const packageManager = 'Unmanaged (C/C++)';
|
|
@@ -1114,6 +1114,9 @@ async function resolveAndTestFactsUnmanagedDeps(scans, options) {
|
|
|
1114
1114
|
for (const scanResult of scanResults) {
|
|
1115
1115
|
try {
|
|
1116
1116
|
const id = await submitHashes({ hashes: (_a = scanResult === null || scanResult === void 0 ? void 0 : scanResult.facts[0]) === null || _a === void 0 ? void 0 : _a.data }, orgId);
|
|
1117
|
+
if (scanResult.analytics) {
|
|
1118
|
+
plugin_analytics_1.extractAndApplyPluginAnalytics(scanResult.analytics, id);
|
|
1119
|
+
}
|
|
1117
1120
|
const { start_time, dep_graph_data, component_details, } = await pollDepGraphAttributes(id, orgId);
|
|
1118
1121
|
const { issues, issuesData, depGraphData, dependencyCount, depsFilePaths, fileSignaturesDetails, } = await fetchIssues(start_time, dep_graph_data, component_details, target_severity, orgId);
|
|
1119
1122
|
const issuesMap = new Map();
|
|
@@ -1134,6 +1137,20 @@ async function resolveAndTestFactsUnmanagedDeps(scans, options) {
|
|
|
1134
1137
|
}
|
|
1135
1138
|
const policy = await policy_1.findAndLoadPolicy(path, 'cpp', options);
|
|
1136
1139
|
const [issuesFiltered, issuesDataFiltered] = policy_2.filterIgnoredIssues(issues, issuesData, policy);
|
|
1140
|
+
plugin_analytics_1.extractAndApplyPluginAnalytics([
|
|
1141
|
+
{
|
|
1142
|
+
name: 'packageManager',
|
|
1143
|
+
data: (_f = (_e = depGraphData === null || depGraphData === void 0 ? void 0 : depGraphData.pkgManager) === null || _e === void 0 ? void 0 : _e.name) !== null && _f !== void 0 ? _f : '',
|
|
1144
|
+
},
|
|
1145
|
+
{
|
|
1146
|
+
name: 'unmanagedDependencyCount',
|
|
1147
|
+
data: (_g = depGraphData === null || depGraphData === void 0 ? void 0 : depGraphData.pkgs.length) !== null && _g !== void 0 ? _g : 0,
|
|
1148
|
+
},
|
|
1149
|
+
{
|
|
1150
|
+
name: 'unmanagedIssuesCount',
|
|
1151
|
+
data: (_h = issues.length) !== null && _h !== void 0 ? _h : 0,
|
|
1152
|
+
},
|
|
1153
|
+
]);
|
|
1137
1154
|
results.push({
|
|
1138
1155
|
issues: issuesFiltered,
|
|
1139
1156
|
issuesData: issuesDataFiltered,
|
|
@@ -3864,21 +3881,34 @@ async function inspect(root, targetFile, options = {}) {
|
|
|
3864
3881
|
const isLockFileBased = targetFile.endsWith('package-lock.json') ||
|
|
3865
3882
|
targetFile.endsWith('yarn.lock');
|
|
3866
3883
|
const getLockFileDeps = isLockFileBased && !options.traverseNodeModules;
|
|
3867
|
-
const
|
|
3884
|
+
const depRes = getLockFileDeps
|
|
3868
3885
|
? await lockParser.parse(root, targetFile, options)
|
|
3869
3886
|
: await modulesParser.parse(root, targetFile, options);
|
|
3870
|
-
|
|
3871
|
-
|
|
3887
|
+
let scannedProjects = [];
|
|
3888
|
+
if (isResDepGraph(depRes)) {
|
|
3889
|
+
if (depRes.pkgManager.version) {
|
|
3890
|
+
analytics.add('lockfileVersion', depRes.pkgManager.version);
|
|
3891
|
+
}
|
|
3892
|
+
scannedProjects = [{ depGraph: depRes }];
|
|
3893
|
+
}
|
|
3894
|
+
else {
|
|
3895
|
+
if ((_a = depRes.meta) === null || _a === void 0 ? void 0 : _a.lockfileVersion) {
|
|
3896
|
+
analytics.add('lockfileVersion', depRes.meta.lockfileVersion);
|
|
3897
|
+
}
|
|
3898
|
+
scannedProjects = [{ depTree: depRes }];
|
|
3872
3899
|
}
|
|
3873
3900
|
return {
|
|
3874
3901
|
plugin: {
|
|
3875
3902
|
name: 'snyk-nodejs-lockfile-parser',
|
|
3876
3903
|
runtime: process.version,
|
|
3877
3904
|
},
|
|
3878
|
-
scannedProjects
|
|
3905
|
+
scannedProjects,
|
|
3879
3906
|
};
|
|
3880
3907
|
}
|
|
3881
3908
|
exports.inspect = inspect;
|
|
3909
|
+
function isResDepGraph(depRes) {
|
|
3910
|
+
return 'rootPkg' in depRes;
|
|
3911
|
+
}
|
|
3882
3912
|
|
|
3883
3913
|
|
|
3884
3914
|
/***/ }),
|
|
@@ -3897,6 +3927,7 @@ const spinner_1 = __webpack_require__(86766);
|
|
|
3897
3927
|
const analytics = __webpack_require__(82744);
|
|
3898
3928
|
const fs = __webpack_require__(35747);
|
|
3899
3929
|
const lockFileParser = __webpack_require__(423);
|
|
3930
|
+
const snyk_nodejs_lockfile_parser_1 = __webpack_require__(423);
|
|
3900
3931
|
async function parse(root, targetFile, options) {
|
|
3901
3932
|
const lockFileFullPath = path.resolve(root, targetFile);
|
|
3902
3933
|
if (!fs.existsSync(lockFileFullPath)) {
|
|
@@ -3922,9 +3953,19 @@ async function parse(root, targetFile, options) {
|
|
|
3922
3953
|
});
|
|
3923
3954
|
const resolveModuleSpinnerLabel = `Analyzing npm dependencies for ${lockFileFullPath}`;
|
|
3924
3955
|
debug(resolveModuleSpinnerLabel);
|
|
3956
|
+
const strictOutOfSync = options.strictOutOfSync !== false;
|
|
3957
|
+
const lockfileVersion = lockFileParser.getLockfileVersionFromFile(lockFileFullPath);
|
|
3958
|
+
if (lockfileVersion === snyk_nodejs_lockfile_parser_1.NodeLockfileVersion.YarnLockV1 ||
|
|
3959
|
+
lockfileVersion === snyk_nodejs_lockfile_parser_1.NodeLockfileVersion.YarnLockV2) {
|
|
3960
|
+
return await buildDepGraph(root, manifestFileFullPath, lockFileFullPath, lockfileVersion, {
|
|
3961
|
+
includeDevDeps: options.dev || false,
|
|
3962
|
+
includeOptionalDeps: true,
|
|
3963
|
+
strictOutOfSync,
|
|
3964
|
+
pruneCycles: true,
|
|
3965
|
+
});
|
|
3966
|
+
}
|
|
3925
3967
|
try {
|
|
3926
3968
|
await spinner_1.spinner(resolveModuleSpinnerLabel);
|
|
3927
|
-
const strictOutOfSync = options.strictOutOfSync !== false;
|
|
3928
3969
|
return lockFileParser.buildDepTreeFromFiles(root, manifestFileFullPath, lockFileFullPath, options.dev, strictOutOfSync);
|
|
3929
3970
|
}
|
|
3930
3971
|
finally {
|
|
@@ -3932,6 +3973,26 @@ async function parse(root, targetFile, options) {
|
|
|
3932
3973
|
}
|
|
3933
3974
|
}
|
|
3934
3975
|
exports.parse = parse;
|
|
3976
|
+
async function buildDepGraph(root, manifestFilePath, lockfilePath, lockfileVersion, options) {
|
|
3977
|
+
const manifestFileFullPath = path.resolve(root, manifestFilePath);
|
|
3978
|
+
const lockFileFullPath = path.resolve(root, lockfilePath);
|
|
3979
|
+
if (!fs.existsSync(manifestFileFullPath)) {
|
|
3980
|
+
throw new snyk_nodejs_lockfile_parser_1.InvalidUserInputError('Target file package.json not found at ' +
|
|
3981
|
+
`location: ${manifestFileFullPath}`);
|
|
3982
|
+
}
|
|
3983
|
+
if (!fs.existsSync(lockFileFullPath)) {
|
|
3984
|
+
throw new snyk_nodejs_lockfile_parser_1.InvalidUserInputError('Lockfile not found at location: ' + lockFileFullPath);
|
|
3985
|
+
}
|
|
3986
|
+
const manifestFileContents = fs.readFileSync(manifestFileFullPath, 'utf-8');
|
|
3987
|
+
const lockFileContents = fs.readFileSync(lockFileFullPath, 'utf-8');
|
|
3988
|
+
switch (lockfileVersion) {
|
|
3989
|
+
case snyk_nodejs_lockfile_parser_1.NodeLockfileVersion.YarnLockV1:
|
|
3990
|
+
return await lockFileParser.parseYarnLockV1Project(manifestFileContents, lockFileContents, options);
|
|
3991
|
+
case snyk_nodejs_lockfile_parser_1.NodeLockfileVersion.YarnLockV2:
|
|
3992
|
+
return lockFileParser.parseYarnLockV2Project(manifestFileContents, lockFileContents, options);
|
|
3993
|
+
}
|
|
3994
|
+
throw new Error('Failed to build dep graph from current project');
|
|
3995
|
+
}
|
|
3935
3996
|
|
|
3936
3997
|
|
|
3937
3998
|
/***/ }),
|