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

Sigint 2282: ADO implement new UI layout #6

Merged
merged 7 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
128 changes: 83 additions & 45 deletions blackduck-security-task/dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion blackduck-security-task/dist/index.js.map

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export const BRIDGE_CLI_ZIP_FILE_NAME = "bridge-cli.zip";

export const APPLICATION_NAME = "blackduck-extension";
export const AZURE_TOKEN_KEY = "azure_token";
export const AZURE_TOKEN_KEY_CLASSIC_EDITOR = "azureToken";
export const POLARIS_AZURE_TOKEN_KEY_CLASSIC_EDITOR = "polarisAzureToken";
export const BLACKDUCKSCA_AZURE_TOKEN_KEY_CLASSIC_EDITOR =
"blackduckScaAzureToken";
export const COVERITY_AZURE_TOKEN_KEY_CLASSIC_EDITOR = "coverityAzureToken";
export const SCAN_TYPE_KEY = "scanType";
export const SPACE = " ";

Expand Down Expand Up @@ -38,9 +41,6 @@ export const POLARIS_ASSESSMENT_TYPES_KEY = "polaris_assessment_types";
export const POLARIS_ASSESSMENT_TYPES_KEY_CLASSIC_EDITOR =
"polarisAssessmentTypes";

export const POLARIS_TRIAGE_KEY = "polaris_triage";
export const POLARIS_TRIAGE_KEY_CLASSIC_EDITOR = "polarisTriage";

export const POLARIS_BRANCH_NAME_KEY = "polaris_branch_name";
export const POLARIS_BRANCH_NAME_KEY_CLASSIC_EDITOR = "polarisBranchName";

Expand Down Expand Up @@ -184,7 +184,7 @@ export const BLACKDUCKSCA_URL_KEY = "blackducksca_url"; // new key
export const BLACKDUCKSCA_URL_KEY_CLASSIC_EDITOR = "blackduckScaUrl"; // classic editor key

/**
* @deprecated Use BLACKDUCK_SCA_TOKEN_KEY instead. This can be removed in future release.
* @deprecated Use BLACKDUCKSCA_TOKEN_KEY instead. This can be removed in future release.
*/
export const BLACKDUCK_TOKEN_KEY = "blackduck_token";
export const BLACKDUCKSCA_TOKEN_KEY = "blackducksca_token";
Expand Down Expand Up @@ -216,7 +216,7 @@ export const BLACKDUCK_SCAN_FAILURE_SEVERITIES_KEY =
"blackduck_scan_failure_severities";
export const BLACKDUCKSCA_SCAN_FAILURE_SEVERITIES_KEY =
"blackducksca_scan_failure_severities";
export const BLACKDUCK_SCA_SCAN_FAILURE_SEVERITIES_KEY_CLASSIC_EDITOR =
export const BLACKDUCKSCA_SCAN_FAILURE_SEVERITIES_KEY_CLASSIC_EDITOR =
"blackduckScaScaScanFailureSeverities";
/**
* @deprecated Use blackducksca_prComment_enabled instead. This can be removed in future release.
Expand Down Expand Up @@ -376,7 +376,14 @@ export const SRM_WAITFORSCAN_KEY_CLASSIC_EDITOR = "srmWaitForScan";
export const SRM_PROJECT_DIRECTORY_KEY_CLASSIC_EDITOR = "srmProjectDirectory";

export const INCLUDE_DIAGNOSTICS_KEY = "include_diagnostics";
export const INCLUDE_DIAGNOSTICS_KEY_CLASSIC_EDITOR = "includeDiagnostics";
export const POLARIS_INCLUDE_DIAGNOSTICS_KEY_CLASSIC_EDITOR =
"polarisIncludeDiagnostics";
export const BLACKDUCKSCA_INCLUDE_DIAGNOSTICS_KEY_CLASSIC_EDITOR =
"blackduckScaIncludeDiagnostics";
export const COVERITY_INCLUDE_DIAGNOSTICS_KEY_CLASSIC_EDITOR =
"coverityIncludeDiagnostics";
export const SRM_INCLUDE_DIAGNOSTICS_KEY_CLASSIC_EDITOR =
"srmIncludeDiagnostics";
/**
* @deprecated Use network_airgap instead. This can be removed in future release.
*/
Expand All @@ -403,7 +410,13 @@ export const RETURN_STATUS_KEY = "return_status";
//export const RETURN_STATUS_KEY_CLASSIC_EDITOR = "returnStatus";

export const MARK_BUILD_STATUS_KEY = "mark_build_status";
export const MARK_BUILD_STATUS_KEY_CLASSIC_EDITOR = "markBuildStatus";
export const POLARIS_MARK_BUILD_STATUS_KEY_CLASSIC_EDITOR =
"polarisMarkBuildStatus";
export const BLACKDUCKSCA_MARK_BUILD_STATUS_KEY_CLASSIC_EDITOR =
"blackduckScaMarkBuildStatus";
export const COVERITY_MARK_BUILD_STATUS_KEY_CLASSIC_EDITOR =
"coverityMarkBuildStatus";
export const SRM_MARK_BUILD_STATUS_KEY_CLASSIC_EDITOR = "srmMarkBuildStatus";

/**
* @deprecated Use bridgecli_install_directory instead. This can be removed in future release.
Expand Down Expand Up @@ -431,7 +444,7 @@ export const MAC_ARM_PLATFORM = "macos_arm";
export const MAC_INTEL_PLATFORM = "macosx";
export const MIN_SUPPORTED_BRIDGE_CLI_MAC_ARM_VERSION = "2.1.0";
export const DEFAULT_AZURE_API_URL = "https://dev.azure.com";
export const BLACKDUCK_SCA_SECURITY_SCAN_AZURE_DEVOPS_DOCS_URL =
export const BLACKDUCKSCA_SECURITY_SCAN_AZURE_DEVOPS_DOCS_URL =
"https://sig-product-docs.synopsys.com/bundle/bridge/page/documentation/c_synopsys-security-scan-for-azure-devops.html";

// Error Messages
Expand Down Expand Up @@ -498,11 +511,11 @@ export const NETWORK_AIR_GAP_ENABLED_SKIP_DOWNLOAD_BRIDGE_CLI =
"Network air gap is enabled, skipping Bridge CLI download.";
export const TASK_RETURN_STATUS =
"`##vso[task.setvariable variable=status;isoutput=true]${result}`";
export const BLACKDUCK_SCA_SARIF_REPOST_ENABLED =
export const BLACKDUCKSCA_SARIF_REPOST_ENABLED =
"BLACKDUCKSCA_REPORTS_SARIF_CREATE is enabled";
export const POLARIS_SCA_SARIF_REPORT_ENABLED =
export const POLARISSCA_SARIF_REPORT_ENABLED =
"POLARIS_REPORTS_SARIF_CREATE is enabled";
export const BLACKDUCK_SCA_SECURITY_SCAN_COMPLETED =
export const BLACKDUCKSCA_SECURITY_SCAN_COMPLETED =
"Black Duck Security Scan completed";

export const AZURE_PULL_REQUEST_NUMBER_IS_EMPTY =
Expand Down
4 changes: 2 additions & 2 deletions blackduck-security-task/src/blackduck-security-task/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class Bridge {
.concat(",")
.concat(constants.COVERITY_URL_KEY)
.concat(",")
.concat(constants.BLACKDUCK_URL_KEY)
.concat(constants.BLACKDUCKSCA_URL_KEY)
.concat(",")
.concat(constants.SRM_URL_KEY)
.concat(")")
Expand Down Expand Up @@ -210,7 +210,7 @@ export class Bridge {
formattedCommand,
tempDir
);
} else if (SCAN_TYPE == "blackduck") {
} else if (SCAN_TYPE == "blackducksca") {
[formattedCommand, errors] = await this.prepareBlackduckCommand(
formattedCommand,
tempDir
Expand Down
103 changes: 77 additions & 26 deletions blackduck-security-task/src/blackduck-security-task/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,49 @@ export function getInput(
classicEditorKey: string,
deprecatedKey: string | null
) {
const newInput = taskLib.getInput(newKey);
if (newInput) {
return newInput?.trim();
const key = getInputForYMLAndDeprecatedKey(newKey, deprecatedKey);
if (key) {
return key;
}
const classEditorInput = taskLib.getInput(classicEditorKey);
if (classEditorInput) {
return classEditorInput?.trim();
}

let deprecatedInput;
if (deprecatedKey) {
deprecatedInput = taskLib.getInput(deprecatedKey);
if (deprecatedInput) {
deprecatedInputs.push(deprecatedKey);
return deprecatedInput?.trim();
}
return "";
}

export function getInputForMultipleClassicEditor(
newKey: string,
polarisClassicEditorKey: string,
blackduckSCAClassicEditorKey: string,
coverityClassicEditorKey: string,
srmClassicEditorKey: string | null,
deprecatedKey: string | null
) {
const key = getInputForYMLAndDeprecatedKey(newKey, deprecatedKey);
if (key) {
return key;
}

const classEditorInput = taskLib.getInput(classicEditorKey);
const scanType = taskLib.getInput(constants.SCAN_TYPE_KEY);
let classEditorInput;
if (polarisClassicEditorKey.length > 0 && scanType == "polaris") {
classEditorInput = taskLib.getInput(polarisClassicEditorKey);
} else if (
blackduckSCAClassicEditorKey.length > 0 &&
scanType == "blackducksca"
) {
classEditorInput = taskLib.getInput(blackduckSCAClassicEditorKey);
} else if (coverityClassicEditorKey.length > 0 && scanType == "coverity") {
classEditorInput = taskLib.getInput(coverityClassicEditorKey);
} else if (
srmClassicEditorKey &&
srmClassicEditorKey?.length > 0 &&
scanType == "srm"
) {
classEditorInput = taskLib.getInput(srmClassicEditorKey);
}
if (classEditorInput) {
return classEditorInput?.trim();
}
Expand All @@ -47,11 +75,30 @@ export function getArbitraryInputs(
return taskLib.getInput(classicEditorKeyForSrm);
} else if (
classicEditorKey.length > 0 &&
(scanType == "coverity" || scanType == "blackduck")
(scanType == "coverity" || scanType == "blackducksca")
lokeshbd marked this conversation as resolved.
Show resolved Hide resolved
) {
return taskLib.getInput(classicEditorKey);
}
return getInput(yamlKey, classicEditorKey, deprecatedKey);
return getInputForYMLAndDeprecatedKey(yamlKey, deprecatedKey);
}
export function getInputForYMLAndDeprecatedKey(
newKey: string,
deprecatedKey: string | null
) {
const newInput = taskLib.getInput(newKey);
if (newInput) {
return newInput?.trim();
}

let deprecatedInput;
if (deprecatedKey) {
deprecatedInput = taskLib.getInput(deprecatedKey);
if (deprecatedInput) {
deprecatedInputs.push(deprecatedKey);
return deprecatedInput?.trim();
}
}
return "";
}

export function getBoolInput(
Expand Down Expand Up @@ -124,7 +171,7 @@ export function showLogForDeprecatedInputs() {
`[${deprecatedInputs.join(
","
)}] is/are deprecated for YAML. Check documentation for new parameters: ${
constants.BLACKDUCK_SCA_SECURITY_SCAN_AZURE_DEVOPS_DOCS_URL
constants.BLACKDUCKSCA_SECURITY_SCAN_AZURE_DEVOPS_DOCS_URL
}`
);
}
Expand Down Expand Up @@ -170,15 +217,21 @@ export const BRIDGECLI_DOWNLOAD_VERSION = getInput(
constants.SYNOPSYS_BRIDGE_DOWNLOAD_VERSION_KEY
);

export const INCLUDE_DIAGNOSTICS = getInput(
export const INCLUDE_DIAGNOSTICS = getInputForMultipleClassicEditor(
constants.INCLUDE_DIAGNOSTICS_KEY,
constants.INCLUDE_DIAGNOSTICS_KEY_CLASSIC_EDITOR,
constants.POLARIS_INCLUDE_DIAGNOSTICS_KEY_CLASSIC_EDITOR,
constants.BLACKDUCKSCA_INCLUDE_DIAGNOSTICS_KEY_CLASSIC_EDITOR,
constants.COVERITY_INCLUDE_DIAGNOSTICS_KEY_CLASSIC_EDITOR,
constants.SRM_INCLUDE_DIAGNOSTICS_KEY_CLASSIC_EDITOR,
null
);

export const AZURE_TOKEN = getInput(
export const AZURE_TOKEN = getInputForMultipleClassicEditor(
constants.AZURE_TOKEN_KEY,
constants.AZURE_TOKEN_KEY_CLASSIC_EDITOR,
constants.POLARIS_AZURE_TOKEN_KEY_CLASSIC_EDITOR,
constants.BLACKDUCKSCA_AZURE_TOKEN_KEY_CLASSIC_EDITOR,
constants.COVERITY_AZURE_TOKEN_KEY_CLASSIC_EDITOR,
null,
null
);

Expand Down Expand Up @@ -211,11 +264,6 @@ export const POLARIS_ASSESSMENT_TYPES = getDelimitedInput(
constants.POLARIS_ASSESSMENT_TYPES_KEY_CLASSIC_EDITOR,
null
);
export const POLARIS_TRIAGE = getInput(
constants.POLARIS_TRIAGE_KEY,
constants.POLARIS_TRIAGE_KEY_CLASSIC_EDITOR,
null
);
export const POLARIS_BRANCH_NAME = getInput(
constants.POLARIS_BRANCH_NAME_KEY,
constants.POLARIS_BRANCH_NAME_KEY_CLASSIC_EDITOR,
Expand Down Expand Up @@ -421,7 +469,7 @@ export const DETECT_SCAN_FULL = getInput(
);
export const BLACKDUCKSCA_SCAN_FAILURE_SEVERITIES = getDelimitedInput(
constants.BLACKDUCKSCA_SCAN_FAILURE_SEVERITIES_KEY,
constants.BLACKDUCK_SCA_SCAN_FAILURE_SEVERITIES_KEY_CLASSIC_EDITOR,
constants.BLACKDUCKSCA_SCAN_FAILURE_SEVERITIES_KEY_CLASSIC_EDITOR,
constants.BLACKDUCK_SCAN_FAILURE_SEVERITIES_KEY
);

Expand Down Expand Up @@ -560,8 +608,11 @@ export const SRM_PROJECT_DIRECTORY = getInput(
export const RETURN_STATUS =
taskLib.getInput(constants.RETURN_STATUS_KEY)?.trim() || "true";

export const MARK_BUILD_STATUS = getInput(
export const MARK_BUILD_STATUS = getInputForMultipleClassicEditor(
constants.MARK_BUILD_STATUS_KEY,
constants.MARK_BUILD_STATUS_KEY_CLASSIC_EDITOR,
constants.POLARIS_MARK_BUILD_STATUS_KEY_CLASSIC_EDITOR,
constants.BLACKDUCKSCA_MARK_BUILD_STATUS_KEY_CLASSIC_EDITOR,
constants.COVERITY_MARK_BUILD_STATUS_KEY_CLASSIC_EDITOR,
constants.SRM_MARK_BUILD_STATUS_KEY_CLASSIC_EDITOR,
null
);
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@ export class BridgeToolsParameter {
polData.data.polaris.branch.name = inputs.POLARIS_BRANCH_NAME;
}

if (inputs.POLARIS_TRIAGE) {
polData.data.polaris.triage = inputs.POLARIS_TRIAGE;
}

if (inputs.POLARIS_TEST_SCA_TYPE) {
polData.data.polaris.test = {
sca: {
Expand Down
12 changes: 6 additions & 6 deletions blackduck-security-task/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import {
import { AzurePrResponse } from "./blackduck-security-task/model/azure";
import { ErrorCode } from "./blackduck-security-task/enum/ErrorCodes";
import {
BLACKDUCK_SCA_SARIF_REPOST_ENABLED,
BLACKDUCK_SCA_SECURITY_SCAN_COMPLETED,
BLACKDUCKSCA_SARIF_REPOST_ENABLED,
BLACKDUCKSCA_SECURITY_SCAN_COMPLETED,
MARK_THE_BUILD_ON_BRIDGE_BREAK,
MARK_THE_BUILD_STATUS,
NETWORK_AIR_GAP_ENABLED_SKIP_DOWNLOAD_BRIDGE_CLI,
POLARIS_SCA_SARIF_REPORT_ENABLED,
POLARISSCA_SARIF_REPORT_ENABLED,
TASK_RETURN_STATUS,
WORKFLOW_FAILED,
} from "./blackduck-security-task/application-constant";
Expand Down Expand Up @@ -67,7 +67,7 @@ export async function run() {
} finally {
if (parseToBoolean(inputs.BLACKDUCKSCA_REPORTS_SARIF_CREATE)) {
if (!IS_PR_EVENT) {
console.log(BLACKDUCK_SCA_SARIF_REPOST_ENABLED);
console.log(BLACKDUCKSCA_SARIF_REPOST_ENABLED);
uploadSarifResultAsArtifact(
constants.DEFAULT_BLACKDUCK_SARIF_GENERATOR_DIRECTORY,
inputs.BLACKDUCKSCA_REPORTS_SARIF_FILE_PATH
Expand All @@ -77,7 +77,7 @@ export async function run() {

if (parseToBoolean(inputs.POLARIS_REPORTS_SARIF_CREATE)) {
if (!IS_PR_EVENT) {
console.log(POLARIS_SCA_SARIF_REPORT_ENABLED);
console.log(POLARISSCA_SARIF_REPORT_ENABLED);
uploadSarifResultAsArtifact(
constants.DEFAULT_POLARIS_SARIF_GENERATOR_DIRECTORY,
inputs.POLARIS_REPORTS_SARIF_FILE_PATH
Expand All @@ -90,7 +90,7 @@ export async function run() {
}
}

console.log(BLACKDUCK_SCA_SECURITY_SCAN_COMPLETED);
console.log(BLACKDUCKSCA_SECURITY_SCAN_COMPLETED);
}

export function getExitMessage(message: string, exitCode: string): string {
Expand Down
Loading