Skip to content

Commit

Permalink
Merge pull request #1558 from snyk/feat/add-impact-and-resolution-to-…
Browse files Browse the repository at this point in the history
…github-security-cc-517

feat: Add impact and resolve fields in sarif output.
  • Loading branch information
ipapast committed Dec 14, 2020
2 parents cc73cc6 + bb2a470 commit 898ae29
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 898ae29

Please sign in to comment.