Skip to content

Commit 78c7fce

Browse files
chore(COD-7131): cleaning up dead code (#271)
1 parent dfe20f2 commit 78c7fce

7 files changed

Lines changed: 21 additions & 68 deletions

File tree

.github/workflows/integration-test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ env:
1313
LW_ACCOUNT: ${{ secrets.LW_ACCOUNT_CAT }}
1414
LW_API_KEY: ${{ secrets.LW_API_KEY_CAT }}
1515
LW_API_SECRET: ${{ secrets.LW_API_SECRET_CAT }}
16-
DEBUG: true
1716

1817
jobs:
1918
build:

action.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ inputs:
99
target:
1010
description: 'One of push, old or new to represent which is being analyzed'
1111
required: false
12-
debug:
13-
description: 'Set to true to enable debug logging'
14-
required: false
15-
default: false
1612
token:
1713
description: 'Set to a GitHub token for the repository with write permissions for PRs to enable PR comments'
1814
required: false
@@ -53,11 +49,6 @@ runs:
5349
echo "Lacework context ID: $LACEWORK_CONTEXT_ID"
5450
echo "LACEWORK_CONTEXT_ID=$(echo $LACEWORK_CONTEXT_ID)" >> $GITHUB_ENV
5551
echo "LACEWORK_ACTION_REF=$(echo $LACEWORK_ACTION_REF)" >> $GITHUB_ENV
56-
- name: Sets LW_LOG var for debug
57-
shell: bash
58-
if: ${{ inputs.debug == 'true' }}
59-
run: |
60-
echo "LW_LOG=debug" >> $GITHUB_ENV
6152
- name: Set Lacework account environment variable
6253
shell: bash
6354
run: |
@@ -80,7 +71,6 @@ runs:
8071
with:
8172
sources: '${{ inputs.sources }}'
8273
target: '${{ inputs.target }}'
83-
debug: '${{ inputs.debug }}'
8474
token: '${{ inputs.token || github.token }}'
8575
footer: '${{ inputs.footer }}'
8676
code-scanning-path: '${{ inputs.code-scanning-path }}'

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"ts-md5": "^1.3.1"
1919
},
2020
"scripts": {
21-
"test": "npx jest",
21+
"test": "npx jest --passWithNoTests",
2222
"compile": "npx tsc",
2323
"lint-check": "npx eslint **/*.ts",
2424
"lint-fix": "npx eslint --fix **/*.ts",

src/index.ts

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,14 @@ async function runAnalysis() {
4949
}
5050
}
5151

52-
const enableIacRunning = true
53-
5452
// Create scan-results directory
5553
const resultsPath = path.join(process.cwd(), 'scan-results')
5654

5755
// Cache the analysis results when scanning the target branch
5856
let cacheHit = false
5957
let cacheKey: string | undefined
6058
if (targetScan === 'old') {
61-
cacheKey = await generateCacheKey(enableIacRunning, targetScan, modifiedFiles)
59+
cacheKey = await generateCacheKey(targetScan, modifiedFiles)
6260
if (cacheKey) {
6361
const restored = await cache.restoreCache([resultsPath], cacheKey)
6462
if (restored) {
@@ -73,11 +71,11 @@ async function runAnalysis() {
7371
}
7472

7573
if (!cacheHit) {
76-
let success = await runCodesec('scan', enableIacRunning, resultsPath, targetScan, modifiedFiles)
74+
let success = await runCodesec('scan', true, resultsPath, targetScan, modifiedFiles)
7775
if (success && targetScan !== 'new') {
7876
// Save the analysis results when not scanning the PR source branch
7977
if (!cacheKey) {
80-
cacheKey = await generateCacheKey(enableIacRunning, targetScan, modifiedFiles)
78+
cacheKey = await generateCacheKey(targetScan, modifiedFiles)
8179
}
8280
if (cacheKey) {
8381
try {
@@ -99,14 +97,12 @@ async function runAnalysis() {
9997
break
10098
}
10199
}
102-
if (enableIacRunning) {
103-
const iacDir = path.join(resultsPath, 'iac')
104-
for (const name of possibleNames) {
105-
const existing = path.join(iacDir, `iac-${name}.json`)
106-
if (existsSync(existing) && name !== targetScan) {
107-
renameSync(existing, path.join(iacDir, `iac-${targetScan}.json`))
108-
break
109-
}
100+
const iacDir = path.join(resultsPath, 'iac')
101+
for (const name of possibleNames) {
102+
const existing = path.join(iacDir, `iac-${name}.json`)
103+
if (existsSync(existing) && name !== targetScan) {
104+
renameSync(existing, path.join(iacDir, `iac-${targetScan}.json`))
105+
break
110106
}
111107
}
112108
}
@@ -128,14 +124,12 @@ async function runAnalysis() {
128124
}
129125

130126
// Upload IAC JSON from the returned results path
131-
if (enableIacRunning) {
132-
const iacJsonFile = path.join(resultsPath, 'iac', `iac-${targetScan}.json`)
133-
if (existsSync(iacJsonFile)) {
134-
info(`Found IAC JSON file to upload: ${iacJsonFile}`)
135-
toUpload.push(iacJsonFile)
136-
} else {
137-
info(`IAC JSON file not found at: ${iacJsonFile}`)
138-
}
127+
const iacJsonFile = path.join(resultsPath, 'iac', `iac-${targetScan}.json`)
128+
if (existsSync(iacJsonFile)) {
129+
info(`Found IAC JSON file to upload: ${iacJsonFile}`)
130+
toUpload.push(iacJsonFile)
131+
} else {
132+
info(`IAC JSON file not found at: ${iacJsonFile}`)
139133
}
140134

141135
const artifactName = 'results-' + target
@@ -145,8 +139,6 @@ async function runAnalysis() {
145139
}
146140

147141
async function displayResults() {
148-
const enableIacRunning = true
149-
150142
info('Displaying results')
151143

152144
// Download artifacts from previous jobs
@@ -155,21 +147,18 @@ async function displayResults() {
155147

156148
// Create local scan-results directory for compare
157149
mkdirSync('scan-results/sca', { recursive: true })
158-
if (enableIacRunning) {
159-
mkdirSync('scan-results/iac', { recursive: true })
160-
}
150+
mkdirSync('scan-results/iac', { recursive: true })
161151

162152
// Check and copy files for each scanner type
163153
if (!(await prepareScannerFiles('sca', artifactOld, artifactNew))) {
164154
error('SCA files not found. Cannot perform compare.')
165155
return
166156
}
167-
const iacAvailable =
168-
enableIacRunning && (await prepareScannerFiles('iac', artifactOld, artifactNew))
157+
const iacAvailable = await prepareScannerFiles('iac', artifactOld, artifactNew)
169158

170159
// Run codesec compare mode with available scanners
171160
const resultsPath = path.join(process.cwd(), 'scan-results')
172-
await runCodesec('compare', enableIacRunning && iacAvailable, resultsPath)
161+
await runCodesec('compare', iacAvailable, resultsPath)
173162

174163
// Read comparison output - check all possible outputs
175164
const outputs = [

src/util.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ function getBooleanInput(name: string) {
3939
return getInput(name).toLowerCase() === 'true'
4040
}
4141

42-
export function debug() {
43-
return getBooleanInput('debug') || isDebug()
44-
}
45-
4642
export function getActionRef(): string {
4743
return getOptionalEnvVariable('LACEWORK_ACTION_REF', 'unknown')
4844
}
@@ -327,14 +323,13 @@ export function readMarkdownFile(filePath: string): string {
327323
}
328324

329325
export async function generateCacheKey(
330-
runIac: boolean,
331326
scanTarget?: string,
332327
modifiedFiles?: string
333328
): Promise<string | undefined> {
334329
const reportsDir = path.join(os.tmpdir(), `codesec-cache-${Date.now()}`)
335330

336331
try {
337-
await runCodesec('scan', runIac, reportsDir, scanTarget, modifiedFiles, true)
332+
await runCodesec('scan', true, reportsDir, scanTarget, modifiedFiles, true)
338333
} catch (e) {
339334
info(`Cache key generation failed: ${(e as Error).message}`)
340335
return undefined

test/util.test.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"strict": true,
77
"skipLibCheck": true,
88
"sourceMap": true,
9+
"rootDir": ".",
910
"outDir": "dist"
1011
}
1112
}

0 commit comments

Comments
 (0)