snyk 1.779.0 → 1.780.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/917.index.js
CHANGED
|
@@ -1937,6 +1937,7 @@ exports.test = test;
|
|
|
1937
1937
|
|
|
1938
1938
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1939
1939
|
const Debug = __webpack_require__(15158);
|
|
1940
|
+
const os_1 = __webpack_require__(12087);
|
|
1940
1941
|
const cloneDeep = __webpack_require__(83465);
|
|
1941
1942
|
const assign = __webpack_require__(31730);
|
|
1942
1943
|
const chalk_1 = __webpack_require__(32589);
|
|
@@ -1957,6 +1958,8 @@ const set_default_test_options_1 = __webpack_require__(13285);
|
|
|
1957
1958
|
const process_command_args_1 = __webpack_require__(52369);
|
|
1958
1959
|
const format_test_error_1 = __webpack_require__(68214);
|
|
1959
1960
|
const display_result_1 = __webpack_require__(89667);
|
|
1961
|
+
const analytics = __webpack_require__(82744);
|
|
1962
|
+
const protect_update_notification_1 = __webpack_require__(79304);
|
|
1960
1963
|
const debug = Debug('snyk-test');
|
|
1961
1964
|
const SEPARATOR = '\n-------------------------------------------------------\n';
|
|
1962
1965
|
// TODO: avoid using `as any` whenever it's possible
|
|
@@ -1965,6 +1968,8 @@ async function test(...args) {
|
|
|
1965
1968
|
const options = set_default_test_options_1.setDefaultTestOptions(originalOptions);
|
|
1966
1969
|
validate_test_options_1.validateTestOptions(options);
|
|
1967
1970
|
validate_credentials_1.validateCredentials(options);
|
|
1971
|
+
const packageJsonPathsWithSnykDepForProtect = protect_update_notification_1.getPackageJsonPathsContainingSnykDependency(options.file, paths);
|
|
1972
|
+
analytics.add('upgradable-snyk-protect-paths', packageJsonPathsWithSnykDepForProtect.length);
|
|
1968
1973
|
// Handles no image arg provided to the container command until
|
|
1969
1974
|
// a validation interface is implemented in the docker plugin.
|
|
1970
1975
|
if (options.docker && paths.length === 0) {
|
|
@@ -2130,6 +2135,8 @@ async function test(...args) {
|
|
|
2130
2135
|
if (!fail) {
|
|
2131
2136
|
// return here to prevent throwing failure
|
|
2132
2137
|
response += chalk_1.default.bold.green(summaryMessage);
|
|
2138
|
+
response += os_1.EOL + os_1.EOL;
|
|
2139
|
+
response += protect_update_notification_1.getProtectUpgradeWarningForPaths(packageJsonPathsWithSnykDepForProtect);
|
|
2133
2140
|
return types_1.TestCommandResult.createHumanReadableTestCommandResult(response, stringifiedJsonData, stringifiedSarifData);
|
|
2134
2141
|
}
|
|
2135
2142
|
}
|
|
@@ -2146,6 +2153,8 @@ async function test(...args) {
|
|
|
2146
2153
|
throw error;
|
|
2147
2154
|
}
|
|
2148
2155
|
response += chalk_1.default.bold.green(summaryMessage);
|
|
2156
|
+
response += os_1.EOL + os_1.EOL;
|
|
2157
|
+
response += protect_update_notification_1.getProtectUpgradeWarningForPaths(packageJsonPathsWithSnykDepForProtect);
|
|
2149
2158
|
return types_1.TestCommandResult.createHumanReadableTestCommandResult(response, stringifiedJsonData, stringifiedSarifData);
|
|
2150
2159
|
}
|
|
2151
2160
|
exports.default = test;
|
|
@@ -2924,6 +2933,110 @@ function metadataForVuln(vuln) {
|
|
|
2924
2933
|
}
|
|
2925
2934
|
|
|
2926
2935
|
|
|
2936
|
+
/***/ }),
|
|
2937
|
+
|
|
2938
|
+
/***/ 79304:
|
|
2939
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2940
|
+
|
|
2941
|
+
"use strict";
|
|
2942
|
+
|
|
2943
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2944
|
+
exports.getPackageJsonPathsContainingSnykDependency = exports.checkPackageJsonForSnykDependency = exports.packageJsonFileExistsInDirectory = exports.getProtectUpgradeWarningForPaths = void 0;
|
|
2945
|
+
const os_1 = __webpack_require__(12087);
|
|
2946
|
+
const theme = __webpack_require__(86988);
|
|
2947
|
+
const fs = __webpack_require__(35747);
|
|
2948
|
+
const path = __webpack_require__(85622);
|
|
2949
|
+
const createDebug = __webpack_require__(15158);
|
|
2950
|
+
const debug = createDebug('snyk-protect-update-notification');
|
|
2951
|
+
function getProtectUpgradeWarningForPaths(packageJsonPaths) {
|
|
2952
|
+
try {
|
|
2953
|
+
if ((packageJsonPaths === null || packageJsonPaths === void 0 ? void 0 : packageJsonPaths.length) > 0) {
|
|
2954
|
+
let message = theme.color.status.warn(`${theme.icon.WARNING} WARNING: It looks like you have the \`snyk\` dependency in the \`package.json\` file(s) at the following path(s):` +
|
|
2955
|
+
os_1.EOL);
|
|
2956
|
+
packageJsonPaths.forEach((p) => {
|
|
2957
|
+
message += theme.color.status.warn(` - ${p}` + os_1.EOL);
|
|
2958
|
+
});
|
|
2959
|
+
const githubReadmeUrlShort = 'https://snyk.co/ud1cR'; // https://github.com/snyk/snyk/tree/master/packages/snyk-protect#migrating-from-snyk-protect-to-snykprotect
|
|
2960
|
+
message += theme.color.status.warn(`For more information and migration instructions, see ${githubReadmeUrlShort}` +
|
|
2961
|
+
os_1.EOL);
|
|
2962
|
+
return message;
|
|
2963
|
+
}
|
|
2964
|
+
else {
|
|
2965
|
+
return '';
|
|
2966
|
+
}
|
|
2967
|
+
}
|
|
2968
|
+
catch (e) {
|
|
2969
|
+
debug('Error in getProtectUpgradeWarningForPaths()', e);
|
|
2970
|
+
return '';
|
|
2971
|
+
}
|
|
2972
|
+
}
|
|
2973
|
+
exports.getProtectUpgradeWarningForPaths = getProtectUpgradeWarningForPaths;
|
|
2974
|
+
function packageJsonFileExistsInDirectory(directoryPath) {
|
|
2975
|
+
try {
|
|
2976
|
+
const packageJsonPath = path.resolve(directoryPath, 'package.json');
|
|
2977
|
+
const fileExists = fs.existsSync(packageJsonPath);
|
|
2978
|
+
return fileExists;
|
|
2979
|
+
}
|
|
2980
|
+
catch (e) {
|
|
2981
|
+
debug('Error in packageJsonFileExistsInDirectory()', e);
|
|
2982
|
+
return false;
|
|
2983
|
+
}
|
|
2984
|
+
}
|
|
2985
|
+
exports.packageJsonFileExistsInDirectory = packageJsonFileExistsInDirectory;
|
|
2986
|
+
function checkPackageJsonForSnykDependency(packageJsonPath) {
|
|
2987
|
+
try {
|
|
2988
|
+
const fileExists = fs.existsSync(packageJsonPath);
|
|
2989
|
+
if (fileExists) {
|
|
2990
|
+
const packageJson = fs.readFileSync(packageJsonPath, 'utf8');
|
|
2991
|
+
const packageJsonObject = JSON.parse(packageJson);
|
|
2992
|
+
const snykDependency = packageJsonObject.dependencies['snyk'];
|
|
2993
|
+
if (snykDependency) {
|
|
2994
|
+
return true;
|
|
2995
|
+
}
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
catch (e) {
|
|
2999
|
+
debug('Error in checkPackageJsonForSnykDependency()', e);
|
|
3000
|
+
}
|
|
3001
|
+
return false;
|
|
3002
|
+
}
|
|
3003
|
+
exports.checkPackageJsonForSnykDependency = checkPackageJsonForSnykDependency;
|
|
3004
|
+
function getPackageJsonPathsContainingSnykDependency(fileOption, paths) {
|
|
3005
|
+
const packageJsonPathsWithSnykDepForProtect = [];
|
|
3006
|
+
try {
|
|
3007
|
+
if (fileOption) {
|
|
3008
|
+
if (fileOption.endsWith('package.json') ||
|
|
3009
|
+
fileOption.endsWith('package-lock.json')) {
|
|
3010
|
+
const directoryWithPackageJson = path.dirname(fileOption);
|
|
3011
|
+
if (packageJsonFileExistsInDirectory(directoryWithPackageJson)) {
|
|
3012
|
+
const packageJsonPath = path.resolve(directoryWithPackageJson, 'package.json');
|
|
3013
|
+
const packageJsonContainsSnykDep = checkPackageJsonForSnykDependency(packageJsonPath);
|
|
3014
|
+
if (packageJsonContainsSnykDep) {
|
|
3015
|
+
packageJsonPathsWithSnykDepForProtect.push(packageJsonPath);
|
|
3016
|
+
}
|
|
3017
|
+
}
|
|
3018
|
+
}
|
|
3019
|
+
}
|
|
3020
|
+
else {
|
|
3021
|
+
paths.forEach((testPath) => {
|
|
3022
|
+
if (packageJsonFileExistsInDirectory(testPath)) {
|
|
3023
|
+
const packageJsonPath = path.resolve(testPath, 'package.json');
|
|
3024
|
+
const packageJsonContainsSnykDep = checkPackageJsonForSnykDependency(packageJsonPath);
|
|
3025
|
+
if (packageJsonContainsSnykDep) {
|
|
3026
|
+
packageJsonPathsWithSnykDepForProtect.push(packageJsonPath);
|
|
3027
|
+
}
|
|
3028
|
+
}
|
|
3029
|
+
});
|
|
3030
|
+
}
|
|
3031
|
+
}
|
|
3032
|
+
catch (e) {
|
|
3033
|
+
debug('Error in getPackageJsonPathsContainingSnykDependency()', e);
|
|
3034
|
+
}
|
|
3035
|
+
return packageJsonPathsWithSnykDepForProtect;
|
|
3036
|
+
}
|
|
3037
|
+
exports.getPackageJsonPathsContainingSnykDependency = getPackageJsonPathsContainingSnykDependency;
|
|
3038
|
+
|
|
3039
|
+
|
|
2927
3040
|
/***/ }),
|
|
2928
3041
|
|
|
2929
3042
|
/***/ 46816:
|