Skip to content

Commit

Permalink
fix: use folder path from workspace folder to find issues (#401)
Browse files Browse the repository at this point in the history
Signed-off-by: Bastian Doetsch <[email protected]>
  • Loading branch information
bastiandoetsch authored Nov 27, 2023
1 parent b52376b commit 274027a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/snyk/common/commands/commandController.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/snyk/snykOss/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface IOssSuggestionWebviewProvider extends IWebViewProvider<Issue<Os
export type OssIssueCommandArg = Issue<OssIssueData> & {
matchingIdVulnerabilities: Issue<OssIssueData>[];
overviewHtml: string;
folderPath: string;
};

export type OssResult = OssFileResult[] | OssFileResult;
Expand Down
13 changes: 9 additions & 4 deletions src/snyk/snykOss/providers/ossVulnerabilityTreeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default class OssIssueTreeProvider extends ProductIssueTreeProvider<OssIs
internal: {
severity: ProductIssueTreeProvider.getSeverityComparatorIndex(issue.severity),
},
command: this.getOpenIssueCommand(issue, '', '', filteredIssues),
command: this.getOpenIssueCommand(issue, folderPath, '', filteredIssues),
});
});

Expand Down Expand Up @@ -185,7 +185,7 @@ export default class OssIssueTreeProvider extends ProductIssueTreeProvider<OssIs

getOpenIssueCommand(
issue: Issue<OssIssueData>,
_folderPath: string,
folderPath: string,
_filePath: string,
filteredIssues: Issue<OssIssueData>[],
): Command {
Expand All @@ -195,13 +195,17 @@ export default class OssIssueTreeProvider extends ProductIssueTreeProvider<OssIs
arguments: [
{
issueType: OpenCommandIssueType.OssVulnerability,
issue: this.getOssIssueCommandArg(issue, filteredIssues),
issue: this.getOssIssueCommandArg(issue, folderPath, filteredIssues),
} as OpenIssueCommandArg,
],
};
}

getOssIssueCommandArg(vuln: Issue<OssIssueData>, filteredVulns: Issue<OssIssueData>[]): OssIssueCommandArg {
getOssIssueCommandArg(
vuln: Issue<OssIssueData>,
folderPath: string,
filteredVulns: Issue<OssIssueData>[],
): OssIssueCommandArg {
const matchingIdVulnerabilities = filteredVulns.filter(v => v.id === vuln.id);
let overviewHtml = '';

Expand All @@ -216,6 +220,7 @@ export default class OssIssueTreeProvider extends ProductIssueTreeProvider<OssIs
...vuln,
matchingIdVulnerabilities,
overviewHtml,
folderPath,
};
}
}

0 comments on commit 274027a

Please sign in to comment.