snyk 1.776.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 +136 -95
- package/dist/cli/917.index.js.map +1 -1
- package/dist/cli/commands/test/iac-local-execution/analytics.d.ts +1 -1
- package/dist/cli/commands/test/iac-local-execution/oci-pull.d.ts +0 -3
- package/dist/cli/exit-codes.d.ts +5 -0
- package/dist/cli/index.js +120 -15
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/main.d.ts +1 -0
- package/dist/lib/protect-update-notification.d.ts +4 -0
- package/dist/lib/theme.d.ts +1 -0
- package/dist/lib/unexpected-error.d.ts +8 -0
- package/package.json +2 -2
package/dist/cli/917.index.js
CHANGED
|
@@ -53,7 +53,7 @@ const types_1 = __webpack_require__(42258);
|
|
|
53
53
|
const analytics = __webpack_require__(82744);
|
|
54
54
|
const math_utils_1 = __webpack_require__(48537);
|
|
55
55
|
const file_utils_1 = __webpack_require__(58486);
|
|
56
|
-
function addIacAnalytics(formattedResults, ignoredIssuesCount
|
|
56
|
+
function addIacAnalytics(formattedResults, ignoredIssuesCount) {
|
|
57
57
|
let totalIssuesCount = 0;
|
|
58
58
|
const customRulesIdsFoundInIssues = {};
|
|
59
59
|
let issuesFromCustomRulesCount = 0;
|
|
@@ -84,9 +84,7 @@ function addIacAnalytics(formattedResults, ignoredIssuesCount, isLocalCustomRule
|
|
|
84
84
|
analytics.add('iac-test-count', formattedResults.length);
|
|
85
85
|
analytics.add('iac-custom-rules-issues-count', issuesFromCustomRulesCount);
|
|
86
86
|
analytics.add('iac-custom-rules-issues-percentage', math_utils_1.calculatePercentage(issuesFromCustomRulesCount, totalIssuesCount));
|
|
87
|
-
|
|
88
|
-
analytics.add('iac-custom-rules-checksum', file_utils_1.computeCustomRulesBundleChecksum());
|
|
89
|
-
}
|
|
87
|
+
analytics.add('iac-custom-rules-checksum', file_utils_1.computeCustomRulesBundleChecksum());
|
|
90
88
|
analytics.add('iac-custom-rules-coverage-count', uniqueCustomRulesCount);
|
|
91
89
|
}
|
|
92
90
|
exports.addIacAnalytics = addIacAnalytics;
|
|
@@ -679,7 +677,6 @@ const analytics_1 = __webpack_require__(22716);
|
|
|
679
677
|
const usage_tracking_1 = __webpack_require__(43156);
|
|
680
678
|
const policy_1 = __webpack_require__(25476);
|
|
681
679
|
const measurable_methods_1 = __webpack_require__(78272);
|
|
682
|
-
const feature_flags_1 = __webpack_require__(63011);
|
|
683
680
|
const assert_iac_options_flag_1 = __webpack_require__(68590);
|
|
684
681
|
const user_config_1 = __webpack_require__(28137);
|
|
685
682
|
const config_1 = __webpack_require__(22541);
|
|
@@ -687,26 +684,33 @@ const policy_2 = __webpack_require__(32615);
|
|
|
687
684
|
const errors_1 = __webpack_require__(55191);
|
|
688
685
|
const error_utils_1 = __webpack_require__(23872);
|
|
689
686
|
const oci_pull_1 = __webpack_require__(5029);
|
|
690
|
-
const unsupported_entitlement_error_1 = __webpack_require__(78673);
|
|
691
687
|
const url_utils_1 = __webpack_require__(80256);
|
|
688
|
+
const chalk_1 = __webpack_require__(32589);
|
|
692
689
|
// this method executes the local processing engine and then formats the results to adapt with the CLI output.
|
|
693
690
|
// this flow is the default GA flow for IAC scanning.
|
|
694
691
|
async function test(pathToScan, options) {
|
|
695
|
-
var _a;
|
|
692
|
+
var _a, _b, _c;
|
|
696
693
|
try {
|
|
697
694
|
let customRulesPath;
|
|
698
695
|
const orgPublicId = (_a = options.org) !== null && _a !== void 0 ? _a : config_1.default.org;
|
|
699
696
|
const iacOrgSettings = await measurable_methods_1.getIacOrgSettings(orgPublicId);
|
|
700
697
|
if (options.rules) {
|
|
701
|
-
|
|
698
|
+
if (!((_b = iacOrgSettings.entitlements) === null || _b === void 0 ? void 0 : _b.iacCustomRulesEntitlement)) {
|
|
699
|
+
throw new assert_iac_options_flag_1.UnsupportedEntitlementFlagError('rules', 'iacCustomRulesEntitlement');
|
|
700
|
+
}
|
|
702
701
|
customRulesPath = options.rules;
|
|
703
702
|
}
|
|
704
703
|
const isOCIRegistryURLProvided = checkOCIRegistryURLProvided(iacOrgSettings);
|
|
704
|
+
if (isOCIRegistryURLProvided || customRulesPath) {
|
|
705
|
+
console.log(chalk_1.default.hex('#ff9b00')('Using custom rules to generate misconfigurations.'));
|
|
706
|
+
}
|
|
705
707
|
if (isOCIRegistryURLProvided && customRulesPath) {
|
|
706
708
|
throw new FailedToExecuteCustomRulesError();
|
|
707
709
|
}
|
|
708
710
|
if (isOCIRegistryURLProvided) {
|
|
709
|
-
|
|
711
|
+
if (!((_c = iacOrgSettings.entitlements) === null || _c === void 0 ? void 0 : _c.iacCustomRulesEntitlement)) {
|
|
712
|
+
throw new oci_pull_1.UnsupportedEntitlementPullError('iacCustomRulesEntitlement');
|
|
713
|
+
}
|
|
710
714
|
await pullIaCCustomRules(iacOrgSettings);
|
|
711
715
|
}
|
|
712
716
|
else {
|
|
@@ -736,7 +740,7 @@ async function test(pathToScan, options) {
|
|
|
736
740
|
// If something has gone wrong, err on the side of allowing the user to
|
|
737
741
|
// run their tests by squashing the error.
|
|
738
742
|
}
|
|
739
|
-
analytics_1.addIacAnalytics(filteredIssues, ignoreCount
|
|
743
|
+
analytics_1.addIacAnalytics(filteredIssues, ignoreCount);
|
|
740
744
|
// TODO: add support for proper typing of old TestResult interface.
|
|
741
745
|
return {
|
|
742
746
|
results: filteredIssues,
|
|
@@ -829,7 +833,7 @@ async function pullIaCCustomRules(iacOrgSettings) {
|
|
|
829
833
|
throw new FailedToPullCustomBundleError('There was an authentication error. Incorrect credentials provided.');
|
|
830
834
|
}
|
|
831
835
|
else if (err.statusCode === 404) {
|
|
832
|
-
throw new FailedToPullCustomBundleError('The remote repository could not be found. Please check the provided URL.');
|
|
836
|
+
throw new FailedToPullCustomBundleError('The remote repository could not be found. Please check the provided registry URL.');
|
|
833
837
|
}
|
|
834
838
|
else if (err instanceof oci_pull_1.InvalidManifestSchemaVersionError) {
|
|
835
839
|
throw new FailedToPullCustomBundleError(err.message);
|
|
@@ -846,62 +850,15 @@ async function pullIaCCustomRules(iacOrgSettings) {
|
|
|
846
850
|
}
|
|
847
851
|
}
|
|
848
852
|
exports.pullIaCCustomRules = pullIaCCustomRules;
|
|
849
|
-
/**
|
|
850
|
-
* Asserts the custom-rules feature is available for the provided org.
|
|
851
|
-
*/
|
|
852
|
-
async function assertCustomRulesAvailable(orgPublicId, iacOrgSettings) {
|
|
853
|
-
var _a;
|
|
854
|
-
const isCustomRulesEnabled = !!(await feature_flags_1.isFeatureFlagSupportedForOrg('iacCustomRules', orgPublicId)).ok;
|
|
855
|
-
if (!isCustomRulesEnabled) {
|
|
856
|
-
throw new errors_1.UnsupportedFeatureFlagError('iacCustomRules');
|
|
857
|
-
}
|
|
858
|
-
const isEntitledToCustomRules = !!((_a = iacOrgSettings.entitlements) === null || _a === void 0 ? void 0 : _a.iacCustomRulesEntitlement);
|
|
859
|
-
if (!isEntitledToCustomRules) {
|
|
860
|
-
throw new unsupported_entitlement_error_1.UnsupportedEntitlementError('iacCustomRulesEntitlement');
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
/**
|
|
864
|
-
* Asserts the --rules flag is available for the provided org.
|
|
865
|
-
*/
|
|
866
|
-
async function assertRulesFlagAvailable(orgPublicId, iacOrgSettings) {
|
|
867
|
-
try {
|
|
868
|
-
await assertCustomRulesAvailable(orgPublicId, iacOrgSettings);
|
|
869
|
-
}
|
|
870
|
-
catch (err) {
|
|
871
|
-
if (err instanceof unsupported_entitlement_error_1.UnsupportedEntitlementError) {
|
|
872
|
-
throw new assert_iac_options_flag_1.UnsupportedEntitlementFlagError('rules', err.entitlement);
|
|
873
|
-
}
|
|
874
|
-
else if (err instanceof errors_1.UnsupportedFeatureFlagError) {
|
|
875
|
-
throw new assert_iac_options_flag_1.FlagError('rules', err.featureFlag);
|
|
876
|
-
}
|
|
877
|
-
else {
|
|
878
|
-
throw err;
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
/**
|
|
883
|
-
* Asserts the feature custom-rules bundles pulling feature is available for the provided org.
|
|
884
|
-
*/
|
|
885
|
-
async function assertPullAvailable(orgPublicId, iacOrgSettings) {
|
|
886
|
-
try {
|
|
887
|
-
await assertCustomRulesAvailable(orgPublicId, iacOrgSettings);
|
|
888
|
-
}
|
|
889
|
-
catch (err) {
|
|
890
|
-
if (err instanceof unsupported_entitlement_error_1.UnsupportedEntitlementError) {
|
|
891
|
-
throw new oci_pull_1.UnsupportedEntitlementPullError(err.entitlement);
|
|
892
|
-
}
|
|
893
|
-
else if (err instanceof errors_1.UnsupportedFeatureFlagError) {
|
|
894
|
-
throw new oci_pull_1.UnsupportedFeatureFlagPullError(err.featureFlag);
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
}
|
|
898
853
|
class FailedToPullCustomBundleError extends errors_1.CustomError {
|
|
899
854
|
constructor(message) {
|
|
900
855
|
super(message || 'Could not pull custom bundle');
|
|
901
856
|
this.code = types_1.IaCErrorCodes.FailedToPullCustomBundleError;
|
|
902
857
|
this.strCode = error_utils_1.getErrorStringCode(this.code);
|
|
903
|
-
this.userMessage =
|
|
904
|
-
|
|
858
|
+
this.userMessage =
|
|
859
|
+
`${message ? message + ' ' : ''}` +
|
|
860
|
+
'\nWe were unable to download the custom bundle to the disk. Please ensure access to the remote Registry and validate you have provided all the right parameters.' +
|
|
861
|
+
'\nSee documentation on troubleshooting: https://docs.snyk.io/products/snyk-infrastructure-as-code/custom-rules/use-IaC-custom-rules-with-CLI/using-a-remote-custom-rules-bundle#troubleshooting';
|
|
905
862
|
}
|
|
906
863
|
}
|
|
907
864
|
exports.FailedToPullCustomBundleError = FailedToPullCustomBundleError;
|
|
@@ -1188,7 +1145,7 @@ exports.pull = measurableOciPull;
|
|
|
1188
1145
|
"use strict";
|
|
1189
1146
|
|
|
1190
1147
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1191
|
-
exports.UnsupportedEntitlementPullError = exports.
|
|
1148
|
+
exports.UnsupportedEntitlementPullError = exports.InvalidRemoteRegistryURLError = exports.InvalidManifestSchemaVersionError = exports.FailedToBuildOCIArtifactError = exports.pull = exports.extractOCIRegistryURLComponents = exports.CUSTOM_RULES_TARBALL = void 0;
|
|
1192
1149
|
const registryClient = __webpack_require__(28310);
|
|
1193
1150
|
const fs_1 = __webpack_require__(35747);
|
|
1194
1151
|
const path = __webpack_require__(85622);
|
|
@@ -1286,15 +1243,6 @@ class InvalidRemoteRegistryURLError extends errors_1.CustomError {
|
|
|
1286
1243
|
}
|
|
1287
1244
|
}
|
|
1288
1245
|
exports.InvalidRemoteRegistryURLError = InvalidRemoteRegistryURLError;
|
|
1289
|
-
class UnsupportedFeatureFlagPullError extends errors_1.CustomError {
|
|
1290
|
-
constructor(featureFlag) {
|
|
1291
|
-
super('OCI Pull not supported - Missing the ${featureFlag} feature flag');
|
|
1292
|
-
this.code = types_1.IaCErrorCodes.UnsupportedFeatureFlagPullError;
|
|
1293
|
-
this.strCode = error_utils_1.getErrorStringCode(this.code);
|
|
1294
|
-
this.userMessage = `The custom rules feature is not supported for this org - The feature flag '${featureFlag}' is not currently enabled. It can be enabled via Snyk Preview, if you are on the Enterprise Plan.`;
|
|
1295
|
-
}
|
|
1296
|
-
}
|
|
1297
|
-
exports.UnsupportedFeatureFlagPullError = UnsupportedFeatureFlagPullError;
|
|
1298
1246
|
class UnsupportedEntitlementPullError extends errors_1.CustomError {
|
|
1299
1247
|
constructor(entitlement) {
|
|
1300
1248
|
super(`OCI Pull not supported - Missing the ${entitlement} entitlement`);
|
|
@@ -1740,7 +1688,9 @@ function formatScanResult(scanResult, meta, options) {
|
|
|
1740
1688
|
},
|
|
1741
1689
|
severity: policy.severity,
|
|
1742
1690
|
lineNumber,
|
|
1743
|
-
documentation:
|
|
1691
|
+
documentation: !isGeneratedByCustomRule
|
|
1692
|
+
? `https://snyk.io/security-rules/${policy.publicId}`
|
|
1693
|
+
: undefined,
|
|
1744
1694
|
isGeneratedByCustomRule,
|
|
1745
1695
|
};
|
|
1746
1696
|
});
|
|
@@ -1987,6 +1937,7 @@ exports.test = test;
|
|
|
1987
1937
|
|
|
1988
1938
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1989
1939
|
const Debug = __webpack_require__(15158);
|
|
1940
|
+
const os_1 = __webpack_require__(12087);
|
|
1990
1941
|
const cloneDeep = __webpack_require__(83465);
|
|
1991
1942
|
const assign = __webpack_require__(31730);
|
|
1992
1943
|
const chalk_1 = __webpack_require__(32589);
|
|
@@ -2007,6 +1958,8 @@ const set_default_test_options_1 = __webpack_require__(13285);
|
|
|
2007
1958
|
const process_command_args_1 = __webpack_require__(52369);
|
|
2008
1959
|
const format_test_error_1 = __webpack_require__(68214);
|
|
2009
1960
|
const display_result_1 = __webpack_require__(89667);
|
|
1961
|
+
const analytics = __webpack_require__(82744);
|
|
1962
|
+
const protect_update_notification_1 = __webpack_require__(79304);
|
|
2010
1963
|
const debug = Debug('snyk-test');
|
|
2011
1964
|
const SEPARATOR = '\n-------------------------------------------------------\n';
|
|
2012
1965
|
// TODO: avoid using `as any` whenever it's possible
|
|
@@ -2015,6 +1968,8 @@ async function test(...args) {
|
|
|
2015
1968
|
const options = set_default_test_options_1.setDefaultTestOptions(originalOptions);
|
|
2016
1969
|
validate_test_options_1.validateTestOptions(options);
|
|
2017
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);
|
|
2018
1973
|
// Handles no image arg provided to the container command until
|
|
2019
1974
|
// a validation interface is implemented in the docker plugin.
|
|
2020
1975
|
if (options.docker && paths.length === 0) {
|
|
@@ -2180,6 +2135,8 @@ async function test(...args) {
|
|
|
2180
2135
|
if (!fail) {
|
|
2181
2136
|
// return here to prevent throwing failure
|
|
2182
2137
|
response += chalk_1.default.bold.green(summaryMessage);
|
|
2138
|
+
response += os_1.EOL + os_1.EOL;
|
|
2139
|
+
response += protect_update_notification_1.getProtectUpgradeWarningForPaths(packageJsonPathsWithSnykDepForProtect);
|
|
2183
2140
|
return types_1.TestCommandResult.createHumanReadableTestCommandResult(response, stringifiedJsonData, stringifiedSarifData);
|
|
2184
2141
|
}
|
|
2185
2142
|
}
|
|
@@ -2196,6 +2153,8 @@ async function test(...args) {
|
|
|
2196
2153
|
throw error;
|
|
2197
2154
|
}
|
|
2198
2155
|
response += chalk_1.default.bold.green(summaryMessage);
|
|
2156
|
+
response += os_1.EOL + os_1.EOL;
|
|
2157
|
+
response += protect_update_notification_1.getProtectUpgradeWarningForPaths(packageJsonPathsWithSnykDepForProtect);
|
|
2199
2158
|
return types_1.TestCommandResult.createHumanReadableTestCommandResult(response, stringifiedJsonData, stringifiedSarifData);
|
|
2200
2159
|
}
|
|
2201
2160
|
exports.default = test;
|
|
@@ -2358,28 +2317,6 @@ FailOnError.ERROR_MESSAGE = 'Invalid fail on argument, please use one of: ' +
|
|
|
2358
2317
|
Object.keys(common_1.FAIL_ON).join(' | ');
|
|
2359
2318
|
|
|
2360
2319
|
|
|
2361
|
-
/***/ }),
|
|
2362
|
-
|
|
2363
|
-
/***/ 78673:
|
|
2364
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2365
|
-
|
|
2366
|
-
"use strict";
|
|
2367
|
-
|
|
2368
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2369
|
-
exports.UnsupportedEntitlementError = void 0;
|
|
2370
|
-
const custom_error_1 = __webpack_require__(17188);
|
|
2371
|
-
class UnsupportedEntitlementError extends custom_error_1.CustomError {
|
|
2372
|
-
constructor(entitlement, userMessage = `This feature is currently not enabled for your org. To enable it, please contact snyk support.`) {
|
|
2373
|
-
super('Unsupported feature - Missing the ${entitlementName} entitlement');
|
|
2374
|
-
this.entitlement = entitlement;
|
|
2375
|
-
this.code = UnsupportedEntitlementError.ERROR_CODE;
|
|
2376
|
-
this.userMessage = userMessage;
|
|
2377
|
-
}
|
|
2378
|
-
}
|
|
2379
|
-
exports.UnsupportedEntitlementError = UnsupportedEntitlementError;
|
|
2380
|
-
UnsupportedEntitlementError.ERROR_CODE = 403;
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
2320
|
/***/ }),
|
|
2384
2321
|
|
|
2385
2322
|
/***/ 9401:
|
|
@@ -2996,6 +2933,110 @@ function metadataForVuln(vuln) {
|
|
|
2996
2933
|
}
|
|
2997
2934
|
|
|
2998
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
|
+
|
|
2999
3040
|
/***/ }),
|
|
3000
3041
|
|
|
3001
3042
|
/***/ 46816:
|