Skip to content

Commit

Permalink
issue fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
maksudur-rahman-maruf committed Sep 12, 2024
1 parent 9cf8719 commit cdeda58
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
14 changes: 9 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.getBridgeExitCode = exports.getBridgeExitCodeAsNumericValue = exports.logBridgeExitCodes = exports.run = void 0;
exports.getBridgeExitCode = exports.getBridgeExitCodeAsNumericValue = exports.logBridgeExitCodes = exports.isWaitForScanEnabled = exports.run = void 0;
const core_1 = __nccwpck_require__(42186);
const utility_1 = __nccwpck_require__(77643);
const synopsys_bridge_1 = __nccwpck_require__(22659);
Expand Down Expand Up @@ -272,21 +272,21 @@ function run() {
}
if (!(0, utility_1.isPullRequestEvent)() && uploadSarifReportBasedOnExitCode) {
// Upload Black Duck sarif file as GitHub artifact
if (inputs.BLACKDUCK_URL && (0, utility_1.parseToBoolean)(inputs.BLACKDUCK_REPORTS_SARIF_CREATE) && !(0, utility_1.parseToBoolean)(inputs.BLACKDUCK_WAITFORSCAN)) {
if (inputs.BLACKDUCK_URL && (0, utility_1.parseToBoolean)(inputs.BLACKDUCK_REPORTS_SARIF_CREATE) && isWaitForScanEnabled(inputs.BLACKDUCK_WAITFORSCAN)) {
yield (0, artifacts_1.uploadSarifReportAsArtifact)(constants.BLACKDUCK_SARIF_GENERATOR_DIRECTORY, inputs.BLACKDUCK_REPORTS_SARIF_FILE_PATH, constants.BLACKDUCK_SARIF_ARTIFACT_NAME);
}
// Upload Polaris sarif file as GitHub artifact
if (inputs.POLARIS_SERVER_URL && (0, utility_1.parseToBoolean)(inputs.POLARIS_REPORTS_SARIF_CREATE) && !(0, utility_1.parseToBoolean)(inputs.POLARIS_WAITFORSCAN)) {
if (inputs.POLARIS_SERVER_URL && (0, utility_1.parseToBoolean)(inputs.POLARIS_REPORTS_SARIF_CREATE) && isWaitForScanEnabled(inputs.POLARIS_WAITFORSCAN)) {
yield (0, artifacts_1.uploadSarifReportAsArtifact)(constants.POLARIS_SARIF_GENERATOR_DIRECTORY, inputs.POLARIS_REPORTS_SARIF_FILE_PATH, constants.POLARIS_SARIF_ARTIFACT_NAME);
}
if (!(0, validators_1.isNullOrEmptyValue)(inputs.GITHUB_TOKEN)) {
// Upload Black Duck SARIF Report to code scanning tab
if (inputs.BLACKDUCK_URL && (0, utility_1.parseToBoolean)(inputs.BLACKDUCK_UPLOAD_SARIF_REPORT) && !(0, utility_1.parseToBoolean)(inputs.BLACKDUCK_WAITFORSCAN)) {
if (inputs.BLACKDUCK_URL && (0, utility_1.parseToBoolean)(inputs.BLACKDUCK_UPLOAD_SARIF_REPORT) && isWaitForScanEnabled(inputs.BLACKDUCK_WAITFORSCAN)) {
const gitHubClientService = yield github_client_service_factory_1.GitHubClientServiceFactory.getGitHubClientServiceInstance();
yield gitHubClientService.uploadSarifReport(constants.BLACKDUCK_SARIF_GENERATOR_DIRECTORY, inputs.BLACKDUCK_REPORTS_SARIF_FILE_PATH);
}
// Upload Polaris SARIF Report to code scanning tab
if (inputs.POLARIS_SERVER_URL && (0, utility_1.parseToBoolean)(inputs.POLARIS_UPLOAD_SARIF_REPORT) && !(0, utility_1.parseToBoolean)(inputs.POLARIS_WAITFORSCAN)) {
if (inputs.POLARIS_SERVER_URL && (0, utility_1.parseToBoolean)(inputs.POLARIS_UPLOAD_SARIF_REPORT) && isWaitForScanEnabled(inputs.POLARIS_WAITFORSCAN)) {
const gitHubClientService = yield github_client_service_factory_1.GitHubClientServiceFactory.getGitHubClientServiceInstance();
yield gitHubClientService.uploadSarifReport(constants.POLARIS_SARIF_GENERATOR_DIRECTORY, inputs.POLARIS_REPORTS_SARIF_FILE_PATH);
}
Expand All @@ -298,6 +298,10 @@ function run() {
});
}
exports.run = run;
function isWaitForScanEnabled(waitForScan) {
return waitForScan === 'true' || waitForScan === '';
}
exports.isWaitForScanEnabled = isWaitForScanEnabled;
function logBridgeExitCodes(message) {
const exitCode = message.trim().slice(-1);
return constants.EXIT_CODE_MAP.has(exitCode) ? `Exit Code: ${exitCode} ${constants.EXIT_CODE_MAP.get(exitCode)}` : message;
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,22 @@ export async function run() {
}
if (!isPullRequestEvent() && uploadSarifReportBasedOnExitCode) {
// Upload Black Duck sarif file as GitHub artifact
if (inputs.BLACKDUCK_URL && parseToBoolean(inputs.BLACKDUCK_REPORTS_SARIF_CREATE) && !parseToBoolean(inputs.BLACKDUCK_WAITFORSCAN)) {
if (inputs.BLACKDUCK_URL && parseToBoolean(inputs.BLACKDUCK_REPORTS_SARIF_CREATE) && isWaitForScanEnabled(inputs.BLACKDUCK_WAITFORSCAN)) {
await uploadSarifReportAsArtifact(constants.BLACKDUCK_SARIF_GENERATOR_DIRECTORY, inputs.BLACKDUCK_REPORTS_SARIF_FILE_PATH, constants.BLACKDUCK_SARIF_ARTIFACT_NAME)
}

// Upload Polaris sarif file as GitHub artifact
if (inputs.POLARIS_SERVER_URL && parseToBoolean(inputs.POLARIS_REPORTS_SARIF_CREATE) && !parseToBoolean(inputs.POLARIS_WAITFORSCAN)) {
if (inputs.POLARIS_SERVER_URL && parseToBoolean(inputs.POLARIS_REPORTS_SARIF_CREATE) && isWaitForScanEnabled(inputs.POLARIS_WAITFORSCAN)) {
await uploadSarifReportAsArtifact(constants.POLARIS_SARIF_GENERATOR_DIRECTORY, inputs.POLARIS_REPORTS_SARIF_FILE_PATH, constants.POLARIS_SARIF_ARTIFACT_NAME)
}
if (!isNullOrEmptyValue(inputs.GITHUB_TOKEN)) {
// Upload Black Duck SARIF Report to code scanning tab
if (inputs.BLACKDUCK_URL && parseToBoolean(inputs.BLACKDUCK_UPLOAD_SARIF_REPORT) && !parseToBoolean(inputs.BLACKDUCK_WAITFORSCAN)) {
if (inputs.BLACKDUCK_URL && parseToBoolean(inputs.BLACKDUCK_UPLOAD_SARIF_REPORT) && isWaitForScanEnabled(inputs.BLACKDUCK_WAITFORSCAN)) {
const gitHubClientService = await GitHubClientServiceFactory.getGitHubClientServiceInstance()
await gitHubClientService.uploadSarifReport(constants.BLACKDUCK_SARIF_GENERATOR_DIRECTORY, inputs.BLACKDUCK_REPORTS_SARIF_FILE_PATH)
}
// Upload Polaris SARIF Report to code scanning tab
if (inputs.POLARIS_SERVER_URL && parseToBoolean(inputs.POLARIS_UPLOAD_SARIF_REPORT) && !parseToBoolean(inputs.POLARIS_WAITFORSCAN)) {
if (inputs.POLARIS_SERVER_URL && parseToBoolean(inputs.POLARIS_UPLOAD_SARIF_REPORT) && isWaitForScanEnabled(inputs.POLARIS_WAITFORSCAN)) {
const gitHubClientService = await GitHubClientServiceFactory.getGitHubClientServiceInstance()
await gitHubClientService.uploadSarifReport(constants.POLARIS_SARIF_GENERATOR_DIRECTORY, inputs.POLARIS_REPORTS_SARIF_FILE_PATH)
}
Expand All @@ -72,6 +72,10 @@ export async function run() {
}
}

export function isWaitForScanEnabled(waitForScan: string): boolean {
return waitForScan === 'true' || waitForScan === ''
}

export function logBridgeExitCodes(message: string): string {
const exitCode = message.trim().slice(-1)
return constants.EXIT_CODE_MAP.has(exitCode) ? `Exit Code: ${exitCode} ${constants.EXIT_CODE_MAP.get(exitCode)}` : message
Expand Down

0 comments on commit cdeda58

Please sign in to comment.