Skip to content

Commit ddab6f9

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

5 files changed

Lines changed: 15 additions & 26 deletions

File tree

.github/workflows/integration-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
workflow_dispatch:
1111

1212
env:
13-
LW_ACCOUNT_NAME: ${{ secrets.LW_ACCOUNT_CAT }}
13+
LW_ACCOUNT: ${{ secrets.LW_ACCOUNT_CAT }}
1414
LW_API_KEY: ${{ secrets.LW_API_KEY_CAT }}
1515
LW_API_SECRET: ${{ secrets.LW_API_SECRET_CAT }}
1616
DEBUG: true

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ permissions:
2323
pull-requests: write
2424

2525
env:
26-
LW_ACCOUNT_NAME: ${{ secrets.LW_ACCOUNT_NAME }}
27-
LW_SUBACCOUNT_NAME: ${{ secrets.LW_SUBACCOUNT_NAME }}
26+
LW_ACCOUNT: ${{ secrets.LW_ACCOUNT }}
27+
LW_SUBACCOUNT: ${{ secrets.LW_SUBACCOUNT }}
2828
LW_API_KEY: ${{ secrets.LW_API_KEY }}
2929
LW_API_SECRET: ${{ secrets.LW_API_SECRET }}
3030

action.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,17 @@ runs:
6969
if: ${{ inputs.debug == 'true' }}
7070
run: |
7171
echo "LW_LOG=debug" >> $GITHUB_ENV
72+
- name: Set Lacework account environment variable
73+
shell: bash
74+
run: |
75+
if [ -n "$LW_ACCOUNT_NAME" ]; then
76+
echo "LW_ACCOUNT=$LW_ACCOUNT_NAME" >> $GITHUB_ENV
77+
fi
7278
- name: Install Lacework CLI component
7379
shell: bash
7480
run: |
75-
lacework --noninteractive -a "${LW_ACCOUNT_NAME}" -k "${LW_API_KEY}" -s "${LW_API_SECRET}" component install sca
76-
lacework --noninteractive -a "${LW_ACCOUNT_NAME}" -k "${LW_API_KEY}" -s "${LW_API_SECRET}" version
81+
lacework --noninteractive component install sca
82+
lacework --noninteractive version
7783
env:
7884
CDK_DOWNLOAD_TIMEOUT_MINUTES: 2
7985
- uses: actions/setup-node@v4

src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ async function runAnalysis() {
4141
await callLaceworkCli(...args)
4242
toUpload.push(sarifReportPath)
4343

44-
const uploadStart = Date.now()
45-
4644
await uploadArtifact(getArtifactName(target), ...toUpload)
4745
setOutput(`${target}-completed`, true)
4846
}

src/util.ts

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,7 @@ export function getOptionalEnvVariable(name: string, defaultValue: string) {
6060
}
6161

6262
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-
]
77-
info('Calling lacework ' + expandedArgs.join(' '))
78-
await callCommand('lacework', ...expandedArgs)
63+
await callCommand('lacework', '--noninteractive', 'sca', ...args)
7964
}
8065

8166
export function getOrDefault(name: string, defaultValue: string) {
@@ -93,7 +78,7 @@ export function generateUILink() {
9378

9479
if (targetBranch !== defaultBranch) return ''
9580

96-
let lwAccountName = process.env.LW_ACCOUNT_NAME
81+
let lwAccountName = process.env.LW_ACCOUNT
9782
lwAccountName = lwAccountName?.replace(/\.lacework\.net$/, '')
9883

9984
let url =
@@ -102,8 +87,8 @@ export function generateUILink() {
10287
`github.com%2F${context.repo.owner}%2F${context.repo.repo}` +
10388
`/${defaultBranch}`
10489

105-
if (process.env.LW_SUBACCOUNT_NAME) {
106-
url += '?accountName=' + process.env.LW_SUBACCOUNT_NAME
90+
if (process.env.LW_SUBACCOUNT) {
91+
url += '?accountName=' + process.env.LW_SUBACCOUNT
10792
}
10893

10994
return url

0 commit comments

Comments
 (0)