Skip to content

Commit

Permalink
Only delete SARIF in PR check if not running on a fork
Browse files Browse the repository at this point in the history
The `Submit SARIF after failure` PR Check was failing when opened on a fork because of a permissions problem when deleting the uploaded SARIF. This change should fix this by only deleting the SARIF when the owner of the current repository is `github`.
  • Loading branch information
angelapwen committed Jan 12, 2024
1 parent 9653106 commit 7a76543
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lib/init-action-post-helper.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/init-action-post-helper.js.map

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

10 changes: 9 additions & 1 deletion src/init-action-post-helper.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as core from "@actions/core";

import * as actionsUtil from "./actions-util";
import { getApiClient } from "./api-client";
import { getCodeQL } from "./codeql";
Expand Down Expand Up @@ -182,7 +184,13 @@ export async function run(
);
}

if (process.env["CODEQL_ACTION_EXPECT_UPLOAD_FAILED_SARIF"] === "true") {
core.info(`GITHUB_ACTOR is ${process.env["GITHUB_ACTOR"]}`);
// We do not delete uploaded SARIFs if we're on a fork, as we're missing the
// appropriate permissions.
if (
process.env["CODEQL_ACTION_EXPECT_UPLOAD_FAILED_SARIF"] === "true" &&
repositoryNwo.owner !== "github"
) {
await removeUploadedSarif(uploadFailedSarifResult, logger);
}

Expand Down

0 comments on commit 7a76543

Please sign in to comment.