Compare commits

...

17 Commits

Author SHA1 Message Date
Simon Engledew bb012c4070 Merge pull request #432 from github/simon-engledew/fix-ref-check
Fix rev-parse errors
2021-03-25 14:02:01 +00:00
Simon Engledew ba14abbca7 Rewrite the ref to correctly point to refs/remotes
Fixes the rev-parse issues caused by https://github.com/github/codeql-action/pull/428
2021-03-25 13:08:55 +00:00
Simon Engledew 972dc3e3f9 Merge pull request #428 from github/simon-engledew/detect-merge
Fix race condition with actions/checkout@v1
2021-03-23 06:18:28 +00:00
Simon Engledew 9165099103 Skip doing work if it is not necessary 2021-03-22 15:50:04 +00:00
Simon Engledew 36a9516acc PR feedback 2021-03-22 15:09:33 +00:00
Simon Engledew ef92c5ac5f Count the number of parents of the current commit to check it is still a merge
Work around a race condition in actions where sometimes GITHUB_SHA != git rev-parse head
2021-03-22 12:05:00 +00:00
Aditya Sharad 5d467d014b Merge pull request #427 from github/hmakholm/pr/2.4.6 2021-03-20 15:52:17 -07:00
Henning Makholm f8e31274f4 Revert "Temporarily use the latest version for testing"
This reverts commit e700075082.
2021-03-20 01:13:11 +01:00
Robin Neatherway e700075082 Temporarily use the latest version for testing 2021-03-20 00:35:46 +01:00
Henning Makholm d2f4021928 Update CodeQL bundle to 20210319 2021-03-20 00:30:46 +01:00
Josh Soref c4fced7348 Fix spelling errors
spelling: executable
spelling: github
spelling: javascript
spelling: latest
spelling: occurred
spelling: parameter

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2021-03-18 09:40:47 -07:00
Andrew Eisenberg 08fae3caba Display better error message on invalid sarif
Specifically, some third party tools do not include a `results`
block for runs when there is an error. This change adds a more
explicit error message for this situation.
2021-03-18 09:03:42 -07:00
Andrew Eisenberg ffd96b38fb Ensure error correct error message on 403 error 2021-03-17 07:55:21 -07:00
Robert 0f834639e4 Merge pull request #423 from github/robertbrignull/toolcache-query-safety
Make unguarded-action-lib better at ignoring uses of toolcache
2021-03-16 16:13:33 +00:00
Robert 5004a54ed3 Merge branch 'main' into robertbrignull/toolcache-query-safety 2021-03-16 15:29:47 +00:00
Robert 378f30f95d call setupActionsVars in the tests too 2021-03-16 13:43:28 +00:00
Robert d698cb3d2b Make unguarded-action-lib better at ignoring uses of toolcache 2021-03-16 13:14:17 +00:00
38 changed files with 330 additions and 158 deletions
+30 -12
View File
@@ -77,7 +77,7 @@ exports.prepareLocalRunEnvironment = prepareLocalRunEnvironment;
/** /**
* Gets the SHA of the commit that is currently checked out. * Gets the SHA of the commit that is currently checked out.
*/ */
exports.getCommitOid = async function () { exports.getCommitOid = async function (ref = "HEAD") {
// Try to use git to get the current commit SHA. If that fails then // Try to use git to get the current commit SHA. If that fails then
// log but otherwise silently fall back to using the SHA from the environment. // log but otherwise silently fall back to using the SHA from the environment.
// The only time these two values will differ is during analysis of a PR when // The only time these two values will differ is during analysis of a PR when
@@ -87,7 +87,7 @@ exports.getCommitOid = async function () {
// reported on the merge commit. // reported on the merge commit.
try { try {
let commitOid = ""; let commitOid = "";
await new toolrunner.ToolRunner(await safeWhich.safeWhich("git"), ["rev-parse", "HEAD"], { await new toolrunner.ToolRunner(await safeWhich.safeWhich("git"), ["rev-parse", ref], {
silent: true, silent: true,
listeners: { listeners: {
stdout: (data) => { stdout: (data) => {
@@ -328,7 +328,7 @@ function getWorkflowRunID() {
} }
exports.getWorkflowRunID = getWorkflowRunID; exports.getWorkflowRunID = getWorkflowRunID;
/** /**
* Get the analysis key paramter for the current job. * Get the analysis key parameter for the current job.
* *
* This will combine the workflow path and current job name. * This will combine the workflow path and current job name.
* Computing this the first time requires making requests to * Computing this the first time requires making requests to
@@ -354,15 +354,28 @@ async function getRef() {
// Will be in the form "refs/heads/master" on a push event // Will be in the form "refs/heads/master" on a push event
// or in the form "refs/pull/N/merge" on a pull_request event // or in the form "refs/pull/N/merge" on a pull_request event
const ref = getRequiredEnvParam("GITHUB_REF"); const ref = getRequiredEnvParam("GITHUB_REF");
const sha = getRequiredEnvParam("GITHUB_SHA");
// For pull request refs we want to detect whether the workflow // For pull request refs we want to detect whether the workflow
// has run `git checkout HEAD^2` to analyze the 'head' ref rather // has run `git checkout HEAD^2` to analyze the 'head' ref rather
// than the 'merge' ref. If so, we want to convert the ref that // than the 'merge' ref. If so, we want to convert the ref that
// we report back. // we report back.
const pull_ref_regex = /refs\/pull\/(\d+)\/merge/; const pull_ref_regex = /refs\/pull\/(\d+)\/merge/;
const checkoutSha = await exports.getCommitOid(); if (!pull_ref_regex.test(ref)) {
if (pull_ref_regex.test(ref) && return ref;
checkoutSha !== getRequiredEnvParam("GITHUB_SHA")) { }
return ref.replace(pull_ref_regex, "refs/pull/$1/head"); const head = await exports.getCommitOid("HEAD");
// in actions/checkout@v2 we can check if git rev-parse HEAD == GITHUB_SHA
// in actions/checkout@v1 this may not be true as it checks out the repository
// using GITHUB_REF. There is a subtle race condition where
// git rev-parse GITHUB_REF != GITHUB_SHA, so we must check
// git git-parse GITHUB_REF == git rev-parse HEAD instead.
const hasChangedRef = sha !== head &&
(await exports.getCommitOid(ref.replace(/^refs\/pull\//, "refs/remotes/pull/"))) !==
head;
if (hasChangedRef) {
const newRef = ref.replace(pull_ref_regex, "refs/pull/$1/head");
core.debug(`No longer on merge commit, rewriting ref from ${ref} to ${newRef}.`);
return newRef;
} }
else { else {
return ref; return ref;
@@ -434,6 +447,10 @@ function isHTTPError(arg) {
var _a; var _a;
return ((_a = arg) === null || _a === void 0 ? void 0 : _a.status) !== undefined && Number.isInteger(arg.status); return ((_a = arg) === null || _a === void 0 ? void 0 : _a.status) !== undefined && Number.isInteger(arg.status);
} }
const GENERIC_403_MSG = "The repo on which this action is running is not opted-in to CodeQL code scanning.";
const GENERIC_404_MSG = "Not authorized to used the CodeQL code scanning feature on this repo.";
const OUT_OF_DATE_MSG = "CodeQL Action is out-of-date. Please upgrade to the latest version of codeql-action.";
const INCOMPATIBLE_MSG = "CodeQL Action version is incompatible with the code scanning endpoint. Please update to a compatible version of codeql-action.";
/** /**
* Send a status report to the code_scanning/analysis/status endpoint. * Send a status report to the code_scanning/analysis/status endpoint.
* *
@@ -462,30 +479,31 @@ async function sendStatusReport(statusReport) {
return true; return true;
} }
catch (e) { catch (e) {
console.log(e);
if (isHTTPError(e)) { if (isHTTPError(e)) {
switch (e.status) { switch (e.status) {
case 403: case 403:
core.setFailed("The repo on which this action is running is not opted-in to CodeQL code scanning."); core.setFailed(e.message || GENERIC_403_MSG);
return false; return false;
case 404: case 404:
core.setFailed("Not authorized to used the CodeQL code scanning feature on this repo."); core.setFailed(GENERIC_404_MSG);
return false; return false;
case 422: case 422:
// schema incompatibility when reporting status // schema incompatibility when reporting status
// this means that this action version is no longer compatible with the API // this means that this action version is no longer compatible with the API
// we still want to continue as it is likely the analysis endpoint will work // we still want to continue as it is likely the analysis endpoint will work
if (getRequiredEnvParam("GITHUB_SERVER_URL") !== util_1.GITHUB_DOTCOM_URL) { if (getRequiredEnvParam("GITHUB_SERVER_URL") !== util_1.GITHUB_DOTCOM_URL) {
core.debug("CodeQL Action version is incompatible with the code scanning endpoint. Please update to a compatible version of codeql-action."); core.debug(INCOMPATIBLE_MSG);
} }
else { else {
core.debug("CodeQL Action is out-of-date. Please upgrade to the latest version of codeql-action."); core.debug(OUT_OF_DATE_MSG);
} }
return true; return true;
} }
} }
// something else has gone wrong and the request/response will be logged by octokit // something else has gone wrong and the request/response will be logged by octokit
// it's possible this is a transient error and we should continue scanning // it's possible this is a transient error and we should continue scanning
core.error("An unexpected error occured when sending code scanning status report."); core.error("An unexpected error occurred when sending code scanning status report.");
return true; return true;
} }
} }
File diff suppressed because one or more lines are too long
+20 -3
View File
@@ -28,16 +28,33 @@ ava_1.default("getRef() returns merge PR ref if GITHUB_SHA still checked out", a
const currentSha = "a".repeat(40); const currentSha = "a".repeat(40);
process.env["GITHUB_REF"] = expectedRef; process.env["GITHUB_REF"] = expectedRef;
process.env["GITHUB_SHA"] = currentSha; process.env["GITHUB_SHA"] = currentSha;
sinon_1.default.stub(actionsutil, "getCommitOid").resolves(currentSha); const callback = sinon_1.default.stub(actionsutil, "getCommitOid");
callback.withArgs("HEAD").resolves(currentSha);
const actualRef = await actionsutil.getRef(); const actualRef = await actionsutil.getRef();
t.deepEqual(actualRef, expectedRef); t.deepEqual(actualRef, expectedRef);
callback.restore();
}); });
ava_1.default("getRef() returns head PR ref if GITHUB_SHA not currently checked out", async (t) => { ava_1.default("getRef() returns merge PR ref if GITHUB_REF still checked out but sha has changed (actions checkout@v1)", async (t) => {
const expectedRef = "refs/pull/1/merge";
process.env["GITHUB_REF"] = expectedRef;
process.env["GITHUB_SHA"] = "b".repeat(40);
const sha = "a".repeat(40);
const callback = sinon_1.default.stub(actionsutil, "getCommitOid");
callback.withArgs("refs/remotes/pull/1/merge").resolves(sha);
callback.withArgs("HEAD").resolves(sha);
const actualRef = await actionsutil.getRef();
t.deepEqual(actualRef, expectedRef);
callback.restore();
});
ava_1.default("getRef() returns head PR ref if GITHUB_REF no longer checked out", async (t) => {
process.env["GITHUB_REF"] = "refs/pull/1/merge"; process.env["GITHUB_REF"] = "refs/pull/1/merge";
process.env["GITHUB_SHA"] = "a".repeat(40); process.env["GITHUB_SHA"] = "a".repeat(40);
sinon_1.default.stub(actionsutil, "getCommitOid").resolves("b".repeat(40)); const callback = sinon_1.default.stub(actionsutil, "getCommitOid");
callback.withArgs("refs/pull/1/merge").resolves("a".repeat(40));
callback.withArgs("HEAD").resolves("b".repeat(40));
const actualRef = await actionsutil.getRef(); const actualRef = await actionsutil.getRef();
t.deepEqual(actualRef, "refs/pull/1/head"); t.deepEqual(actualRef, "refs/pull/1/head");
callback.restore();
}); });
ava_1.default("getAnalysisKey() when a local run", async (t) => { ava_1.default("getAnalysisKey() when a local run", async (t) => {
process.env.CODEQL_LOCAL_RUN = "true"; process.env.CODEQL_LOCAL_RUN = "true";
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -28,7 +28,7 @@ function printPathFiltersWarning(config, logger) {
// If any other languages are detected/configured then show a warning. // If any other languages are detected/configured then show a warning.
if ((config.paths.length !== 0 || config.pathsIgnore.length !== 0) && if ((config.paths.length !== 0 || config.pathsIgnore.length !== 0) &&
!config.languages.every(isInterpretedLanguage)) { !config.languages.every(isInterpretedLanguage)) {
logger.warning('The "paths"/"paths-ignore" fields of the config only have effect for Javascript and Python'); logger.warning('The "paths"/"paths-ignore" fields of the config only have effect for JavaScript and Python');
} }
} }
exports.printPathFiltersWarning = printPathFiltersWarning; exports.printPathFiltersWarning = printPathFiltersWarning;
Generated
+1 -6
View File
@@ -156,12 +156,7 @@ async function toolcacheDownloadTool(url, headers, tempDir, logger) {
await pipeline(response.message, fs.createWriteStream(dest)); await pipeline(response.message, fs.createWriteStream(dest));
return dest; return dest;
} }
async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolsDir, mode, variant, logger) { async function setupCodeQL(codeqlURL, apiDetails, tempDir, mode, variant, logger) {
// Setting these two env vars makes the toolcache code safe to use outside,
// of actions but this is obviously not a great thing we're doing and it would
// be better to write our own implementation to use outside of actions.
process.env["RUNNER_TEMP"] = tempDir;
process.env["RUNNER_TOOL_CACHE"] = toolsDir;
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
// defaults over any pinned cached version. // defaults over any pinned cached version.
+1 -1
View File
File diff suppressed because one or more lines are too long
+17 -11
View File
@@ -30,13 +30,14 @@ const sampleGHAEApiDetails = {
}; };
ava_1.default("download codeql bundle cache", async (t) => { ava_1.default("download codeql bundle cache", async (t) => {
await util.withTmpDir(async (tmpDir) => { await util.withTmpDir(async (tmpDir) => {
util.setupActionsVars(tmpDir, tmpDir);
const versions = ["20200601", "20200610"]; const versions = ["20200601", "20200610"];
for (let i = 0; i < versions.length; i++) { for (let i = 0; i < versions.length; i++) {
const version = versions[i]; const version = versions[i];
nock_1.default("https://example.com") nock_1.default("https://example.com")
.get(`/download/codeql-bundle-${version}/codeql-bundle.tar.gz`) .get(`/download/codeql-bundle-${version}/codeql-bundle.tar.gz`)
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`)); .replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
await codeql.setupCodeQL(`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`, sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true)); await codeql.setupCodeQL(`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`, sampleApiDetails, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`)); t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
} }
const cachedVersions = toolcache.findAllVersions("CodeQL"); const cachedVersions = toolcache.findAllVersions("CodeQL");
@@ -45,36 +46,39 @@ ava_1.default("download codeql bundle cache", async (t) => {
}); });
ava_1.default("download codeql bundle cache explicitly requested with pinned different version cached", async (t) => { ava_1.default("download codeql bundle cache explicitly requested with pinned different version cached", async (t) => {
await util.withTmpDir(async (tmpDir) => { await util.withTmpDir(async (tmpDir) => {
util.setupActionsVars(tmpDir, tmpDir);
nock_1.default("https://example.com") nock_1.default("https://example.com")
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`) .get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`)); .replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true)); await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
t.assert(toolcache.find("CodeQL", "0.0.0-20200601")); t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
nock_1.default("https://example.com") nock_1.default("https://example.com")
.get(`/download/codeql-bundle-20200610/codeql-bundle.tar.gz`) .get(`/download/codeql-bundle-20200610/codeql-bundle.tar.gz`)
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`)); .replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200610/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true)); await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200610/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
t.assert(toolcache.find("CodeQL", "0.0.0-20200610")); t.assert(toolcache.find("CodeQL", "0.0.0-20200610"));
}); });
}); });
ava_1.default("don't download codeql bundle cache with pinned different version cached", async (t) => { ava_1.default("don't download codeql bundle cache with pinned different version cached", async (t) => {
await util.withTmpDir(async (tmpDir) => { await util.withTmpDir(async (tmpDir) => {
util.setupActionsVars(tmpDir, tmpDir);
nock_1.default("https://example.com") nock_1.default("https://example.com")
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`) .get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`)); .replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true)); await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
t.assert(toolcache.find("CodeQL", "0.0.0-20200601")); t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true)); await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
const cachedVersions = toolcache.findAllVersions("CodeQL"); const cachedVersions = toolcache.findAllVersions("CodeQL");
t.is(cachedVersions.length, 1); t.is(cachedVersions.length, 1);
}); });
}); });
ava_1.default("download codeql bundle cache with different version cached (not pinned)", async (t) => { ava_1.default("download codeql bundle cache with different version cached (not pinned)", async (t) => {
await util.withTmpDir(async (tmpDir) => { await util.withTmpDir(async (tmpDir) => {
util.setupActionsVars(tmpDir, tmpDir);
nock_1.default("https://example.com") nock_1.default("https://example.com")
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`) .get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`)); .replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true)); await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
t.assert(toolcache.find("CodeQL", "0.0.0-20200601")); t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
const platform = process.platform === "win32" const platform = process.platform === "win32"
? "win64" ? "win64"
@@ -84,17 +88,18 @@ ava_1.default("download codeql bundle cache with different version cached (not p
nock_1.default("https://github.com") nock_1.default("https://github.com")
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`) .get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`)
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`)); .replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true)); await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
const cachedVersions = toolcache.findAllVersions("CodeQL"); const cachedVersions = toolcache.findAllVersions("CodeQL");
t.is(cachedVersions.length, 2); t.is(cachedVersions.length, 2);
}); });
}); });
ava_1.default('download codeql bundle cache with pinned different version cached if "latests" tools specified', async (t) => { ava_1.default('download codeql bundle cache with pinned different version cached if "latest" tools specified', async (t) => {
await util.withTmpDir(async (tmpDir) => { await util.withTmpDir(async (tmpDir) => {
util.setupActionsVars(tmpDir, tmpDir);
nock_1.default("https://example.com") nock_1.default("https://example.com")
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`) .get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`)); .replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true)); await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
t.assert(toolcache.find("CodeQL", "0.0.0-20200601")); t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
const platform = process.platform === "win32" const platform = process.platform === "win32"
? "win64" ? "win64"
@@ -104,13 +109,14 @@ ava_1.default('download codeql bundle cache with pinned different version cached
nock_1.default("https://github.com") nock_1.default("https://github.com")
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`) .get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`)
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`)); .replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
await codeql.setupCodeQL("latest", sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true)); await codeql.setupCodeQL("latest", sampleApiDetails, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
const cachedVersions = toolcache.findAllVersions("CodeQL"); const cachedVersions = toolcache.findAllVersions("CodeQL");
t.is(cachedVersions.length, 2); t.is(cachedVersions.length, 2);
}); });
}); });
ava_1.default("download codeql bundle from github ae endpoint", async (t) => { ava_1.default("download codeql bundle from github ae endpoint", async (t) => {
await util.withTmpDir(async (tmpDir) => { await util.withTmpDir(async (tmpDir) => {
util.setupActionsVars(tmpDir, tmpDir);
const bundleAssetID = 10; const bundleAssetID = 10;
const platform = process.platform === "win32" const platform = process.platform === "win32"
? "win64" ? "win64"
@@ -131,7 +137,7 @@ ava_1.default("download codeql bundle from github ae endpoint", async (t) => {
nock_1.default("https://example.githubenterprise.com") nock_1.default("https://example.githubenterprise.com")
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/${codeQLBundleName}`) .get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/${codeQLBundleName}`)
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`)); .replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
await codeql.setupCodeQL(undefined, sampleGHAEApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.GHAE, logging_1.getRunnerLogger(true)); await codeql.setupCodeQL(undefined, sampleGHAEApiDetails, tmpDir, "runner", util.GitHubVariant.GHAE, logging_1.getRunnerLogger(true));
const cachedVersions = toolcache.findAllVersions("CodeQL"); const cachedVersions = toolcache.findAllVersions("CodeQL");
t.is(cachedVersions.length, 1); t.is(cachedVersions.length, 1);
}); });
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,3 +1,3 @@
{ {
"bundleVersion": "codeql-bundle-20210308" "bundleVersion": "codeql-bundle-20210319"
} }
+1 -1
View File
@@ -67,7 +67,7 @@ async function run() {
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("init", "starting", startedAt, workflowErrors)))) { if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("init", "starting", startedAt, workflowErrors)))) {
return; return;
} }
const initCodeQLResult = await init_1.initCodeQL(actionsUtil.getOptionalInput("tools"), apiDetails, actionsUtil.getTemporaryDirectory(), actionsUtil.getRequiredEnvParam("RUNNER_TOOL_CACHE"), "actions", gitHubVersion.type, logger); const initCodeQLResult = await init_1.initCodeQL(actionsUtil.getOptionalInput("tools"), apiDetails, actionsUtil.getTemporaryDirectory(), "actions", gitHubVersion.type, logger);
codeql = initCodeQLResult.codeql; codeql = initCodeQLResult.codeql;
toolsVersion = initCodeQLResult.toolsVersion; toolsVersion = initCodeQLResult.toolsVersion;
config = await init_1.initConfig(actionsUtil.getOptionalInput("languages"), actionsUtil.getOptionalInput("queries"), actionsUtil.getOptionalInput("config-file"), repository_1.parseRepositoryNwo(actionsUtil.getRequiredEnvParam("GITHUB_REPOSITORY")), actionsUtil.getTemporaryDirectory(), actionsUtil.getRequiredEnvParam("RUNNER_TOOL_CACHE"), codeql, actionsUtil.getRequiredEnvParam("GITHUB_WORKSPACE"), gitHubVersion, apiDetails, logger); config = await init_1.initConfig(actionsUtil.getOptionalInput("languages"), actionsUtil.getOptionalInput("queries"), actionsUtil.getOptionalInput("config-file"), repository_1.parseRepositoryNwo(actionsUtil.getRequiredEnvParam("GITHUB_REPOSITORY")), actionsUtil.getTemporaryDirectory(), actionsUtil.getRequiredEnvParam("RUNNER_TOOL_CACHE"), codeql, actionsUtil.getRequiredEnvParam("GITHUB_WORKSPACE"), gitHubVersion, apiDetails, logger);
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"init-action.js","sourceRoot":"","sources":["../src/init-action.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAEtC,4DAA8C;AAG9C,iCAMgB;AAChB,2CAAuC;AACvC,uCAA6C;AAC7C,6CAAkD;AAClD,iCAAqE;AAsBrE,KAAK,UAAU,uBAAuB,CACpC,SAAe,EACf,MAA0B,EAC1B,YAAoB;;IAEpB,MAAM,gBAAgB,GAAG,MAAM,WAAW,CAAC,sBAAsB,CAC/D,MAAM,EACN,SAAS,EACT,SAAS,CACV,CAAC;IAEF,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7C,MAAM,iBAAiB,GAAG,WAAW,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACpE,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/D,MAAM,WAAW,GAAG,CAAC,MAAM,CAAC,iBAAiB,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CACvE,GAAG,CACJ,CAAC;IACF,MAAM,qBAAqB,GAAG,MAAM,CAAC,iBAAiB,CACpD,yBAAyB,CAC1B;QACC,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,EAAE,CAAC;IAEP,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,YAAY,SAAG,WAAW,CAAC,gBAAgB,CAAC,SAAS,CAAC,0CAAE,IAAI,EAAE,CAAC;IACnE,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;QAC9D,OAAO,CA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AO,EAAE;gBAChC,MAAM,0BAAmB,CACvB,mBAAmB,EACnB,SAAS,EACT,MAAM,EACN,MAAM,EACN,YAAY,CACb,CAAC;aACH;SACF;QAED,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;KACjD;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC9B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnB,MAAM,WAAW,CAAC,gBAAgB,CAChC,MAAM,WAAW,CAAC,sBAAsB,CACtC,MAAM,EACN,SAAS,EACT,SAAS,EACT,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,KAAK,CACZ,CACF,CAAC;QACF,OAAO;KACR;IACD,MAAM,uBAAuB,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;AACjE,CAAC;AAED,KAAK,UAAU,UAAU;IACvB,IAAI;QACF,MAAM,GAAG,EAAE,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,uBAAuB,KAAK,EAAE,CAAC,CAAC;QAC/C,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"} {"version":3,"file":"init-action.js","sourceRoot":"","sources":["../src/init-action.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAEtC,4DAA8C;AAG9C,iCAMgB;AAChB,2CAAuC;AACvC,uCAA6C;AAC7C,6CAAkD;AAClD,iCAAqE;AAsBrE,KAAK,UAAU,uBAAuB,CACpC,SAAe,EACf,MAA0B,EAC1B,YAAoB;;IAEpB,MAAM,gBAAgB,GAAG,MAAM,WAAW,CAAC,sBAAsB,CAC/D,MAAM,EACN,SAAS,EACT,SAAS,CACV,CAAC;IAEF,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,G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QACF,MAAM,GAAG,EAAE,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,uBAAuB,KAAK,EAAE,CAAC,CAAC;QAC/C,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
Generated
+3 -3
View File
@@ -16,9 +16,9 @@ const codeql_1 = require("./codeql");
const configUtils = __importStar(require("./config-utils")); const configUtils = __importStar(require("./config-utils"));
const tracer_config_1 = require("./tracer-config"); const tracer_config_1 = require("./tracer-config");
const util = __importStar(require("./util")); const util = __importStar(require("./util"));
async function initCodeQL(codeqlURL, apiDetails, tempDir, toolsDir, mode, variant, logger) { async function initCodeQL(codeqlURL, apiDetails, tempDir, mode, variant, logger) {
logger.startGroup("Setup CodeQL tools"); logger.startGroup("Setup CodeQL tools");
const { codeql, toolsVersion } = await codeql_1.setupCodeQL(codeqlURL, apiDetails, tempDir, toolsDir, mode, variant, logger); const { codeql, toolsVersion } = await codeql_1.setupCodeQL(codeqlURL, apiDetails, tempDir, mode, variant, logger);
await codeql.printVersion(); await codeql.printVersion();
logger.endGroup(); logger.endGroup();
return { codeql, toolsVersion }; return { codeql, toolsVersion };
@@ -129,7 +129,7 @@ exports.injectWindowsTracer = injectWindowsTracer;
async function installPythonDeps(codeql, logger) { async function installPythonDeps(codeql, logger) {
logger.startGroup("Setup Python dependencies"); logger.startGroup("Setup Python dependencies");
const scriptsFolder = path.resolve(__dirname, "../python-setup"); const scriptsFolder = path.resolve(__dirname, "../python-setup");
// Setup tools on the Github hosted runners // Setup tools on the GitHub hosted runners
if (process.env["ImageOS"] !== undefined) { if (process.env["ImageOS"] !== undefined) {
try { try {
if (process.platform === "win32") { if (process.platform === "win32") {
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,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AI,EAAE,CAAC;SACX;KACF;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,CAAC,QAAQ,EAAE,CAAC;QAClB,MAAM,CAAC,OAAO,CACZ,+IAA+I,CAChJ,CAAC;QACF,OAAO;KACR;IACD,MAAM,CAAC,QAAQ,EAAE,CAAC;AACpB,CAAC;AAnDD,8CAmDC"}
Generated
+8 -6
View File
@@ -100,6 +100,7 @@ program
try { try {
const tempDir = getTempDir(cmd.tempDir); const tempDir = getTempDir(cmd.tempDir);
const toolsDir = getToolsDir(cmd.toolsDir); const toolsDir = getToolsDir(cmd.toolsDir);
util_1.setupActionsVars(tempDir, toolsDir);
// Wipe the temp dir // Wipe the temp dir
logger.info(`Cleaning temp directory ${tempDir}`); logger.info(`Cleaning temp directory ${tempDir}`);
fs.rmdirSync(tempDir, { recursive: true }); fs.rmdirSync(tempDir, { recursive: true });
@@ -108,7 +109,7 @@ program
const apiDetails = { const apiDetails = {
auth, auth,
externalRepoAuth: auth, externalRepoAuth: auth,
url: util_1.parseGithubUrl(cmd.githubUrl), url: util_1.parseGitHubUrl(cmd.githubUrl),
}; };
const gitHubVersion = await util_1.getGitHubVersion(apiDetails); const gitHubVersion = await util_1.getGitHubVersion(apiDetails);
util_1.checkGitHubVersionInRange(gitHubVersion, "runner", logger); util_1.checkGitHubVersionInRange(gitHubVersion, "runner", logger);
@@ -117,7 +118,7 @@ program
codeql = codeql_1.getCodeQL(cmd.codeqlPath); codeql = codeql_1.getCodeQL(cmd.codeqlPath);
} }
else { else {
codeql = (await init_1.initCodeQL(undefined, apiDetails, tempDir, toolsDir, "runner", gitHubVersion.type, logger)).codeql; codeql = (await init_1.initCodeQL(undefined, apiDetails, tempDir, "runner", gitHubVersion.type, logger)).codeql;
} }
const config = await init_1.initConfig(cmd.languages, cmd.queries, cmd.configFile, repository_1.parseRepositoryNwo(cmd.repository), tempDir, toolsDir, codeql, cmd.checkoutPath || process.cwd(), gitHubVersion, apiDetails, logger); const config = await init_1.initConfig(cmd.languages, cmd.queries, cmd.configFile, repository_1.parseRepositoryNwo(cmd.repository), tempDir, toolsDir, codeql, cmd.checkoutPath || process.cwd(), gitHubVersion, apiDetails, logger);
const tracerConfig = await init_1.runInit(codeql, config); const tracerConfig = await init_1.runInit(codeql, config);
@@ -179,6 +180,7 @@ program
throw new Error("Config file could not be found at expected location. " + throw new Error("Config file could not be found at expected location. " +
"Was the 'init' command run with the same '--temp-dir' argument as this command."); "Was the 'init' command run with the same '--temp-dir' argument as this command.");
} }
util_1.setupActionsVars(config.tempDir, config.toolCacheDir);
importTracerEnvironment(config); importTracerEnvironment(config);
let language = undefined; let language = undefined;
if (cmd.language !== undefined) { if (cmd.language !== undefined) {
@@ -222,18 +224,18 @@ program
.action(async (cmd) => { .action(async (cmd) => {
const logger = logging_1.getRunnerLogger(cmd.debug); const logger = logging_1.getRunnerLogger(cmd.debug);
try { try {
const tempDir = getTempDir(cmd.tempDir);
const outputDir = cmd.outputDir || path.join(tempDir, "codeql-sarif");
const config = await config_utils_1.getConfig(getTempDir(cmd.tempDir), logger); const config = await config_utils_1.getConfig(getTempDir(cmd.tempDir), logger);
if (config === undefined) { if (config === undefined) {
throw new Error("Config file could not be found at expected location. " + throw new Error("Config file could not be found at expected location. " +
"Was the 'init' command run with the same '--temp-dir' argument as this command."); "Was the 'init' command run with the same '--temp-dir' argument as this command.");
} }
util_1.setupActionsVars(config.tempDir, config.toolCacheDir);
const auth = await util_1.getGitHubAuth(logger, cmd.githubAuth, cmd.githubAuthStdin); const auth = await util_1.getGitHubAuth(logger, cmd.githubAuth, cmd.githubAuthStdin);
const apiDetails = { const apiDetails = {
auth, auth,
url: util_1.parseGithubUrl(cmd.githubUrl), url: util_1.parseGitHubUrl(cmd.githubUrl),
}; };
const outputDir = cmd.outputDir || path.join(config.tempDir, "codeql-sarif");
await analyze_1.runAnalyze(outputDir, util_1.getMemoryFlag(cmd.ram), util_1.getAddSnippetsFlag(cmd.addSnippets), util_1.getThreadsFlag(cmd.threads, logger), config, logger); await analyze_1.runAnalyze(outputDir, util_1.getMemoryFlag(cmd.ram), util_1.getAddSnippetsFlag(cmd.addSnippets), util_1.getThreadsFlag(cmd.threads, logger), config, logger);
if (!cmd.upload) { if (!cmd.upload) {
logger.info("Not uploading results"); logger.info("Not uploading results");
@@ -264,7 +266,7 @@ program
const auth = await util_1.getGitHubAuth(logger, cmd.githubAuth, cmd.githubAuthStdin); const auth = await util_1.getGitHubAuth(logger, cmd.githubAuth, cmd.githubAuthStdin);
const apiDetails = { const apiDetails = {
auth, auth,
url: util_1.parseGithubUrl(cmd.githubUrl), url: util_1.parseGitHubUrl(cmd.githubUrl),
}; };
try { try {
const gitHubVersion = await util_1.getGitHubVersion(apiDetails); const gitHubVersion = await util_1.getGitHubVersion(apiDetails);
+1 -1
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -141,9 +141,9 @@ async function getCombinedTracerConfig(config, codeql) {
else if (process.platform !== "win32") { else if (process.platform !== "win32") {
mainTracerConfig.env["LD_PRELOAD"] = path.join(codeQLDir, "tools", "linux64", "${LIB}trace.so"); mainTracerConfig.env["LD_PRELOAD"] = path.join(codeQLDir, "tools", "linux64", "${LIB}trace.so");
} }
// On macos it's necessary to prefix the build command with the runner exectuable // On macos it's necessary to prefix the build command with the runner executable
// on order to trace when System Integrity Protection is enabled. // on order to trace when System Integrity Protection is enabled.
// The exectuable also exists and works for other platforms so we output this env // The executable also exists and works for other platforms so we output this env
// var with a path to the runner regardless so it's always available. // var with a path to the runner regardless so it's always available.
const runnerExeName = process.platform === "win32" ? "runner.exe" : "runner"; const runnerExeName = process.platform === "win32" ? "runner.exe" : "runner";
mainTracerConfig.env["CODEQL_RUNNER"] = path.join(mainTracerConfig.env["CODEQL_DIST"], "tools", mainTracerConfig.env["CODEQL_PLATFORM"], runnerExeName); mainTracerConfig.env["CODEQL_RUNNER"] = path.join(mainTracerConfig.env["CODEQL_DIST"], "tools", mainTracerConfig.env["CODEQL_PLATFORM"], runnerExeName);
+14 -1
View File
@@ -117,7 +117,20 @@ function getSarifFilePaths(sarifPath) {
// Counts the number of results in the given SARIF file // Counts the number of results in the given SARIF file
function countResultsInSarif(sarif) { function countResultsInSarif(sarif) {
let numResults = 0; let numResults = 0;
for (const run of JSON.parse(sarif).runs) { let parsedSarif;
try {
parsedSarif = JSON.parse(sarif);
}
catch (e) {
throw new Error(`Invalid SARIF. JSON syntax error: ${e.message}`);
}
if (!Array.isArray(parsedSarif.runs)) {
throw new Error("Invalid SARIF. Missing 'runs' array.");
}
for (const run of parsedSarif.runs) {
if (!Array.isArray(run.results)) {
throw new Error("Invalid SARIF. Missing 'results' array in run.");
}
numResults += run.results.length; numResults += run.results.length;
} }
return numResults; return numResults;
File diff suppressed because one or more lines are too long
Generated
+19 -3
View File
@@ -171,7 +171,7 @@ exports.getCodeQLDatabasePath = getCodeQLDatabasePath;
* Parses user input of a github.com or GHES URL to a canonical form. * Parses user input of a github.com or GHES URL to a canonical form.
* Removes any API prefix or suffix if one is present. * Removes any API prefix or suffix if one is present.
*/ */
function parseGithubUrl(inputUrl) { function parseGitHubUrl(inputUrl) {
const originalUrl = inputUrl; const originalUrl = inputUrl;
if (inputUrl.indexOf("://") === -1) { if (inputUrl.indexOf("://") === -1) {
inputUrl = `https://${inputUrl}`; inputUrl = `https://${inputUrl}`;
@@ -205,7 +205,7 @@ function parseGithubUrl(inputUrl) {
} }
return url.toString(); return url.toString();
} }
exports.parseGithubUrl = parseGithubUrl; exports.parseGitHubUrl = parseGitHubUrl;
const GITHUB_ENTERPRISE_VERSION_HEADER = "x-github-enterprise-version"; const GITHUB_ENTERPRISE_VERSION_HEADER = "x-github-enterprise-version";
const CODEQL_ACTION_WARNED_ABOUT_VERSION_ENV_VAR = "CODEQL_ACTION_WARNED_ABOUT_VERSION"; const CODEQL_ACTION_WARNED_ABOUT_VERSION_ENV_VAR = "CODEQL_ACTION_WARNED_ABOUT_VERSION";
let hasBeenWarnedAboutVersion = false; let hasBeenWarnedAboutVersion = false;
@@ -217,7 +217,7 @@ var GitHubVariant;
})(GitHubVariant = exports.GitHubVariant || (exports.GitHubVariant = {})); })(GitHubVariant = exports.GitHubVariant || (exports.GitHubVariant = {}));
async function getGitHubVersion(apiDetails) { async function getGitHubVersion(apiDetails) {
// We can avoid making an API request in the standard dotcom case // We can avoid making an API request in the standard dotcom case
if (parseGithubUrl(apiDetails.url) === exports.GITHUB_DOTCOM_URL) { if (parseGitHubUrl(apiDetails.url) === exports.GITHUB_DOTCOM_URL) {
return { type: GitHubVariant.DOTCOM }; return { type: GitHubVariant.DOTCOM };
} }
// Doesn't strictly have to be the meta endpoint as we're only // Doesn't strictly have to be the meta endpoint as we're only
@@ -320,4 +320,20 @@ async function getGitHubAuth(logger, githubAuth, fromStdIn, readable = process.s
throw new Error("No GitHub authentication token was specified. Please provide a token via the GITHUB_TOKEN environment variable, or by adding the `--github-auth-stdin` flag and passing the token via standard input."); throw new Error("No GitHub authentication token was specified. Please provide a token via the GITHUB_TOKEN environment variable, or by adding the `--github-auth-stdin` flag and passing the token via standard input.");
} }
exports.getGitHubAuth = getGitHubAuth; exports.getGitHubAuth = getGitHubAuth;
// Sets environment variables that make using some libraries designed for
// use only on actions safe to use outside of actions.
//
// Obviously this is not a tremendously great thing we're doing and it
// would be better to write our own implementation of libraries to use
// outside of actions. For now this works well enough.
//
// Currently this list of libraries that is deemed to now be safe includes:
// - @actions/tool-cache
//
// Also see "queries/unguarded-action-lib.ql".
function setupActionsVars(tempDir, toolsDir) {
process.env["RUNNER_TEMP"] = tempDir;
process.env["RUNNER_TOOL_CACHE"] = toolsDir;
}
exports.setupActionsVars = setupActionsVars;
//# sourceMappingURL=util.js.map //# sourceMappingURL=util.js.map
+1 -1
View File
File diff suppressed because one or more lines are too long
+17 -17
View File
@@ -102,27 +102,27 @@ ava_1.default("getExtraOptionsEnvParam() fails on invalid JSON", (t) => {
t.throws(util.getExtraOptionsEnvParam); t.throws(util.getExtraOptionsEnvParam);
process.env.CODEQL_ACTION_EXTRA_OPTIONS = origExtraOptions; process.env.CODEQL_ACTION_EXTRA_OPTIONS = origExtraOptions;
}); });
ava_1.default("parseGithubUrl", (t) => { ava_1.default("parseGitHubUrl", (t) => {
t.deepEqual(util.parseGithubUrl("github.com"), "https://github.com"); t.deepEqual(util.parseGitHubUrl("github.com"), "https://github.com");
t.deepEqual(util.parseGithubUrl("https://github.com"), "https://github.com"); t.deepEqual(util.parseGitHubUrl("https://github.com"), "https://github.com");
t.deepEqual(util.parseGithubUrl("https://api.github.com"), "https://github.com"); t.deepEqual(util.parseGitHubUrl("https://api.github.com"), "https://github.com");
t.deepEqual(util.parseGithubUrl("https://github.com/foo/bar"), "https://github.com"); t.deepEqual(util.parseGitHubUrl("https://github.com/foo/bar"), "https://github.com");
t.deepEqual(util.parseGithubUrl("github.example.com"), "https://github.example.com/"); t.deepEqual(util.parseGitHubUrl("github.example.com"), "https://github.example.com/");
t.deepEqual(util.parseGithubUrl("https://github.example.com"), "https://github.example.com/"); t.deepEqual(util.parseGitHubUrl("https://github.example.com"), "https://github.example.com/");
t.deepEqual(util.parseGithubUrl("https://api.github.example.com"), "https://github.example.com/"); t.deepEqual(util.parseGitHubUrl("https://api.github.example.com"), "https://github.example.com/");
t.deepEqual(util.parseGithubUrl("https://github.example.com/api/v3"), "https://github.example.com/"); t.deepEqual(util.parseGitHubUrl("https://github.example.com/api/v3"), "https://github.example.com/");
t.deepEqual(util.parseGithubUrl("https://github.example.com:1234"), "https://github.example.com:1234/"); t.deepEqual(util.parseGitHubUrl("https://github.example.com:1234"), "https://github.example.com:1234/");
t.deepEqual(util.parseGithubUrl("https://api.github.example.com:1234"), "https://github.example.com:1234/"); t.deepEqual(util.parseGitHubUrl("https://api.github.example.com:1234"), "https://github.example.com:1234/");
t.deepEqual(util.parseGithubUrl("https://github.example.com:1234/api/v3"), "https://github.example.com:1234/"); t.deepEqual(util.parseGitHubUrl("https://github.example.com:1234/api/v3"), "https://github.example.com:1234/");
t.deepEqual(util.parseGithubUrl("https://github.example.com/base/path"), "https://github.example.com/base/path/"); t.deepEqual(util.parseGitHubUrl("https://github.example.com/base/path"), "https://github.example.com/base/path/");
t.deepEqual(util.parseGithubUrl("https://github.example.com/base/path/api/v3"), "https://github.example.com/base/path/"); t.deepEqual(util.parseGitHubUrl("https://github.example.com/base/path/api/v3"), "https://github.example.com/base/path/");
t.throws(() => util.parseGithubUrl(""), { t.throws(() => util.parseGitHubUrl(""), {
message: '"" is not a valid URL', message: '"" is not a valid URL',
}); });
t.throws(() => util.parseGithubUrl("ssh://github.com"), { t.throws(() => util.parseGitHubUrl("ssh://github.com"), {
message: '"ssh://github.com" is not a http or https URL', message: '"ssh://github.com" is not a http or https URL',
}); });
t.throws(() => util.parseGithubUrl("http:///::::433"), { t.throws(() => util.parseGitHubUrl("http:///::::433"), {
message: '"http:///::::433" is not a valid URL', message: '"http:///::::433" is not a valid URL',
}); });
}); });
+42
View File
@@ -19,6 +19,21 @@ predicate isSafeActionLib(string lib) {
lib.matches("@actions/exec/%") lib.matches("@actions/exec/%")
} }
/**
* Matches libraries that are not always safe to use outside of actions
* but can be made so by setting certain environment variables.
*/
predicate isSafeActionLibWithActionsEnvVars(string lib) {
lib = "@actions/tool-cache"
}
/**
* Matches the names of runner commands that set action env vars
*/
predicate commandSetsActionsEnvVars(string commandName) {
commandName = "init" or commandName = "autobuild" or commandName = "analyze"
}
/** /**
* An import from a library that is meant for GitHub Actions and * An import from a library that is meant for GitHub Actions and
* we do not want to be using outside of actions. * we do not want to be using outside of actions.
@@ -45,6 +60,32 @@ class RunnerEntrypoint extends Function {
RunnerEntrypoint() { RunnerEntrypoint() {
getFile().getAbsolutePath().matches("%/runner.ts") getFile().getAbsolutePath().matches("%/runner.ts")
} }
/**
* Does this runner entry point set the RUNNER_TEMP and
* RUNNER_TOOL_CACHE env vars which make some actions libraries
* safe to use outside of actions.
* See "setupActionsVars" in "util.ts".
*/
predicate setsActionsEnvVars() {
// This is matching code of the following format, where "this"
// is the function being passed to the "action" method.
//
// program
// .command("init")
// ...
// .action(async (cmd: InitArgs) => {
// ...
// })
exists(MethodCallExpr actionCall,
MethodCallExpr commandCall |
commandCall.getMethodName() = "command" and
commandCall.getReceiver().(VarAccess).getVariable().getName() = "program" and
commandSetsActionsEnvVars(commandCall.getArgument(0).(StringLiteral).getValue()) and
actionCall.getMethodName() = "action" and
actionCall.getReceiver().getAChildExpr*() = commandCall and
actionCall.getArgument(0).getAChildExpr*() = this)
}
} }
/** /**
@@ -114,6 +155,7 @@ Function calledBy(Function f) {
from VarAccess v, ActionsLibImport actionsLib, RunnerEntrypoint runnerEntry from VarAccess v, ActionsLibImport actionsLib, RunnerEntrypoint runnerEntry
where actionsLib.getAProvidedVariable() = v.getVariable() where actionsLib.getAProvidedVariable() = v.getVariable()
and getAFunctionChildExpr(calledBy*(runnerEntry)) = v and getAFunctionChildExpr(calledBy*(runnerEntry)) = v
and not (isSafeActionLibWithActionsEnvVars(actionsLib.getName()) and runnerEntry.setsActionsEnvVars())
select v, "$@ is imported from $@ and this code can be called from $@", select v, "$@ is imported from $@ and this code can be called from $@",
v, v.getName(), v, v.getName(),
actionsLib, actionsLib.getName(), actionsLib, actionsLib.getName(),
+23 -3
View File
@@ -25,20 +25,40 @@ test("getRef() returns merge PR ref if GITHUB_SHA still checked out", async (t)
process.env["GITHUB_REF"] = expectedRef; process.env["GITHUB_REF"] = expectedRef;
process.env["GITHUB_SHA"] = currentSha; process.env["GITHUB_SHA"] = currentSha;
sinon.stub(actionsutil, "getCommitOid").resolves(currentSha); const callback = sinon.stub(actionsutil, "getCommitOid");
callback.withArgs("HEAD").resolves(currentSha);
const actualRef = await actionsutil.getRef(); const actualRef = await actionsutil.getRef();
t.deepEqual(actualRef, expectedRef); t.deepEqual(actualRef, expectedRef);
callback.restore();
}); });
test("getRef() returns head PR ref if GITHUB_SHA not currently checked out", async (t) => { test("getRef() returns merge PR ref if GITHUB_REF still checked out but sha has changed (actions checkout@v1)", async (t) => {
const expectedRef = "refs/pull/1/merge";
process.env["GITHUB_REF"] = expectedRef;
process.env["GITHUB_SHA"] = "b".repeat(40);
const sha = "a".repeat(40);
const callback = sinon.stub(actionsutil, "getCommitOid");
callback.withArgs("refs/remotes/pull/1/merge").resolves(sha);
callback.withArgs("HEAD").resolves(sha);
const actualRef = await actionsutil.getRef();
t.deepEqual(actualRef, expectedRef);
callback.restore();
});
test("getRef() returns head PR ref if GITHUB_REF no longer checked out", async (t) => {
process.env["GITHUB_REF"] = "refs/pull/1/merge"; process.env["GITHUB_REF"] = "refs/pull/1/merge";
process.env["GITHUB_SHA"] = "a".repeat(40); process.env["GITHUB_SHA"] = "a".repeat(40);
sinon.stub(actionsutil, "getCommitOid").resolves("b".repeat(40)); const callback = sinon.stub(actionsutil, "getCommitOid");
callback.withArgs("refs/pull/1/merge").resolves("a".repeat(40));
callback.withArgs("HEAD").resolves("b".repeat(40));
const actualRef = await actionsutil.getRef(); const actualRef = await actionsutil.getRef();
t.deepEqual(actualRef, "refs/pull/1/head"); t.deepEqual(actualRef, "refs/pull/1/head");
callback.restore();
}); });
test("getAnalysisKey() when a local run", async (t) => { test("getAnalysisKey() when a local run", async (t) => {
+41 -23
View File
@@ -75,7 +75,7 @@ export function prepareLocalRunEnvironment() {
/** /**
* Gets the SHA of the commit that is currently checked out. * Gets the SHA of the commit that is currently checked out.
*/ */
export const getCommitOid = async function (): Promise<string> { export const getCommitOid = async function (ref = "HEAD"): Promise<string> {
// Try to use git to get the current commit SHA. If that fails then // Try to use git to get the current commit SHA. If that fails then
// log but otherwise silently fall back to using the SHA from the environment. // log but otherwise silently fall back to using the SHA from the environment.
// The only time these two values will differ is during analysis of a PR when // The only time these two values will differ is during analysis of a PR when
@@ -87,7 +87,7 @@ export const getCommitOid = async function (): Promise<string> {
let commitOid = ""; let commitOid = "";
await new toolrunner.ToolRunner( await new toolrunner.ToolRunner(
await safeWhich.safeWhich("git"), await safeWhich.safeWhich("git"),
["rev-parse", "HEAD"], ["rev-parse", ref],
{ {
silent: true, silent: true,
listeners: { listeners: {
@@ -396,7 +396,7 @@ export function getWorkflowRunID(): number {
} }
/** /**
* Get the analysis key paramter for the current job. * Get the analysis key parameter for the current job.
* *
* This will combine the workflow path and current job name. * This will combine the workflow path and current job name.
* Computing this the first time requires making requests to * Computing this the first time requires making requests to
@@ -425,19 +425,35 @@ export async function getRef(): Promise<string> {
// Will be in the form "refs/heads/master" on a push event // Will be in the form "refs/heads/master" on a push event
// or in the form "refs/pull/N/merge" on a pull_request event // or in the form "refs/pull/N/merge" on a pull_request event
const ref = getRequiredEnvParam("GITHUB_REF"); const ref = getRequiredEnvParam("GITHUB_REF");
const sha = getRequiredEnvParam("GITHUB_SHA");
// For pull request refs we want to detect whether the workflow // For pull request refs we want to detect whether the workflow
// has run `git checkout HEAD^2` to analyze the 'head' ref rather // has run `git checkout HEAD^2` to analyze the 'head' ref rather
// than the 'merge' ref. If so, we want to convert the ref that // than the 'merge' ref. If so, we want to convert the ref that
// we report back. // we report back.
const pull_ref_regex = /refs\/pull\/(\d+)\/merge/; const pull_ref_regex = /refs\/pull\/(\d+)\/merge/;
const checkoutSha = await getCommitOid(); if (!pull_ref_regex.test(ref)) {
return ref;
}
if ( const head = await getCommitOid("HEAD");
pull_ref_regex.test(ref) &&
checkoutSha !== getRequiredEnvParam("GITHUB_SHA") // in actions/checkout@v2 we can check if git rev-parse HEAD == GITHUB_SHA
) { // in actions/checkout@v1 this may not be true as it checks out the repository
return ref.replace(pull_ref_regex, "refs/pull/$1/head"); // using GITHUB_REF. There is a subtle race condition where
// git rev-parse GITHUB_REF != GITHUB_SHA, so we must check
// git git-parse GITHUB_REF == git rev-parse HEAD instead.
const hasChangedRef =
sha !== head &&
(await getCommitOid(ref.replace(/^refs\/pull\//, "refs/remotes/pull/"))) !==
head;
if (hasChangedRef) {
const newRef = ref.replace(pull_ref_regex, "refs/pull/$1/head");
core.debug(
`No longer on merge commit, rewriting ref from ${ref} to ${newRef}.`
);
return newRef;
} else { } else {
return ref; return ref;
} }
@@ -556,12 +572,22 @@ export async function createStatusReportBase(
interface HTTPError { interface HTTPError {
status: number; status: number;
message?: string;
} }
function isHTTPError(arg: any): arg is HTTPError { function isHTTPError(arg: any): arg is HTTPError {
return arg?.status !== undefined && Number.isInteger(arg.status); return arg?.status !== undefined && Number.isInteger(arg.status);
} }
const GENERIC_403_MSG =
"The repo on which this action is running is not opted-in to CodeQL code scanning.";
const GENERIC_404_MSG =
"Not authorized to used the CodeQL code scanning feature on this repo.";
const OUT_OF_DATE_MSG =
"CodeQL Action is out-of-date. Please upgrade to the latest version of codeql-action.";
const INCOMPATIBLE_MSG =
"CodeQL Action version is incompatible with the code scanning endpoint. Please update to a compatible version of codeql-action.";
/** /**
* Send a status report to the code_scanning/analysis/status endpoint. * Send a status report to the code_scanning/analysis/status endpoint.
* *
@@ -598,32 +624,24 @@ export async function sendStatusReport<S extends StatusReportBase>(
return true; return true;
} catch (e) { } catch (e) {
console.log(e);
if (isHTTPError(e)) { if (isHTTPError(e)) {
switch (e.status) { switch (e.status) {
case 403: case 403:
core.setFailed( core.setFailed(e.message || GENERIC_403_MSG);
"The repo on which this action is running is not opted-in to CodeQL code scanning."
);
return false; return false;
case 404: case 404:
core.setFailed( core.setFailed(GENERIC_404_MSG);
"Not authorized to used the CodeQL code scanning feature on this repo."
);
return false; return false;
case 422: case 422:
// schema incompatibility when reporting status // schema incompatibility when reporting status
// this means that this action version is no longer compatible with the API // this means that this action version is no longer compatible with the API
// we still want to continue as it is likely the analysis endpoint will work // we still want to continue as it is likely the analysis endpoint will work
if (getRequiredEnvParam("GITHUB_SERVER_URL") !== GITHUB_DOTCOM_URL) { if (getRequiredEnvParam("GITHUB_SERVER_URL") !== GITHUB_DOTCOM_URL) {
core.debug( core.debug(INCOMPATIBLE_MSG);
"CodeQL Action version is incompatible with the code scanning endpoint. Please update to a compatible version of codeql-action."
);
} else { } else {
core.debug( core.debug(OUT_OF_DATE_MSG);
"CodeQL Action is out-of-date. Please upgrade to the latest version of codeql-action."
);
} }
return true; return true;
} }
} }
@@ -631,7 +649,7 @@ export async function sendStatusReport<S extends StatusReportBase>(
// something else has gone wrong and the request/response will be logged by octokit // something else has gone wrong and the request/response will be logged by octokit
// it's possible this is a transient error and we should continue scanning // it's possible this is a transient error and we should continue scanning
core.error( core.error(
"An unexpected error occured when sending code scanning status report." "An unexpected error occurred when sending code scanning status report."
); );
return true; return true;
} }
+1 -1
View File
@@ -34,7 +34,7 @@ export function printPathFiltersWarning(
!config.languages.every(isInterpretedLanguage) !config.languages.every(isInterpretedLanguage)
) { ) {
logger.warning( logger.warning(
'The "paths"/"paths-ignore" fields of the config only have effect for Javascript and Python' 'The "paths"/"paths-ignore" fields of the config only have effect for JavaScript and Python'
); );
} }
} }
+13 -11
View File
@@ -24,6 +24,8 @@ const sampleGHAEApiDetails = {
test("download codeql bundle cache", async (t) => { test("download codeql bundle cache", async (t) => {
await util.withTmpDir(async (tmpDir) => { await util.withTmpDir(async (tmpDir) => {
util.setupActionsVars(tmpDir, tmpDir);
const versions = ["20200601", "20200610"]; const versions = ["20200601", "20200610"];
for (let i = 0; i < versions.length; i++) { for (let i = 0; i < versions.length; i++) {
@@ -40,7 +42,6 @@ test("download codeql bundle cache", async (t) => {
`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`, `https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`,
sampleApiDetails, sampleApiDetails,
tmpDir, tmpDir,
tmpDir,
"runner", "runner",
util.GitHubVariant.DOTCOM, util.GitHubVariant.DOTCOM,
getRunnerLogger(true) getRunnerLogger(true)
@@ -57,6 +58,8 @@ test("download codeql bundle cache", async (t) => {
test("download codeql bundle cache explicitly requested with pinned different version cached", async (t) => { test("download codeql bundle cache explicitly requested with pinned different version cached", async (t) => {
await util.withTmpDir(async (tmpDir) => { await util.withTmpDir(async (tmpDir) => {
util.setupActionsVars(tmpDir, tmpDir);
nock("https://example.com") nock("https://example.com")
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`) .get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
.replyWithFile( .replyWithFile(
@@ -68,7 +71,6 @@ test("download codeql bundle cache explicitly requested with pinned different ve
"https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", "https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz",
sampleApiDetails, sampleApiDetails,
tmpDir, tmpDir,
tmpDir,
"runner", "runner",
util.GitHubVariant.DOTCOM, util.GitHubVariant.DOTCOM,
getRunnerLogger(true) getRunnerLogger(true)
@@ -87,7 +89,6 @@ test("download codeql bundle cache explicitly requested with pinned different ve
"https://example.com/download/codeql-bundle-20200610/codeql-bundle.tar.gz", "https://example.com/download/codeql-bundle-20200610/codeql-bundle.tar.gz",
sampleApiDetails, sampleApiDetails,
tmpDir, tmpDir,
tmpDir,
"runner", "runner",
util.GitHubVariant.DOTCOM, util.GitHubVariant.DOTCOM,
getRunnerLogger(true) getRunnerLogger(true)
@@ -99,6 +100,8 @@ test("download codeql bundle cache explicitly requested with pinned different ve
test("don't download codeql bundle cache with pinned different version cached", async (t) => { test("don't download codeql bundle cache with pinned different version cached", async (t) => {
await util.withTmpDir(async (tmpDir) => { await util.withTmpDir(async (tmpDir) => {
util.setupActionsVars(tmpDir, tmpDir);
nock("https://example.com") nock("https://example.com")
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`) .get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
.replyWithFile( .replyWithFile(
@@ -110,7 +113,6 @@ test("don't download codeql bundle cache with pinned different version cached",
"https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", "https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz",
sampleApiDetails, sampleApiDetails,
tmpDir, tmpDir,
tmpDir,
"runner", "runner",
util.GitHubVariant.DOTCOM, util.GitHubVariant.DOTCOM,
getRunnerLogger(true) getRunnerLogger(true)
@@ -122,7 +124,6 @@ test("don't download codeql bundle cache with pinned different version cached",
undefined, undefined,
sampleApiDetails, sampleApiDetails,
tmpDir, tmpDir,
tmpDir,
"runner", "runner",
util.GitHubVariant.DOTCOM, util.GitHubVariant.DOTCOM,
getRunnerLogger(true) getRunnerLogger(true)
@@ -136,6 +137,8 @@ test("don't download codeql bundle cache with pinned different version cached",
test("download codeql bundle cache with different version cached (not pinned)", async (t) => { test("download codeql bundle cache with different version cached (not pinned)", async (t) => {
await util.withTmpDir(async (tmpDir) => { await util.withTmpDir(async (tmpDir) => {
util.setupActionsVars(tmpDir, tmpDir);
nock("https://example.com") nock("https://example.com")
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`) .get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
.replyWithFile( .replyWithFile(
@@ -147,7 +150,6 @@ test("download codeql bundle cache with different version cached (not pinned)",
"https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", "https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz",
sampleApiDetails, sampleApiDetails,
tmpDir, tmpDir,
tmpDir,
"runner", "runner",
util.GitHubVariant.DOTCOM, util.GitHubVariant.DOTCOM,
getRunnerLogger(true) getRunnerLogger(true)
@@ -174,7 +176,6 @@ test("download codeql bundle cache with different version cached (not pinned)",
undefined, undefined,
sampleApiDetails, sampleApiDetails,
tmpDir, tmpDir,
tmpDir,
"runner", "runner",
util.GitHubVariant.DOTCOM, util.GitHubVariant.DOTCOM,
getRunnerLogger(true) getRunnerLogger(true)
@@ -186,8 +187,10 @@ test("download codeql bundle cache with different version cached (not pinned)",
}); });
}); });
test('download codeql bundle cache with pinned different version cached if "latests" tools specified', async (t) => { test('download codeql bundle cache with pinned different version cached if "latest" tools specified', async (t) => {
await util.withTmpDir(async (tmpDir) => { await util.withTmpDir(async (tmpDir) => {
util.setupActionsVars(tmpDir, tmpDir);
nock("https://example.com") nock("https://example.com")
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`) .get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
.replyWithFile( .replyWithFile(
@@ -199,7 +202,6 @@ test('download codeql bundle cache with pinned different version cached if "late
"https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", "https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz",
sampleApiDetails, sampleApiDetails,
tmpDir, tmpDir,
tmpDir,
"runner", "runner",
util.GitHubVariant.DOTCOM, util.GitHubVariant.DOTCOM,
getRunnerLogger(true) getRunnerLogger(true)
@@ -227,7 +229,6 @@ test('download codeql bundle cache with pinned different version cached if "late
"latest", "latest",
sampleApiDetails, sampleApiDetails,
tmpDir, tmpDir,
tmpDir,
"runner", "runner",
util.GitHubVariant.DOTCOM, util.GitHubVariant.DOTCOM,
getRunnerLogger(true) getRunnerLogger(true)
@@ -241,6 +242,8 @@ test('download codeql bundle cache with pinned different version cached if "late
test("download codeql bundle from github ae endpoint", async (t) => { test("download codeql bundle from github ae endpoint", async (t) => {
await util.withTmpDir(async (tmpDir) => { await util.withTmpDir(async (tmpDir) => {
util.setupActionsVars(tmpDir, tmpDir);
const bundleAssetID = 10; const bundleAssetID = 10;
const platform = const platform =
@@ -280,7 +283,6 @@ test("download codeql bundle from github ae endpoint", async (t) => {
undefined, undefined,
sampleGHAEApiDetails, sampleGHAEApiDetails,
tmpDir, tmpDir,
tmpDir,
"runner", "runner",
util.GitHubVariant.GHAE, util.GitHubVariant.GHAE,
getRunnerLogger(true) getRunnerLogger(true)
-7
View File
@@ -281,17 +281,10 @@ export async function setupCodeQL(
codeqlURL: string | undefined, codeqlURL: string | undefined,
apiDetails: api.GitHubApiDetails, apiDetails: api.GitHubApiDetails,
tempDir: string, tempDir: string,
toolsDir: string,
mode: util.Mode, mode: util.Mode,
variant: util.GitHubVariant, variant: util.GitHubVariant,
logger: Logger logger: Logger
): Promise<{ codeql: CodeQL; toolsVersion: string }> { ): Promise<{ codeql: CodeQL; toolsVersion: string }> {
// Setting these two env vars makes the toolcache code safe to use outside,
// of actions but this is obviously not a great thing we're doing and it would
// be better to write our own implementation to use outside of actions.
process.env["RUNNER_TEMP"] = tempDir;
process.env["RUNNER_TOOL_CACHE"] = toolsDir;
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
// defaults over any pinned cached version. // defaults over any pinned cached version.
+1 -1
View File
@@ -1,3 +1,3 @@
{ {
"bundleVersion": "codeql-bundle-20210308" "bundleVersion": "codeql-bundle-20210319"
} }
-1
View File
@@ -125,7 +125,6 @@ async function run() {
actionsUtil.getOptionalInput("tools"), actionsUtil.getOptionalInput("tools"),
apiDetails, apiDetails,
actionsUtil.getTemporaryDirectory(), actionsUtil.getTemporaryDirectory(),
actionsUtil.getRequiredEnvParam("RUNNER_TOOL_CACHE"),
"actions", "actions",
gitHubVersion.type, gitHubVersion.type,
logger logger
+1 -3
View File
@@ -17,7 +17,6 @@ export async function initCodeQL(
codeqlURL: string | undefined, codeqlURL: string | undefined,
apiDetails: GitHubApiDetails, apiDetails: GitHubApiDetails,
tempDir: string, tempDir: string,
toolsDir: string,
mode: util.Mode, mode: util.Mode,
variant: util.GitHubVariant, variant: util.GitHubVariant,
logger: Logger logger: Logger
@@ -27,7 +26,6 @@ export async function initCodeQL(
codeqlURL, codeqlURL,
apiDetails, apiDetails,
tempDir, tempDir,
toolsDir,
mode, mode,
variant, variant,
logger logger
@@ -194,7 +192,7 @@ export async function installPythonDeps(codeql: CodeQL, logger: Logger) {
const scriptsFolder = path.resolve(__dirname, "../python-setup"); const scriptsFolder = path.resolve(__dirname, "../python-setup");
// Setup tools on the Github hosted runners // Setup tools on the GitHub hosted runners
if (process.env["ImageOS"] !== undefined) { if (process.env["ImageOS"] !== undefined) {
try { try {
if (process.platform === "win32") { if (process.platform === "win32") {
+11 -7
View File
@@ -19,8 +19,9 @@ import {
getGitHubVersion, getGitHubVersion,
getMemoryFlag, getMemoryFlag,
getThreadsFlag, getThreadsFlag,
parseGithubUrl, parseGitHubUrl,
getGitHubAuth, getGitHubAuth,
setupActionsVars,
} from "./util"; } from "./util";
const program = new Command(); const program = new Command();
@@ -149,6 +150,8 @@ program
const tempDir = getTempDir(cmd.tempDir); const tempDir = getTempDir(cmd.tempDir);
const toolsDir = getToolsDir(cmd.toolsDir); const toolsDir = getToolsDir(cmd.toolsDir);
setupActionsVars(tempDir, toolsDir);
// Wipe the temp dir // Wipe the temp dir
logger.info(`Cleaning temp directory ${tempDir}`); logger.info(`Cleaning temp directory ${tempDir}`);
fs.rmdirSync(tempDir, { recursive: true }); fs.rmdirSync(tempDir, { recursive: true });
@@ -163,7 +166,7 @@ program
const apiDetails = { const apiDetails = {
auth, auth,
externalRepoAuth: auth, externalRepoAuth: auth,
url: parseGithubUrl(cmd.githubUrl), url: parseGitHubUrl(cmd.githubUrl),
}; };
const gitHubVersion = await getGitHubVersion(apiDetails); const gitHubVersion = await getGitHubVersion(apiDetails);
@@ -178,7 +181,6 @@ program
undefined, undefined,
apiDetails, apiDetails,
tempDir, tempDir,
toolsDir,
"runner", "runner",
gitHubVersion.type, gitHubVersion.type,
logger logger
@@ -290,6 +292,7 @@ program
"Was the 'init' command run with the same '--temp-dir' argument as this command." "Was the 'init' command run with the same '--temp-dir' argument as this command."
); );
} }
setupActionsVars(config.tempDir, config.toolCacheDir);
importTracerEnvironment(config); importTracerEnvironment(config);
let language: Language | undefined = undefined; let language: Language | undefined = undefined;
if (cmd.language !== undefined) { if (cmd.language !== undefined) {
@@ -380,8 +383,6 @@ program
.action(async (cmd: AnalyzeArgs) => { .action(async (cmd: AnalyzeArgs) => {
const logger = getRunnerLogger(cmd.debug); const logger = getRunnerLogger(cmd.debug);
try { try {
const tempDir = getTempDir(cmd.tempDir);
const outputDir = cmd.outputDir || path.join(tempDir, "codeql-sarif");
const config = await getConfig(getTempDir(cmd.tempDir), logger); const config = await getConfig(getTempDir(cmd.tempDir), logger);
if (config === undefined) { if (config === undefined) {
throw new Error( throw new Error(
@@ -389,6 +390,7 @@ program
"Was the 'init' command run with the same '--temp-dir' argument as this command." "Was the 'init' command run with the same '--temp-dir' argument as this command."
); );
} }
setupActionsVars(config.tempDir, config.toolCacheDir);
const auth = await getGitHubAuth( const auth = await getGitHubAuth(
logger, logger,
@@ -398,9 +400,11 @@ program
const apiDetails = { const apiDetails = {
auth, auth,
url: parseGithubUrl(cmd.githubUrl), url: parseGitHubUrl(cmd.githubUrl),
}; };
const outputDir =
cmd.outputDir || path.join(config.tempDir, "codeql-sarif");
await runAnalyze( await runAnalyze(
outputDir, outputDir,
getMemoryFlag(cmd.ram), getMemoryFlag(cmd.ram),
@@ -482,7 +486,7 @@ program
); );
const apiDetails = { const apiDetails = {
auth, auth,
url: parseGithubUrl(cmd.githubUrl), url: parseGitHubUrl(cmd.githubUrl),
}; };
try { try {
const gitHubVersion = await getGitHubVersion(apiDetails); const gitHubVersion = await getGitHubVersion(apiDetails);
+2 -2
View File
@@ -185,9 +185,9 @@ export async function getCombinedTracerConfig(
); );
} }
// On macos it's necessary to prefix the build command with the runner exectuable // On macos it's necessary to prefix the build command with the runner executable
// on order to trace when System Integrity Protection is enabled. // on order to trace when System Integrity Protection is enabled.
// The exectuable also exists and works for other platforms so we output this env // The executable also exists and works for other platforms so we output this env
// var with a path to the runner regardless so it's always available. // var with a path to the runner regardless so it's always available.
const runnerExeName = process.platform === "win32" ? "runner.exe" : "runner"; const runnerExeName = process.platform === "win32" ? "runner.exe" : "runner";
mainTracerConfig.env["CODEQL_RUNNER"] = path.join( mainTracerConfig.env["CODEQL_RUNNER"] = path.join(
+14 -1
View File
@@ -176,7 +176,20 @@ function getSarifFilePaths(sarifPath: string) {
// Counts the number of results in the given SARIF file // Counts the number of results in the given SARIF file
export function countResultsInSarif(sarif: string): number { export function countResultsInSarif(sarif: string): number {
let numResults = 0; let numResults = 0;
for (const run of JSON.parse(sarif).runs) { let parsedSarif;
try {
parsedSarif = JSON.parse(sarif);
} catch (e) {
throw new Error(`Invalid SARIF. JSON syntax error: ${e.message}`);
}
if (!Array.isArray(parsedSarif.runs)) {
throw new Error("Invalid SARIF. Missing 'runs' array.");
}
for (const run of parsedSarif.runs) {
if (!Array.isArray(run.results)) {
throw new Error("Invalid SARIF. Missing 'results' array in run.");
}
numResults += run.results.length; numResults += run.results.length;
} }
return numResults; return numResults;
+17 -17
View File
@@ -125,62 +125,62 @@ test("getExtraOptionsEnvParam() fails on invalid JSON", (t) => {
process.env.CODEQL_ACTION_EXTRA_OPTIONS = origExtraOptions; process.env.CODEQL_ACTION_EXTRA_OPTIONS = origExtraOptions;
}); });
test("parseGithubUrl", (t) => { test("parseGitHubUrl", (t) => {
t.deepEqual(util.parseGithubUrl("github.com"), "https://github.com"); t.deepEqual(util.parseGitHubUrl("github.com"), "https://github.com");
t.deepEqual(util.parseGithubUrl("https://github.com"), "https://github.com"); t.deepEqual(util.parseGitHubUrl("https://github.com"), "https://github.com");
t.deepEqual( t.deepEqual(
util.parseGithubUrl("https://api.github.com"), util.parseGitHubUrl("https://api.github.com"),
"https://github.com" "https://github.com"
); );
t.deepEqual( t.deepEqual(
util.parseGithubUrl("https://github.com/foo/bar"), util.parseGitHubUrl("https://github.com/foo/bar"),
"https://github.com" "https://github.com"
); );
t.deepEqual( t.deepEqual(
util.parseGithubUrl("github.example.com"), util.parseGitHubUrl("github.example.com"),
"https://github.example.com/" "https://github.example.com/"
); );
t.deepEqual( t.deepEqual(
util.parseGithubUrl("https://github.example.com"), util.parseGitHubUrl("https://github.example.com"),
"https://github.example.com/" "https://github.example.com/"
); );
t.deepEqual( t.deepEqual(
util.parseGithubUrl("https://api.github.example.com"), util.parseGitHubUrl("https://api.github.example.com"),
"https://github.example.com/" "https://github.example.com/"
); );
t.deepEqual( t.deepEqual(
util.parseGithubUrl("https://github.example.com/api/v3"), util.parseGitHubUrl("https://github.example.com/api/v3"),
"https://github.example.com/" "https://github.example.com/"
); );
t.deepEqual( t.deepEqual(
util.parseGithubUrl("https://github.example.com:1234"), util.parseGitHubUrl("https://github.example.com:1234"),
"https://github.example.com:1234/" "https://github.example.com:1234/"
); );
t.deepEqual( t.deepEqual(
util.parseGithubUrl("https://api.github.example.com:1234"), util.parseGitHubUrl("https://api.github.example.com:1234"),
"https://github.example.com:1234/" "https://github.example.com:1234/"
); );
t.deepEqual( t.deepEqual(
util.parseGithubUrl("https://github.example.com:1234/api/v3"), util.parseGitHubUrl("https://github.example.com:1234/api/v3"),
"https://github.example.com:1234/" "https://github.example.com:1234/"
); );
t.deepEqual( t.deepEqual(
util.parseGithubUrl("https://github.example.com/base/path"), util.parseGitHubUrl("https://github.example.com/base/path"),
"https://github.example.com/base/path/" "https://github.example.com/base/path/"
); );
t.deepEqual( t.deepEqual(
util.parseGithubUrl("https://github.example.com/base/path/api/v3"), util.parseGitHubUrl("https://github.example.com/base/path/api/v3"),
"https://github.example.com/base/path/" "https://github.example.com/base/path/"
); );
t.throws(() => util.parseGithubUrl(""), { t.throws(() => util.parseGitHubUrl(""), {
message: '"" is not a valid URL', message: '"" is not a valid URL',
}); });
t.throws(() => util.parseGithubUrl("ssh://github.com"), { t.throws(() => util.parseGitHubUrl("ssh://github.com"), {
message: '"ssh://github.com" is not a http or https URL', message: '"ssh://github.com" is not a http or https URL',
}); });
t.throws(() => util.parseGithubUrl("http:///::::433"), { t.throws(() => util.parseGitHubUrl("http:///::::433"), {
message: '"http:///::::433" is not a valid URL', message: '"http:///::::433" is not a valid URL',
}); });
}); });
+18 -2
View File
@@ -189,7 +189,7 @@ export function getCodeQLDatabasePath(tempDir: string, language: Language) {
* Parses user input of a github.com or GHES URL to a canonical form. * Parses user input of a github.com or GHES URL to a canonical form.
* Removes any API prefix or suffix if one is present. * Removes any API prefix or suffix if one is present.
*/ */
export function parseGithubUrl(inputUrl: string): string { export function parseGitHubUrl(inputUrl: string): string {
const originalUrl = inputUrl; const originalUrl = inputUrl;
if (inputUrl.indexOf("://") === -1) { if (inputUrl.indexOf("://") === -1) {
inputUrl = `https://${inputUrl}`; inputUrl = `https://${inputUrl}`;
@@ -247,7 +247,7 @@ export async function getGitHubVersion(
apiDetails: GitHubApiDetails apiDetails: GitHubApiDetails
): Promise<GitHubVersion> { ): Promise<GitHubVersion> {
// We can avoid making an API request in the standard dotcom case // We can avoid making an API request in the standard dotcom case
if (parseGithubUrl(apiDetails.url) === GITHUB_DOTCOM_URL) { if (parseGitHubUrl(apiDetails.url) === GITHUB_DOTCOM_URL) {
return { type: GitHubVariant.DOTCOM }; return { type: GitHubVariant.DOTCOM };
} }
@@ -390,3 +390,19 @@ export async function getGitHubAuth(
"No GitHub authentication token was specified. Please provide a token via the GITHUB_TOKEN environment variable, or by adding the `--github-auth-stdin` flag and passing the token via standard input." "No GitHub authentication token was specified. Please provide a token via the GITHUB_TOKEN environment variable, or by adding the `--github-auth-stdin` flag and passing the token via standard input."
); );
} }
// Sets environment variables that make using some libraries designed for
// use only on actions safe to use outside of actions.
//
// Obviously this is not a tremendously great thing we're doing and it
// would be better to write our own implementation of libraries to use
// outside of actions. For now this works well enough.
//
// Currently this list of libraries that is deemed to now be safe includes:
// - @actions/tool-cache
//
// Also see "queries/unguarded-action-lib.ql".
export function setupActionsVars(tempDir: string, toolsDir: string) {
process.env["RUNNER_TEMP"] = tempDir;
process.env["RUNNER_TOOL_CACHE"] = toolsDir;
}
@@ -23,7 +23,7 @@ queries:
uses: Anthophila/go-querypack@master uses: Anthophila/go-querypack@master
- name: Cpp queries - name: Cpp queries
uses: Anthophila/cpp-querypack@second-branch uses: Anthophila/cpp-querypack@second-branch
- name: Javascript queries - name: JavaScript queries
uses: Anthophila/javascript-querypack/show_ifs2.ql@master uses: Anthophila/javascript-querypack/show_ifs2.ql@master
- name: Python queries - name: Python queries
uses: Anthophila/python-querypack/show_ifs2.ql@second-branch uses: Anthophila/python-querypack/show_ifs2.ql@second-branch
@@ -1,6 +1,6 @@
/** /**
* @name Show Javascript Ifs * @name Show JavaScript Ifs
* @description Show Javascript Ifs * @description Show JavaScript Ifs
* @kind problem * @kind problem
* @id inrepo-javascript-querypack/show-ifs * @id inrepo-javascript-querypack/show-ifs
*/ */