@@ -1464,7 +1464,7 @@ class GithubClientServiceBase {
1464
1464
this.repoName = this.githubRepo !== '' ? this.githubRepo.substring(this.githubRepo.indexOf('/') + 1, this.githubRepo.length).trim() : '';
1465
1465
this.repoOwner = process.env[constants.GITHUB_ENVIRONMENT_VARIABLES.GITHUB_REPOSITORY_OWNER] || '';
1466
1466
this.githubServerUrl = process.env[constants.GITHUB_ENVIRONMENT_VARIABLES.GITHUB_SERVER_URL] || '';
1467
- this.githubApiURL = this.githubServerUrl === constants.GITHUB_CLOUD_URL ? constants.GITHUB_CLOUD_API_URL : this.githubServerUrl ;
1467
+ this.githubApiURL = process.env[ constants.GITHUB_ENVIRONMENT_VARIABLES.GITHUB_API_URL] || '' ;
1468
1468
this.commit_sha = process.env[constants.GITHUB_ENVIRONMENT_VARIABLES.GITHUB_SHA] || '';
1469
1469
this.githubRef = process.env[constants.GITHUB_ENVIRONMENT_VARIABLES.GITHUB_REF] || '';
1470
1470
}
@@ -1484,12 +1484,7 @@ class GithubClientServiceBase {
1484
1484
const sarifContent = fs.readFileSync(sarifFilePath, 'utf8');
1485
1485
const compressedSarif = zlib.gzipSync(sarifContent);
1486
1486
const base64Sarif = compressedSarif.toString('base64');
1487
- const data = {
1488
- commit_sha: this.commit_sha,
1489
- ref: this.githubRef,
1490
- sarif: base64Sarif,
1491
- validate: true
1492
- };
1487
+ const data = this.createSarifData(base64Sarif);
1493
1488
do {
1494
1489
const httpClient = new HttpClient_1.HttpClient('GithubClientServiceBase');
1495
1490
const httpResponse = yield httpClient.post(endpoint, JSON.stringify(data), {
@@ -1535,6 +1530,17 @@ class GithubClientServiceBase {
1535
1530
}
1536
1531
});
1537
1532
}
1533
+ createSarifData(base64Sarif) {
1534
+ const data = {
1535
+ commit_sha: this.commit_sha,
1536
+ ref: this.githubRef,
1537
+ sarif: base64Sarif
1538
+ };
1539
+ if (this.githubApiURL === constants.GITHUB_CLOUD_API_URL) {
1540
+ data.validate = true;
1541
+ }
1542
+ return data;
1543
+ }
1538
1544
retrySleepHelper(message, retryCountLocal, retryDelay) {
1539
1545
return __awaiter(this, void 0, void 0, function* () {
1540
1546
(0, core_1.info)(message
@@ -2803,14 +2809,13 @@ function run() {
2803
2809
yield (0, artifacts_1.uploadSarifReportAsArtifact)(constants.POLARIS_SARIF_GENERATOR_DIRECTORY, inputs.POLARIS_REPORTS_SARIF_FILE_PATH, constants.POLARIS_SARIF_ARTIFACT_NAME);
2804
2810
}
2805
2811
if (!(0, validators_1.isNullOrEmptyValue)(inputs.GITHUB_TOKEN)) {
2812
+ const gitHubClientService = yield github_client_service_factory_1.GitHubClientServiceFactory.getGitHubClientServiceInstance();
2806
2813
// Upload Black Duck SARIF Report to code scanning tab
2807
2814
if (inputs.BLACKDUCKSCA_URL && (0, utility_1.parseToBoolean)(inputs.BLACKDUCK_UPLOAD_SARIF_REPORT)) {
2808
- const gitHubClientService = yield github_client_service_factory_1.GitHubClientServiceFactory.getGitHubClientServiceInstance();
2809
2815
yield gitHubClientService.uploadSarifReport(constants.BLACKDUCK_SARIF_GENERATOR_DIRECTORY, inputs.BLACKDUCKSCA_REPORTS_SARIF_FILE_PATH);
2810
2816
}
2811
2817
// Upload Polaris SARIF Report to code scanning tab
2812
2818
if (inputs.POLARIS_SERVER_URL && (0, utility_1.parseToBoolean)(inputs.POLARIS_UPLOAD_SARIF_REPORT)) {
2813
- const gitHubClientService = yield github_client_service_factory_1.GitHubClientServiceFactory.getGitHubClientServiceInstance();
2814
2819
yield gitHubClientService.uploadSarifReport(constants.POLARIS_SARIF_GENERATOR_DIRECTORY, inputs.POLARIS_REPORTS_SARIF_FILE_PATH);
2815
2820
}
2816
2821
}
0 commit comments