From 9434fad81c762b0f8037ef8d2bee4aab5cbdbbd3 Mon Sep 17 00:00:00 2001 From: Bastian Doetsch Date: Fri, 24 Nov 2023 17:54:00 +0100 Subject: [PATCH] fix: use folder path from workspace folder to find issues Signed-off-by: Bastian Doetsch --- src/snyk/common/commands/commandController.ts | 3 +-- src/snyk/snykOss/interfaces.ts | 1 + .../providers/ossVulnerabilityTreeProvider.ts | 13 +++++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/snyk/common/commands/commandController.ts b/src/snyk/common/commands/commandController.ts index a58ea1799..630ec0e26 100644 --- a/src/snyk/common/commands/commandController.ts +++ b/src/snyk/common/commands/commandController.ts @@ -1,6 +1,5 @@ /* eslint-disable @typescript-eslint/no-unsafe-argument */ import _ from 'lodash'; -import path from 'path'; import { IAuthenticationService } from '../../base/services/authenticationService'; import { ScanModeService } from '../../base/services/scanModeService'; import { createDCIgnore as createDCIgnoreUtil } from '../../snykCode/utils/ignoreFileUtils'; @@ -122,7 +121,7 @@ export class CommandController { }); } else if (arg.issueType == OpenCommandIssueType.OssVulnerability) { const issueArgs = arg.issue as CodeIssueCommandArg; - const folderPath = path.dirname(issueArgs.filePath); + const folderPath = issueArgs.folderPath; const issue = this.ossService.getIssue(folderPath, issueArgs.id); if (!issue) { diff --git a/src/snyk/snykOss/interfaces.ts b/src/snyk/snykOss/interfaces.ts index 70056124a..fde681716 100644 --- a/src/snyk/snykOss/interfaces.ts +++ b/src/snyk/snykOss/interfaces.ts @@ -10,6 +10,7 @@ export interface IOssSuggestionWebviewProvider extends IWebViewProvider & { matchingIdVulnerabilities: Issue[]; overviewHtml: string; + folderPath: string; }; export type OssResult = OssFileResult[] | OssFileResult; diff --git a/src/snyk/snykOss/providers/ossVulnerabilityTreeProvider.ts b/src/snyk/snykOss/providers/ossVulnerabilityTreeProvider.ts index 1b04c0419..d2649eda4 100644 --- a/src/snyk/snykOss/providers/ossVulnerabilityTreeProvider.ts +++ b/src/snyk/snykOss/providers/ossVulnerabilityTreeProvider.ts @@ -88,7 +88,7 @@ export default class OssIssueTreeProvider extends ProductIssueTreeProvider, - _folderPath: string, + folderPath: string, _filePath: string, filteredIssues: Issue[], ): Command { @@ -195,13 +195,17 @@ export default class OssIssueTreeProvider extends ProductIssueTreeProvider, filteredVulns: Issue[]): OssIssueCommandArg { + getOssIssueCommandArg( + vuln: Issue, + folderPath: string, + filteredVulns: Issue[], + ): OssIssueCommandArg { const matchingIdVulnerabilities = filteredVulns.filter(v => v.id === vuln.id); let overviewHtml = ''; @@ -216,6 +220,7 @@ export default class OssIssueTreeProvider extends ProductIssueTreeProvider