Skip to content

Commit 5c0a4f1

Browse files
committed
Add transformPayload to AnalysisConfig
1 parent 6f8631f commit 5c0a4f1

File tree

6 files changed

+100
-72
lines changed

6 files changed

+100
-72
lines changed

lib/analyze-action.js

Lines changed: 20 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action-post.js

Lines changed: 20 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-lib.js

Lines changed: 20 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-sarif-action.js

Lines changed: 20 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/analyses.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
getRequiredInput,
55
} from "./actions-util";
66
import { Logger } from "./logging";
7+
import { UploadPayload } from "./upload-lib/types";
78
import { ConfigurationError } from "./util";
89

910
export enum AnalysisKind {
@@ -146,6 +147,8 @@ export interface AnalysisConfig {
146147
fixCategory: (logger: Logger, category?: string) => string | undefined;
147148
/** A prefix for environment variables used to track the uniqueness of SARIF uploads. */
148149
sentinelPrefix: string;
150+
/** Transforms the upload payload in an analysis-specific way. */
151+
transformPayload: (payload: UploadPayload) => UploadPayload;
149152
}
150153

151154
// Represents the Code Scanning analysis configuration.
@@ -160,6 +163,7 @@ export const CodeScanning: AnalysisConfig = {
160163
!CSRA.sarifPredicate(name),
161164
fixCategory: (_, category) => category,
162165
sentinelPrefix: "CODEQL_UPLOAD_SARIF_",
166+
transformPayload: (payload) => payload,
163167
};
164168

165169
// Represents the Code Quality analysis configuration.
@@ -171,6 +175,7 @@ export const CodeQuality: AnalysisConfig = {
171175
sarifPredicate: (name) => name.endsWith(CodeQuality.sarifExtension),
172176
fixCategory: fixCodeQualityCategory,
173177
sentinelPrefix: "CODEQL_UPLOAD_QUALITY_SARIF_",
178+
transformPayload: (payload) => payload,
174179
};
175180

176181
export const CSRA: AnalysisConfig = {
@@ -181,6 +186,7 @@ export const CSRA: AnalysisConfig = {
181186
sarifPredicate: (name) => name.endsWith(CSRA.sarifExtension),
182187
fixCategory: fixCodeQualityCategory,
183188
sentinelPrefix: "CODEQL_UPLOAD_CSRA_SARIF_",
189+
transformPayload: (payload) => payload,
184190
};
185191

186192
/**

src/upload-lib.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -848,18 +848,20 @@ export async function uploadPostProcessedFiles(
848848
const zippedSarif = zlib.gzipSync(sarifPayload).toString("base64");
849849
const checkoutURI = url.pathToFileURL(checkoutPath).href;
850850

851-
const payload = buildPayload(
852-
await gitUtils.getCommitOid(checkoutPath),
853-
await gitUtils.getRef(),
854-
postProcessingResults.analysisKey,
855-
util.getRequiredEnvParam("GITHUB_WORKFLOW"),
856-
zippedSarif,
857-
actionsUtil.getWorkflowRunID(),
858-
actionsUtil.getWorkflowRunAttempt(),
859-
checkoutURI,
860-
postProcessingResults.environment,
861-
toolNames,
862-
await gitUtils.determineBaseBranchHeadCommitOid(),
851+
const payload = uploadTarget.transformPayload(
852+
buildPayload(
853+
await gitUtils.getCommitOid(checkoutPath),
854+
await gitUtils.getRef(),
855+
postProcessingResults.analysisKey,
856+
util.getRequiredEnvParam("GITHUB_WORKFLOW"),
857+
zippedSarif,
858+
actionsUtil.getWorkflowRunID(),
859+
actionsUtil.getWorkflowRunAttempt(),
860+
checkoutURI,
861+
postProcessingResults.environment,
862+
toolNames,
863+
await gitUtils.determineBaseBranchHeadCommitOid(),
864+
),
863865
);
864866

865867
// Log some useful debug info about the info

0 commit comments

Comments
 (0)