Skip to content

Commit

Permalink
remove password visibility from cb export
Browse files Browse the repository at this point in the history
  • Loading branch information
lokesh-couchbase committed Nov 7, 2023
1 parent 0c367ca commit 513ca57
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ export function activate(context: vscode.ExtensionContext) {
vscode.commands.registerCommand(
Commands.dataExport,
async () => {
await dataExport();
await dataExport(context);
}
)
);
Expand Down
5 changes: 3 additions & 2 deletions src/pages/Tools/DataExport/dataExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export interface IDataExportWebviewState {
webviewPanel: vscode.WebviewPanel;
}

export const dataExport = async () => {
export const dataExport = async (context: vscode.ExtensionContext) => {
const connection = getActiveConnection();
if (!connection) {
return;
Expand Down Expand Up @@ -146,7 +146,8 @@ export const dataExport = async () => {
formData.collectionFieldName,
formData.format,
formData.threads,
formData.verboseLog
formData.verboseLog,
context
);
} else {
currentPanel.webview.postMessage({
Expand Down
14 changes: 10 additions & 4 deletions src/tools/CBExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export class CBExport {
colName: string,
format: string,
threads: string,
verbose: boolean
verbose: boolean,
context: vscode.ExtensionContext
): Promise<void> {

const connection = getActiveConnection();
Expand Down Expand Up @@ -66,8 +67,8 @@ export class CBExport {
cmd.push(connection.url);
cmd.push("-u");
cmd.push(connection.username);
cmd.push("-p");
cmd.push('"' + password + '"');
// cmd.push("-p");
// cmd.push('"' + password + '"');
cmd.push("-b");
cmd.push(bucket);

Expand All @@ -94,10 +95,15 @@ export class CBExport {
}

// Run Command
const terminal = vscode.window.createTerminal("CBExport");
const terminal: vscode.Terminal = vscode.window.createTerminal("CBExport");
// sending password to vscode environment variables. Note: Password is still accessible via terminal, till its removed
context.environmentVariableCollection.replace('CB_PASSWORD', password);
let text = cmd.join(" ");
terminal.sendText(text);
terminal.show();
// removing password from vscode environment variables after 5 seconds
await new Promise((resolve)=>setTimeout(resolve, 5000));
context.environmentVariableCollection.replace('CB_PASSWORD', '');
} catch (error) {
console.error("An error occurred while trying to export the dataset");
console.error(error);
Expand Down

0 comments on commit 513ca57

Please sign in to comment.