Skip to content

Commit

Permalink
Remove support for empty analysis keys from runner
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Mercer committed Nov 14, 2022
1 parent 3d46406 commit 8ecbaea
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 59 deletions.
15 changes: 2 additions & 13 deletions lib/upload-lib.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/upload-lib.js.map

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions lib/util.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/util.js.map

Large diffs are not rendered by default.

44 changes: 4 additions & 40 deletions src/upload-lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand All @@ -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.
Expand Down Expand Up @@ -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}`);
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down

0 comments on commit 8ecbaea

Please sign in to comment.