From 0849da4703859b1de59ae849de61413c4838e869 Mon Sep 17 00:00:00 2001 From: Jason Luong Date: Fri, 27 Oct 2023 13:35:01 +0100 Subject: [PATCH] fix: linting --- src/snyk/common/views/issueTreeProvider.ts | 7 +++- .../providers/ossVulnerabilityTreeProvider.ts | 32 +++++++++++++------ 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/snyk/common/views/issueTreeProvider.ts b/src/snyk/common/views/issueTreeProvider.ts index e4d8a00dd..b55fe4b01 100644 --- a/src/snyk/common/views/issueTreeProvider.ts +++ b/src/snyk/common/views/issueTreeProvider.ts @@ -42,7 +42,12 @@ export abstract class ProductIssueTreeProvider extends AnalysisTreeNodeProvid abstract getIssueTitle(issue: Issue): string; abstract getIssueRange(issue?: Issue): Range | undefined; - abstract getOpenIssueCommand(issue: Issue, folderPath: string, filePath: string, filteredIssues?: Issue[]): Command; + abstract getOpenIssueCommand( + issue: Issue, + folderPath: string, + filePath: string, + filteredIssues?: Issue[], + ): Command; getRootChildren(): TreeNode[] { const nodes: TreeNode[] = []; diff --git a/src/snyk/snykOss/providers/ossVulnerabilityTreeProvider.ts b/src/snyk/snykOss/providers/ossVulnerabilityTreeProvider.ts index f4e111a59..d64997b34 100644 --- a/src/snyk/snykOss/providers/ossVulnerabilityTreeProvider.ts +++ b/src/snyk/snykOss/providers/ossVulnerabilityTreeProvider.ts @@ -1,5 +1,5 @@ import _ from 'lodash'; -import marked from 'marked'; +import * as marked from 'marked'; import { Command, Uri } from 'vscode'; import { OpenCommandIssueType, OpenIssueCommandArg } from '../../common/commands/types'; import { IConfiguration } from '../../common/configuration/configuration'; @@ -71,7 +71,9 @@ export default class OssIssueTreeProvider extends ProductIssueTreeProvider index === self.findIndex(t => t.id === issue.id)); + const uniqueIssues = fileIssues.filter( + (issue, index, self) => index === self.findIndex(t => t.id === issue.id), + ); const filteredIssues = this.filterIssues(uniqueIssues); @@ -153,7 +155,9 @@ export default class OssIssueTreeProvider extends ProductIssueTreeProvider[]): Issue[] { @@ -179,7 +183,12 @@ export default class OssIssueTreeProvider extends ProductIssueTreeProvider undefined; - getOpenIssueCommand(issue: Issue, _folderPath: string, _filePath: string, filteredIssues: Issue[]): Command { + getOpenIssueCommand( + issue: Issue, + _folderPath: string, + _filePath: string, + filteredIssues: Issue[], + ): Command { return { command: SNYK_OPEN_ISSUE_COMMAND, title: '', @@ -192,21 +201,24 @@ export default class OssIssueTreeProvider extends ProductIssueTreeProvider, filteredVulns: Issue[]): OssIssueCommandArgLanguageServer { + getOssIssueCommandArg( + vuln: Issue, + filteredVulns: Issue[], + ): OssIssueCommandArgLanguageServer { const matchingIdVulnerabilities = filteredVulns.filter(v => v.id === vuln.id); - let overviewHtml: string; + let overviewHtml = ''; try { + // TODO: marked.parse does not sanitize the HTML. See: https://marked.js.org/#usage overviewHtml = marked.parse(vuln.additionalData.description); - console.log('****', 'overviewHtml ****\n', overviewHtml, '\n'); } catch (error) { - console.log('****', 'overviewHtml error ****\n', error, '\n'); + overviewHtml = '

There was a problem rendering the vulnerability overview

'; } return { ...vuln, matchingIdVulnerabilities, - overviewHtml: vuln.additionalData.description, + overviewHtml, }; - }; + } }