Skip to content

Commit e3eb86b

Browse files
committed
fix(COD-6066): hide the Lacework credentials from the running commands
1 parent 7813866 commit e3eb86b

1 file changed

Lines changed: 14 additions & 17 deletions

File tree

src/util.ts

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ export function getRunUrl(): string {
3030
return result
3131
}
3232

33-
export async function callCommand(command: string, ...args: string[]) {
33+
export async function callCommand(
34+
command: string,
35+
environment: NodeJS.ProcessEnv,
36+
...args: string[]
37+
) {
3438
info('Invoking ' + command + ' ' + args.join(' '))
35-
const child = spawn(command, args, { stdio: 'inherit' })
39+
const child = spawn(command, args, { stdio: 'inherit', env: environment })
3640
const exitCode = await new Promise((resolve, _) => {
3741
child.on('close', resolve)
3842
})
@@ -60,22 +64,15 @@ export function getOptionalEnvVariable(name: string, defaultValue: string) {
6064
}
6165

6266
export async function callLaceworkCli(...args: string[]) {
63-
const accountName = getRequiredEnvVariable('LW_ACCOUNT_NAME')
64-
const apiKey = getRequiredEnvVariable('LW_API_KEY')
65-
const apiSecret = getRequiredEnvVariable('LW_API_SECRET')
66-
const expandedArgs = [
67-
'--noninteractive',
68-
'--account',
69-
accountName,
70-
'--api_key',
71-
apiKey,
72-
'--api_secret',
73-
apiSecret,
74-
'sca',
75-
...args,
76-
]
67+
let laceworkEnv = {
68+
...process.env,
69+
LW_ACCOUNT_NAME: getRequiredEnvVariable('LW_ACCOUNT_NAME'),
70+
LW_API_KEY: getRequiredEnvVariable('LW_API_KEY'),
71+
LW_API_SECRET: getRequiredEnvVariable('LW_API_SECRET'),
72+
}
73+
const expandedArgs = ['--noninteractive', 'sca', ...args]
7774
info('Calling lacework ' + expandedArgs.join(' '))
78-
await callCommand('lacework', ...expandedArgs)
75+
await callCommand('lacework', laceworkEnv, ...expandedArgs)
7976
}
8077

8178
export function getOrDefault(name: string, defaultValue: string) {

0 commit comments

Comments
 (0)