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

Enable upload support for Contrast Assess Findings XML #17

Merged
merged 1 commit into from
May 20, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ description:
automatically fix issues found.

inputs:
pixee-api-url:
pixee-api-url:
description: The base URL of the Pixee API
default: https://api.pixee.ai
tool:
description: >
The supported code scanning tool that produced the results being uploaded.
Allowed values: 'sonar', 'codeql', 'semgrep', 'defectdojo'
Allowed values: 'sonar', 'codeql', 'semgrep', 'defectdojo', 'contrast'
required: true
file:
description: Path to the tool's results file to share with Pixeebot.
Expand Down
16 changes: 15 additions & 1 deletion src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ export async function run() {
const tool = getTool();

switch(tool){
case "contrast":
const contrastFile = await fetchOrLocateContrastResultsFile();
await uploadInputFile(tool, contrastFile);
core.info(`Uploaded ${contrastFile} to Pixeebot for analysis`);
break;
case "defectdojo":
const file = await fetchOrLocateDefectDojoResultsFile();
await uploadInputFile(tool, file);
Expand All @@ -34,7 +39,7 @@ export async function run() {
default:
throw new Error("Action not implemented for tool: " + tool);
}

const { prNumber } = getGitHubContext();
if (prNumber) {
await triggerPrAnalysis(prNumber);
Expand All @@ -51,6 +56,15 @@ async function fetchOrLocateDefectDojoResultsFile() {
return fetchOrLocateResultsFile("defectdojo", results, fileName);
}

async function fetchOrLocateContrastResultsFile() {
let file = core.getInput("file");
if (file !== "") {
return file;
}

throw new Error("Contrast requires a file to be provided");
}

async function fetchOrLocateSonarResultsFile(resultType : SONAR_RESULT) {
let results = resultType == "issues" ? await fetchSonarCloudIssues() : await fetchSonarCloudHotspots();
let fileName = `sonar-${resultType}.json`;
Expand Down
6 changes: 3 additions & 3 deletions src/inputs.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as core from "@actions/core";
import { UserError } from "./errors";

export type Tool = "sonar" | "codeql" | "semgrep" | "appscan" | "defectdojo";
export type Tool = "sonar" | "codeql" | "semgrep" | "appscan" | "defectdojo" | "contrast";

export type TOOL_PATH = "sonar_issues" | "sonar_hotspots" | "codeql" | "semgrep" | "appscan" | "defectdojo";
export type TOOL_PATH = "sonar_issues" | "sonar_hotspots" | "codeql" | "semgrep" | "appscan" | "defectdojo" | "contrast";

/**
* Helper function to get the selected tool from the action's inputs.
Expand All @@ -26,4 +26,4 @@ function validateTool(tool: Tool) {
}
}

const VALID_TOOLS: Tool[] = ["sonar", "codeql", "semgrep", "appscan", "defectdojo"];
const VALID_TOOLS: Tool[] = ["sonar", "codeql", "semgrep", "appscan", "defectdojo", "contrast"];