snyk 1.866.0 → 1.869.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/367.index.js +5 -3
- package/dist/cli/367.index.js.map +1 -1
- package/dist/cli/917.index.js +27 -17
- package/dist/cli/917.index.js.map +1 -1
- package/dist/cli/919.index.js +14 -3
- package/dist/cli/919.index.js.map +1 -1
- package/dist/cli/985.index.js +66 -41
- package/dist/cli/985.index.js.map +1 -1
- package/dist/cli/commands/test/iac-local-execution/measurable-methods.d.ts +5 -1
- package/dist/cli/commands/test/iac-local-execution/share-results.d.ts +3 -1
- package/dist/cli/thirdPartyNotice.json +2 -2
- package/dist/lib/iac/cli-share-results.d.ts +2 -1
- package/dist/lib/iac/drift.d.ts +13 -36
- package/dist/lib/iac/envelope-formatters.d.ts +2 -1
- package/package.json +1 -1
- package/pysrc/pip_resolve.py +1 -1
package/dist/cli/367.index.js
CHANGED
|
@@ -30,9 +30,11 @@ exports.default = async (...args) => {
|
|
|
30
30
|
throw new assert_iac_options_flag_1.UnsupportedEntitlementCommandError('gen-driftignore', 'iacDrift');
|
|
31
31
|
}
|
|
32
32
|
try {
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
const ret = await drift_1.runDriftCTL({
|
|
34
|
+
options: { kind: 'gen-driftignore', ...options },
|
|
35
|
+
stdio: 'inherit',
|
|
36
|
+
});
|
|
37
|
+
process.exit(ret.code);
|
|
36
38
|
}
|
|
37
39
|
catch (e) {
|
|
38
40
|
const err = new Error('Error running `iac gen-driftignore` ' + e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"367.index.js","mappings":";;;;;;;;;;AACA,0DAA4D;AAC5D,+CAA8D;AAC9D,
|
|
1
|
+
{"version":3,"file":"367.index.js","mappings":";;;;;;;;;;AACA,0DAA4D;AAC5D,+CAA8D;AAC9D,2CAAkD;AAClD,yDAAiG;AACjG,6DAAwG;AACxG,4CAAsC;AAEtC,kBAAe,KAAK,EAAE,GAAG,IAAgB,EAAgB,EAAE;;IACzD,MAAM,EAAE,OAAO,EAAE,GAAG,yCAAkB,CAAC,GAAG,IAAI,CAAC,CAAC;IAEhD,oGAAoG;IACpG,4CAA4C;IAC5C,IAAI,OAAO,CAAC,GAAG,IAAI,IAAI,EAAE;QACvB,OAAO,WAAW,CAAC,iBAAiB,CAAC,CAAC;KACvC;IAED,iDAAiD;IACjD,8BAA8B;IAC9B,MAAM,WAAW,SAAG,OAAO,CAAC,GAAG,mCAAI,gBAAM,CAAC,GAAG,CAAC;IAC9C,MAAM,cAAc,GAAG,MAAM,wCAAiB,CAAC,WAAW,CAAC,CAAC;IAC5D,IAAI,QAAC,cAAc,CAAC,YAAY,0CAAE,QAAQ,GAAE;QAC1C,MAAM,IAAI,4DAAkC,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;KAC7E;IAED,IAAI;QACF,MAAM,GAAG,GAAG,MAAM,mBAAW,CAAC;YAC5B,OAAO,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,OAAO,EAAE;YAChD,KAAK,EAAE,SAAS;SACjB,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;KACxB;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,sCAAsC,GAAG,CAAC,CAAC,CAAC;QAClE,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;KAC5B;AACH,CAAC,CAAC","sources":["webpack://snyk/./src/cli/commands/gen-driftignore.ts"],"sourcesContent":["import { MethodArgs } from '../args';\nimport { processCommandArgs } from './process-command-args';\nimport * as legacyError from '../../lib/errors/legacy-errors';\nimport { runDriftCTL } from '../../lib/iac/drift';\nimport { getIacOrgSettings } from './test/iac-local-execution/org-settings/get-iac-org-settings';\nimport { UnsupportedEntitlementCommandError } from './test/iac-local-execution/assert-iac-options-flag';\nimport config from '../../lib/config';\n\nexport default async (...args: MethodArgs): Promise<any> => {\n const { options } = processCommandArgs(...args);\n\n // Ensure that this gen-driftignore command can only be runned when using `snyk iac gen-driftignore`\n // Avoid `snyk gen-driftignore` direct usage\n if (options.iac != true) {\n return legacyError('gen-driftignore');\n }\n\n // Ensure that we are allowed to run that command\n // by checking the entitlement\n const orgPublicId = options.org ?? config.org;\n const iacOrgSettings = await getIacOrgSettings(orgPublicId);\n if (!iacOrgSettings.entitlements?.iacDrift) {\n throw new UnsupportedEntitlementCommandError('gen-driftignore', 'iacDrift');\n }\n\n try {\n const ret = await runDriftCTL({\n options: { kind: 'gen-driftignore', ...options },\n stdio: 'inherit',\n });\n process.exit(ret.code);\n } catch (e) {\n const err = new Error('Error running `iac gen-driftignore` ' + e);\n return Promise.reject(err);\n }\n};\n"],"names":[],"sourceRoot":""}
|
package/dist/cli/917.index.js
CHANGED
|
@@ -873,8 +873,16 @@ async function loadAndParseTerraformFiles(pathToScan, parsedFiles, failedFiles,
|
|
|
873
873
|
// this is because we need all files in the same directory to share the same variable context
|
|
874
874
|
for (const currentDirectory of allDirectories) {
|
|
875
875
|
const filePathsInDirectory = getFilesForDirectory(pathToScan, currentDirectory);
|
|
876
|
-
if (filePathsInDirectory.length === 0
|
|
877
|
-
|
|
876
|
+
if (filePathsInDirectory.length === 0 || // skip directories that have 0 files but have other directories
|
|
877
|
+
(filePathsInDirectory.length === 1 && allParsedFiles.length === 1) // skip single files that have already been parsed
|
|
878
|
+
)
|
|
879
|
+
continue;
|
|
880
|
+
if (filePathsInDirectory.length === 1 &&
|
|
881
|
+
allParsedFiles.length === 0 &&
|
|
882
|
+
(!handle_terraform_files_utils_1.shouldBeParsed(filePathsInDirectory[0]) ||
|
|
883
|
+
handle_terraform_files_utils_1.isIgnoredFile(filePathsInDirectory[0]))) {
|
|
884
|
+
throw new file_loader_1.NoFilesToScanError();
|
|
885
|
+
}
|
|
878
886
|
try {
|
|
879
887
|
const tfFilesToParse = await file_loader_1.loadContentForFiles(filePathsInDirectory);
|
|
880
888
|
const { parsedFiles: parsedTfFiles, failedFiles: failedTfFiles, } = file_parser_1.parseTerraformFiles(tfFilesToParse);
|
|
@@ -883,7 +891,8 @@ async function loadAndParseTerraformFiles(pathToScan, parsedFiles, failedFiles,
|
|
|
883
891
|
}
|
|
884
892
|
catch (err) {
|
|
885
893
|
if (allParsedFiles.length !== 0 && err instanceof file_loader_1.NoFilesToScanError) {
|
|
886
|
-
// ignore this error since we might only have
|
|
894
|
+
// ignore this error since we might only have TF files in the folder and we have separated them,
|
|
895
|
+
// or if we have a single file scan of a non-TF file, and we have already parsed it
|
|
887
896
|
}
|
|
888
897
|
else {
|
|
889
898
|
throw err;
|
|
@@ -900,12 +909,9 @@ exports.loadAndParseTerraformFiles = loadAndParseTerraformFiles;
|
|
|
900
909
|
* @returns {string[]} An array with all the non-empty nested directories in this path
|
|
901
910
|
*/
|
|
902
911
|
function getAllDirectoriesForPath(pathToScan, maxDepth) {
|
|
903
|
-
// if it is a single file (it has an extension)
|
|
912
|
+
// if it is a single file (it has an extension), we return the current path
|
|
904
913
|
if (handle_terraform_files_utils_1.isSingleFile(pathToScan)) {
|
|
905
|
-
|
|
906
|
-
throw new file_loader_1.NoFilesToScanError();
|
|
907
|
-
}
|
|
908
|
-
return [path.resolve(pathToScan)]; // we return the current path if it is a single file
|
|
914
|
+
return [path.resolve(pathToScan)];
|
|
909
915
|
}
|
|
910
916
|
// if the path we scanned itself is an empty directory, finish the scan here
|
|
911
917
|
if (fs.readdirSync(pathToScan).length === 0) {
|
|
@@ -984,7 +990,6 @@ const feature_flags_1 = __webpack_require__(63011);
|
|
|
984
990
|
const rules_1 = __webpack_require__(98895);
|
|
985
991
|
const file_loader_1 = __webpack_require__(13552);
|
|
986
992
|
const share_results_1 = __webpack_require__(3558);
|
|
987
|
-
const handle_terraform_files_1 = __webpack_require__(41806);
|
|
988
993
|
// this method executes the local processing engine and then formats the results to adapt with the CLI output.
|
|
989
994
|
// this flow is the default GA flow for IAC scanning.
|
|
990
995
|
async function test(pathToScan, options) {
|
|
@@ -1023,7 +1028,7 @@ async function test(pathToScan, options) {
|
|
|
1023
1028
|
// we may have loaded and parsed all but terraform files in the previous step
|
|
1024
1029
|
// so now we check if we need to do a second load and parse which dereferences TF vars
|
|
1025
1030
|
if (validFileTypes && !validFileTypes.includes(types_1.ValidFileType.Terraform)) {
|
|
1026
|
-
const { allParsedFiles, allFailedFiles, } = await
|
|
1031
|
+
const { allParsedFiles, allFailedFiles, } = await measurable_methods_1.loadAndParseTerraformFiles(pathToScan, parsedFiles, failedFiles, options.detectionDepth);
|
|
1027
1032
|
parsedFiles = allParsedFiles;
|
|
1028
1033
|
failedFiles = allFailedFiles;
|
|
1029
1034
|
}
|
|
@@ -1038,7 +1043,7 @@ async function test(pathToScan, options) {
|
|
|
1038
1043
|
const resultsWithCustomSeverities = await measurable_methods_1.applyCustomSeverities(scannedFiles, iacOrgSettings.customPolicies);
|
|
1039
1044
|
let projectPublicIds = {};
|
|
1040
1045
|
if (options.report) {
|
|
1041
|
-
projectPublicIds = await share_results_1.formatAndShareResults(resultsWithCustomSeverities, options, orgPublicId);
|
|
1046
|
+
projectPublicIds = await share_results_1.formatAndShareResults(resultsWithCustomSeverities, options, orgPublicId, policy);
|
|
1042
1047
|
}
|
|
1043
1048
|
const formattedResults = measurable_methods_1.formatScanResults(resultsWithCustomSeverities, options, iacOrgSettings.meta, projectPublicIds);
|
|
1044
1049
|
const { filteredIssues, ignoreCount } = policy_1.filterIgnoredIssues(policy, formattedResults);
|
|
@@ -1283,7 +1288,7 @@ exports.calculatePercentage = (relativeValue, totalValue) => +(totalValue ? (rel
|
|
|
1283
1288
|
"use strict";
|
|
1284
1289
|
|
|
1285
1290
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1286
|
-
exports.pull = exports.localTest = exports.cleanLocalCache = exports.trackUsage = exports.formatScanResults = exports.applyCustomSeverities = exports.getIacOrgSettings = exports.scanFiles = exports.parseFiles = exports.loadFiles = exports.initLocalCache = exports.performanceAnalyticsDecorator = exports.asyncPerformanceAnalyticsDecorator = void 0;
|
|
1291
|
+
exports.loadAndParseTerraformFiles = exports.pull = exports.localTest = exports.cleanLocalCache = exports.trackUsage = exports.formatScanResults = exports.applyCustomSeverities = exports.getIacOrgSettings = exports.scanFiles = exports.parseFiles = exports.loadFiles = exports.initLocalCache = exports.performanceAnalyticsDecorator = exports.asyncPerformanceAnalyticsDecorator = void 0;
|
|
1287
1292
|
const file_loader_1 = __webpack_require__(13552);
|
|
1288
1293
|
const file_parser_1 = __webpack_require__(2314);
|
|
1289
1294
|
const file_scanner_1 = __webpack_require__(16879);
|
|
@@ -1296,6 +1301,7 @@ const index_1 = __webpack_require__(55409);
|
|
|
1296
1301
|
const oci_pull_1 = __webpack_require__(5029);
|
|
1297
1302
|
const analytics_1 = __webpack_require__(22716);
|
|
1298
1303
|
const types_1 = __webpack_require__(42258);
|
|
1304
|
+
const handle_terraform_files_1 = __webpack_require__(41806);
|
|
1299
1305
|
// Note: The return type of the returned async function needs to be Promise<Val> for
|
|
1300
1306
|
// the compiler to be happy, so we need to unwrap it with the messy
|
|
1301
1307
|
// Awaiter<ReturnType<T>> rather than just using ReturnType<T> directly.
|
|
@@ -1341,6 +1347,8 @@ const measurableLocalTest = asyncPerformanceAnalyticsDecorator(index_1.test, typ
|
|
|
1341
1347
|
exports.localTest = measurableLocalTest;
|
|
1342
1348
|
const measurableOciPull = asyncPerformanceAnalyticsDecorator(oci_pull_1.pull, types_1.PerformanceAnalyticsKey.Total);
|
|
1343
1349
|
exports.pull = measurableOciPull;
|
|
1350
|
+
const measurableLoadAndParseTerraformFiles = asyncPerformanceAnalyticsDecorator(handle_terraform_files_1.loadAndParseTerraformFiles, types_1.PerformanceAnalyticsKey.Total);
|
|
1351
|
+
exports.loadAndParseTerraformFiles = measurableLoadAndParseTerraformFiles;
|
|
1344
1352
|
|
|
1345
1353
|
|
|
1346
1354
|
/***/ }),
|
|
@@ -2228,13 +2236,13 @@ const feature_flags_1 = __webpack_require__(63011);
|
|
|
2228
2236
|
const cli_share_results_1 = __webpack_require__(24016);
|
|
2229
2237
|
const assert_iac_options_flag_1 = __webpack_require__(68590);
|
|
2230
2238
|
const share_results_formatter_1 = __webpack_require__(37324);
|
|
2231
|
-
async function formatAndShareResults(results, options, orgPublicId) {
|
|
2239
|
+
async function formatAndShareResults(results, options, orgPublicId, policy) {
|
|
2232
2240
|
const isCliReportEnabled = await feature_flags_1.isFeatureFlagSupportedForOrg('iacCliShareResults', orgPublicId);
|
|
2233
2241
|
if (!isCliReportEnabled.ok) {
|
|
2234
2242
|
throw new assert_iac_options_flag_1.FeatureFlagError('report', 'iacCliShareResults');
|
|
2235
2243
|
}
|
|
2236
2244
|
const formattedResults = share_results_formatter_1.formatShareResults(results, options);
|
|
2237
|
-
return await cli_share_results_1.shareResults(formattedResults);
|
|
2245
|
+
return await cli_share_results_1.shareResults(formattedResults, policy);
|
|
2238
2246
|
}
|
|
2239
2247
|
exports.formatAndShareResults = formatAndShareResults;
|
|
2240
2248
|
|
|
@@ -3337,8 +3345,8 @@ const request_1 = __webpack_require__(52050);
|
|
|
3337
3345
|
const api_token_1 = __webpack_require__(95181);
|
|
3338
3346
|
const envelope_formatters_1 = __webpack_require__(88784);
|
|
3339
3347
|
const authentication_failed_error_1 = __webpack_require__(23770);
|
|
3340
|
-
async function shareResults(results) {
|
|
3341
|
-
const scanResults = results.map(envelope_formatters_1.convertIacResultToScanResult);
|
|
3348
|
+
async function shareResults(results, policy) {
|
|
3349
|
+
const scanResults = results.map((result) => envelope_formatters_1.convertIacResultToScanResult(result, policy));
|
|
3342
3350
|
const { res, body } = await request_1.makeRequest({
|
|
3343
3351
|
method: 'POST',
|
|
3344
3352
|
url: `${config_1.default.API}/iac-cli-share-results`,
|
|
@@ -3365,7 +3373,8 @@ exports.shareResults = shareResults;
|
|
|
3365
3373
|
|
|
3366
3374
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3367
3375
|
exports.convertIacResultToScanResult = void 0;
|
|
3368
|
-
function convertIacResultToScanResult(iacResult) {
|
|
3376
|
+
function convertIacResultToScanResult(iacResult, policy) {
|
|
3377
|
+
var _a;
|
|
3369
3378
|
return {
|
|
3370
3379
|
identity: {
|
|
3371
3380
|
type: iacResult.projectType,
|
|
@@ -3380,6 +3389,7 @@ function convertIacResultToScanResult(iacResult) {
|
|
|
3380
3389
|
}),
|
|
3381
3390
|
name: iacResult.projectName,
|
|
3382
3391
|
target: { name: iacResult.projectName },
|
|
3392
|
+
policy: (_a = policy === null || policy === void 0 ? void 0 : policy.toString()) !== null && _a !== void 0 ? _a : '',
|
|
3383
3393
|
};
|
|
3384
3394
|
}
|
|
3385
3395
|
exports.convertIacResultToScanResult = convertIacResultToScanResult;
|