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:
parent
ff9d53b61a
commit
219a937551
6 changed files with 7 additions and 40 deletions
18
lib/actions-util.js
generated
18
lib/actions-util.js
generated
|
|
@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.isAnalyzingCodeQLActionRepoOrFork = exports.printDebugLogs = exports.isAnalyzingDefaultBranch = exports.getRelativeScriptPath = exports.isRunningLocalAction = exports.sendStatusReport = exports.createStatusReportBase = exports.getActionsStatus = exports.getRef = exports.computeAutomationID = exports.getAutomationID = exports.getAnalysisKey = exports.getWorkflowRunID = exports.getWorkflow = exports.formatWorkflowCause = exports.formatWorkflowErrors = exports.validateWorkflow = exports.getWorkflowErrors = exports.WorkflowErrors = exports.patternIsSuperset = exports.determineMergeBaseCommitOid = exports.getCommitOid = exports.getTemporaryDirectory = exports.getOptionalInput = exports.getRequiredInput = void 0;
|
||||
exports.printDebugLogs = exports.isAnalyzingDefaultBranch = exports.getRelativeScriptPath = exports.isRunningLocalAction = exports.sendStatusReport = exports.createStatusReportBase = exports.getActionsStatus = exports.getRef = exports.computeAutomationID = exports.getAutomationID = exports.getAnalysisKey = exports.getWorkflowRunID = exports.getWorkflow = exports.formatWorkflowCause = exports.formatWorkflowErrors = exports.validateWorkflow = exports.getWorkflowErrors = exports.WorkflowErrors = exports.patternIsSuperset = exports.determineMergeBaseCommitOid = exports.getCommitOid = exports.getTemporaryDirectory = exports.getOptionalInput = exports.getRequiredInput = void 0;
|
||||
const fs = __importStar(require("fs"));
|
||||
const os = __importStar(require("os"));
|
||||
const path = __importStar(require("path"));
|
||||
|
|
@ -28,7 +28,6 @@ const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
|||
const safeWhich = __importStar(require("@chrisgavin/safe-which"));
|
||||
const yaml = __importStar(require("js-yaml"));
|
||||
const api = __importStar(require("./api-client"));
|
||||
const codeql_1 = require("./codeql");
|
||||
const sharedEnv = __importStar(require("./shared-environment"));
|
||||
const util_1 = require("./util");
|
||||
// eslint-disable-next-line import/no-commonjs
|
||||
|
|
@ -703,19 +702,4 @@ async function printDebugLogs(config) {
|
|||
}
|
||||
}
|
||||
exports.printDebugLogs = printDebugLogs;
|
||||
// Returns whether workflow kicked off by codeql-action repo itself,
|
||||
// or a fork of it.
|
||||
function isAnalyzingCodeQLActionRepoOrFork() {
|
||||
var _a, _b;
|
||||
const codeQLActionRepoUrl = `https://api.github.com/repos/${codeql_1.CODEQL_DEFAULT_ACTION_REPOSITORY}`;
|
||||
const repo = (_a = getWorkflowEvent()) === null || _a === void 0 ? void 0 : _a.repository;
|
||||
if ((repo === null || repo === void 0 ? void 0 : repo.url) === codeQLActionRepoUrl) {
|
||||
return true;
|
||||
}
|
||||
if ((repo === null || repo === void 0 ? void 0 : repo.fork) && ((_b = repo === null || repo === void 0 ? void 0 : repo.parent) === null || _b === void 0 ? void 0 : _b.url) === codeQLActionRepoUrl) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
exports.isAnalyzingCodeQLActionRepoOrFork = isAnalyzingCodeQLActionRepoOrFork;
|
||||
//# sourceMappingURL=actions-util.js.map
|
||||
File diff suppressed because one or more lines are too long
5
lib/analyze-action.js
generated
5
lib/analyze-action.js
generated
|
|
@ -60,11 +60,10 @@ async function sendStatusReport(startedAt, config, stats, error, trapCacheUpload
|
|||
}
|
||||
}
|
||||
exports.sendStatusReport = 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() {
|
||||
return (actionsUtil.getOptionalInput("expect-error") !== "false" &&
|
||||
!actionsUtil.isAnalyzingCodeQLActionRepoOrFork());
|
||||
!util.isInTestMode());
|
||||
}
|
||||
async function run() {
|
||||
const startedAt = new Date();
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue