snyk 1.1032.0 → 1.1034.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 +78 -116
- package/dist/cli/917.index.js.map +1 -1
- package/dist/cli/commands/test/iac/local-execution/types.d.ts +14 -5
- package/dist/cli/index.js +2 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/lib/iac/test/v2/json.d.ts +1 -3
- package/dist/lib/iac/test/v2/output.d.ts +1 -3
- package/dist/lib/iac/test/v2/scan/results.d.ts +11 -0
- package/dist/lib/iac/test/v2/types.d.ts +1 -5
- package/package.json +1 -1
package/dist/cli/917.index.js
CHANGED
|
@@ -1375,6 +1375,8 @@ function formatScanResult(scanResult, meta, options, projectRoot) {
|
|
|
1375
1375
|
...meta,
|
|
1376
1376
|
projectId: '',
|
|
1377
1377
|
policy: '',
|
|
1378
|
+
isPrivate: true,
|
|
1379
|
+
isLicensesEnabled: false,
|
|
1378
1380
|
},
|
|
1379
1381
|
filesystemPolicy: false,
|
|
1380
1382
|
vulnerabilities: [],
|
|
@@ -2343,22 +2345,13 @@ const config_1 = __webpack_require__(25425);
|
|
|
2343
2345
|
const output_1 = __webpack_require__(39313);
|
|
2344
2346
|
const text_1 = __webpack_require__(86166);
|
|
2345
2347
|
const output_2 = __webpack_require__(99687);
|
|
2346
|
-
const get_iac_org_settings_1 = __webpack_require__(11693);
|
|
2347
|
-
const monitor_1 = __webpack_require__(3708);
|
|
2348
|
-
const local_execution_1 = __webpack_require__(89627);
|
|
2349
2348
|
const scan_1 = __webpack_require__(50277);
|
|
2350
2349
|
const index_1 = __webpack_require__(55935);
|
|
2351
2350
|
const policy_1 = __webpack_require__(32615);
|
|
2352
2351
|
const assert_iac_options_1 = __webpack_require__(15335);
|
|
2353
|
-
const unsupported_entitlement_error_1 = __webpack_require__(78673);
|
|
2354
2352
|
async function test(paths, options) {
|
|
2355
|
-
var _a;
|
|
2356
2353
|
assert_iac_options_1.assertIacV2Options(options);
|
|
2357
2354
|
const testConfig = await prepareTestConfig(paths, options);
|
|
2358
|
-
const { orgSettings } = testConfig;
|
|
2359
|
-
if (!((_a = orgSettings.entitlements) === null || _a === void 0 ? void 0 : _a.infrastructureAsCode)) {
|
|
2360
|
-
throw new unsupported_entitlement_error_1.UnsupportedEntitlementError('infrastructureAsCode');
|
|
2361
|
-
}
|
|
2362
2355
|
const testSpinner = output_1.buildSpinner(options);
|
|
2363
2356
|
output_1.printHeader(options);
|
|
2364
2357
|
testSpinner === null || testSpinner === void 0 ? void 0 : testSpinner.start(text_1.spinnerMessage);
|
|
@@ -2367,7 +2360,6 @@ async function test(paths, options) {
|
|
|
2367
2360
|
return output_2.buildOutput({
|
|
2368
2361
|
scanResult,
|
|
2369
2362
|
testSpinner,
|
|
2370
|
-
orgSettings,
|
|
2371
2363
|
options,
|
|
2372
2364
|
});
|
|
2373
2365
|
}
|
|
@@ -2380,12 +2372,9 @@ async function prepareTestConfig(paths, options) {
|
|
|
2380
2372
|
var _a;
|
|
2381
2373
|
const iacCachePath = pathLib.join(scan_1.systemCachePath, 'iac');
|
|
2382
2374
|
const org = options.org || config_1.default.org;
|
|
2383
|
-
const orgSettings = await get_iac_org_settings_1.getIacOrgSettings(org);
|
|
2384
|
-
const projectTags = local_execution_1.parseTags(options);
|
|
2385
2375
|
const targetName = index_1.getFlag(options, 'target-name');
|
|
2386
2376
|
const remoteRepoUrl = index_1.getFlag(options, 'remote-repo-url');
|
|
2387
2377
|
const depthDetection = parseInt(index_1.getFlag(options, 'depth-detection')) || undefined;
|
|
2388
|
-
const attributes = parseAttributes(options);
|
|
2389
2378
|
const policy = await policy_1.findAndLoadPolicy(process.cwd(), 'iac', options);
|
|
2390
2379
|
const scan = (_a = options.scan) !== null && _a !== void 0 ? _a : 'resource-changes';
|
|
2391
2380
|
const varFile = options['var-file'];
|
|
@@ -2394,13 +2383,10 @@ async function prepareTestConfig(paths, options) {
|
|
|
2394
2383
|
return {
|
|
2395
2384
|
paths,
|
|
2396
2385
|
iacCachePath,
|
|
2397
|
-
orgSettings,
|
|
2398
2386
|
userRulesBundlePath: config_1.default.IAC_BUNDLE_PATH,
|
|
2399
2387
|
userPolicyEnginePath: config_1.default.IAC_POLICY_ENGINE_PATH,
|
|
2400
2388
|
severityThreshold: options.severityThreshold,
|
|
2401
2389
|
report: !!options.report,
|
|
2402
|
-
attributes,
|
|
2403
|
-
projectTags,
|
|
2404
2390
|
targetReference: options['target-reference'],
|
|
2405
2391
|
targetName,
|
|
2406
2392
|
remoteRepoUrl,
|
|
@@ -2410,13 +2396,9 @@ async function prepareTestConfig(paths, options) {
|
|
|
2410
2396
|
depthDetection,
|
|
2411
2397
|
cloudContext,
|
|
2412
2398
|
insecure,
|
|
2399
|
+
org,
|
|
2413
2400
|
};
|
|
2414
2401
|
}
|
|
2415
|
-
function parseAttributes(options) {
|
|
2416
|
-
if (options.report) {
|
|
2417
|
-
return monitor_1.generateProjectAttributes(options);
|
|
2418
|
-
}
|
|
2419
|
-
}
|
|
2420
2402
|
|
|
2421
2403
|
|
|
2422
2404
|
/***/ }),
|
|
@@ -4563,7 +4545,7 @@ exports.convertEngineToJsonResults = void 0;
|
|
|
4563
4545
|
const path = __webpack_require__(85622);
|
|
4564
4546
|
const format_test_results_1 = __webpack_require__(59744);
|
|
4565
4547
|
const constants_1 = __webpack_require__(68620);
|
|
4566
|
-
function convertEngineToJsonResults({ results, projectName,
|
|
4548
|
+
function convertEngineToJsonResults({ results, projectName, }) {
|
|
4567
4549
|
const vulnerabilityGroups = groupVulnerabilitiesByFile(results); // all vulns groups by file
|
|
4568
4550
|
const resourceGroups = groupResourcesByFile(results); // all resources grouped by file
|
|
4569
4551
|
const filesWithoutIssues = findFilesWithoutIssues(resourceGroups, vulnerabilityGroups); // all resources without issues grouped by file
|
|
@@ -4572,10 +4554,10 @@ function convertEngineToJsonResults({ results, projectName, orgSettings, }) {
|
|
|
4572
4554
|
output.push(...format_test_results_1.createErrorMappedResultsForJsonOutput(results.errors));
|
|
4573
4555
|
}
|
|
4574
4556
|
for (const [file, resources] of Object.entries(filesWithoutIssues)) {
|
|
4575
|
-
output.push(resourcesToResult(
|
|
4557
|
+
output.push(resourcesToResult(results, projectName, file, resources));
|
|
4576
4558
|
}
|
|
4577
4559
|
for (const [file, vulnerabilities] of Object.entries(vulnerabilityGroups)) {
|
|
4578
|
-
output.push(vulnerabilitiesToResult(
|
|
4560
|
+
output.push(vulnerabilitiesToResult(results, projectName, file, vulnerabilities));
|
|
4579
4561
|
}
|
|
4580
4562
|
return output;
|
|
4581
4563
|
}
|
|
@@ -4617,11 +4599,10 @@ function findFilesWithoutIssues(resourceGroups, vulnerabilityGroups) {
|
|
|
4617
4599
|
}
|
|
4618
4600
|
return groups;
|
|
4619
4601
|
}
|
|
4620
|
-
function resourcesToResult(
|
|
4602
|
+
function resourcesToResult(testOutput, projectName, file, resources) {
|
|
4621
4603
|
const kind = resourcesToKind(resources);
|
|
4622
|
-
const ignoreSettings =
|
|
4623
|
-
const meta = orgSettingsToMeta(
|
|
4624
|
-
const { meta: { org, isPrivate, policy }, } = orgSettings;
|
|
4604
|
+
const ignoreSettings = testOutput.settings.ignoreSettings;
|
|
4605
|
+
const meta = orgSettingsToMeta(testOutput, ignoreSettings);
|
|
4625
4606
|
return {
|
|
4626
4607
|
meta,
|
|
4627
4608
|
filesystemPolicy: false,
|
|
@@ -4631,9 +4612,9 @@ function resourcesToResult(orgSettings, projectName, file, resources) {
|
|
|
4631
4612
|
ignoreSettings,
|
|
4632
4613
|
targetFile: file,
|
|
4633
4614
|
projectName,
|
|
4634
|
-
org,
|
|
4635
|
-
policy:
|
|
4636
|
-
isPrivate,
|
|
4615
|
+
org: testOutput.settings.org,
|
|
4616
|
+
policy: '',
|
|
4617
|
+
isPrivate: true,
|
|
4637
4618
|
targetFilePath: path.resolve(file),
|
|
4638
4619
|
packageManager: kind,
|
|
4639
4620
|
path: process.cwd(),
|
|
@@ -4642,12 +4623,11 @@ function resourcesToResult(orgSettings, projectName, file, resources) {
|
|
|
4642
4623
|
infrastructureAsCodeIssues: [],
|
|
4643
4624
|
};
|
|
4644
4625
|
}
|
|
4645
|
-
function vulnerabilitiesToResult(
|
|
4626
|
+
function vulnerabilitiesToResult(testOutput, projectName, file, vulnerabilities) {
|
|
4646
4627
|
const kind = vulnerabilitiesToKind(vulnerabilities);
|
|
4647
|
-
const ignoreSettings =
|
|
4648
|
-
const meta = orgSettingsToMeta(
|
|
4628
|
+
const ignoreSettings = testOutput.settings.ignoreSettings;
|
|
4629
|
+
const meta = orgSettingsToMeta(testOutput, ignoreSettings);
|
|
4649
4630
|
const infrastructureAsCodeIssues = vulnerabilitiesToIacIssues(vulnerabilities);
|
|
4650
|
-
const { meta: { org, isPrivate, policy }, } = orgSettings;
|
|
4651
4631
|
return {
|
|
4652
4632
|
meta,
|
|
4653
4633
|
filesystemPolicy: false,
|
|
@@ -4657,9 +4637,9 @@ function vulnerabilitiesToResult(orgSettings, projectName, file, vulnerabilities
|
|
|
4657
4637
|
ignoreSettings,
|
|
4658
4638
|
targetFile: file,
|
|
4659
4639
|
projectName,
|
|
4660
|
-
org,
|
|
4661
|
-
policy:
|
|
4662
|
-
isPrivate,
|
|
4640
|
+
org: testOutput.settings.org,
|
|
4641
|
+
policy: '',
|
|
4642
|
+
isPrivate: true,
|
|
4663
4643
|
targetFilePath: path.resolve(file),
|
|
4664
4644
|
packageManager: kind,
|
|
4665
4645
|
path: process.cwd(),
|
|
@@ -4720,24 +4700,16 @@ function vulnerabilitiesToKind(vulnerabilities) {
|
|
|
4720
4700
|
}
|
|
4721
4701
|
return '';
|
|
4722
4702
|
}
|
|
4723
|
-
function orgSettingsToMeta(
|
|
4724
|
-
const
|
|
4703
|
+
function orgSettingsToMeta(testOutput, ignoreSettings) {
|
|
4704
|
+
const org = testOutput.settings.org;
|
|
4725
4705
|
return {
|
|
4726
|
-
isPrivate,
|
|
4727
|
-
isLicensesEnabled,
|
|
4706
|
+
isPrivate: true,
|
|
4707
|
+
isLicensesEnabled: false,
|
|
4728
4708
|
org,
|
|
4729
|
-
policy:
|
|
4709
|
+
policy: '',
|
|
4730
4710
|
ignoreSettings,
|
|
4731
4711
|
};
|
|
4732
4712
|
}
|
|
4733
|
-
function orgSettingsToIgnoreSettings(orgSettings) {
|
|
4734
|
-
const { meta: { ignoreSettings }, } = orgSettings;
|
|
4735
|
-
return {
|
|
4736
|
-
adminOnly: (ignoreSettings === null || ignoreSettings === void 0 ? void 0 : ignoreSettings.adminOnly) || false,
|
|
4737
|
-
reasonRequired: (ignoreSettings === null || ignoreSettings === void 0 ? void 0 : ignoreSettings.reasonRequired) || false,
|
|
4738
|
-
disregardFilesystemIgnores: (ignoreSettings === null || ignoreSettings === void 0 ? void 0 : ignoreSettings.disregardFilesystemIgnores) || false,
|
|
4739
|
-
};
|
|
4740
|
-
}
|
|
4741
4713
|
|
|
4742
4714
|
|
|
4743
4715
|
/***/ }),
|
|
@@ -4800,12 +4772,12 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
4800
4772
|
exports.getChecksum = exports.formatPolicyEngineFileName = exports.policyEngineVersion = void 0;
|
|
4801
4773
|
const os = __webpack_require__(12087);
|
|
4802
4774
|
const policyEngineChecksums = `
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4775
|
+
289368b4e85d455c619b7f25e1680ca520e61f0bd727a02b55adeff85980ee57 snyk-iac-test_0.33.5_Linux_arm64
|
|
4776
|
+
51092d8e7bb51a0b7323f5e8f072d9f6690e2cc81561eba0615e847f68f00731 snyk-iac-test_0.33.5_Linux_x86_64
|
|
4777
|
+
6836d69eb527cf9ae8d87327278624ca3a487afff86da5a87c81d4a1a8785ce9 snyk-iac-test_0.33.5_Darwin_arm64
|
|
4778
|
+
83740d8b61000b986a6092188897b98dbeea634c64840c8beaaf9199f7055b68 snyk-iac-test_0.33.5_Darwin_x86_64
|
|
4779
|
+
bdc42a135e8319768841f56f0985722a7aabdc8c6259b9e426dc55efc37ecf61 snyk-iac-test_0.33.5_Windows_x86_64.exe
|
|
4780
|
+
cb34a3e8aaddebe2e2ba01c62c042723f832c686626cad1e15e296b7a0c0106c snyk-iac-test_0.33.5_Windows_arm64.exe
|
|
4809
4781
|
`;
|
|
4810
4782
|
exports.policyEngineVersion = getPolicyEngineVersion();
|
|
4811
4783
|
function formatPolicyEngineFileName(releaseVersion) {
|
|
@@ -5220,7 +5192,7 @@ const error_utils_1 = __webpack_require__(36401);
|
|
|
5220
5192
|
const output_1 = __webpack_require__(39313);
|
|
5221
5193
|
const utils_1 = __webpack_require__(9176);
|
|
5222
5194
|
const wrapAnsi = __webpack_require__(88152);
|
|
5223
|
-
function buildOutput({ scanResult, testSpinner,
|
|
5195
|
+
function buildOutput({ scanResult, testSpinner, options, }) {
|
|
5224
5196
|
if (scanResult.results) {
|
|
5225
5197
|
testSpinner === null || testSpinner === void 0 ? void 0 : testSpinner.succeed(text_1.spinnerSuccessMessage);
|
|
5226
5198
|
}
|
|
@@ -5229,7 +5201,6 @@ function buildOutput({ scanResult, testSpinner, orgSettings, options, }) {
|
|
|
5229
5201
|
}
|
|
5230
5202
|
const { responseData, jsonData, sarifData } = buildTestCommandResultData({
|
|
5231
5203
|
scanResult,
|
|
5232
|
-
orgSettings,
|
|
5233
5204
|
options,
|
|
5234
5205
|
});
|
|
5235
5206
|
if (options.json || options.sarif) {
|
|
@@ -5238,13 +5209,12 @@ function buildOutput({ scanResult, testSpinner, orgSettings, options, }) {
|
|
|
5238
5209
|
return types_1.TestCommandResult.createHumanReadableTestCommandResult(responseData, jsonData, sarifData);
|
|
5239
5210
|
}
|
|
5240
5211
|
exports.buildOutput = buildOutput;
|
|
5241
|
-
function buildTestCommandResultData({ scanResult,
|
|
5212
|
+
function buildTestCommandResultData({ scanResult, options, }) {
|
|
5242
5213
|
var _a, _b, _c, _d, _e;
|
|
5243
5214
|
const projectName = (_c = (_b = (_a = scanResult.results) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.projectName) !== null && _c !== void 0 ? _c : path.basename(process.cwd());
|
|
5244
5215
|
const jsonData = json_2.jsonStringifyLargeObject(json_1.convertEngineToJsonResults({
|
|
5245
5216
|
results: scanResult,
|
|
5246
5217
|
projectName,
|
|
5247
|
-
orgSettings,
|
|
5248
5218
|
}));
|
|
5249
5219
|
const sarifData = json_2.jsonStringifyLargeObject(sarif_1.convertEngineToSarifResults(scanResult));
|
|
5250
5220
|
assertHasSuccessfulScans(scanResult, { json: jsonData, sarif: sarifData }, options);
|
|
@@ -5259,7 +5229,6 @@ function buildTestCommandResultData({ scanResult, orgSettings, options, }) {
|
|
|
5259
5229
|
responseData = buildTextOutput({
|
|
5260
5230
|
scanResult,
|
|
5261
5231
|
projectName,
|
|
5262
|
-
orgSettings,
|
|
5263
5232
|
options,
|
|
5264
5233
|
});
|
|
5265
5234
|
}
|
|
@@ -5274,9 +5243,9 @@ function buildTestCommandResultData({ scanResult, orgSettings, options, }) {
|
|
|
5274
5243
|
return { responseData, jsonData, sarifData };
|
|
5275
5244
|
}
|
|
5276
5245
|
const SEPARATOR = '\n-------------------------------------------------------\n';
|
|
5277
|
-
function buildTextOutput({ scanResult, projectName,
|
|
5246
|
+
function buildTextOutput({ scanResult, projectName, options, }) {
|
|
5278
5247
|
let response = '';
|
|
5279
|
-
const testData = text_1.formatSnykIacTestTestData(scanResult.results, projectName,
|
|
5248
|
+
const testData = text_1.formatSnykIacTestTestData(scanResult.results, projectName, scanResult.settings.org);
|
|
5280
5249
|
response +=
|
|
5281
5250
|
os_1.EOL +
|
|
5282
5251
|
text_1.getIacDisplayedIssues(testData.resultsBySeverity, {
|
|
@@ -5296,7 +5265,7 @@ function buildTextOutput({ scanResult, projectName, orgSettings, options, }) {
|
|
|
5296
5265
|
response += os_1.EOL;
|
|
5297
5266
|
if (options.report) {
|
|
5298
5267
|
response += output_1.buildShareResultsSummaryV2({
|
|
5299
|
-
orgName:
|
|
5268
|
+
orgName: scanResult.settings.org,
|
|
5300
5269
|
projectName,
|
|
5301
5270
|
options,
|
|
5302
5271
|
isIacCustomRulesEntitlementEnabled: false,
|
|
@@ -5310,7 +5279,7 @@ function buildTextOutput({ scanResult, projectName, orgSettings, options, }) {
|
|
|
5310
5279
|
response += os_1.EOL;
|
|
5311
5280
|
response += utils_1.colors.title('Info') + os_1.EOL;
|
|
5312
5281
|
response += os_1.EOL;
|
|
5313
|
-
response += wrapWithPadding(infoMessage(
|
|
5282
|
+
response += wrapWithPadding(infoMessage(scanResult), 80) + os_1.EOL;
|
|
5314
5283
|
return response;
|
|
5315
5284
|
}
|
|
5316
5285
|
function wrapWithPadding(s, columns) {
|
|
@@ -5320,7 +5289,7 @@ function wrapWithPadding(s, columns) {
|
|
|
5320
5289
|
.join('\n');
|
|
5321
5290
|
}
|
|
5322
5291
|
function infoMessage(orgSettings) {
|
|
5323
|
-
return `Your organization ${orgSettings.
|
|
5292
|
+
return `Your organization ${orgSettings.settings.org} is using Integrated IaC. To switch to Current IaC, use --org=<ORG_ID> to select a different organization. For more information about Integrated IaC, see https://snyk.co/integrated-iac.`;
|
|
5324
5293
|
}
|
|
5325
5294
|
function assertHasSuccessfulScans(scanResult, responseData, options) {
|
|
5326
5295
|
var _a, _b, _c;
|
|
@@ -5586,29 +5555,33 @@ const env_paths_1 = __webpack_require__(21766);
|
|
|
5586
5555
|
const debug = newDebug('snyk-iac');
|
|
5587
5556
|
exports.systemCachePath = (_a = config_1.default.CACHE_PATH) !== null && _a !== void 0 ? _a : env_paths_1.default('snyk').cache;
|
|
5588
5557
|
function scan(options, policyEnginePath, rulesBundlePath) {
|
|
5589
|
-
const {
|
|
5558
|
+
const { tempOutput: outputPath, tempDir: tempDirPath, tempPolicy: tempPolicyPath, } = createTemporaryFiles(options);
|
|
5590
5559
|
try {
|
|
5591
|
-
return scanWithConfig(options, policyEnginePath, rulesBundlePath,
|
|
5560
|
+
return scanWithConfig(options, policyEnginePath, rulesBundlePath, outputPath, tempPolicyPath);
|
|
5592
5561
|
}
|
|
5593
5562
|
finally {
|
|
5594
5563
|
deleteTemporaryFiles(tempDirPath);
|
|
5595
5564
|
}
|
|
5596
5565
|
}
|
|
5597
5566
|
exports.scan = scan;
|
|
5598
|
-
function scanWithConfig(options, policyEnginePath, rulesBundlePath,
|
|
5599
|
-
const
|
|
5567
|
+
function scanWithConfig(options, policyEnginePath, rulesBundlePath, outputPath, policyPath) {
|
|
5568
|
+
const env = { ...process.env };
|
|
5569
|
+
env['SNYK_API_URL'] = getApiUrl();
|
|
5570
|
+
env['SNYK_API_TOKEN'] = getApiToken();
|
|
5571
|
+
const args = processFlags(options, rulesBundlePath, outputPath, policyPath);
|
|
5600
5572
|
args.push(...options.paths);
|
|
5601
|
-
const
|
|
5573
|
+
const child = childProcess.spawnSync(policyEnginePath, args, {
|
|
5602
5574
|
encoding: 'utf-8',
|
|
5603
5575
|
stdio: 'pipe',
|
|
5576
|
+
env: env,
|
|
5604
5577
|
maxBuffer: 1024 * 1024 * 10,
|
|
5605
5578
|
});
|
|
5606
|
-
debug('policy engine standard error:\n%s', '\n' +
|
|
5607
|
-
if (
|
|
5608
|
-
throw new ScanError(`invalid exit status: ${
|
|
5579
|
+
debug('policy engine standard error:\n%s', '\n' + child.stderr);
|
|
5580
|
+
if (child.status && child.status !== 0) {
|
|
5581
|
+
throw new ScanError(`invalid exit status: ${child.status}`);
|
|
5609
5582
|
}
|
|
5610
|
-
if (
|
|
5611
|
-
throw new ScanError(`spawning process: ${
|
|
5583
|
+
if (child.error) {
|
|
5584
|
+
throw new ScanError(`spawning process: ${child.error}`);
|
|
5612
5585
|
}
|
|
5613
5586
|
let snykIacTestOutput, parsedSnykIacTestOutput;
|
|
5614
5587
|
try {
|
|
@@ -5620,41 +5593,23 @@ function scanWithConfig(options, policyEnginePath, rulesBundlePath, configPath,
|
|
|
5620
5593
|
}
|
|
5621
5594
|
return results_1.mapSnykIacTestOutputToTestOutput(parsedSnykIacTestOutput);
|
|
5622
5595
|
}
|
|
5623
|
-
function processFlags(options, rulesBundlePath,
|
|
5624
|
-
var _a, _b, _c;
|
|
5596
|
+
function processFlags(options, rulesBundlePath, outputPath, policyPath) {
|
|
5625
5597
|
const flags = [
|
|
5626
5598
|
'-cache-dir',
|
|
5627
5599
|
exports.systemCachePath,
|
|
5628
5600
|
'-bundle',
|
|
5629
5601
|
rulesBundlePath,
|
|
5630
|
-
'-
|
|
5631
|
-
|
|
5602
|
+
'-policy',
|
|
5603
|
+
policyPath,
|
|
5632
5604
|
];
|
|
5633
5605
|
flags.push('-output', outputPath);
|
|
5634
5606
|
if (options.severityThreshold) {
|
|
5635
5607
|
flags.push('-severity-threshold', options.severityThreshold);
|
|
5636
5608
|
}
|
|
5637
|
-
if ((_a = options.attributes) === null || _a === void 0 ? void 0 : _a.criticality) {
|
|
5638
|
-
flags.push('-project-business-criticality', options.attributes.criticality.join(','));
|
|
5639
|
-
}
|
|
5640
|
-
if ((_b = options.attributes) === null || _b === void 0 ? void 0 : _b.environment) {
|
|
5641
|
-
flags.push('-project-environment', options.attributes.environment.join(','));
|
|
5642
|
-
}
|
|
5643
|
-
if ((_c = options.attributes) === null || _c === void 0 ? void 0 : _c.lifecycle) {
|
|
5644
|
-
flags.push('-project-lifecycle', options.attributes.lifecycle.join(','));
|
|
5645
|
-
}
|
|
5646
5609
|
if (options.depthDetection) {
|
|
5647
5610
|
flags.push('-depth-detection', `${options.depthDetection}`);
|
|
5648
5611
|
}
|
|
5649
|
-
if (options.
|
|
5650
|
-
const stringifiedTags = options.projectTags
|
|
5651
|
-
.map((tag) => {
|
|
5652
|
-
return `${tag.key}=${tag.value}`;
|
|
5653
|
-
})
|
|
5654
|
-
.join(',');
|
|
5655
|
-
flags.push('-project-tags', stringifiedTags);
|
|
5656
|
-
}
|
|
5657
|
-
if (options.report) {
|
|
5612
|
+
if (options.report && analytics_1.allowAnalytics()) {
|
|
5658
5613
|
flags.push('-report');
|
|
5659
5614
|
}
|
|
5660
5615
|
if (options.targetReference) {
|
|
@@ -5678,25 +5633,19 @@ function processFlags(options, rulesBundlePath, configPath, outputPath) {
|
|
|
5678
5633
|
if (options.insecure) {
|
|
5679
5634
|
flags.push('-http-tls-skip-verify');
|
|
5680
5635
|
}
|
|
5636
|
+
if (options.org) {
|
|
5637
|
+
flags.push('-org', options.org);
|
|
5638
|
+
}
|
|
5681
5639
|
return flags;
|
|
5682
5640
|
}
|
|
5683
5641
|
function createTemporaryFiles(options) {
|
|
5684
5642
|
try {
|
|
5685
5643
|
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'snyk-'));
|
|
5686
|
-
const tempConfig = path.join(tempDir, 'config.json');
|
|
5687
5644
|
const tempOutput = path.join(tempDir, 'output.json');
|
|
5688
|
-
const
|
|
5689
|
-
org: options.orgSettings.meta.org,
|
|
5690
|
-
orgPublicId: options.orgSettings.meta.orgPublicId,
|
|
5691
|
-
apiUrl: getApiUrl(),
|
|
5692
|
-
apiAuth: api_token_1.getAuthHeader(),
|
|
5693
|
-
allowAnalytics: analytics_1.allowAnalytics(),
|
|
5694
|
-
policy: options.policy,
|
|
5695
|
-
customSeverities: options.orgSettings.customPolicies,
|
|
5696
|
-
});
|
|
5697
|
-
fs.writeFileSync(tempConfig, configData);
|
|
5645
|
+
const tempPolicy = path.join(tempDir, '.snyk');
|
|
5698
5646
|
fs.writeFileSync(tempOutput, '');
|
|
5699
|
-
|
|
5647
|
+
fs.writeFileSync(tempPolicy, options.policy || '');
|
|
5648
|
+
return { tempOutput, tempDir, tempPolicy };
|
|
5700
5649
|
}
|
|
5701
5650
|
catch (e) {
|
|
5702
5651
|
throw new ScanError(`unable to create config/output file: ${e}`);
|
|
@@ -5711,9 +5660,10 @@ function deleteTemporaryFiles(tempDirPath) {
|
|
|
5711
5660
|
}
|
|
5712
5661
|
}
|
|
5713
5662
|
function getApiUrl() {
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5663
|
+
return config_1.default.API_REST_URL;
|
|
5664
|
+
}
|
|
5665
|
+
function getApiToken() {
|
|
5666
|
+
return api_token_1.api() || '';
|
|
5717
5667
|
}
|
|
5718
5668
|
class ScanError extends errors_1.CustomError {
|
|
5719
5669
|
constructor(message) {
|
|
@@ -5735,15 +5685,27 @@ class ScanError extends errors_1.CustomError {
|
|
|
5735
5685
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
5736
5686
|
exports.mapSnykIacTestOutputToTestOutput = void 0;
|
|
5737
5687
|
const errors_1 = __webpack_require__(87198);
|
|
5688
|
+
const types_1 = __webpack_require__(94820);
|
|
5689
|
+
const unsupported_entitlement_error_1 = __webpack_require__(78673);
|
|
5690
|
+
const get_iac_org_settings_1 = __webpack_require__(11693);
|
|
5738
5691
|
function mapSnykIacTestOutputToTestOutput(snykIacOutput) {
|
|
5739
|
-
var _a;
|
|
5740
|
-
const
|
|
5692
|
+
var _a, _b, _c, _d;
|
|
5693
|
+
const entitlementError = (_a = snykIacOutput.errors) === null || _a === void 0 ? void 0 : _a.find((err) => err.code === types_1.IaCErrorCodes.EntitlementNotEnabled);
|
|
5694
|
+
if (entitlementError) {
|
|
5695
|
+
throw new unsupported_entitlement_error_1.UnsupportedEntitlementError(((_b = entitlementError === null || entitlementError === void 0 ? void 0 : entitlementError.fields) === null || _b === void 0 ? void 0 : _b.entitlement) || '');
|
|
5696
|
+
}
|
|
5697
|
+
const readSettingsError = (_c = snykIacOutput.errors) === null || _c === void 0 ? void 0 : _c.find((err) => err.code === types_1.IaCErrorCodes.ReadSettings);
|
|
5698
|
+
if (readSettingsError) {
|
|
5699
|
+
throw new get_iac_org_settings_1.FailedToGetIacOrgSettingsError();
|
|
5700
|
+
}
|
|
5701
|
+
const errors = (_d = snykIacOutput.errors) === null || _d === void 0 ? void 0 : _d.map((err) => new errors_1.SnykIacTestError(err));
|
|
5741
5702
|
const errWithoutPath = errors === null || errors === void 0 ? void 0 : errors.find((err) => { var _a; return !((_a = err.fields) === null || _a === void 0 ? void 0 : _a.path); });
|
|
5742
5703
|
if (errWithoutPath) {
|
|
5743
5704
|
throw errWithoutPath;
|
|
5744
5705
|
}
|
|
5745
5706
|
return {
|
|
5746
5707
|
results: snykIacOutput.results,
|
|
5708
|
+
settings: snykIacOutput.settings,
|
|
5747
5709
|
errors,
|
|
5748
5710
|
};
|
|
5749
5711
|
}
|