mirror of
https://github.com/github/codeql-action.git
synced 2025-12-21 23:00:14 +08:00
Compare commits
1 Commits
codeql-bun
...
edoardo/be
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e201b621d |
@@ -79,7 +79,7 @@ jobs:
|
|||||||
echo "Missing database initialization logs"
|
echo "Missing database initialization logs"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [[ ! "$language" == "go" ]] && [[ ! -d "$language/log" ]] ; then
|
if [[ ! -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") or contains("test-setup-python-scripts") | 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") | not)] | unique | sort')"
|
||||||
|
|
||||||
echo "$CHECKS" | jq
|
echo "$CHECKS" | jq
|
||||||
|
|
||||||
|
|||||||
@@ -2,14 +2,6 @@
|
|||||||
|
|
||||||
## [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
lib/analyze.js
generated
1
lib/analyze.js
generated
@@ -136,7 +136,6 @@ 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"]);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
|||||||
{ "maximumVersion": "3.7", "minimumVersion": "3.2" }
|
{ "maximumVersion": "3.7", "minimumVersion": "3.3" }
|
||||||
|
|||||||
3
lib/codeql.js
generated
3
lib/codeql.js
generated
@@ -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 a { CodeQL, toolsVersion } object.
|
* @returns
|
||||||
*/
|
*/
|
||||||
async function setupCodeQL(codeqlURL, apiDetails, tempDir, variant, featureFlags, logger, checkVersion) {
|
async function setupCodeQL(codeqlURL, apiDetails, tempDir, variant, featureFlags, logger, checkVersion) {
|
||||||
try {
|
try {
|
||||||
@@ -267,7 +267,6 @@ 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];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
35
lib/codeql.test.js
generated
35
lib/codeql.test.js
generated
@@ -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`));
|
||||||
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);
|
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,9 +103,8 @@ 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];
|
||||||
const codeQLConfig = await mockApiAndSetupCodeQL({ version, tmpDir });
|
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);
|
||||||
});
|
});
|
||||||
@@ -113,33 +112,26 @@ 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);
|
||||||
const pinnedCodeQLConfig = await mockApiAndSetupCodeQL({
|
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");
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(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);
|
||||||
const pinnedCodeQLConfig = await mockApiAndSetupCodeQL({
|
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(undefined, sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true), false);
|
||||||
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);
|
||||||
});
|
});
|
||||||
@@ -147,19 +139,14 @@ 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);
|
||||||
const cachedCodeQLConfig = await mockApiAndSetupCodeQL({
|
await mockApiAndSetupCodeQL({ version: "20200601", tmpDir });
|
||||||
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");
|
||||||
t.is(cachedVersions.length, 2);
|
t.is(cachedVersions.length, 2);
|
||||||
});
|
});
|
||||||
@@ -167,20 +154,18 @@ 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);
|
||||||
const pinnedCodeQLConfig = await mockApiAndSetupCodeQL({
|
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");
|
||||||
t.is(cachedVersions.length, 2);
|
t.is(cachedVersions.length, 2);
|
||||||
});
|
});
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
1
lib/config-utils.js
generated
1
lib/config-utils.js
generated
@@ -908,7 +908,6 @@ 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
46
lib/init.js
generated
46
lib/init.js
generated
@@ -47,6 +47,7 @@ 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)) {
|
||||||
@@ -61,41 +62,24 @@ async function runInit(codeql, config, sourceRoot, processName, processLevel, fe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
throw processError(e);
|
// Handle the situation where init is called twice
|
||||||
|
// 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 @@
|
|||||||
{"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;A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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"}
|
||||||
17
lib/trap-caching.js
generated
17
lib/trap-caching.js
generated
@@ -37,11 +37,6 @@ 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)
|
||||||
@@ -100,11 +95,9 @@ 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 (0, util_1.withTimeout)(MAX_CACHE_OPERATION_MS, cache.restoreCache([cacheDir], preferredKey, [
|
const found = await 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,
|
||||||
@@ -126,6 +119,7 @@ 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)
|
||||||
@@ -141,10 +135,9 @@ 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}`);
|
||||||
await (0, util_1.withTimeout)(MAX_CACHE_OPERATION_MS, cache.saveCache([cacheDir], key), () => {
|
toAwait.push(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
67
lib/util.js
generated
67
lib/util.js
generated
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.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;
|
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.getTotalMemoryBytes = 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"));
|
||||||
@@ -130,7 +130,7 @@ function getMemoryFlagValue(userInput) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const totalMemoryBytes = os.totalmem();
|
const totalMemoryBytes = getTotalMemoryBytes();
|
||||||
const totalMemoryMegaBytes = totalMemoryBytes / (1024 * 1024);
|
const totalMemoryMegaBytes = totalMemoryBytes / (1024 * 1024);
|
||||||
const reservedMemoryMegaBytes = getSystemReservedMemoryMegaBytes();
|
const reservedMemoryMegaBytes = getSystemReservedMemoryMegaBytes();
|
||||||
memoryToUseMegaBytes = totalMemoryMegaBytes - reservedMemoryMegaBytes;
|
memoryToUseMegaBytes = totalMemoryMegaBytes - reservedMemoryMegaBytes;
|
||||||
@@ -138,6 +138,41 @@ function getMemoryFlagValue(userInput) {
|
|||||||
return Math.floor(memoryToUseMegaBytes);
|
return Math.floor(memoryToUseMegaBytes);
|
||||||
}
|
}
|
||||||
exports.getMemoryFlagValue = getMemoryFlagValue;
|
exports.getMemoryFlagValue = getMemoryFlagValue;
|
||||||
|
function getTotalMemoryBytes() {
|
||||||
|
const nodeReportedMemory = os.totalmem();
|
||||||
|
console.log(`Node reported ${nodeReportedMemory} bytes of memory.`);
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
console.log("On Windows, so just returning the memory Node reported.");
|
||||||
|
return nodeReportedMemory;
|
||||||
|
}
|
||||||
|
let lowestMemorySeen = nodeReportedMemory;
|
||||||
|
try {
|
||||||
|
const dockerMemoryLimit = parseInt(fs.readFileSync("/sys/fs/cgroup/memory/memory.limit_in_bytes", "utf8"));
|
||||||
|
console.log(`Docker set a limit of ${dockerMemoryLimit} bytes of memory.`);
|
||||||
|
lowestMemorySeen = Math.min(lowestMemorySeen, dockerMemoryLimit);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const memoryInfo = fs.readFileSync("/proc/meminfo", "utf8").split("\n");
|
||||||
|
const relevantLine = /^\s*MemTotal:\s*(\d+)\s*kB\s*$/;
|
||||||
|
for (const line of memoryInfo) {
|
||||||
|
const match = relevantLine.exec(line);
|
||||||
|
if (match) {
|
||||||
|
const memoryFromMemoryInfo = parseInt(match[1]) * 1024;
|
||||||
|
console.log(`Found total memory of ${memoryFromMemoryInfo} in memory info.`);
|
||||||
|
lowestMemorySeen = Math.min(lowestMemorySeen, memoryFromMemoryInfo);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
return lowestMemorySeen;
|
||||||
|
}
|
||||||
|
exports.getTotalMemoryBytes = getTotalMemoryBytes;
|
||||||
/**
|
/**
|
||||||
* Get the codeql `--ram` flag as configured by the `ram` input. If no value was
|
* Get the codeql `--ram` flag as configured by the `ram` input. If no value was
|
||||||
* specified, the total available memory will be used minus a threshold
|
* specified, the total available memory will be used minus a threshold
|
||||||
@@ -679,15 +714,6 @@ 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.
|
||||||
*/
|
*/
|
||||||
@@ -744,23 +770,4 @@ 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
|
||||||
File diff suppressed because one or more lines are too long
28
lib/util.test.js
generated
28
lib/util.test.js
generated
@@ -396,32 +396,4 @@ 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
|
||||||
File diff suppressed because one or more lines are too long
2
node_modules/.package-lock.json
generated
vendored
2
node_modules/.package-lock.json
generated
vendored
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "codeql",
|
"name": "codeql",
|
||||||
"version": "2.1.28",
|
"version": "2.1.26",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "codeql",
|
"name": "codeql",
|
||||||
"version": "2.1.28",
|
"version": "2.1.26",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "codeql",
|
"name": "codeql",
|
||||||
"version": "2.1.28",
|
"version": "2.1.26",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/artifact": "^1.0.0",
|
"@actions/artifact": "^1.0.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "codeql",
|
"name": "codeql",
|
||||||
"version": "2.1.28",
|
"version": "2.1.26",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "CodeQL action",
|
"description": "CodeQL action",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -239,9 +239,6 @@ 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 @@
|
|||||||
{"maximumVersion": "3.7", "minimumVersion": "3.2"}
|
{"maximumVersion": "3.7", "minimumVersion": "3.3"}
|
||||||
|
|||||||
@@ -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({
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
return await codeql.setupCodeQL(
|
await codeql.setupCodeQL(
|
||||||
toolsInput ? toolsInput.input : `${baseUrl}${relativeUrl}`,
|
toolsInput ? toolsInput.input : `${baseUrl}${relativeUrl}`,
|
||||||
apiDetails ?? sampleApiDetails,
|
apiDetails ?? sampleApiDetails,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
@@ -124,9 +124,8 @@ 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];
|
||||||
|
|
||||||
const codeQLConfig = await mockApiAndSetupCodeQL({ version, tmpDir });
|
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);
|
||||||
@@ -137,20 +136,15 @@ 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);
|
||||||
|
|
||||||
const pinnedCodeQLConfig = await mockApiAndSetupCodeQL({
|
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");
|
|
||||||
|
|
||||||
const unpinnedCodeQLConfig = await mockApiAndSetupCodeQL({
|
await mockApiAndSetupCodeQL({ version: "20200610", tmpDir });
|
||||||
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");
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -158,16 +152,15 @@ 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);
|
||||||
|
|
||||||
const pinnedCodeQLConfig = await mockApiAndSetupCodeQL({
|
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");
|
|
||||||
|
|
||||||
const codeQLConfig = await codeql.setupCodeQL(
|
await codeql.setupCodeQL(
|
||||||
undefined,
|
undefined,
|
||||||
sampleApiDetails,
|
sampleApiDetails,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
@@ -176,7 +169,6 @@ 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");
|
||||||
|
|
||||||
@@ -188,24 +180,16 @@ 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);
|
||||||
|
|
||||||
const cachedCodeQLConfig = await mockApiAndSetupCodeQL({
|
await mockApiAndSetupCodeQL({ version: "20200601", tmpDir });
|
||||||
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");
|
|
||||||
|
|
||||||
const codeQLConfig = await mockApiAndSetupCodeQL({
|
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");
|
||||||
|
|
||||||
@@ -217,25 +201,20 @@ 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);
|
||||||
|
|
||||||
const pinnedCodeQLConfig = await mockApiAndSetupCodeQL({
|
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");
|
|
||||||
|
|
||||||
const latestCodeQLConfig = await mockApiAndSetupCodeQL({
|
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");
|
||||||
|
|
||||||
|
|||||||
@@ -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 a { CodeQL, toolsVersion } object.
|
* @returns
|
||||||
*/
|
*/
|
||||||
export async function setupCodeQL(
|
export async function setupCodeQL(
|
||||||
codeqlURL: string | undefined,
|
codeqlURL: string | undefined,
|
||||||
@@ -479,7 +479,6 @@ 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];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ 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";
|
||||||
@@ -1705,8 +1704,6 @@ 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(
|
||||||
|
|||||||
55
src/init.ts
55
src/init.ts
@@ -117,7 +117,24 @@ export async function runInit(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw processError(e);
|
// Handle the situation where init is called twice
|
||||||
|
// 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,
|
||||||
@@ -127,42 +144,6 @@ 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
|
||||||
|
|||||||
@@ -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, withTimeout } from "./util";
|
import { codeQlVersionAbove, tryGetFolderBytes } 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,12 +24,6 @@ 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[]> {
|
||||||
@@ -113,17 +107,9 @@ 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 withTimeout(
|
const found = await cache.restoreCache([cacheDir], preferredKey, [
|
||||||
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,
|
||||||
@@ -150,6 +136,7 @@ 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;
|
||||||
@@ -172,16 +159,9 @@ 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}`);
|
||||||
await withTimeout(
|
toAwait.push(cache.saveCache([cacheDir], key));
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -601,34 +601,3 @@ 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);
|
|
||||||
});
|
|
||||||
|
|||||||
79
src/util.ts
79
src/util.ts
@@ -162,7 +162,7 @@ export function getMemoryFlagValue(userInput: string | undefined): number {
|
|||||||
throw new Error(`Invalid RAM setting "${userInput}", specified.`);
|
throw new Error(`Invalid RAM setting "${userInput}", specified.`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const totalMemoryBytes = os.totalmem();
|
const totalMemoryBytes = getTotalMemoryBytes();
|
||||||
const totalMemoryMegaBytes = totalMemoryBytes / (1024 * 1024);
|
const totalMemoryMegaBytes = totalMemoryBytes / (1024 * 1024);
|
||||||
const reservedMemoryMegaBytes = getSystemReservedMemoryMegaBytes();
|
const reservedMemoryMegaBytes = getSystemReservedMemoryMegaBytes();
|
||||||
memoryToUseMegaBytes = totalMemoryMegaBytes - reservedMemoryMegaBytes;
|
memoryToUseMegaBytes = totalMemoryMegaBytes - reservedMemoryMegaBytes;
|
||||||
@@ -170,6 +170,43 @@ export function getMemoryFlagValue(userInput: string | undefined): number {
|
|||||||
return Math.floor(memoryToUseMegaBytes);
|
return Math.floor(memoryToUseMegaBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getTotalMemoryBytes(): number {
|
||||||
|
const nodeReportedMemory = os.totalmem();
|
||||||
|
console.log(`Node reported ${nodeReportedMemory} bytes of memory.`);
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
console.log("On Windows, so just returning the memory Node reported.");
|
||||||
|
return nodeReportedMemory;
|
||||||
|
}
|
||||||
|
let lowestMemorySeen = nodeReportedMemory;
|
||||||
|
try {
|
||||||
|
const dockerMemoryLimit = parseInt(
|
||||||
|
fs.readFileSync("/sys/fs/cgroup/memory/memory.limit_in_bytes", "utf8")
|
||||||
|
);
|
||||||
|
console.log(`Docker set a limit of ${dockerMemoryLimit} bytes of memory.`);
|
||||||
|
lowestMemorySeen = Math.min(lowestMemorySeen, dockerMemoryLimit);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const memoryInfo = fs.readFileSync("/proc/meminfo", "utf8").split("\n");
|
||||||
|
const relevantLine = /^\s*MemTotal:\s*(\d+)\s*kB\s*$/;
|
||||||
|
for (const line of memoryInfo) {
|
||||||
|
const match = relevantLine.exec(line);
|
||||||
|
if (match) {
|
||||||
|
const memoryFromMemoryInfo = parseInt(match[1]) * 1024;
|
||||||
|
console.log(
|
||||||
|
`Found total memory of ${memoryFromMemoryInfo} in memory info.`
|
||||||
|
);
|
||||||
|
lowestMemorySeen = Math.min(lowestMemorySeen, memoryFromMemoryInfo);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
return lowestMemorySeen;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the codeql `--ram` flag as configured by the `ram` input. If no value was
|
* Get the codeql `--ram` flag as configured by the `ram` input. If no value was
|
||||||
* specified, the total available memory will be used minus a threshold
|
* specified, the total available memory will be used minus a threshold
|
||||||
@@ -817,22 +854,6 @@ 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.
|
||||||
*/
|
*/
|
||||||
@@ -894,27 +915,3 @@ 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,10 +3,8 @@ 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:
|
tags contain: external/cwe/cwe-022
|
||||||
- external/cwe/cwe-022
|
|
||||||
|
|
||||||
# Removes js/path-injection
|
# Removes js/path-injection
|
||||||
- exclude:
|
- exclude:
|
||||||
id:
|
id: js/path-injection
|
||||||
- js/path-injection
|
|
||||||
|
|||||||
@@ -10,15 +10,12 @@ 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:
|
tags contain: external/cwe/cwe-022
|
||||||
- external/cwe/cwe-022
|
|
||||||
|
|
||||||
# Removes js/path-injection
|
# Removes js/path-injection
|
||||||
- exclude:
|
- exclude:
|
||||||
id:
|
id: js/path-injection
|
||||||
- js/path-injection
|
|
||||||
|
|
||||||
# Query from extra pack
|
# Query from extra pack
|
||||||
- include:
|
- include:
|
||||||
id:
|
id: javascript/example/empty-or-one-block
|
||||||
- javascript/example/empty-or-one-block
|
|
||||||
|
|||||||
@@ -20,20 +20,16 @@ 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:
|
tags contain: external/cwe/cwe-022
|
||||||
- external/cwe/cwe-022
|
|
||||||
|
|
||||||
# Removes js/path-injection
|
# Removes js/path-injection
|
||||||
- exclude:
|
- exclude:
|
||||||
id:
|
id: js/path-injection
|
||||||
- js/path-injection
|
|
||||||
|
|
||||||
# Query from extra pack
|
# Query from extra pack
|
||||||
- include:
|
- include:
|
||||||
id:
|
id: javascript/example/empty-or-one-block
|
||||||
- javascript/example/empty-or-one-block
|
|
||||||
|
|
||||||
# Local query
|
# Local query
|
||||||
- include:
|
- include:
|
||||||
id:
|
id: inrepo-javascript-querypack/show-ifs
|
||||||
- inrepo-javascript-querypack/show-ifs
|
|
||||||
|
|||||||
Reference in New Issue
Block a user