Skip to content

Commit

Permalink
Merge pull request #31 from aquasecurity/owenr-fix-filepaths-windows
Browse files Browse the repository at this point in the history
fix: windows filepaths
  • Loading branch information
Owen Rumney authored Jun 3, 2022
2 parents 5a6acc6 + 0d597b1 commit 6d9adb2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

All notable changes to the "tfsec" extension will be documented in this file.

### 1.10.1
- Fix Windows filepaths

### 1.10.0
- Fix issue with file path names in the explorer
- Add context support for locally ignoring files and directories
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ To remove ignores, edit the `tfsec.excludedPath` in the `.vscode/settings.json`

## Release Notes

### 1.10.1
- Fix Windows filepaths

### 1.10.0
- Fix issue with file path names in the explorer
- Add context support for locally ignoring files and directories
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "tfsec",
"publisher": "tfsec",
"description": "tfsec integration for Visual Studio Code",
"version": "1.10.0",
"version": "1.10.1",
"engines": {
"vscode": "^1.54.0"
},
Expand Down
16 changes: 3 additions & 13 deletions src/explorer/issues_treeview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class TfsecIssueProvider implements vscode.TreeDataProvider<TfsecTreeItem
if (result.code !== code) {
continue;
}
const filename = this.relativizePath(result.filename);
const filename = path.relative(this.rootpath, result.filename);
const cmd = this.createFileOpenCommand(result);
var item = new TfsecTreeItem(`${filename}:${result.startLine}`, result, vscode.TreeItemCollapsibleState.None, cmd);
results.push(item);
Expand All @@ -149,21 +149,11 @@ export class TfsecIssueProvider implements vscode.TreeDataProvider<TfsecTreeItem
}


private relativizePath(incomingPath: string): string {
const pathParts = path.parse(this.rootpath);
const workingIncomingPath = pathParts.root + incomingPath;
return path.relative(this.rootpath, workingIncomingPath);
}

private absolutizePath(incomingPath: string): string {
const pathParts = path.parse(this.rootpath);
return path.join(pathParts.root, incomingPath);
}

private createFileOpenCommand(result: CheckResult) {
const issueRange = new vscode.Range(new vscode.Position(result.startLine - 1, 0), new vscode.Position(result.endLine, 0));

const pathToOpen = this.absolutizePath(result.filename);
const pathToOpen = path.join(result.filename);

return {
command: "vscode.open",
title: "",
Expand Down

0 comments on commit 6d9adb2

Please sign in to comment.