Compare commits

...

20 Commits

Author SHA1 Message Date
github-actions[bot] 3d39294047 Mergeback v2.1.27 refs/heads/releases/v2 into main (#1289)
* Merge main into releases/v2 (#1287)

* Update changelog and version after v2.1.26

* Update checked-in dependencies

* Don't check for Go logs on failure (#1279)

* Update supported GitHub Enterprise Server versions. (#1275)

Co-authored-by: GitHub <noreply@github.com>

* TRAP Caching: Add timeouts to upload/download operations

* Add logging statements declaring state of the cli_config_file_enabled

It's possible to determine this otherwise, but this makes it easier to
spot.

* Avoid using single value as array

The user config parser in the CLI doesn't yet support it.

* Extract logging statements to separate function

* Correctly report CodeQL version when using cache (#1259)

* Correctly report CodeQL version when using cache

* Add JS generated files

* Add test for return value of `setupCodeQL`

* Fill in missing return value comment

* Convert "Invalid source root" errors to UserErrors

* Add changelog note for Go extraction reconciliation (#1286)

* Add changelog note for Go extraction reconciliation

* Update CHANGELOG.md

Co-authored-by: Henry Mercer <henrymercer@github.com>

* Update CHANGELOG.md

Co-authored-by: Andrew Eisenberg <aeisenberg@github.com>

* Tweaks from PR review

Co-authored-by: Henry Mercer <henrymercer@github.com>
Co-authored-by: Andrew Eisenberg <aeisenberg@github.com>

* Update changelog for v2.1.27

Co-authored-by: github-actions[bot] <github-actions@github.com>
Co-authored-by: Chuan-kai Lin <cklin@github.com>
Co-authored-by: Angela P Wen <angelapwen@github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: GitHub <noreply@github.com>
Co-authored-by: Edoardo Pirovano <edoardo.pirovano@gmail.com>
Co-authored-by: Edoardo Pirovano <6748066+edoardopirovano@users.noreply.github.com>
Co-authored-by: Andrew Eisenberg <aeisenberg@github.com>
Co-authored-by: Henry Mercer <henrymercer@github.com>

* Update changelog and version after v2.1.27

* Update checked-in dependencies

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions@github.com>
Co-authored-by: Chuan-kai Lin <cklin@github.com>
Co-authored-by: Angela P Wen <angelapwen@github.com>
Co-authored-by: GitHub <noreply@github.com>
Co-authored-by: Edoardo Pirovano <edoardo.pirovano@gmail.com>
Co-authored-by: Edoardo Pirovano <6748066+edoardopirovano@users.noreply.github.com>
Co-authored-by: Andrew Eisenberg <aeisenberg@github.com>
Co-authored-by: Henry Mercer <henrymercer@github.com>
2022-10-07 02:22:33 +00:00
Angela P Wen e4cc4a2fef Add changelog note for Go extraction reconciliation (#1286)
* Add changelog note for Go extraction reconciliation

* Update CHANGELOG.md

Co-authored-by: Henry Mercer <henrymercer@github.com>

* Update CHANGELOG.md

Co-authored-by: Andrew Eisenberg <aeisenberg@github.com>

* Tweaks from PR review

Co-authored-by: Henry Mercer <henrymercer@github.com>
Co-authored-by: Andrew Eisenberg <aeisenberg@github.com>
2022-10-06 22:18:52 +00:00
Andrew Eisenberg 84dffe700c Merge pull request #1282 from github/aeisenberg/user-error-source-root
Convert "Invalid source root" errors to UserErrors
2022-10-06 10:48:35 -07:00
Andrew Eisenberg 9e044c5432 Convert "Invalid source root" errors to UserErrors 2022-10-06 09:28:29 -07:00
Angela P Wen 24c8de16fa Correctly report CodeQL version when using cache (#1259)
* Correctly report CodeQL version when using cache

* Add JS generated files

* Add test for return value of `setupCodeQL`

* Fill in missing return value comment
2022-10-05 09:16:42 -07:00
Andrew Eisenberg f359ba7af1 Merge pull request #1281 from github/aeisenberg/cli-config-processing
Add logging statements declaring state of the cli_config_file_enabled
2022-10-04 12:30:23 -07:00
Andrew Eisenberg 5960ce1190 Extract logging statements to separate function 2022-10-03 09:35:40 -07:00
Andrew Eisenberg 59fbe34861 Avoid using single value as array
The user config parser in the CLI doesn't yet support it.
2022-10-02 17:13:04 -07:00
Andrew Eisenberg 6ace05baa3 Add logging statements declaring state of the cli_config_file_enabled
It's possible to determine this otherwise, but this makes it easier to
spot.
2022-10-01 12:03:01 -07:00
Edoardo Pirovano 4cf80047d0 Merge pull request #1280 from github/edoardo/add-timeout
TRAP Caching: Add timeouts to upload/download operations
2022-09-30 14:13:18 +01:00
Edoardo Pirovano c0641ea1d3 TRAP Caching: Add timeouts to upload/download operations 2022-09-30 13:18:46 +01:00
github-actions[bot] 61b87c69a6 Update supported GitHub Enterprise Server versions. (#1275)
Co-authored-by: GitHub <noreply@github.com>
2022-09-29 22:37:10 +00:00
Angela P Wen 57719e015c Don't check for Go logs on failure (#1279) 2022-09-29 14:23:35 -07:00
Chuan-kai Lin 0831a67a20 Merge pull request #1277 from github/mergeback/v2.1.26-to-main-e0e5ded3
Mergeback v2.1.26 refs/heads/releases/v2 into main
2022-09-29 12:37:55 -07:00
github-actions[bot] ffa74c5cb3 Update checked-in dependencies 2022-09-29 17:59:28 +00:00
github-actions[bot] 885b397f2e Update changelog and version after v2.1.26 2022-09-29 17:46:49 +00:00
Chuan-kai Lin e0e5ded33c Merge pull request #1276 from github/update-v2.1.26-97054749
Merge main into releases/v2
2022-09-29 10:44:20 -07:00
github-actions[bot] c60b8543e6 Update changelog for v2.1.26 2022-09-29 16:06:08 +00:00
Andrew Eisenberg 97054749c9 Merge pull request #1274 from github/aeisenberg/update-checks-script
Update the checks script
2022-09-29 08:34:28 -07:00
Andrew Eisenberg fb0f74784f Update the checks script
Avoid requiring test-setup-python-scripts checks.
2022-09-28 16:04:46 -07:00
35 changed files with 346 additions and 94 deletions
@@ -79,7 +79,7 @@ jobs:
echo "Missing database initialization logs" echo "Missing database initialization logs"
exit 1 exit 1
fi fi
if [[ ! -d "$language/log" ]] ; then if [[ ! "$language" == "go" ]] && [[ ! -d "$language/log" ]] ; then
echo "Missing logs for $language" echo "Missing logs for $language"
exit 1 exit 1
fi fi
@@ -23,7 +23,7 @@ fi
echo "Getting checks for $GITHUB_SHA" echo "Getting checks for $GITHUB_SHA"
# Ignore any checks with "https://", CodeQL, LGTM, and Update checks. # Ignore any checks with "https://", CodeQL, LGTM, and Update checks.
CHECKS="$(gh api repos/github/codeql-action/commits/"${GITHUB_SHA}"/check-runs --paginate | jq --slurp --compact-output --raw-output '[.[].check_runs | .[].name | select(contains("https://") or . == "CodeQL" or . == "LGTM.com" or contains("Update") or contains("update") | not)] | unique | sort')" CHECKS="$(gh api repos/github/codeql-action/commits/"${GITHUB_SHA}"/check-runs --paginate | jq --slurp --compact-output --raw-output '[.[].check_runs | .[].name | select(contains("https://") or . == "CodeQL" or . == "LGTM.com" or contains("Update") or contains("update") or contains("test-setup-python-scripts") | not)] | unique | sort')"
echo "$CHECKS" | jq echo "$CHECKS" | jq
+8
View File
@@ -2,6 +2,14 @@
## [UNRELEASED] ## [UNRELEASED]
No user facing changes.
## 2.1.27 - 06 Oct 2022
- We are rolling out a feature of the CodeQL Action in October 2022 that changes the way that Go code is analyzed to be more consistent with other compiled languages like C/C++, C#, and Java. You do not need to alter your code scanning workflows. If you encounter any problems, please [file an issue](https://github.com/github/codeql-action/issues) or open a private ticket with GitHub Support and request an escalation to engineering.
## 2.1.26 - 29 Sep 2022
- Update default CodeQL bundle version to 2.11.0. [#1267](https://github.com/github/codeql-action/pull/1267) - Update default CodeQL bundle version to 2.11.0. [#1267](https://github.com/github/codeql-action/pull/1267)
## 2.1.25 - 21 Sep 2022 ## 2.1.25 - 21 Sep 2022
+1
View File
@@ -136,6 +136,7 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
config.paths, config.pathsIgnore, config.languages, logger); config.paths, config.pathsIgnore, config.languages, logger);
} }
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd); const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
await util.logCodeScanningConfigInCli(codeql, featureFlags, logger);
for (const language of config.languages) { for (const language of config.languages) {
const queries = config.queries[language]; const queries = config.queries[language];
const queryFilters = validateQueryFilters(config.originalUserInput["query-filters"]); const queryFilters = validateQueryFilters(config.originalUserInput["query-filters"]);
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
{ "maximumVersion": "3.7", "minimumVersion": "3.3" } { "maximumVersion": "3.7", "minimumVersion": "3.2" }
Generated
+2 -1
View File
@@ -224,7 +224,7 @@ async function getCodeQLBundleDownloadURL(apiDetails, variant, logger) {
* @param logger * @param logger
* @param checkVersion Whether to check that CodeQL CLI meets the minimum * @param checkVersion Whether to check that CodeQL CLI meets the minimum
* version requirement. Must be set to true outside tests. * version requirement. Must be set to true outside tests.
* @returns * @returns a { CodeQL, toolsVersion } object.
*/ */
async function setupCodeQL(codeqlURL, apiDetails, tempDir, variant, featureFlags, logger, checkVersion) { async function setupCodeQL(codeqlURL, apiDetails, tempDir, variant, featureFlags, logger, checkVersion) {
try { try {
@@ -267,6 +267,7 @@ async function setupCodeQL(codeqlURL, apiDetails, tempDir, variant, featureFlags
if (fs.existsSync(path.join(tmpCodeqlFolder, "pinned-version"))) { if (fs.existsSync(path.join(tmpCodeqlFolder, "pinned-version"))) {
logger.debug(`CodeQL in cache overriding the default ${CODEQL_BUNDLE_VERSION}`); logger.debug(`CodeQL in cache overriding the default ${CODEQL_BUNDLE_VERSION}`);
codeqlFolder = tmpCodeqlFolder; codeqlFolder = tmpCodeqlFolder;
codeqlURLVersion = codeqlVersions[0];
} }
} }
} }
+1 -1
View File
File diff suppressed because one or more lines are too long
+25 -10
View File
@@ -95,7 +95,7 @@ async function mockApiAndSetupCodeQL({ apiDetails, featureFlags, isPinned, tmpDi
(0, nock_1.default)(baseUrl) (0, nock_1.default)(baseUrl)
.get(relativeUrl) .get(relativeUrl)
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle${isPinned ? "-pinned" : ""}.tar.gz`)); .replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle${isPinned ? "-pinned" : ""}.tar.gz`));
await codeql.setupCodeQL(toolsInput ? toolsInput.input : `${baseUrl}${relativeUrl}`, apiDetails !== null && apiDetails !== void 0 ? apiDetails : sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, featureFlags !== null && featureFlags !== void 0 ? featureFlags : (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true), false); return await codeql.setupCodeQL(toolsInput ? toolsInput.input : `${baseUrl}${relativeUrl}`, apiDetails !== null && apiDetails !== void 0 ? apiDetails : sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, featureFlags !== null && featureFlags !== void 0 ? featureFlags : (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true), false);
} }
(0, ava_1.default)("download codeql bundle cache", async (t) => { (0, ava_1.default)("download codeql bundle cache", async (t) => {
await util.withTmpDir(async (tmpDir) => { await util.withTmpDir(async (tmpDir) => {
@@ -103,8 +103,9 @@ async function mockApiAndSetupCodeQL({ apiDetails, featureFlags, isPinned, tmpDi
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];
await mockApiAndSetupCodeQL({ version, tmpDir }); const codeQLConfig = await mockApiAndSetupCodeQL({ version, tmpDir });
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`)); t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
t.deepEqual(codeQLConfig.toolsVersion, version);
} }
t.is(toolcache.findAllVersions("CodeQL").length, 2); t.is(toolcache.findAllVersions("CodeQL").length, 2);
}); });
@@ -112,26 +113,33 @@ async function mockApiAndSetupCodeQL({ apiDetails, featureFlags, isPinned, tmpDi
(0, ava_1.default)("download codeql bundle cache explicitly requested with pinned different version cached", async (t) => { (0, 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) => {
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir); (0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
await mockApiAndSetupCodeQL({ const pinnedCodeQLConfig = await mockApiAndSetupCodeQL({
version: "20200601", version: "20200601",
isPinned: true, isPinned: true,
tmpDir, tmpDir,
}); });
t.assert(toolcache.find("CodeQL", "0.0.0-20200601")); t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
await mockApiAndSetupCodeQL({ version: "20200610", tmpDir }); t.deepEqual(pinnedCodeQLConfig.toolsVersion, "20200601");
const unpinnedCodeQLConfig = await mockApiAndSetupCodeQL({
version: "20200610",
tmpDir,
});
t.assert(toolcache.find("CodeQL", "0.0.0-20200610")); t.assert(toolcache.find("CodeQL", "0.0.0-20200610"));
t.deepEqual(unpinnedCodeQLConfig.toolsVersion, "20200610");
}); });
}); });
(0, ava_1.default)("don't download codeql bundle cache with pinned different version cached", async (t) => { (0, 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) => {
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir); (0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
await mockApiAndSetupCodeQL({ const pinnedCodeQLConfig = await mockApiAndSetupCodeQL({
version: "20200601", version: "20200601",
isPinned: true, isPinned: true,
tmpDir, tmpDir,
}); });
t.assert(toolcache.find("CodeQL", "0.0.0-20200601")); t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true), false); t.deepEqual(pinnedCodeQLConfig.toolsVersion, "20200601");
const codeQLConfig = await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true), false);
t.deepEqual(codeQLConfig.toolsVersion, "0.0.0-20200601");
const cachedVersions = toolcache.findAllVersions("CodeQL"); const cachedVersions = toolcache.findAllVersions("CodeQL");
t.is(cachedVersions.length, 1); t.is(cachedVersions.length, 1);
}); });
@@ -139,14 +147,19 @@ async function mockApiAndSetupCodeQL({ apiDetails, featureFlags, isPinned, tmpDi
(0, ava_1.default)("download codeql bundle cache with different version cached (not pinned)", async (t) => { (0, 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) => {
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir); (0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
await mockApiAndSetupCodeQL({ version: "20200601", tmpDir }); const cachedCodeQLConfig = await mockApiAndSetupCodeQL({
version: "20200601",
tmpDir,
});
t.assert(toolcache.find("CodeQL", "0.0.0-20200601")); t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
await mockApiAndSetupCodeQL({ t.deepEqual(cachedCodeQLConfig.toolsVersion, "20200601");
const codeQLConfig = await mockApiAndSetupCodeQL({
version: defaults.bundleVersion, version: defaults.bundleVersion,
tmpDir, tmpDir,
apiDetails: sampleApiDetails, apiDetails: sampleApiDetails,
toolsInput: { input: undefined }, toolsInput: { input: undefined },
}); });
t.deepEqual(codeQLConfig.toolsVersion, defaults.bundleVersion.replace("codeql-bundle-", ""));
const cachedVersions = toolcache.findAllVersions("CodeQL"); const cachedVersions = toolcache.findAllVersions("CodeQL");
t.is(cachedVersions.length, 2); t.is(cachedVersions.length, 2);
}); });
@@ -154,18 +167,20 @@ async function mockApiAndSetupCodeQL({ apiDetails, featureFlags, isPinned, tmpDi
(0, ava_1.default)('download codeql bundle cache with pinned different version cached if "latest" tools specified', async (t) => { (0, 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) => {
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir); (0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
await mockApiAndSetupCodeQL({ const pinnedCodeQLConfig = await mockApiAndSetupCodeQL({
version: "20200601", version: "20200601",
isPinned: true, isPinned: true,
tmpDir, tmpDir,
}); });
t.assert(toolcache.find("CodeQL", "0.0.0-20200601")); t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
await mockApiAndSetupCodeQL({ t.deepEqual(pinnedCodeQLConfig.toolsVersion, "20200601");
const latestCodeQLConfig = await mockApiAndSetupCodeQL({
version: defaults.bundleVersion, version: defaults.bundleVersion,
apiDetails: sampleApiDetails, apiDetails: sampleApiDetails,
toolsInput: { input: "latest" }, toolsInput: { input: "latest" },
tmpDir, tmpDir,
}); });
t.deepEqual(latestCodeQLConfig.toolsVersion, defaults.bundleVersion.replace("codeql-bundle-", ""));
const cachedVersions = toolcache.findAllVersions("CodeQL"); const cachedVersions = toolcache.findAllVersions("CodeQL");
t.is(cachedVersions.length, 2); t.is(cachedVersions.length, 2);
}); });
File diff suppressed because one or more lines are too long
+1
View File
@@ -908,6 +908,7 @@ async function initConfig(languagesInput, queriesInput, packsInput, registriesIn
// When using the codescanning config in the CLI, pack downloads // When using the codescanning config in the CLI, pack downloads
// happen in the CLI during the `database init` command, so no need // happen in the CLI during the `database init` command, so no need
// to download them here. // to download them here.
await (0, util_1.logCodeScanningConfigInCli)(codeQL, featureFlags, logger);
if (!(await (0, util_1.useCodeScanningConfigInCli)(codeQL, featureFlags))) { if (!(await (0, util_1.useCodeScanningConfigInCli)(codeQL, featureFlags))) {
const registries = parseRegistries(registriesInput); const registries = parseRegistries(registriesInput);
await downloadPacks(codeQL, config.languages, config.packs, registries, apiDetails, config.tempDir, logger); await downloadPacks(codeQL, config.languages, config.packs, registries, apiDetails, config.tempDir, logger);
File diff suppressed because one or more lines are too long
Generated
+31 -15
View File
@@ -47,7 +47,6 @@ async function initConfig(languagesInput, queriesInput, packsInput, registriesIn
} }
exports.initConfig = initConfig; exports.initConfig = initConfig;
async function runInit(codeql, config, sourceRoot, processName, processLevel, featureFlags, logger) { async function runInit(codeql, config, sourceRoot, processName, processLevel, featureFlags, logger) {
var _a, _b;
fs.mkdirSync(config.dbLocation, { recursive: true }); fs.mkdirSync(config.dbLocation, { recursive: true });
try { try {
if (await (0, util_1.codeQlVersionAbove)(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING)) { if (await (0, util_1.codeQlVersionAbove)(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING)) {
@@ -62,24 +61,41 @@ async function runInit(codeql, config, sourceRoot, processName, processLevel, fe
} }
} }
catch (e) { catch (e) {
// Handle the situation where init is called twice throw processError(e);
// for the same database in the same job.
if (e instanceof Error &&
((_a = e.message) === null || _a === void 0 ? void 0 : _a.includes("Refusing to create databases")) &&
e.message.includes("exists and is not an empty directory.")) {
throw new util.UserError(`Is the "init" action called twice in the same job? ${e.message}`);
}
else if (e instanceof Error &&
((_b = e.message) === null || _b === void 0 ? void 0 : _b.includes("is not compatible with this CodeQL CLI"))) {
throw new util.UserError(e.message);
}
else {
throw e;
}
} }
return await (0, tracer_config_1.getCombinedTracerConfig)(config, codeql, await util.isGoExtractionReconciliationEnabled(featureFlags), logger); return await (0, tracer_config_1.getCombinedTracerConfig)(config, codeql, await util.isGoExtractionReconciliationEnabled(featureFlags), logger);
} }
exports.runInit = runInit; exports.runInit = runInit;
/**
* Possibly convert this error into a UserError in order to avoid
* counting this error towards our internal error budget.
*
* @param e The error to possibly convert to a UserError.
*
* @returns A UserError if the error is a known error that can be
* attributed to the user, otherwise the original error.
*/
function processError(e) {
var _a, _b, _c, _d;
if (!(e instanceof Error)) {
return e;
}
if (
// Init action called twice
((_a = e.message) === null || _a === void 0 ? void 0 : _a.includes("Refusing to create databases")) &&
((_b = e.message) === null || _b === void 0 ? void 0 : _b.includes("exists and is not an empty directory."))) {
return new util.UserError(`Is the "init" action called twice in the same job? ${e.message}`);
}
if (
// Version of CodeQL CLI is incompatible with this version of the CodeQL Action
((_c = e.message) === null || _c === void 0 ? void 0 : _c.includes("is not compatible with this CodeQL CLI")) ||
(
// Expected source location for database creation does not exist
(_d = e.message) === null || _d === void 0 ? void 0 : _d.includes("Invalid source root"))) {
return new util.UserError(e.message);
}
return e;
}
// Runs a powershell script to inject the tracer into a parent process // Runs a powershell script to inject the tracer into a parent process
// so it can tracer future processes, hopefully including the build process. // so it can tracer future processes, hopefully including the build process.
// If processName is given then injects into the nearest parent process with // If processName is given then injects into the nearest parent process with
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,yEAA2D;AAC3D,kEAAoD;AAEpD,gEAAkD;AAElD,qCAA2E;AAC3E,4DAA8C;AAI9C,mDAAwE;AACxE,6CAA+B;AAC/B,iCAA4C;AAErC,KAAK,UAAU,UAAU,CAC9B,SAA6B,EAC7B,UAA4B,EAC5B,OAAe,EACf,OAA2B,EAC3B,YAA0B,EAC1B,MAAc;IAEd,MAAM,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACxC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,IAAA,oBAAW,EAChD,SAAS,EACT,UAAU,EACV,OAAO,EACP,OAAO,EACP,YAAY,EACZ,MAAM,EACN,IAAI,CACL,CAAC;IACF,MAAM,MAAM,CAAC,YAAY,EAAE,CAAC;IAC5B,MAAM,CAAC,QAAQ,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;AAClC,CAAC;AArBD,gCAqBC;AAEM,KAAK,UAAU,UAAU,CAC9B,cAAkC,EAClC,YAAgC,EAChC,UAA8B,EAC9B,eAAmC,EACnC,UAA8B,EAC9B,UAA8B,EAC9B,kBAA2B,EAC3B,SAAkB,EAClB,iBAAyB,EACzB,iBAAyB,EACzB,UAAyB,EACzB,OAAe,EACf,MAAc,EACd,aAAqB,EACrB,aAAiC,EACjC,UAAoC,EACpC,YAA0B,EAC1B,MAAc;IAEd,MAAM,CAAC,UAAU,CAAC,6BAA6B,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,UAAU,CACzC,cAAc,EACd,YAAY,EACZ,UAAU,EACV,eAAe,EACf,UAAU,EACV,UAAU,EACV,kBAAkB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,CAAC,EAAE;gBACvE,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,mBAAmB,CAAC;aAC9C,CAAC,CAAC,IAAI,EAAE,CAAC;SACX;aAAM;YACL,MAAM,IAAI,UAAU,CAAC,UAAU,CAC7B,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAC7C,CAAC,IAAI,EAAE,CAAC;SACV;QACD,MAAM,MAAM,GAAG,0BAA0B,CAAC;QAC1C,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE;YAChC,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;gBAC/D,IAAI;gBACJ,IAAI;gBACJ,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC;gBAChC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;aAC/B,CAAC,CAAC,IAAI,EAAE,CAAC;SACX;aAAM;YACL,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE;gBACpE,IAAI;gBACJ,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC;gBAChC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;aAC/B,CAAC,CAAC,IAAI,EAAE,CAAC;SACX;KACF;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,CAAC,QAAQ,EAAE,CAAC;QAClB,MAAM,CAAC,OAAO,CACZ,gFAAgF,CAAC,IAAI;YACnF,qGAAqG;YACrG,oGAAoG;YACpG,iDAAiD,CACpD,CAAC;QACF,OAAO;KACR;IACD,MAAM,CAAC,QAAQ,EAAE,CAAC;AACpB,CAAC;AAzCD,8CAyCC"}
+12 -5
View File
@@ -37,6 +37,11 @@ const CACHE_SIZE_MB = 1024;
// This constant sets the minimum size in megabytes of a TRAP // This constant sets the minimum size in megabytes of a TRAP
// cache for us to consider it worth uploading. // cache for us to consider it worth uploading.
const MINIMUM_CACHE_MB_TO_UPLOAD = 10; const MINIMUM_CACHE_MB_TO_UPLOAD = 10;
// The maximum number of milliseconds to wait for TRAP cache
// uploads or downloads to complete before continuing. Note
// this timeout is per operation, so will be run as many
// times as there are languages with TRAP caching enabled.
const MAX_CACHE_OPERATION_MS = 120000; // Two minutes
async function getTrapCachingExtractorConfigArgs(config) { async function getTrapCachingExtractorConfigArgs(config) {
const result = []; const result = [];
for (const language of config.languages) for (const language of config.languages)
@@ -95,9 +100,11 @@ async function downloadTrapCaches(codeql, languages, logger) {
// The SHA from the base of the PR is the most similar commit we might have a cache for // The SHA from the base of the PR is the most similar commit we might have a cache for
const preferredKey = await cacheKey(codeql, language, baseSha); const preferredKey = await cacheKey(codeql, language, baseSha);
logger.info(`Looking in Actions cache for TRAP cache with key ${preferredKey}`); logger.info(`Looking in Actions cache for TRAP cache with key ${preferredKey}`);
const found = await cache.restoreCache([cacheDir], preferredKey, [ const found = await (0, util_1.withTimeout)(MAX_CACHE_OPERATION_MS, cache.restoreCache([cacheDir], preferredKey, [
await cachePrefix(codeql, language), // Fall back to any cache with the right key prefix await cachePrefix(codeql, language), // Fall back to any cache with the right key prefix
]); ]), () => {
logger.info(`Timed out waiting for TRAP cache download for ${language}, will continue without it`);
});
if (found === undefined) { if (found === undefined) {
// We didn't find a TRAP cache in the Actions cache, so the directory on disk is // We didn't find a TRAP cache in the Actions cache, so the directory on disk is
// still just an empty directory. There's no reason to tell the extractor to use it, // still just an empty directory. There's no reason to tell the extractor to use it,
@@ -119,7 +126,6 @@ exports.downloadTrapCaches = downloadTrapCaches;
async function uploadTrapCaches(codeql, config, logger) { async function uploadTrapCaches(codeql, config, logger) {
if (!(await actionsUtil.isAnalyzingDefaultBranch())) if (!(await actionsUtil.isAnalyzingDefaultBranch()))
return false; // Only upload caches from the default branch return false; // Only upload caches from the default branch
const toAwait = [];
for (const language of config.languages) { for (const language of config.languages) {
const cacheDir = config.trapCaches[language]; const cacheDir = config.trapCaches[language];
if (cacheDir === undefined) if (cacheDir === undefined)
@@ -135,9 +141,10 @@ async function uploadTrapCaches(codeql, config, logger) {
} }
const key = await cacheKey(codeql, language, process.env.GITHUB_SHA || "unknown"); const key = await cacheKey(codeql, language, process.env.GITHUB_SHA || "unknown");
logger.info(`Uploading TRAP cache to Actions cache with key ${key}`); logger.info(`Uploading TRAP cache to Actions cache with key ${key}`);
toAwait.push(cache.saveCache([cacheDir], key)); await (0, util_1.withTimeout)(MAX_CACHE_OPERATION_MS, cache.saveCache([cacheDir], key), () => {
logger.info(`Timed out waiting for TRAP cache for ${language} to upload, will continue without uploading`);
});
} }
await Promise.all(toAwait);
return true; return true;
} }
exports.uploadTrapCaches = uploadTrapCaches; exports.uploadTrapCaches = uploadTrapCaches;
File diff suppressed because one or more lines are too long
Generated
+29 -1
View File
@@ -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.tryGetFolderBytes = exports.isGoExtractionReconciliationEnabled = exports.listFolder = exports.doesDirectoryExist = exports.useCodeScanningConfigInCli = exports.isInTestMode = exports.checkActionVersion = exports.getMlPoweredJsQueriesStatus = exports.getMlPoweredJsQueriesPack = exports.ML_POWERED_JS_QUERIES_PACK_NAME = 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.EnvVar = 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.DID_AUTOBUILD_GO_ENV_VAR_NAME = exports.DEFAULT_DEBUG_DATABASE_NAME = exports.DEFAULT_DEBUG_ARTIFACT_NAME = exports.GITHUB_DOTCOM_URL = void 0; exports.withTimeout = exports.tryGetFolderBytes = exports.isGoExtractionReconciliationEnabled = exports.listFolder = exports.doesDirectoryExist = exports.logCodeScanningConfigInCli = exports.useCodeScanningConfigInCli = exports.isInTestMode = exports.checkActionVersion = exports.getMlPoweredJsQueriesStatus = exports.getMlPoweredJsQueriesPack = exports.ML_POWERED_JS_QUERIES_PACK_NAME = 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.EnvVar = 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.DID_AUTOBUILD_GO_ENV_VAR_NAME = 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"));
@@ -679,6 +679,15 @@ async function useCodeScanningConfigInCli(codeql, featureFlags) {
return await codeQlVersionAbove(codeql, codeql_1.CODEQL_VERSION_CONFIG_FILES); return await codeQlVersionAbove(codeql, codeql_1.CODEQL_VERSION_CONFIG_FILES);
} }
exports.useCodeScanningConfigInCli = useCodeScanningConfigInCli; exports.useCodeScanningConfigInCli = useCodeScanningConfigInCli;
async function logCodeScanningConfigInCli(codeql, featureFlags, logger) {
if (await useCodeScanningConfigInCli(codeql, featureFlags)) {
logger.info("Code Scanning configuration file being processed in the codeql CLI.");
}
else {
logger.info("Code Scanning configuration file being processed in the codeql-action.");
}
}
exports.logCodeScanningConfigInCli = logCodeScanningConfigInCli;
/* /*
* Returns whether the path in the argument represents an existing directory. * Returns whether the path in the argument represents an existing directory.
*/ */
@@ -735,4 +744,23 @@ async function tryGetFolderBytes(cacheDir, logger) {
} }
} }
exports.tryGetFolderBytes = tryGetFolderBytes; exports.tryGetFolderBytes = tryGetFolderBytes;
/**
* Run a promise for a given amount of time, and if it doesn't resolve within
* that time, call the provided callback and then return undefined.
*
* @param timeoutMs The timeout in milliseconds.
* @param promise The promise to run.
* @param onTimeout A callback to call if the promise times out.
* @returns The result of the promise, or undefined if the promise times out.
*/
async function withTimeout(timeoutMs, promise, onTimeout) {
const timeout = new Promise((resolve) => {
setTimeout(() => {
onTimeout();
resolve(undefined);
}, timeoutMs);
});
return await Promise.race([promise, timeout]);
}
exports.withTimeout = withTimeout;
//# sourceMappingURL=util.js.map //# sourceMappingURL=util.js.map
+1 -1
View File
File diff suppressed because one or more lines are too long
+28
View File
@@ -396,4 +396,32 @@ function mockVersion(version) {
}, },
}; };
} }
const longTime = 999999;
const shortTime = 10;
(0, ava_1.default)("withTimeout on long task", async (t) => {
let longTaskTimedOut = false;
const longTask = new Promise((resolve) => {
setTimeout(() => {
resolve(42);
}, longTime);
});
const result = await util.withTimeout(shortTime, longTask, () => {
longTaskTimedOut = true;
});
t.deepEqual(longTaskTimedOut, true);
t.deepEqual(result, undefined);
});
(0, ava_1.default)("withTimeout on short task", async (t) => {
let shortTaskTimedOut = false;
const shortTask = new Promise((resolve) => {
setTimeout(() => {
resolve(99);
}, shortTime);
});
const result = await util.withTimeout(longTime, shortTask, () => {
shortTaskTimedOut = true;
});
t.deepEqual(shortTaskTimedOut, false);
t.deepEqual(result, 99);
});
//# sourceMappingURL=util.test.js.map //# sourceMappingURL=util.test.js.map
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "codeql", "name": "codeql",
"version": "2.1.26", "version": "2.1.28",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "codeql", "name": "codeql",
"version": "2.1.26", "version": "2.1.28",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "codeql", "name": "codeql",
"version": "2.1.26", "version": "2.1.28",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/artifact": "^1.0.0", "@actions/artifact": "^1.0.0",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "codeql", "name": "codeql",
"version": "2.1.26", "version": "2.1.28",
"private": true, "private": true,
"description": "CodeQL action", "description": "CodeQL action",
"scripts": { "scripts": {
+3
View File
@@ -239,6 +239,9 @@ export async function runQueries(
} }
const codeql = await getCodeQL(config.codeQLCmd); const codeql = await getCodeQL(config.codeQLCmd);
await util.logCodeScanningConfigInCli(codeql, featureFlags, logger);
for (const language of config.languages) { for (const language of config.languages) {
const queries = config.queries[language]; const queries = config.queries[language];
const queryFilters = validateQueryFilters( const queryFilters = validateQueryFilters(
+1 -1
View File
@@ -1 +1 @@
{"maximumVersion": "3.7", "minimumVersion": "3.3"} {"maximumVersion": "3.7", "minimumVersion": "3.2"}
+32 -11
View File
@@ -81,7 +81,7 @@ async function mockApiAndSetupCodeQL({
tmpDir: string; tmpDir: string;
toolsInput?: { input?: string }; toolsInput?: { input?: string };
version: string; version: string;
}) { }): Promise<{ codeql: codeql.CodeQL; toolsVersion: string }> {
const platform = const platform =
process.platform === "win32" process.platform === "win32"
? "win64" ? "win64"
@@ -104,7 +104,7 @@ async function mockApiAndSetupCodeQL({
) )
); );
await codeql.setupCodeQL( return await codeql.setupCodeQL(
toolsInput ? toolsInput.input : `${baseUrl}${relativeUrl}`, toolsInput ? toolsInput.input : `${baseUrl}${relativeUrl}`,
apiDetails ?? sampleApiDetails, apiDetails ?? sampleApiDetails,
tmpDir, tmpDir,
@@ -124,8 +124,9 @@ test("download codeql bundle cache", async (t) => {
for (let i = 0; i < versions.length; i++) { for (let i = 0; i < versions.length; i++) {
const version = versions[i]; const version = versions[i];
await mockApiAndSetupCodeQL({ version, tmpDir }); const codeQLConfig = await mockApiAndSetupCodeQL({ version, tmpDir });
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`)); t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
t.deepEqual(codeQLConfig.toolsVersion, version);
} }
t.is(toolcache.findAllVersions("CodeQL").length, 2); t.is(toolcache.findAllVersions("CodeQL").length, 2);
@@ -136,15 +137,20 @@ test("download codeql bundle cache explicitly requested with pinned different ve
await util.withTmpDir(async (tmpDir) => { await util.withTmpDir(async (tmpDir) => {
setupActionsVars(tmpDir, tmpDir); setupActionsVars(tmpDir, tmpDir);
await mockApiAndSetupCodeQL({ const pinnedCodeQLConfig = await mockApiAndSetupCodeQL({
version: "20200601", version: "20200601",
isPinned: true, isPinned: true,
tmpDir, tmpDir,
}); });
t.assert(toolcache.find("CodeQL", "0.0.0-20200601")); t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
t.deepEqual(pinnedCodeQLConfig.toolsVersion, "20200601");
await mockApiAndSetupCodeQL({ version: "20200610", tmpDir }); const unpinnedCodeQLConfig = await mockApiAndSetupCodeQL({
version: "20200610",
tmpDir,
});
t.assert(toolcache.find("CodeQL", "0.0.0-20200610")); t.assert(toolcache.find("CodeQL", "0.0.0-20200610"));
t.deepEqual(unpinnedCodeQLConfig.toolsVersion, "20200610");
}); });
}); });
@@ -152,15 +158,16 @@ test("don't download codeql bundle cache with pinned different version cached",
await util.withTmpDir(async (tmpDir) => { await util.withTmpDir(async (tmpDir) => {
setupActionsVars(tmpDir, tmpDir); setupActionsVars(tmpDir, tmpDir);
await mockApiAndSetupCodeQL({ const pinnedCodeQLConfig = await mockApiAndSetupCodeQL({
version: "20200601", version: "20200601",
isPinned: true, isPinned: true,
tmpDir, tmpDir,
}); });
t.assert(toolcache.find("CodeQL", "0.0.0-20200601")); t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
t.deepEqual(pinnedCodeQLConfig.toolsVersion, "20200601");
await codeql.setupCodeQL( const codeQLConfig = await codeql.setupCodeQL(
undefined, undefined,
sampleApiDetails, sampleApiDetails,
tmpDir, tmpDir,
@@ -169,6 +176,7 @@ test("don't download codeql bundle cache with pinned different version cached",
getRunnerLogger(true), getRunnerLogger(true),
false false
); );
t.deepEqual(codeQLConfig.toolsVersion, "0.0.0-20200601");
const cachedVersions = toolcache.findAllVersions("CodeQL"); const cachedVersions = toolcache.findAllVersions("CodeQL");
@@ -180,16 +188,24 @@ test("download codeql bundle cache with different version cached (not pinned)",
await util.withTmpDir(async (tmpDir) => { await util.withTmpDir(async (tmpDir) => {
setupActionsVars(tmpDir, tmpDir); setupActionsVars(tmpDir, tmpDir);
await mockApiAndSetupCodeQL({ version: "20200601", tmpDir }); const cachedCodeQLConfig = await mockApiAndSetupCodeQL({
version: "20200601",
tmpDir,
});
t.assert(toolcache.find("CodeQL", "0.0.0-20200601")); t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
t.deepEqual(cachedCodeQLConfig.toolsVersion, "20200601");
await mockApiAndSetupCodeQL({ const codeQLConfig = await mockApiAndSetupCodeQL({
version: defaults.bundleVersion, version: defaults.bundleVersion,
tmpDir, tmpDir,
apiDetails: sampleApiDetails, apiDetails: sampleApiDetails,
toolsInput: { input: undefined }, toolsInput: { input: undefined },
}); });
t.deepEqual(
codeQLConfig.toolsVersion,
defaults.bundleVersion.replace("codeql-bundle-", "")
);
const cachedVersions = toolcache.findAllVersions("CodeQL"); const cachedVersions = toolcache.findAllVersions("CodeQL");
@@ -201,20 +217,25 @@ test('download codeql bundle cache with pinned different version cached if "late
await util.withTmpDir(async (tmpDir) => { await util.withTmpDir(async (tmpDir) => {
setupActionsVars(tmpDir, tmpDir); setupActionsVars(tmpDir, tmpDir);
await mockApiAndSetupCodeQL({ const pinnedCodeQLConfig = await mockApiAndSetupCodeQL({
version: "20200601", version: "20200601",
isPinned: true, isPinned: true,
tmpDir, tmpDir,
}); });
t.assert(toolcache.find("CodeQL", "0.0.0-20200601")); t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
t.deepEqual(pinnedCodeQLConfig.toolsVersion, "20200601");
await mockApiAndSetupCodeQL({ const latestCodeQLConfig = await mockApiAndSetupCodeQL({
version: defaults.bundleVersion, version: defaults.bundleVersion,
apiDetails: sampleApiDetails, apiDetails: sampleApiDetails,
toolsInput: { input: "latest" }, toolsInput: { input: "latest" },
tmpDir, tmpDir,
}); });
t.deepEqual(
latestCodeQLConfig.toolsVersion,
defaults.bundleVersion.replace("codeql-bundle-", "")
);
const cachedVersions = toolcache.findAllVersions("CodeQL"); const cachedVersions = toolcache.findAllVersions("CodeQL");
+2 -1
View File
@@ -421,7 +421,7 @@ async function getCodeQLBundleDownloadURL(
* @param logger * @param logger
* @param checkVersion Whether to check that CodeQL CLI meets the minimum * @param checkVersion Whether to check that CodeQL CLI meets the minimum
* version requirement. Must be set to true outside tests. * version requirement. Must be set to true outside tests.
* @returns * @returns a { CodeQL, toolsVersion } object.
*/ */
export async function setupCodeQL( export async function setupCodeQL(
codeqlURL: string | undefined, codeqlURL: string | undefined,
@@ -479,6 +479,7 @@ export async function setupCodeQL(
`CodeQL in cache overriding the default ${CODEQL_BUNDLE_VERSION}` `CodeQL in cache overriding the default ${CODEQL_BUNDLE_VERSION}`
); );
codeqlFolder = tmpCodeqlFolder; codeqlFolder = tmpCodeqlFolder;
codeqlURLVersion = codeqlVersions[0];
} }
} }
} }
+3
View File
@@ -24,6 +24,7 @@ import {
codeQlVersionAbove, codeQlVersionAbove,
getMlPoweredJsQueriesPack, getMlPoweredJsQueriesPack,
GitHubVersion, GitHubVersion,
logCodeScanningConfigInCli,
ML_POWERED_JS_QUERIES_PACK_NAME, ML_POWERED_JS_QUERIES_PACK_NAME,
useCodeScanningConfigInCli, useCodeScanningConfigInCli,
} from "./util"; } from "./util";
@@ -1704,6 +1705,8 @@ export async function initConfig(
// When using the codescanning config in the CLI, pack downloads // When using the codescanning config in the CLI, pack downloads
// happen in the CLI during the `database init` command, so no need // happen in the CLI during the `database init` command, so no need
// to download them here. // to download them here.
await logCodeScanningConfigInCli(codeQL, featureFlags, logger);
if (!(await useCodeScanningConfigInCli(codeQL, featureFlags))) { if (!(await useCodeScanningConfigInCli(codeQL, featureFlags))) {
const registries = parseRegistries(registriesInput); const registries = parseRegistries(registriesInput);
await downloadPacks( await downloadPacks(
+37 -18
View File
@@ -117,24 +117,7 @@ export async function runInit(
} }
} }
} catch (e) { } catch (e) {
// Handle the situation where init is called twice throw processError(e);
// for the same database in the same job.
if (
e instanceof Error &&
e.message?.includes("Refusing to create databases") &&
e.message.includes("exists and is not an empty directory.")
) {
throw new util.UserError(
`Is the "init" action called twice in the same job? ${e.message}`
);
} else if (
e instanceof Error &&
e.message?.includes("is not compatible with this CodeQL CLI")
) {
throw new util.UserError(e.message);
} else {
throw e;
}
} }
return await getCombinedTracerConfig( return await getCombinedTracerConfig(
config, config,
@@ -144,6 +127,42 @@ export async function runInit(
); );
} }
/**
* Possibly convert this error into a UserError in order to avoid
* counting this error towards our internal error budget.
*
* @param e The error to possibly convert to a UserError.
*
* @returns A UserError if the error is a known error that can be
* attributed to the user, otherwise the original error.
*/
function processError(e: any): Error {
if (!(e instanceof Error)) {
return e;
}
if (
// Init action called twice
e.message?.includes("Refusing to create databases") &&
e.message?.includes("exists and is not an empty directory.")
) {
return new util.UserError(
`Is the "init" action called twice in the same job? ${e.message}`
);
}
if (
// Version of CodeQL CLI is incompatible with this version of the CodeQL Action
e.message?.includes("is not compatible with this CodeQL CLI") ||
// Expected source location for database creation does not exist
e.message?.includes("Invalid source root")
) {
return new util.UserError(e.message);
}
return e;
}
// Runs a powershell script to inject the tracer into a parent process // Runs a powershell script to inject the tracer into a parent process
// so it can tracer future processes, hopefully including the build process. // so it can tracer future processes, hopefully including the build process.
// If processName is given then injects into the nearest parent process with // If processName is given then injects into the nearest parent process with
+27 -7
View File
@@ -8,7 +8,7 @@ import { CodeQL, CODEQL_VERSION_BETTER_RESOLVE_LANGUAGES } from "./codeql";
import { Config } from "./config-utils"; import { Config } from "./config-utils";
import { Language } from "./languages"; import { Language } from "./languages";
import { Logger } from "./logging"; import { Logger } from "./logging";
import { codeQlVersionAbove, tryGetFolderBytes } from "./util"; import { codeQlVersionAbove, tryGetFolderBytes, withTimeout } from "./util";
// This constant should be bumped if we make a breaking change // This constant should be bumped if we make a breaking change
// to how the CodeQL Action stores or retrieves the TRAP cache, // to how the CodeQL Action stores or retrieves the TRAP cache,
@@ -24,6 +24,12 @@ const CACHE_SIZE_MB = 1024;
// cache for us to consider it worth uploading. // cache for us to consider it worth uploading.
const MINIMUM_CACHE_MB_TO_UPLOAD = 10; const MINIMUM_CACHE_MB_TO_UPLOAD = 10;
// The maximum number of milliseconds to wait for TRAP cache
// uploads or downloads to complete before continuing. Note
// this timeout is per operation, so will be run as many
// times as there are languages with TRAP caching enabled.
const MAX_CACHE_OPERATION_MS = 120_000; // Two minutes
export async function getTrapCachingExtractorConfigArgs( export async function getTrapCachingExtractorConfigArgs(
config: Config config: Config
): Promise<string[]> { ): Promise<string[]> {
@@ -107,9 +113,17 @@ export async function downloadTrapCaches(
logger.info( logger.info(
`Looking in Actions cache for TRAP cache with key ${preferredKey}` `Looking in Actions cache for TRAP cache with key ${preferredKey}`
); );
const found = await cache.restoreCache([cacheDir], preferredKey, [ const found = await withTimeout(
await cachePrefix(codeql, language), // Fall back to any cache with the right key prefix MAX_CACHE_OPERATION_MS,
]); cache.restoreCache([cacheDir], preferredKey, [
await cachePrefix(codeql, language), // Fall back to any cache with the right key prefix
]),
() => {
logger.info(
`Timed out waiting for TRAP cache download for ${language}, will continue without it`
);
}
);
if (found === undefined) { if (found === undefined) {
// We didn't find a TRAP cache in the Actions cache, so the directory on disk is // We didn't find a TRAP cache in the Actions cache, so the directory on disk is
// still just an empty directory. There's no reason to tell the extractor to use it, // still just an empty directory. There's no reason to tell the extractor to use it,
@@ -136,7 +150,6 @@ export async function uploadTrapCaches(
): Promise<boolean> { ): Promise<boolean> {
if (!(await actionsUtil.isAnalyzingDefaultBranch())) return false; // Only upload caches from the default branch if (!(await actionsUtil.isAnalyzingDefaultBranch())) return false; // Only upload caches from the default branch
const toAwait: Array<Promise<number>> = [];
for (const language of config.languages) { for (const language of config.languages) {
const cacheDir = config.trapCaches[language]; const cacheDir = config.trapCaches[language];
if (cacheDir === undefined) continue; if (cacheDir === undefined) continue;
@@ -159,9 +172,16 @@ export async function uploadTrapCaches(
process.env.GITHUB_SHA || "unknown" process.env.GITHUB_SHA || "unknown"
); );
logger.info(`Uploading TRAP cache to Actions cache with key ${key}`); logger.info(`Uploading TRAP cache to Actions cache with key ${key}`);
toAwait.push(cache.saveCache([cacheDir], key)); await withTimeout(
MAX_CACHE_OPERATION_MS,
cache.saveCache([cacheDir], key),
() => {
logger.info(
`Timed out waiting for TRAP cache for ${language} to upload, will continue without uploading`
);
}
);
} }
await Promise.all(toAwait);
return true; return true;
} }
+31
View File
@@ -601,3 +601,34 @@ function mockVersion(version) {
}, },
} as CodeQL; } as CodeQL;
} }
const longTime = 999_999;
const shortTime = 10;
test("withTimeout on long task", async (t) => {
let longTaskTimedOut = false;
const longTask = new Promise((resolve) => {
setTimeout(() => {
resolve(42);
}, longTime);
});
const result = await util.withTimeout(shortTime, longTask, () => {
longTaskTimedOut = true;
});
t.deepEqual(longTaskTimedOut, true);
t.deepEqual(result, undefined);
});
test("withTimeout on short task", async (t) => {
let shortTaskTimedOut = false;
const shortTask = new Promise((resolve) => {
setTimeout(() => {
resolve(99);
}, shortTime);
});
const result = await util.withTimeout(longTime, shortTask, () => {
shortTaskTimedOut = true;
});
t.deepEqual(shortTaskTimedOut, false);
t.deepEqual(result, 99);
});
+40
View File
@@ -817,6 +817,22 @@ export async function useCodeScanningConfigInCli(
return await codeQlVersionAbove(codeql, CODEQL_VERSION_CONFIG_FILES); return await codeQlVersionAbove(codeql, CODEQL_VERSION_CONFIG_FILES);
} }
export async function logCodeScanningConfigInCli(
codeql: CodeQL,
featureFlags: FeatureFlags,
logger: Logger
) {
if (await useCodeScanningConfigInCli(codeql, featureFlags)) {
logger.info(
"Code Scanning configuration file being processed in the codeql CLI."
);
} else {
logger.info(
"Code Scanning configuration file being processed in the codeql-action."
);
}
}
/* /*
* Returns whether the path in the argument represents an existing directory. * Returns whether the path in the argument represents an existing directory.
*/ */
@@ -878,3 +894,27 @@ export async function tryGetFolderBytes(
return undefined; return undefined;
} }
} }
/**
* Run a promise for a given amount of time, and if it doesn't resolve within
* that time, call the provided callback and then return undefined.
*
* @param timeoutMs The timeout in milliseconds.
* @param promise The promise to run.
* @param onTimeout A callback to call if the promise times out.
* @returns The result of the promise, or undefined if the promise times out.
*/
export async function withTimeout<T>(
timeoutMs: number,
promise: Promise<T>,
onTimeout: () => void
): Promise<T | undefined> {
const timeout: Promise<undefined> = new Promise((resolve) => {
setTimeout(() => {
onTimeout();
resolve(undefined);
}, timeoutMs);
});
return await Promise.race([promise, timeout]);
}
@@ -3,8 +3,10 @@ name: "Check SARIF for default queries with Single include, Single exclude"
query-filters: query-filters:
# This should run js/path-injection and js/zipslip # This should run js/path-injection and js/zipslip
- include: - include:
tags contain: external/cwe/cwe-022 tags contain:
- external/cwe/cwe-022
# Removes js/path-injection # Removes js/path-injection
- exclude: - exclude:
id: js/path-injection id:
- js/path-injection
@@ -10,12 +10,15 @@ packs:
query-filters: query-filters:
# This should run js/path-injection and js/zipslip # This should run js/path-injection and js/zipslip
- include: - include:
tags contain: external/cwe/cwe-022 tags contain:
- external/cwe/cwe-022
# Removes js/path-injection # Removes js/path-injection
- exclude: - exclude:
id: js/path-injection id:
- js/path-injection
# Query from extra pack # Query from extra pack
- include: - include:
id: javascript/example/empty-or-one-block id:
- javascript/example/empty-or-one-block
@@ -20,16 +20,20 @@ packs:
query-filters: query-filters:
# This should run js/path-injection and js/zipslip # This should run js/path-injection and js/zipslip
- include: - include:
tags contain: external/cwe/cwe-022 tags contain:
- external/cwe/cwe-022
# Removes js/path-injection # Removes js/path-injection
- exclude: - exclude:
id: js/path-injection id:
- js/path-injection
# Query from extra pack # Query from extra pack
- include: - include:
id: javascript/example/empty-or-one-block id:
- javascript/example/empty-or-one-block
# Local query # Local query
- include: - include:
id: inrepo-javascript-querypack/show-ifs id:
- inrepo-javascript-querypack/show-ifs