Skip to content

Commit 8a0dae5

Browse files
brendandburnsgithub-advanced-security[bot]mstruebing
authored
Don't concatenate shell arguments. (#1974)
* Don't concatenate the string arguments. Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * Fix up generated code. * fix : test * Fix up generated code. * Revert initial fix * fix style --------- Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Co-authored-by: Max Strübing <mxstrbng@gmail.com>
1 parent b8c5bfc commit 8a0dae5

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/gcp_auth.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,21 @@ export class GoogleCloudPlatformAuth implements Authenticator {
6262
}
6363

6464
private updateAccessToken(config: Config): void {
65-
let cmd = config['cmd-path'];
65+
const cmd = config['cmd-path'];
6666
if (!cmd) {
6767
throw new Error('Token is expired!');
6868
}
69-
// Wrap cmd in quotes to make it cope with spaces in path
70-
cmd = `"${cmd}"`;
71-
const args = config['cmd-args'];
72-
if (args) {
73-
cmd = cmd + ' ' + args;
74-
}
69+
const args = (config['cmd-args'] ? config['cmd-args'].split(' ') : []).map((arg: string): string => {
70+
if (arg[0] === "'" || arg[0] === '"') {
71+
return arg.substring(1, arg.length - 1);
72+
}
73+
return arg;
74+
});
7575
// TODO: Cache to file?
7676
// TODO: do this asynchronously
7777
let output: any;
7878
try {
79-
output = proc.execSync(cmd);
79+
output = proc.execFileSync(cmd, args);
8080
} catch (err) {
8181
throw new Error('Failed to refresh token: ' + (err as Error).message);
8282
}

0 commit comments

Comments
 (0)