Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add impact and resolve fields in sarif output. #1558

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
aron marked this conversation as resolved.
Show resolved Hide resolved
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