Skip to content

Commit

Permalink
Add configuration option to set the username
Browse files Browse the repository at this point in the history
  • Loading branch information
fcasal committed Sep 23, 2024
1 parent 85e2186 commit c410819
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,11 @@
"type": "string",
"default": "trailofbits",
"description": "Defining the organization name for the audit repository enhances the heuristic to determine the correct git remote when creating permalinks."
},
"weAudit.general.username": {
"type": "string",
"default": "",
"description": "The username to use as the finding's author. (Defaults to the system's username if left empty.)"
}
}
},
Expand Down
9 changes: 8 additions & 1 deletion src/codeMarker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class CodeMarker implements vscode.TreeDataProvider<TreeEntry> {
this.treeViewMode = TreeViewMode.List;
this.loadTreeViewModeConfiguration();

this.username = userInfo().username;
this.username = this.setUsernameConfigOrDefault();
this.currentlySelectedUsernames = [];
this.findAndLoadConfigurationUsernames();
this.resolvedEntriesTree = new ResolvedEntries(context, this.resolvedEntries);
Expand Down Expand Up @@ -323,6 +323,11 @@ export class CodeMarker implements vscode.TreeDataProvider<TreeEntry> {
});
}

public setUsernameConfigOrDefault(): string {
this.username = vscode.workspace.getConfiguration("weAudit").get("general.username") || userInfo().username;
return this.username;
}

/**
* Exports the findings to a markdown file
* allowing the user to select which findings to export
Expand Down Expand Up @@ -2714,6 +2719,8 @@ export class AuditMarker {
private selectivelyReloadConfigurations(e: vscode.ConfigurationChangeEvent): void {
if (e.affectsConfiguration("weAudit.general.treeViewMode")) {
treeDataProvider.loadTreeViewModeConfiguration();
} else if (e.affectsConfiguration("weAudit.general.username")) {
treeDataProvider.setUsernameConfigOrDefault();
} else {
this.decorationManager.reloadAllDecorationConfigurations();
this.decorate();
Expand Down

0 comments on commit c410819

Please sign in to comment.