Skip to content

Commit

Permalink
feat: mark findings as ignored in tree view
Browse files Browse the repository at this point in the history
  • Loading branch information
acke committed Apr 3, 2024
1 parent ea1cfb8 commit e1ca02b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Snyk Security Changelog

## [2.3.10]
### Added
- Added the [ Ignored ] text if the finding should be marked as ignored.

## [2.3.9]
### Fixes
- do not restrict activation of extension (auto-scan on startup)
Expand Down
1 change: 1 addition & 0 deletions src/snyk/common/languageServer/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export type Issue<T> = {
severity: IssueSeverity;
filePath: string;
additionalData: T;
isIgnored: boolean;
};

export enum IssueSeverity {
Expand Down
14 changes: 12 additions & 2 deletions src/snyk/snykCode/views/issueTreeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,18 @@ export class IssueTreeProvider extends ProductIssueTreeProvider<CodeIssueData> {
getRunTestMessage = () => messages.runTest;

// The title in the tree is taken from the title for vulnerabilities and from the message for quality rules
getIssueTitle = (issue: Issue<CodeIssueData>) =>
issue.additionalData.isSecurityType ? issue.title.split(':')[0] : issue.additionalData.message.split('.')[0];
getIssueTitle(issue: Issue<CodeIssueData>): string {
const issueTitle = issue.additionalData.isSecurityType
? issue.title.split(':')[0]
: issue.additionalData.message.split('.')[0];

let prefixIgnored = '';
if (issue.isIgnored) {
prefixIgnored = '[ Ignored ] ';
}

return prefixIgnored + issueTitle;
}

getIssueRange(issue: Issue<CodeIssueData>): Range {
return IssueUtils.createVsCodeRange(issue.additionalData, this.languages);
Expand Down
1 change: 1 addition & 0 deletions src/test/unit/common/services/learnService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ suite('LearnService', () => {
title: 'not used',
severity: IssueSeverity.Critical,
filePath: 'not used',
isIgnored: false,
};

await learnService.getCodeLesson(issue);
Expand Down

0 comments on commit e1ca02b

Please sign in to comment.