Require test mode to be set to use expect-error input

This should be more robust than determining whether the repo is the
CodeQL Action or a fork of it.
This commit is contained in:
Henry Mercer 2022-08-17 14:39:30 +01:00
parent ff9d53b61a
commit 219a937551
6 changed files with 7 additions and 40 deletions

View file

@ -8,7 +8,6 @@ import * as safeWhich from "@chrisgavin/safe-which";
import * as yaml from "js-yaml";
import * as api from "./api-client";
import { CODEQL_DEFAULT_ACTION_REPOSITORY } from "./codeql";
import { Config } from "./config-utils";
import * as sharedEnv from "./shared-environment";
import {
@ -901,17 +900,3 @@ export async function printDebugLogs(config: Config) {
walkLogFiles(logsDirectory);
}
}
// Returns whether workflow kicked off by codeql-action repo itself,
// or a fork of it.
export function isAnalyzingCodeQLActionRepoOrFork(): boolean {
const codeQLActionRepoUrl = `https://api.github.com/repos/${CODEQL_DEFAULT_ACTION_REPOSITORY}`;
const repo = getWorkflowEvent()?.repository;
if (repo?.url === codeQLActionRepoUrl) {
return true;
}
if (repo?.fork && repo?.parent?.url === codeQLActionRepoUrl) {
return true;
}
return false;
}

View file

@ -82,12 +82,11 @@ export async function sendStatusReport(
}
}
// `expect-error` should only be set to any value by the
// codeql-action repo or a fork of it.
// `expect-error` should only be set to a non-false value by the CodeQL Action PR checks.
function hasBadExpectErrorInput(): boolean {
return (
actionsUtil.getOptionalInput("expect-error") !== "false" &&
!actionsUtil.isAnalyzingCodeQLActionRepoOrFork()
!util.isInTestMode()
);
}