Skip to content

Commit

Permalink
feat: Add impact and resolve fields in sarif output.
Browse files Browse the repository at this point in the history
Adds fields in sarif output but also markdown text for the Github Security tab.
CC-517

refactor: Format helpText with a replace function
  • Loading branch information
Ilianna Papastefanou committed Dec 14, 2020
1 parent 47eaff9 commit bb2a470
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/cli/commands/test/iac-output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,14 @@ export function extractReportingDescriptor(
text: `${iacTypeToText[issue.type]} ${issue.subType}`,
},
help: {
text: '',
markdown: issue.description,
text: `The issue is... \n${issue.iacDescription.issue}\n\n The impact of this is... \n ${issue.iacDescription.impact}\n\n You can resolve this by... \n${issue.iacDescription.resolve}`.replace(
/^\s+/g,
'',
),
markdown: `**The issue is...** \n${issue.iacDescription.issue}\n\n **The impact of this is...** \n ${issue.iacDescription.impact}\n\n **You can resolve this by...** \n${issue.iacDescription.resolve}`.replace(
/^\s+/g,
'',
),
},
defaultConfiguration: {
level: getIssueLevel(issue.severity),
Expand Down
7 changes: 6 additions & 1 deletion src/lib/snyk-test/iac-test-result.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BasicResultData, TestDepGraphMeta, SEVERITY } from './legacy';
import { BasicResultData, SEVERITY, TestDepGraphMeta } from './legacy';

export interface AnnotatedIacIssue {
id: string;
Expand All @@ -14,6 +14,11 @@ export interface AnnotatedIacIssue {
name?: string;
from?: string[];
lineNumber?: number;
iacDescription: {
issue: string;
impact: string;
resolve: string;
};
}

type FILTERED_OUT_FIELDS = 'cloudConfigPath' | 'name' | 'from';
Expand Down
3 changes: 2 additions & 1 deletion test/acceptance/cli-test/iac/cli-test.iac-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ export function iacTestSarifAssertions(

function generateDummyIssue(severity): AnnotatedIacIssue {
return {
iacDescription: { issue: '', impact: '', resolve: '' },
id: 'SNYK-CC-K8S-1',
title: 'Reducing the admission of containers with dropped capabilities',
name: 'Reducing the admission of containers with dropped capabilities',
Expand All @@ -303,7 +304,7 @@ function generateDummyIssue(severity): AnnotatedIacIssue {
}

function generateDummyTestData(
cloudConfigResults: Array<AnnotatedIacIssue>,
cloudConfigResults: AnnotatedIacIssue[],
): IacTestResponse {
return {
path: '',
Expand Down

0 comments on commit bb2a470

Please sign in to comment.