Skip to content

Don't concatenate shell arguments. #1974

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/gcp_auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,21 @@ export class GoogleCloudPlatformAuth implements Authenticator {
}

private updateAccessToken(config: Config): void {
let cmd = config['cmd-path'];
const cmd = config['cmd-path'];
if (!cmd) {
throw new Error('Token is expired!');
}
// Wrap cmd in quotes to make it cope with spaces in path
cmd = `"${cmd}"`;
const args = config['cmd-args'];
if (args) {
cmd = cmd + ' ' + args;
}
const args = (config['cmd-args'] ? config['cmd-args'].split(' ') : []).map((arg: string): string => {
if (arg[0] === "'" || arg[0] === '"') {
return arg.substring(1, arg.length - 1);
}
return arg;
});
// TODO: Cache to file?
// TODO: do this asynchronously
let output: any;
try {
output = proc.execSync(cmd);
output = proc.execFileSync(cmd, args);
} catch (err) {
throw new Error('Failed to refresh token: ' + (err as Error).message);
}
Expand Down
Loading