Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#72 Fixes command line arguments for --scanners to be backwards compatible with previous version of trivy #73

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions trivy-task/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,7 @@ function getAquaAccount(): aquaCredentials {
}

async function createRunner(docker: boolean, loginDockerConfig: boolean): Promise<ToolRunner> {
const version: string | undefined = task.getInput('version', true);
if (version === undefined) {
throw new Error("version is not defined")
}
const version = getVersion();

if (!docker) {
console.log("Run requested using local Trivy binary...")
Expand Down Expand Up @@ -152,12 +149,30 @@ function configureScan(runner: ToolRunner, type: string, target: string, outputP
if (options.length) {
runner.line(options)
} else {
runner.arg(["--scanners", "vuln,misconfig,secret"])
const version = stripV(getVersion());
if(version < "0.40.0") {
runner.arg(["--security-checks", "vuln,config,secret"])
} else if(version < "0.48.0") {
runner.arg(["--scanners", "vuln,config,secret"])
} else {
runner.arg(["--scanners", "vuln,misconfig,secret"])
}
}

runner.arg(target)
}

function getVersion() {
const version: string | undefined = task.getInput('version', true);
if (version === undefined) {
throw new Error("version is not defined")
}
if (version === "latest") {
version = latestTrivyVersion
}
return version;
}

async function installTrivy(version: string): Promise<string> {

console.log("Finding correct Trivy version to install...")
Expand Down Expand Up @@ -196,9 +211,6 @@ function stripV(version: string): string {
}

async function getArtifactURL(version: string): Promise<string> {
if(version === "latest") {
version = latestTrivyVersion
}
console.log("Required Trivy version is " + version)
let arch = ""
switch (os.arch()) {
Expand Down
Loading