mirror of
https://github.com/github/codeql-action.git
synced 2025-12-24 08:10:06 +08:00
Remove support for empty analysis keys from runner
This commit is contained in:
15
lib/upload-lib.js
generated
15
lib/upload-lib.js
generated
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.pruneInvalidResults = exports.validateUniqueCategory = exports.waitForProcessing = exports.buildPayload = exports.validateSarifFileSchema = exports.countResultsInSarif = exports.uploadFromRunner = exports.uploadFromActions = exports.findSarifFilesInDir = exports.populateRunAutomationDetails = exports.combineSarifFiles = void 0;
|
||||
exports.pruneInvalidResults = exports.validateUniqueCategory = exports.waitForProcessing = exports.buildPayload = exports.validateSarifFileSchema = exports.countResultsInSarif = exports.uploadFromActions = exports.findSarifFilesInDir = exports.populateRunAutomationDetails = exports.combineSarifFiles = void 0;
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
const process_1 = require("process");
|
||||
@@ -83,11 +83,7 @@ function getAutomationID(category, analysis_key, environment) {
|
||||
}
|
||||
return automationID;
|
||||
}
|
||||
// analysis_key is undefined for the runner.
|
||||
if (analysis_key !== undefined) {
|
||||
return actionsUtil.computeAutomationID(analysis_key, environment);
|
||||
}
|
||||
return undefined;
|
||||
return actionsUtil.computeAutomationID(analysis_key, environment);
|
||||
}
|
||||
// Upload the given payload.
|
||||
// If the request fails then this will retry a small number of times.
|
||||
@@ -137,13 +133,6 @@ async function uploadFromActions(sarifPath, gitHubVersion, apiDetails, logger) {
|
||||
return await uploadFiles(getSarifFilePaths(sarifPath), (0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY")), await actionsUtil.getCommitOid(actionsUtil.getRequiredInput("checkout_path")), await actionsUtil.getRef(), await actionsUtil.getAnalysisKey(), actionsUtil.getOptionalInput("category"), util.getRequiredEnvParam("GITHUB_WORKFLOW"), actionsUtil.getWorkflowRunID(), actionsUtil.getRequiredInput("checkout_path"), actionsUtil.getRequiredInput("matrix"), gitHubVersion, apiDetails, logger);
|
||||
}
|
||||
exports.uploadFromActions = uploadFromActions;
|
||||
// Uploads a single sarif file or a directory of sarif files
|
||||
// depending on what the path happens to refer to.
|
||||
// Returns true iff the upload occurred and succeeded
|
||||
async function uploadFromRunner(sarifPath, repositoryNwo, commitOid, ref, category, sourceRoot, gitHubVersion, apiDetails, logger) {
|
||||
return await uploadFiles(getSarifFilePaths(sarifPath), repositoryNwo, commitOid, ref, undefined, category, undefined, undefined, sourceRoot, undefined, gitHubVersion, apiDetails, logger);
|
||||
}
|
||||
exports.uploadFromRunner = uploadFromRunner;
|
||||
function getSarifFilePaths(sarifPath) {
|
||||
if (!fs.existsSync(sarifPath)) {
|
||||
throw new Error(`Path does not exist: ${sarifPath}`);
|
||||
|
||||
File diff suppressed because one or more lines are too long
3
lib/util.js
generated
3
lib/util.js
generated
@@ -332,8 +332,7 @@ function assertNever(value) {
|
||||
exports.assertNever = assertNever;
|
||||
/**
|
||||
* Environment variables to be set by codeql-action and used by the
|
||||
* CLI. These environment variables are relevant for both the runner
|
||||
* and the action.
|
||||
* CLI.
|
||||
*/
|
||||
var EnvVar;
|
||||
(function (EnvVar) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -50,7 +50,7 @@ export function combineSarifFiles(sarifFiles: string[]): SarifFile {
|
||||
export function populateRunAutomationDetails(
|
||||
sarif: SarifFile,
|
||||
category: string | undefined,
|
||||
analysis_key: string | undefined,
|
||||
analysis_key: string,
|
||||
environment: string | undefined
|
||||
): SarifFile {
|
||||
const automationID = getAutomationID(category, analysis_key, environment);
|
||||
@@ -70,7 +70,7 @@ export function populateRunAutomationDetails(
|
||||
|
||||
function getAutomationID(
|
||||
category: string | undefined,
|
||||
analysis_key: string | undefined,
|
||||
analysis_key: string,
|
||||
environment: string | undefined
|
||||
): string | undefined {
|
||||
if (category !== undefined) {
|
||||
@@ -81,12 +81,7 @@ function getAutomationID(
|
||||
return automationID;
|
||||
}
|
||||
|
||||
// analysis_key is undefined for the runner.
|
||||
if (analysis_key !== undefined) {
|
||||
return actionsUtil.computeAutomationID(analysis_key, environment);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
return actionsUtil.computeAutomationID(analysis_key, environment);
|
||||
}
|
||||
|
||||
// Upload the given payload.
|
||||
@@ -190,37 +185,6 @@ export async function uploadFromActions(
|
||||
);
|
||||
}
|
||||
|
||||
// Uploads a single sarif file or a directory of sarif files
|
||||
// depending on what the path happens to refer to.
|
||||
// Returns true iff the upload occurred and succeeded
|
||||
export async function uploadFromRunner(
|
||||
sarifPath: string,
|
||||
repositoryNwo: RepositoryNwo,
|
||||
commitOid: string,
|
||||
ref: string,
|
||||
category: string | undefined,
|
||||
sourceRoot: string,
|
||||
gitHubVersion: util.GitHubVersion,
|
||||
apiDetails: api.GitHubApiDetails,
|
||||
logger: Logger
|
||||
): Promise<UploadResult> {
|
||||
return await uploadFiles(
|
||||
getSarifFilePaths(sarifPath),
|
||||
repositoryNwo,
|
||||
commitOid,
|
||||
ref,
|
||||
undefined,
|
||||
category,
|
||||
undefined,
|
||||
undefined,
|
||||
sourceRoot,
|
||||
undefined,
|
||||
gitHubVersion,
|
||||
apiDetails,
|
||||
logger
|
||||
);
|
||||
}
|
||||
|
||||
function getSarifFilePaths(sarifPath: string) {
|
||||
if (!fs.existsSync(sarifPath)) {
|
||||
throw new Error(`Path does not exist: ${sarifPath}`);
|
||||
@@ -359,7 +323,7 @@ async function uploadFiles(
|
||||
repositoryNwo: RepositoryNwo,
|
||||
commitOid: string,
|
||||
ref: string,
|
||||
analysisKey: string | undefined,
|
||||
analysisKey: string,
|
||||
category: string | undefined,
|
||||
analysisName: string | undefined,
|
||||
workflowRunID: number | undefined,
|
||||
|
||||
@@ -415,8 +415,7 @@ export function assertNever(value: never): never {
|
||||
|
||||
/**
|
||||
* Environment variables to be set by codeql-action and used by the
|
||||
* CLI. These environment variables are relevant for both the runner
|
||||
* and the action.
|
||||
* CLI.
|
||||
*/
|
||||
export enum EnvVar {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user