Skip to content

Commit 1c2428e

Browse files
Merge pull request #3848 from snyk/feat/iac-test-v2-show-cloud-issues-url
feat: show Cloud Issues URL when sharing results with snyk iac test
2 parents 55c0352 + 9e1f2d7 commit 1c2428e

File tree

6 files changed

+63
-10
lines changed

6 files changed

+63
-10
lines changed

src/cli/commands/test/iac/local-execution/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ export enum IaCErrorCodes {
390390
NoLoadableInput = 2114,
391391
FailedToMakeResourcesResolvers = 2115,
392392
ResourcesResolverError = 2116,
393-
FailedToShareResults = 2200,
393+
FailedToProcessResults = 2200,
394394
}
395395

396396
export interface TestReturnValue {

src/cli/commands/test/iac/output.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
shareResultsTip,
3333
formatTestData,
3434
} from '../../../../lib/formatters/iac-output/text';
35+
import { formatShareResultsOutputV2 } from '../../../../lib/formatters/iac-output/text/share-results';
3536

3637
const SEPARATOR = '\n-------------------------------------------------------\n';
3738

@@ -269,6 +270,37 @@ export function buildShareResultsSummary({
269270
return response;
270271
}
271272

273+
export function buildShareResultsSummaryV2({
274+
orgName,
275+
projectName,
276+
options,
277+
isIacCustomRulesEntitlementEnabled,
278+
isIacShareCliResultsCustomRulesSupported,
279+
}: {
280+
orgName: string;
281+
projectName: string;
282+
options: IaCTestFlags;
283+
isIacCustomRulesEntitlementEnabled: boolean;
284+
isIacShareCliResultsCustomRulesSupported: boolean;
285+
}): string {
286+
let response = '';
287+
288+
response +=
289+
SEPARATOR + EOL + formatShareResultsOutputV2(orgName, projectName);
290+
291+
if (
292+
shouldPrintShareCustomRulesDisclaimer(
293+
options,
294+
isIacCustomRulesEntitlementEnabled,
295+
isIacShareCliResultsCustomRulesSupported,
296+
)
297+
) {
298+
response += EOL + EOL + shareCustomRulesDisclaimer;
299+
}
300+
301+
return response;
302+
}
303+
272304
export function shouldPrintShareResultsTip(options: IaCTestFlags): boolean {
273305
return shouldLogUserMessages(options) && !options.report;
274306
}

src/lib/formatters/iac-output/text/share-results.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,26 @@ export function formatShareResultsOutput(orgName: string, projectName: string) {
1717
);
1818
}
1919

20+
export function formatShareResultsOutputV2(
21+
orgName: string,
22+
projectName: string,
23+
) {
24+
return (
25+
colors.title('Report Complete') +
26+
EOL +
27+
EOL +
28+
contentPadding +
29+
'Your test results are available at: ' +
30+
colors.title(
31+
`${
32+
config.ROOT
33+
}/org/${orgName}/cloud/issues?environment_name=${encodeURIComponent(
34+
projectName,
35+
)}`,
36+
)
37+
);
38+
}
39+
2040
export const shareResultsTip =
2141
colors.title('Tip') +
2242
EOL +

src/lib/iac/test/v2/errors.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ const snykIacTestErrorsUserMessages = {
3434
'An error occurred preparing the requested cloud context. Please run the command again with the `-d` flag for more information.',
3535
ResourcesResolverError:
3636
'An error occurred scanning cloud resources. Please run the command again with the `-d` flag for more information.',
37-
FailedToShareResults: 'Failed to upload the test results with the platform',
37+
FailedToProcessResults:
38+
'An error occurred while processing results. Please run the command again with the `-d` flag for more information.',
3839
};
3940

4041
export function getErrorUserMessage(code: number): string {

src/lib/iac/test/v2/local-cache/policy-engine/constants/utils.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import * as os from 'os';
22

33
const policyEngineChecksums = `
4-
16211f1b806a85127cad2f1165e39a679a82c6c3d0d6a0bc4fde196710280b73 snyk-iac-test_0.31.2_Linux_x86_64
5-
931a8eb829c912251ae1d47c7b729148dca2bd3c60a4c8b564f614aeeee9d7c9 snyk-iac-test_0.31.2_Darwin_x86_64
6-
9536c5b4b4bf6fef94dd110033311b4447857c43bb07d64f5d2bc498cb53366b snyk-iac-test_0.31.2_Windows_arm64.exe
7-
cf24c3b562f5c4282c029510cf679cabb5fa2a96bbf207cdd57f42e960173fb4 snyk-iac-test_0.31.2_Darwin_arm64
8-
d3bc0efa5e7eec34e9cd2f226e3686329e4a4f371e532851e4d10226e250505d snyk-iac-test_0.31.2_Linux_arm64
9-
fcebb81c0745d8636d55ac9aa4582acbc38d93a496970d3069c19ab278b5ebb6 snyk-iac-test_0.31.2_Windows_x86_64.exe
4+
287c2b8c97b2b6208264e5bf9dab3132c34355efdecf29974a84bd56e7e1654d snyk-iac-test_0.31.3_Darwin_x86_64
5+
4cb497eac74ed543dde6935e5cc0519cffbcced6bfe9a98c697b125edfb75a2e snyk-iac-test_0.31.3_Linux_arm64
6+
6059e32181c32f364757cb39204beea73c1ed4c477d5ae8fa8e970d5c792bb37 snyk-iac-test_0.31.3_Darwin_arm64
7+
7767548480f2479205bdf3d792a66d43313717a471e1c300841504b63ae2581b snyk-iac-test_0.31.3_Windows_arm64.exe
8+
8363ae002cf64f4bb0c65ddc2312d4c6b23098032983d61d8c4c439b705750ed snyk-iac-test_0.31.3_Windows_x86_64.exe
9+
e36cc18b60f7b41fccf5a097f685f437813b9183aa9c6fa97ea4c1fe36ac0e42 snyk-iac-test_0.31.3_Linux_x86_64
1010
`;
1111

1212
export const policyEngineVersion = getPolicyEngineVersion();

src/lib/iac/test/v2/output.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import stripAnsi from 'strip-ansi';
2626
import * as path from 'path';
2727
import { getErrorStringCode } from '../../../../cli/commands/test/iac/local-execution/error-utils';
2828
import {
29-
buildShareResultsSummary,
29+
buildShareResultsSummaryV2,
3030
shouldPrintShareResultsTip,
3131
} from '../../../../cli/commands/test/iac/output';
3232

@@ -167,7 +167,7 @@ function buildTextOutput({
167167
response += EOL;
168168

169169
if (options.report) {
170-
response += buildShareResultsSummary({
170+
response += buildShareResultsSummaryV2({
171171
orgName: orgSettings.meta.org,
172172
projectName,
173173
options,

0 commit comments

Comments
 (0)