Skip to content

Commit

Permalink
chore(COD-4237): removing unused option --autofix (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydubreil authored Jan 29, 2025
1 parent 4dbec19 commit af48154
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 37 deletions.
5 changes: 0 additions & 5 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ inputs:
description: 'Show vulnerabilities found in transitive dependencies'
required: false
default: false
autofix:
description: 'Set to true to enable automated pull-requests for fix suggestions'
required: false
default: false
outputs:
old-completed:
description: 'If running a target called old, whether the analysis for this was completed'
Expand Down Expand Up @@ -119,4 +115,3 @@ runs:
token: '${{ inputs.token || github.token }}'
footer: '${{ inputs.footer }}'
eval-indirect-dependencies: '${{ inputs.eval-indirect-dependencies }}'
autofix: '${{ inputs.autofix }}'
9 changes: 1 addition & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import {
uploadArtifact,
} from './actions'
import { downloadKeys, trustedKeys } from './keys'
import { compareResults, createPRs, printResults } from './tool'
import { compareResults, printResults } from './tool'
import {
autofix,
callCommand,
callLaceworkCli,
debug,
Expand Down Expand Up @@ -66,18 +65,12 @@ async function runAnalysis() {
if (debug()) {
args.push('--debug')
}
if (autofix()) {
args.push('--fix-suggestions')
}
await callLaceworkCli(...args)
// make a copy of the sarif file
args = [scaSarifReport, scaReport]
await callCommand('cp', ...args)

await printResults('sca', scaReport)
if (autofix()) {
await createPRs(scaLWJSONReport)
}
toUpload.push(scaReport)

const uploadStart = Date.now()
Expand Down
20 changes: 4 additions & 16 deletions src/tool.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import { info, startGroup, endGroup, error } from '@actions/core'
import { endGroup, info, startGroup } from '@actions/core'
import { context } from '@actions/github'
import { existsSync, readFileSync } from 'fs'
import {
callCommand,
callLaceworkCli,
debug,
getOptionalEnvVariable,
getRequiredEnvVariable,
telemetryCollector,
} from './util'
import { Log } from 'sarif'
import { LWJSON } from './lw-json'
import { getPrApi } from './actions'
import { simpleGit, SimpleGitOptions } from 'simple-git'
import { getPrApi } from './actions'
import { LWJSON } from './lw-json'
import { callLaceworkCli, debug, getOptionalEnvVariable, getRequiredEnvVariable } from './util'

export async function printResults(tool: string, sarifFile: string) {
startGroup(`Results for ${tool}`)
Expand Down Expand Up @@ -198,11 +191,6 @@ export async function createPRs(jsonFile: string) {
await prForFixSuggestion(jsonFile, fixId, repoOwner, repoName, telem)
}
const after = Date.now()
telemetryCollector.addField('autofix.totalPRs', telem.prsCounter.toString())
telemetryCollector.addField('autofix.updatedPRs', telem.prsUpdated.toString())
telemetryCollector.addField('autofix.timeAPI', telem.totalAPITime.toString())
telemetryCollector.addField('autofix.APIerrors', telem.errors.map(String).join(', '))
telemetryCollector.addField('autofix.totalTime', (after - before).toString())
}

export async function compareResults(
Expand Down
9 changes: 1 addition & 8 deletions src/util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { getInput, isDebug } from '@actions/core'
import { error, info } from '@actions/core'
import { error, getInput, info, isDebug } from '@actions/core'
import { spawn } from 'child_process'
import { TelemetryCollector } from './telemetry'

Expand All @@ -23,12 +22,6 @@ export function getActionRef(): string {
return getOptionalEnvVariable('LACEWORK_ACTION_REF', 'unknown')
}

export function autofix() {
// autofix does fix all vulnerabilities, regardless of whether they are newly introduced or no
// for this reason, we skip if we are scanning the old branch
return getBooleanInput('autofix') && getInput('target') != 'old'
}

export function getRunUrl(): string {
let result = getRequiredEnvVariable('GITHUB_SERVER_URL')
result += '/'
Expand Down

0 comments on commit af48154

Please sign in to comment.