mirror of
https://github.com/github/codeql-action.git
synced 2025-12-23 15:50:11 +08:00
Compare commits
13 Commits
v1.1.5
...
codeql-bun
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81bfc289f5 | ||
|
|
6de8537e54 | ||
|
|
1d81ec489b | ||
|
|
c592f89989 | ||
|
|
f71aeef4dc | ||
|
|
0a713019c3 | ||
|
|
243ebf6e35 | ||
|
|
3886398541 | ||
|
|
f60bb5cc38 | ||
|
|
d0ee2b4276 | ||
|
|
34905f691e | ||
|
|
ac7bd44c3b | ||
|
|
1457c164a9 |
@@ -1,5 +1,9 @@
|
|||||||
# CodeQL Action Changelog
|
# CodeQL Action Changelog
|
||||||
|
|
||||||
|
## [UNRELEASED]
|
||||||
|
|
||||||
|
No user facing changes.
|
||||||
|
|
||||||
## 1.1.5 - 15 Mar 2022
|
## 1.1.5 - 15 Mar 2022
|
||||||
|
|
||||||
- Update default CodeQL bundle version to 2.8.3.
|
- Update default CodeQL bundle version to 2.8.3.
|
||||||
|
|||||||
@@ -39,8 +39,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
CodeQL-Build:
|
CodeQL-Build:
|
||||||
# If you're only analyzing JavaScript or Python, CodeQL runs on ubuntu-latest, windows-latest, and macos-latest.
|
# CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
|
||||||
# If you're analyzing C/C++, C#, Go, or Java, CodeQL runs on ubuntu-latest, windows-2019, and macos-latest.
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
|
|||||||
9
lib/actions-util.js
generated
9
lib/actions-util.js
generated
@@ -30,6 +30,8 @@ const yaml = __importStar(require("js-yaml"));
|
|||||||
const api = __importStar(require("./api-client"));
|
const api = __importStar(require("./api-client"));
|
||||||
const sharedEnv = __importStar(require("./shared-environment"));
|
const sharedEnv = __importStar(require("./shared-environment"));
|
||||||
const util_1 = require("./util");
|
const util_1 = require("./util");
|
||||||
|
// eslint-disable-next-line import/no-commonjs
|
||||||
|
const pkg = require("../package.json");
|
||||||
/**
|
/**
|
||||||
* The utils in this module are meant to be run inside of the action only.
|
* The utils in this module are meant to be run inside of the action only.
|
||||||
* Code paths from the runner should not enter this module.
|
* Code paths from the runner should not enter this module.
|
||||||
@@ -500,6 +502,7 @@ async function createStatusReportBase(actionName, status, actionStartedAt, cause
|
|||||||
core.exportVariable(sharedEnv.CODEQL_WORKFLOW_STARTED_AT, workflowStartedAt);
|
core.exportVariable(sharedEnv.CODEQL_WORKFLOW_STARTED_AT, workflowStartedAt);
|
||||||
}
|
}
|
||||||
const runnerOs = (0, util_1.getRequiredEnvParam)("RUNNER_OS");
|
const runnerOs = (0, util_1.getRequiredEnvParam)("RUNNER_OS");
|
||||||
|
const codeQlCliVersion = (0, util_1.getCachedCodeQlVersion)();
|
||||||
// If running locally then the GITHUB_ACTION_REF cannot be trusted as it may be for the previous action
|
// If running locally then the GITHUB_ACTION_REF cannot be trusted as it may be for the previous action
|
||||||
// See https://github.com/actions/runner/issues/803
|
// See https://github.com/actions/runner/issues/803
|
||||||
const actionRef = isRunningLocalAction()
|
const actionRef = isRunningLocalAction()
|
||||||
@@ -519,6 +522,7 @@ async function createStatusReportBase(actionName, status, actionStartedAt, cause
|
|||||||
action_started_at: actionStartedAt.toISOString(),
|
action_started_at: actionStartedAt.toISOString(),
|
||||||
status,
|
status,
|
||||||
runner_os: runnerOs,
|
runner_os: runnerOs,
|
||||||
|
action_version: pkg.version,
|
||||||
};
|
};
|
||||||
// Add optional parameters
|
// Add optional parameters
|
||||||
if (cause) {
|
if (cause) {
|
||||||
@@ -545,6 +549,9 @@ async function createStatusReportBase(actionName, status, actionStartedAt, cause
|
|||||||
if (runnerOs === "Windows" || runnerOs === "macOS") {
|
if (runnerOs === "Windows" || runnerOs === "macOS") {
|
||||||
statusReport.runner_os_release = os.release();
|
statusReport.runner_os_release = os.release();
|
||||||
}
|
}
|
||||||
|
if (codeQlCliVersion !== undefined) {
|
||||||
|
statusReport.codeql_cli_version = codeQlCliVersion;
|
||||||
|
}
|
||||||
return statusReport;
|
return statusReport;
|
||||||
}
|
}
|
||||||
exports.createStatusReportBase = createStatusReportBase;
|
exports.createStatusReportBase = createStatusReportBase;
|
||||||
@@ -666,7 +673,7 @@ async function isAnalyzingDefaultBranch() {
|
|||||||
// Get the current ref and trim and refs/heads/ prefix
|
// Get the current ref and trim and refs/heads/ prefix
|
||||||
let currentRef = await getRef();
|
let currentRef = await getRef();
|
||||||
currentRef = currentRef.startsWith("refs/heads/")
|
currentRef = currentRef.startsWith("refs/heads/")
|
||||||
? currentRef.substr("refs/heads/".length)
|
? currentRef.slice("refs/heads/".length)
|
||||||
: currentRef;
|
: currentRef;
|
||||||
const event = getWorkflowEvent();
|
const event = getWorkflowEvent();
|
||||||
const defaultBranch = (_a = event === null || event === void 0 ? void 0 : event.repository) === null || _a === void 0 ? void 0 : _a.default_branch;
|
const defaultBranch = (_a = event === null || event === void 0 ? void 0 : event.repository) === null || _a === void 0 ? void 0 : _a.default_branch;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
4
lib/api-client.js
generated
4
lib/api-client.js
generated
@@ -81,8 +81,8 @@ let cachedGitHubVersion = undefined;
|
|||||||
* @returns GitHub version
|
* @returns GitHub version
|
||||||
*/
|
*/
|
||||||
async function getGitHubVersionActionsOnly() {
|
async function getGitHubVersionActionsOnly() {
|
||||||
if (!util.isActions) {
|
if (!util.isActions()) {
|
||||||
throw new Error("This getGitHubVersion() function works only in an action");
|
throw new Error("getGitHubVersionActionsOnly() works only in an action");
|
||||||
}
|
}
|
||||||
if (cachedGitHubVersion === undefined) {
|
if (cachedGitHubVersion === undefined) {
|
||||||
cachedGitHubVersion = await util.getGitHubVersion(getApiDetails());
|
cachedGitHubVersion = await util.getGitHubVersion(getApiDetails());
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":";;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A+C;AAC/C,SAAgB,mBAAmB;IACjC,OAAO,IAAA,oBAAY,EAAC,aAAa,EAAE,CAAC,CAAC;AACvC,CAAC;AAFD,kDAEC;AAED,IAAI,mBAAmB,GAA8B,SAAS,CAAC;AAE/D;;;;;;;GAOG;AACI,KAAK,UAAU,2BAA2B;IAC/C,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;KAC1E;IACD,IAAI,mBAAmB,KAAK,SAAS,EAAE;QACrC,mBAAmB,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,aAAa,EAAE,CAAC,CAAC;KACpE;IACD,OAAO,mBAAmB,CAAC;AAC7B,CAAC;AARD,kEAQC"}
|
||||||
@@ -1 +1 @@
|
|||||||
{ "maximumVersion": "3.4", "minimumVersion": "3.1" }
|
{ "maximumVersion": "3.5", "minimumVersion": "3.1" }
|
||||||
|
|||||||
39
lib/codeql.js
generated
39
lib/codeql.js
generated
@@ -196,6 +196,19 @@ async function getCodeQLBundleDownloadURL(apiDetails, variant, logger) {
|
|||||||
}
|
}
|
||||||
return `https://github.com/${CODEQL_DEFAULT_ACTION_REPOSITORY}/releases/download/${CODEQL_BUNDLE_VERSION}/${codeQLBundleName}`;
|
return `https://github.com/${CODEQL_DEFAULT_ACTION_REPOSITORY}/releases/download/${CODEQL_BUNDLE_VERSION}/${codeQLBundleName}`;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Set up CodeQL CLI access.
|
||||||
|
*
|
||||||
|
* @param codeqlURL
|
||||||
|
* @param apiDetails
|
||||||
|
* @param tempDir
|
||||||
|
* @param toolCacheDir
|
||||||
|
* @param variant
|
||||||
|
* @param logger
|
||||||
|
* @param checkVersion Whether to check that CodeQL CLI meets the minimum
|
||||||
|
* version requirement. Must be set to true outside tests.
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant, logger, checkVersion) {
|
async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant, logger, checkVersion) {
|
||||||
try {
|
try {
|
||||||
// We use the special value of 'latest' to prioritize the version in the
|
// We use the special value of 'latest' to prioritize the version in the
|
||||||
@@ -367,16 +380,26 @@ async function getCodeQLForTesting() {
|
|||||||
return getCodeQLForCmd("codeql-for-testing", false);
|
return getCodeQLForCmd("codeql-for-testing", false);
|
||||||
}
|
}
|
||||||
exports.getCodeQLForTesting = getCodeQLForTesting;
|
exports.getCodeQLForTesting = getCodeQLForTesting;
|
||||||
|
/**
|
||||||
|
* Return a CodeQL object for CodeQL CLI access.
|
||||||
|
*
|
||||||
|
* @param cmd Path to CodeQL CLI
|
||||||
|
* @param checkVersion Whether to check that CodeQL CLI meets the minimum
|
||||||
|
* version requirement. Must be set to true outside tests.
|
||||||
|
* @returns A new CodeQL object
|
||||||
|
*/
|
||||||
async function getCodeQLForCmd(cmd, checkVersion) {
|
async function getCodeQLForCmd(cmd, checkVersion) {
|
||||||
let cachedVersion = undefined;
|
|
||||||
const codeql = {
|
const codeql = {
|
||||||
getPath() {
|
getPath() {
|
||||||
return cmd;
|
return cmd;
|
||||||
},
|
},
|
||||||
async getVersion() {
|
async getVersion() {
|
||||||
if (cachedVersion === undefined)
|
let result = util.getCachedCodeQlVersion();
|
||||||
cachedVersion = runTool(cmd, ["version", "--format=terse"]);
|
if (result === undefined) {
|
||||||
return await cachedVersion;
|
result = await runTool(cmd, ["version", "--format=terse"]);
|
||||||
|
util.cacheCodeQlVersion(result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
},
|
},
|
||||||
async printVersion() {
|
async printVersion() {
|
||||||
await runTool(cmd, ["version", "--format=json"]);
|
await runTool(cmd, ["version", "--format=json"]);
|
||||||
@@ -672,6 +695,14 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
|||||||
await new toolrunner.ToolRunner(cmd, args).exec();
|
await new toolrunner.ToolRunner(cmd, args).exec();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
// To ensure that status reports include the CodeQL CLI version whereever
|
||||||
|
// possbile, we want to call getVersion(), which populates the version value
|
||||||
|
// used by status reporting, at the earliest opportunity. But invoking
|
||||||
|
// getVersion() directly here breaks tests that only pretend to create a
|
||||||
|
// CodeQL object. So instead we rely on the assumption that all non-test
|
||||||
|
// callers would set checkVersion to true, and util.codeQlVersionAbove()
|
||||||
|
// would call getVersion(), so the CLI version would be cached as soon as the
|
||||||
|
// CodeQL object is created.
|
||||||
if (checkVersion &&
|
if (checkVersion &&
|
||||||
!(await util.codeQlVersionAbove(codeql, CODEQL_MINIMUM_VERSION))) {
|
!(await util.codeQlVersionAbove(codeql, CODEQL_MINIMUM_VERSION))) {
|
||||||
throw new Error(`Expected a CodeQL CLI with version at least ${CODEQL_MINIMUM_VERSION} but got version ${await codeql.getVersion()}`);
|
throw new Error(`Expected a CodeQL CLI with version at least ${CODEQL_MINIMUM_VERSION} but got version ${await codeql.getVersion()}`);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
2
lib/config-utils.js
generated
2
lib/config-utils.js
generated
@@ -435,7 +435,7 @@ async function addQueriesAndPacksFromWorkflow(codeQL, queriesInput, languages, r
|
|||||||
// should instead be added in addition
|
// should instead be added in addition
|
||||||
function shouldAddConfigFileQueries(queriesInput) {
|
function shouldAddConfigFileQueries(queriesInput) {
|
||||||
if (queriesInput) {
|
if (queriesInput) {
|
||||||
return queriesInput.trimStart().substr(0, 1) === "+";
|
return queriesInput.trimStart().slice(0, 1) === "+";
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
2
lib/init-action.js
generated
2
lib/init-action.js
generated
@@ -49,7 +49,7 @@ async function sendSuccessStatusReport(startedAt, config, toolsVersion) {
|
|||||||
}
|
}
|
||||||
if (queriesInput !== undefined) {
|
if (queriesInput !== undefined) {
|
||||||
queriesInput = queriesInput.startsWith("+")
|
queriesInput = queriesInput.startsWith("+")
|
||||||
? queriesInput.substr(1)
|
? queriesInput.slice(1)
|
||||||
: queriesInput;
|
: queriesInput;
|
||||||
queries.push(...queriesInput.split(","));
|
queries.push(...queriesInput.split(","));
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
14
lib/util.js
generated
14
lib/util.js
generated
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.getMlPoweredJsQueriesStatus = exports.ML_POWERED_JS_QUERIES_PACK = exports.isGoodVersion = exports.delay = exports.bundleDb = exports.codeQlVersionAbove = exports.isGitHubGhesVersionBelow = exports.isHTTPError = exports.UserError = exports.HTTPError = exports.getRequiredEnvParam = exports.isActions = exports.getMode = exports.enrichEnvironment = exports.initializeEnvironment = exports.Mode = exports.assertNever = exports.getGitHubAuth = exports.apiVersionInRange = exports.DisallowedAPIVersionReason = exports.checkGitHubVersionInRange = exports.getGitHubVersion = exports.GitHubVariant = exports.parseGitHubUrl = exports.getCodeQLDatabasePath = exports.getThreadsFlag = exports.getThreadsFlagValue = exports.getAddSnippetsFlag = exports.getMemoryFlag = exports.getMemoryFlagValue = exports.withTmpDir = exports.getToolNames = exports.getExtraOptionsEnvParam = exports.DEFAULT_DEBUG_DATABASE_NAME = exports.DEFAULT_DEBUG_ARTIFACT_NAME = exports.GITHUB_DOTCOM_URL = void 0;
|
exports.getMlPoweredJsQueriesStatus = exports.ML_POWERED_JS_QUERIES_PACK = exports.isGoodVersion = exports.delay = exports.bundleDb = exports.codeQlVersionAbove = exports.getCachedCodeQlVersion = exports.cacheCodeQlVersion = exports.isGitHubGhesVersionBelow = exports.isHTTPError = exports.UserError = exports.HTTPError = exports.getRequiredEnvParam = exports.isActions = exports.getMode = exports.enrichEnvironment = exports.initializeEnvironment = exports.Mode = exports.assertNever = exports.getGitHubAuth = exports.apiVersionInRange = exports.DisallowedAPIVersionReason = exports.checkGitHubVersionInRange = exports.getGitHubVersion = exports.GitHubVariant = exports.parseGitHubUrl = exports.getCodeQLDatabasePath = exports.getThreadsFlag = exports.getThreadsFlagValue = exports.getAddSnippetsFlag = exports.getMemoryFlag = exports.getMemoryFlagValue = exports.withTmpDir = exports.getToolNames = exports.getExtraOptionsEnvParam = exports.DEFAULT_DEBUG_DATABASE_NAME = exports.DEFAULT_DEBUG_ARTIFACT_NAME = exports.GITHUB_DOTCOM_URL = void 0;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const os = __importStar(require("os"));
|
const os = __importStar(require("os"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
@@ -505,6 +505,18 @@ function isGitHubGhesVersionBelow(gitHubVersion, expectedVersion) {
|
|||||||
semver.lt(gitHubVersion.version, expectedVersion));
|
semver.lt(gitHubVersion.version, expectedVersion));
|
||||||
}
|
}
|
||||||
exports.isGitHubGhesVersionBelow = isGitHubGhesVersionBelow;
|
exports.isGitHubGhesVersionBelow = isGitHubGhesVersionBelow;
|
||||||
|
let cachedCodeQlVersion = undefined;
|
||||||
|
function cacheCodeQlVersion(version) {
|
||||||
|
if (cachedCodeQlVersion !== undefined) {
|
||||||
|
throw new Error("cacheCodeQlVersion() should be called only once");
|
||||||
|
}
|
||||||
|
cachedCodeQlVersion = version;
|
||||||
|
}
|
||||||
|
exports.cacheCodeQlVersion = cacheCodeQlVersion;
|
||||||
|
function getCachedCodeQlVersion() {
|
||||||
|
return cachedCodeQlVersion;
|
||||||
|
}
|
||||||
|
exports.getCachedCodeQlVersion = getCachedCodeQlVersion;
|
||||||
async function codeQlVersionAbove(codeql, requiredVersion) {
|
async function codeQlVersionAbove(codeql, requiredVersion) {
|
||||||
return semver.gte(await codeql.getVersion(), requiredVersion);
|
return semver.gte(await codeql.getVersion(), requiredVersion);
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
2
node_modules/.package-lock.json
generated
vendored
2
node_modules/.package-lock.json
generated
vendored
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "codeql",
|
"name": "codeql",
|
||||||
"version": "1.1.5",
|
"version": "1.1.6",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "codeql",
|
"name": "codeql",
|
||||||
"version": "1.1.5",
|
"version": "1.1.6",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "codeql",
|
"name": "codeql",
|
||||||
"version": "1.1.5",
|
"version": "1.1.6",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/artifact": "^1.0.0",
|
"@actions/artifact": "^1.0.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "codeql",
|
"name": "codeql",
|
||||||
"version": "1.1.5",
|
"version": "1.1.6",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "CodeQL action",
|
"description": "CodeQL action",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
2
runner/package-lock.json
generated
2
runner/package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "codeql-runner",
|
"name": "codeql-runner",
|
||||||
"version": "1.1.5",
|
"version": "1.1.6",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "codeql-runner",
|
"name": "codeql-runner",
|
||||||
"version": "1.1.5",
|
"version": "1.1.6",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "CodeQL runner",
|
"description": "CodeQL runner",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import * as yaml from "js-yaml";
|
|||||||
import * as api from "./api-client";
|
import * as api from "./api-client";
|
||||||
import * as sharedEnv from "./shared-environment";
|
import * as sharedEnv from "./shared-environment";
|
||||||
import {
|
import {
|
||||||
|
getCachedCodeQlVersion,
|
||||||
getRequiredEnvParam,
|
getRequiredEnvParam,
|
||||||
GITHUB_DOTCOM_URL,
|
GITHUB_DOTCOM_URL,
|
||||||
isGitHubGhesVersionBelow,
|
isGitHubGhesVersionBelow,
|
||||||
@@ -17,6 +18,9 @@ import {
|
|||||||
UserError,
|
UserError,
|
||||||
} from "./util";
|
} from "./util";
|
||||||
|
|
||||||
|
// eslint-disable-next-line import/no-commonjs
|
||||||
|
const pkg = require("../package.json");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The utils in this module are meant to be run inside of the action only.
|
* The utils in this module are meant to be run inside of the action only.
|
||||||
* Code paths from the runner should not enter this module.
|
* Code paths from the runner should not enter this module.
|
||||||
@@ -604,6 +608,10 @@ export interface StatusReportBase {
|
|||||||
runner_arch?: string;
|
runner_arch?: string;
|
||||||
/** Action runner operating system release (x.y.z from os.release()). */
|
/** Action runner operating system release (x.y.z from os.release()). */
|
||||||
runner_os_release?: string;
|
runner_os_release?: string;
|
||||||
|
/** Action version (x.y.z from package.json). */
|
||||||
|
action_version: string;
|
||||||
|
/** CodeQL CLI version (x.y.z from the CLI). */
|
||||||
|
codeql_cli_version?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getActionsStatus(
|
export function getActionsStatus(
|
||||||
@@ -652,6 +660,7 @@ export async function createStatusReportBase(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
const runnerOs = getRequiredEnvParam("RUNNER_OS");
|
const runnerOs = getRequiredEnvParam("RUNNER_OS");
|
||||||
|
const codeQlCliVersion = getCachedCodeQlVersion();
|
||||||
|
|
||||||
// If running locally then the GITHUB_ACTION_REF cannot be trusted as it may be for the previous action
|
// If running locally then the GITHUB_ACTION_REF cannot be trusted as it may be for the previous action
|
||||||
// See https://github.com/actions/runner/issues/803
|
// See https://github.com/actions/runner/issues/803
|
||||||
@@ -673,6 +682,7 @@ export async function createStatusReportBase(
|
|||||||
action_started_at: actionStartedAt.toISOString(),
|
action_started_at: actionStartedAt.toISOString(),
|
||||||
status,
|
status,
|
||||||
runner_os: runnerOs,
|
runner_os: runnerOs,
|
||||||
|
action_version: pkg.version,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add optional parameters
|
// Add optional parameters
|
||||||
@@ -702,6 +712,9 @@ export async function createStatusReportBase(
|
|||||||
if (runnerOs === "Windows" || runnerOs === "macOS") {
|
if (runnerOs === "Windows" || runnerOs === "macOS") {
|
||||||
statusReport.runner_os_release = os.release();
|
statusReport.runner_os_release = os.release();
|
||||||
}
|
}
|
||||||
|
if (codeQlCliVersion !== undefined) {
|
||||||
|
statusReport.codeql_cli_version = codeQlCliVersion;
|
||||||
|
}
|
||||||
|
|
||||||
return statusReport;
|
return statusReport;
|
||||||
}
|
}
|
||||||
@@ -845,7 +858,7 @@ export async function isAnalyzingDefaultBranch(): Promise<boolean> {
|
|||||||
// Get the current ref and trim and refs/heads/ prefix
|
// Get the current ref and trim and refs/heads/ prefix
|
||||||
let currentRef = await getRef();
|
let currentRef = await getRef();
|
||||||
currentRef = currentRef.startsWith("refs/heads/")
|
currentRef = currentRef.startsWith("refs/heads/")
|
||||||
? currentRef.substr("refs/heads/".length)
|
? currentRef.slice("refs/heads/".length)
|
||||||
: currentRef;
|
: currentRef;
|
||||||
|
|
||||||
const event = getWorkflowEvent();
|
const event = getWorkflowEvent();
|
||||||
|
|||||||
@@ -84,8 +84,8 @@ let cachedGitHubVersion: GitHubVersion | undefined = undefined;
|
|||||||
* @returns GitHub version
|
* @returns GitHub version
|
||||||
*/
|
*/
|
||||||
export async function getGitHubVersionActionsOnly(): Promise<GitHubVersion> {
|
export async function getGitHubVersionActionsOnly(): Promise<GitHubVersion> {
|
||||||
if (!util.isActions) {
|
if (!util.isActions()) {
|
||||||
throw new Error("This getGitHubVersion() function works only in an action");
|
throw new Error("getGitHubVersionActionsOnly() works only in an action");
|
||||||
}
|
}
|
||||||
if (cachedGitHubVersion === undefined) {
|
if (cachedGitHubVersion === undefined) {
|
||||||
cachedGitHubVersion = await util.getGitHubVersion(getApiDetails());
|
cachedGitHubVersion = await util.getGitHubVersion(getApiDetails());
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"maximumVersion": "3.4", "minimumVersion": "3.1"}
|
{"maximumVersion": "3.5", "minimumVersion": "3.1"}
|
||||||
|
|||||||
@@ -367,6 +367,19 @@ async function getCodeQLBundleDownloadURL(
|
|||||||
return `https://github.com/${CODEQL_DEFAULT_ACTION_REPOSITORY}/releases/download/${CODEQL_BUNDLE_VERSION}/${codeQLBundleName}`;
|
return `https://github.com/${CODEQL_DEFAULT_ACTION_REPOSITORY}/releases/download/${CODEQL_BUNDLE_VERSION}/${codeQLBundleName}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up CodeQL CLI access.
|
||||||
|
*
|
||||||
|
* @param codeqlURL
|
||||||
|
* @param apiDetails
|
||||||
|
* @param tempDir
|
||||||
|
* @param toolCacheDir
|
||||||
|
* @param variant
|
||||||
|
* @param logger
|
||||||
|
* @param checkVersion Whether to check that CodeQL CLI meets the minimum
|
||||||
|
* version requirement. Must be set to true outside tests.
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
export async function setupCodeQL(
|
export async function setupCodeQL(
|
||||||
codeqlURL: string | undefined,
|
codeqlURL: string | undefined,
|
||||||
apiDetails: api.GitHubApiDetails,
|
apiDetails: api.GitHubApiDetails,
|
||||||
@@ -611,19 +624,29 @@ export async function getCodeQLForTesting(): Promise<CodeQL> {
|
|||||||
return getCodeQLForCmd("codeql-for-testing", false);
|
return getCodeQLForCmd("codeql-for-testing", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a CodeQL object for CodeQL CLI access.
|
||||||
|
*
|
||||||
|
* @param cmd Path to CodeQL CLI
|
||||||
|
* @param checkVersion Whether to check that CodeQL CLI meets the minimum
|
||||||
|
* version requirement. Must be set to true outside tests.
|
||||||
|
* @returns A new CodeQL object
|
||||||
|
*/
|
||||||
async function getCodeQLForCmd(
|
async function getCodeQLForCmd(
|
||||||
cmd: string,
|
cmd: string,
|
||||||
checkVersion: boolean
|
checkVersion: boolean
|
||||||
): Promise<CodeQL> {
|
): Promise<CodeQL> {
|
||||||
let cachedVersion: undefined | Promise<string> = undefined;
|
|
||||||
const codeql = {
|
const codeql = {
|
||||||
getPath() {
|
getPath() {
|
||||||
return cmd;
|
return cmd;
|
||||||
},
|
},
|
||||||
async getVersion() {
|
async getVersion() {
|
||||||
if (cachedVersion === undefined)
|
let result = util.getCachedCodeQlVersion();
|
||||||
cachedVersion = runTool(cmd, ["version", "--format=terse"]);
|
if (result === undefined) {
|
||||||
return await cachedVersion;
|
result = await runTool(cmd, ["version", "--format=terse"]);
|
||||||
|
util.cacheCodeQlVersion(result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
},
|
},
|
||||||
async printVersion() {
|
async printVersion() {
|
||||||
await runTool(cmd, ["version", "--format=json"]);
|
await runTool(cmd, ["version", "--format=json"]);
|
||||||
@@ -997,6 +1020,14 @@ async function getCodeQLForCmd(
|
|||||||
await new toolrunner.ToolRunner(cmd, args).exec();
|
await new toolrunner.ToolRunner(cmd, args).exec();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
// To ensure that status reports include the CodeQL CLI version whereever
|
||||||
|
// possbile, we want to call getVersion(), which populates the version value
|
||||||
|
// used by status reporting, at the earliest opportunity. But invoking
|
||||||
|
// getVersion() directly here breaks tests that only pretend to create a
|
||||||
|
// CodeQL object. So instead we rely on the assumption that all non-test
|
||||||
|
// callers would set checkVersion to true, and util.codeQlVersionAbove()
|
||||||
|
// would call getVersion(), so the CLI version would be cached as soon as the
|
||||||
|
// CodeQL object is created.
|
||||||
if (
|
if (
|
||||||
checkVersion &&
|
checkVersion &&
|
||||||
!(await util.codeQlVersionAbove(codeql, CODEQL_MINIMUM_VERSION))
|
!(await util.codeQlVersionAbove(codeql, CODEQL_MINIMUM_VERSION))
|
||||||
|
|||||||
@@ -849,7 +849,7 @@ async function addQueriesAndPacksFromWorkflow(
|
|||||||
// should instead be added in addition
|
// should instead be added in addition
|
||||||
function shouldAddConfigFileQueries(queriesInput: string | undefined): boolean {
|
function shouldAddConfigFileQueries(queriesInput: string | undefined): boolean {
|
||||||
if (queriesInput) {
|
if (queriesInput) {
|
||||||
return queriesInput.trimStart().substr(0, 1) === "+";
|
return queriesInput.trimStart().slice(0, 1) === "+";
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ async function sendSuccessStatusReport(
|
|||||||
}
|
}
|
||||||
if (queriesInput !== undefined) {
|
if (queriesInput !== undefined) {
|
||||||
queriesInput = queriesInput.startsWith("+")
|
queriesInput = queriesInput.startsWith("+")
|
||||||
? queriesInput.substr(1)
|
? queriesInput.slice(1)
|
||||||
: queriesInput;
|
: queriesInput;
|
||||||
queries.push(...queriesInput.split(","));
|
queries.push(...queriesInput.split(","));
|
||||||
}
|
}
|
||||||
|
|||||||
13
src/util.ts
13
src/util.ts
@@ -604,6 +604,19 @@ export function isGitHubGhesVersionBelow(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let cachedCodeQlVersion: undefined | string = undefined;
|
||||||
|
|
||||||
|
export function cacheCodeQlVersion(version: string): void {
|
||||||
|
if (cachedCodeQlVersion !== undefined) {
|
||||||
|
throw new Error("cacheCodeQlVersion() should be called only once");
|
||||||
|
}
|
||||||
|
cachedCodeQlVersion = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getCachedCodeQlVersion(): undefined | string {
|
||||||
|
return cachedCodeQlVersion;
|
||||||
|
}
|
||||||
|
|
||||||
export async function codeQlVersionAbove(
|
export async function codeQlVersionAbove(
|
||||||
codeql: CodeQL,
|
codeql: CodeQL,
|
||||||
requiredVersion: string
|
requiredVersion: string
|
||||||
|
|||||||
Reference in New Issue
Block a user