From e1ca02b4f465d7baed7a407db1f6216b37789a87 Mon Sep 17 00:00:00 2001 From: acke Date: Tue, 2 Apr 2024 14:26:49 +0200 Subject: [PATCH] feat: mark findings as ignored in tree view --- CHANGELOG.md | 4 ++++ src/snyk/common/languageServer/types.ts | 1 + src/snyk/snykCode/views/issueTreeProvider.ts | 14 ++++++++++++-- src/test/unit/common/services/learnService.test.ts | 1 + 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2a7260b1..35d2efc90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/src/snyk/common/languageServer/types.ts b/src/snyk/common/languageServer/types.ts index 254b91656..fe995d829 100644 --- a/src/snyk/common/languageServer/types.ts +++ b/src/snyk/common/languageServer/types.ts @@ -24,6 +24,7 @@ export type Issue = { severity: IssueSeverity; filePath: string; additionalData: T; + isIgnored: boolean; }; export enum IssueSeverity { diff --git a/src/snyk/snykCode/views/issueTreeProvider.ts b/src/snyk/snykCode/views/issueTreeProvider.ts index acc96239f..8ccd9662d 100644 --- a/src/snyk/snykCode/views/issueTreeProvider.ts +++ b/src/snyk/snykCode/views/issueTreeProvider.ts @@ -33,8 +33,18 @@ export class IssueTreeProvider extends ProductIssueTreeProvider { 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) => - issue.additionalData.isSecurityType ? issue.title.split(':')[0] : issue.additionalData.message.split('.')[0]; + getIssueTitle(issue: Issue): 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): Range { return IssueUtils.createVsCodeRange(issue.additionalData, this.languages); diff --git a/src/test/unit/common/services/learnService.test.ts b/src/test/unit/common/services/learnService.test.ts index 94c595e41..b97bb9529 100644 --- a/src/test/unit/common/services/learnService.test.ts +++ b/src/test/unit/common/services/learnService.test.ts @@ -39,6 +39,7 @@ suite('LearnService', () => { title: 'not used', severity: IssueSeverity.Critical, filePath: 'not used', + isIgnored: false, }; await learnService.getCodeLesson(issue);