Merge pull request #1129 from github/update-v2.1.15-e8c48cc8
Merge main into releases/v2
This commit is contained in:
commit
3f62b754e2
34 changed files with 3339 additions and 239 deletions
9
.github/workflows/python-deps.yml
vendored
9
.github/workflows/python-deps.yml
vendored
|
|
@ -18,6 +18,11 @@ jobs:
|
|||
os: [ubuntu-latest, macos-latest]
|
||||
python_deps_type: [pipenv, poetry, requirements, setup_py]
|
||||
python_version: [2, 3]
|
||||
exclude:
|
||||
# Python2 and poetry are not supported. See https://github.com/actions/setup-python/issues/374
|
||||
- python_version: 2
|
||||
python_deps_type: poetry
|
||||
|
||||
|
||||
env:
|
||||
PYTHON_DEPS_TYPE: ${{ matrix.python_deps_type }}
|
||||
|
|
@ -115,6 +120,10 @@ jobs:
|
|||
matrix:
|
||||
python_deps_type: [pipenv, poetry, requirements, setup_py]
|
||||
python_version: [2, 3]
|
||||
exclude:
|
||||
# Python2 and poetry are not supported. See https://github.com/actions/setup-python/issues/374
|
||||
- python_version: 2
|
||||
python_deps_type: poetry
|
||||
|
||||
env:
|
||||
PYTHON_DEPS_TYPE: ${{ matrix.python_deps_type }}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
# CodeQL Action Changelog
|
||||
|
||||
## 2.1.15 - 28 Jun 2022
|
||||
|
||||
- CodeQL query packs listed in the `packs` configuration field will be skipped if their target language is not being analyzed in the current Actions job. Previously, this would throw an error. [#1116](https://github.com/github/codeql-action/pull/1116)
|
||||
- The combination of python2 and poetry is no longer supported. See https://github.com/actions/setup-python/issues/374 for more details. [#1124](https://github.com/github/codeql-action/pull/1124)
|
||||
- Update default CodeQL bundle version to 2.10.0. [#1123](https://github.com/github/codeql-action/pull/1123)
|
||||
|
||||
## 2.1.14 - 22 Jun 2022
|
||||
|
||||
No user facing changes.
|
||||
|
|
|
|||
6
lib/analyze-action.js
generated
6
lib/analyze-action.js
generated
|
|
@ -26,9 +26,11 @@ const artifact = __importStar(require("@actions/artifact"));
|
|||
const core = __importStar(require("@actions/core"));
|
||||
const actionsUtil = __importStar(require("./actions-util"));
|
||||
const analyze_1 = require("./analyze");
|
||||
const api_client_1 = require("./api-client");
|
||||
const codeql_1 = require("./codeql");
|
||||
const config_utils_1 = require("./config-utils");
|
||||
const database_upload_1 = require("./database-upload");
|
||||
const feature_flags_1 = require("./feature-flags");
|
||||
const logging_1 = require("./logging");
|
||||
const repository_1 = require("./repository");
|
||||
const upload_lib = __importStar(require("./upload-lib"));
|
||||
|
|
@ -76,7 +78,9 @@ async function run() {
|
|||
const threads = util.getThreadsFlag(actionsUtil.getOptionalInput("threads") || process.env["CODEQL_THREADS"], logger);
|
||||
const memory = util.getMemoryFlag(actionsUtil.getOptionalInput("ram") || process.env["CODEQL_RAM"]);
|
||||
const repositoryNwo = (0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY"));
|
||||
await (0, analyze_1.runFinalize)(outputDir, threads, memory, config, logger);
|
||||
const gitHubVersion = await (0, api_client_1.getGitHubVersionActionsOnly)();
|
||||
const featureFlags = new feature_flags_1.GitHubFeatureFlags(gitHubVersion, apiDetails, repositoryNwo, logger);
|
||||
await (0, analyze_1.runFinalize)(outputDir, threads, memory, config, logger, featureFlags);
|
||||
if (actionsUtil.getRequiredInput("skip-queries") !== "true") {
|
||||
runStats = await (0, analyze_1.runQueries)(outputDir, memory, util.getAddSnippetsFlag(actionsUtil.getRequiredInput("add-snippets")), threads, actionsUtil.getOptionalInput("category"), config, logger);
|
||||
if (config.debugMode) {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
16
lib/analyze.js
generated
16
lib/analyze.js
generated
|
|
@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.runCleanup = exports.runFinalize = exports.runQueries = exports.CodeQLAnalysisError = void 0;
|
||||
exports.runCleanup = exports.runFinalize = exports.runQueries = exports.createdDBForScannedLanguages = exports.CodeQLAnalysisError = void 0;
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
||||
|
|
@ -68,11 +68,10 @@ async function setupPythonExtractor(logger) {
|
|||
logger.info(`Setting LGTM_PYTHON_SETUP_VERSION=${output}`);
|
||||
process.env["LGTM_PYTHON_SETUP_VERSION"] = output;
|
||||
}
|
||||
async function createdDBForScannedLanguages(config, logger) {
|
||||
async function createdDBForScannedLanguages(codeql, config, logger, featureFlags) {
|
||||
// Insert the LGTM_INDEX_X env vars at this point so they are set when
|
||||
// we extract any scanned languages.
|
||||
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
||||
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||
for (const language of config.languages) {
|
||||
if ((0, languages_1.isScannedLanguage)(language) &&
|
||||
!dbIsFinalized(config, language, logger)) {
|
||||
|
|
@ -80,11 +79,12 @@ async function createdDBForScannedLanguages(config, logger) {
|
|||
if (language === languages_1.Language.python) {
|
||||
await setupPythonExtractor(logger);
|
||||
}
|
||||
await codeql.extractScannedLanguage(util.getCodeQLDatabasePath(config, language), language);
|
||||
await codeql.extractScannedLanguage(util.getCodeQLDatabasePath(config, language), language, featureFlags);
|
||||
logger.endGroup();
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.createdDBForScannedLanguages = createdDBForScannedLanguages;
|
||||
function dbIsFinalized(config, language, logger) {
|
||||
const dbPath = util.getCodeQLDatabasePath(config, language);
|
||||
try {
|
||||
|
|
@ -96,9 +96,9 @@ function dbIsFinalized(config, language, logger) {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
async function finalizeDatabaseCreation(config, threadsFlag, memoryFlag, logger) {
|
||||
await createdDBForScannedLanguages(config, logger);
|
||||
async function finalizeDatabaseCreation(config, threadsFlag, memoryFlag, logger, featureFlags) {
|
||||
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||
await createdDBForScannedLanguages(codeql, config, logger, featureFlags);
|
||||
for (const language of config.languages) {
|
||||
if (dbIsFinalized(config, language, logger)) {
|
||||
logger.info(`There is already a finalized database for ${language} at the location where the CodeQL Action places databases, so we did not create one.`);
|
||||
|
|
@ -238,7 +238,7 @@ exports.runQueries = runQueries;
|
|||
function createQuerySuiteContents(queries) {
|
||||
return queries.map((q) => `- query: ${q}`).join("\n");
|
||||
}
|
||||
async function runFinalize(outputDir, threadsFlag, memoryFlag, config, logger) {
|
||||
async function runFinalize(outputDir, threadsFlag, memoryFlag, config, logger, featureFlags) {
|
||||
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||
if (await util.codeQlVersionAbove(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING)) {
|
||||
// Delete variables as specified by the end-tracing script
|
||||
|
|
@ -257,7 +257,7 @@ async function runFinalize(outputDir, threadsFlag, memoryFlag, config, logger) {
|
|||
}
|
||||
}
|
||||
await fs.promises.mkdir(outputDir, { recursive: true });
|
||||
await finalizeDatabaseCreation(config, threadsFlag, memoryFlag, logger);
|
||||
await finalizeDatabaseCreation(config, threadsFlag, memoryFlag, logger, featureFlags);
|
||||
}
|
||||
exports.runFinalize = runFinalize;
|
||||
async function runCleanup(config, cleanupLevel, logger) {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
70
lib/analyze.test.js
generated
70
lib/analyze.test.js
generated
|
|
@ -29,7 +29,9 @@ const yaml = __importStar(require("js-yaml"));
|
|||
const sinon = __importStar(require("sinon"));
|
||||
const analyze_1 = require("./analyze");
|
||||
const codeql_1 = require("./codeql");
|
||||
const codeql_test_1 = require("./codeql.test");
|
||||
const count = __importStar(require("./count-loc"));
|
||||
const feature_flags_1 = require("./feature-flags");
|
||||
const languages_1 = require("./languages");
|
||||
const logging_1 = require("./logging");
|
||||
const testing_utils_1 = require("./testing-utils");
|
||||
|
|
@ -210,4 +212,72 @@ const util = __importStar(require("./util"));
|
|||
}
|
||||
}
|
||||
});
|
||||
const stubConfig = {
|
||||
languages: [languages_1.Language.cpp, languages_1.Language.go],
|
||||
queries: {},
|
||||
pathsIgnore: [],
|
||||
paths: [],
|
||||
originalUserInput: {},
|
||||
tempDir: "",
|
||||
toolCacheDir: "",
|
||||
codeQLCmd: "",
|
||||
gitHubVersion: {
|
||||
type: util.GitHubVariant.DOTCOM,
|
||||
},
|
||||
dbLocation: "",
|
||||
packs: {},
|
||||
debugMode: false,
|
||||
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME,
|
||||
debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME,
|
||||
injectedMlQueries: false,
|
||||
};
|
||||
for (const options of [
|
||||
{
|
||||
name: "Lua feature flag enabled, but old CLI",
|
||||
version: "2.9.0",
|
||||
featureFlags: [feature_flags_1.FeatureFlag.LuaTracerConfigEnabled],
|
||||
yesFlagSet: false,
|
||||
noFlagSet: false,
|
||||
},
|
||||
{
|
||||
name: "Lua feature flag disabled, with old CLI",
|
||||
version: "2.9.0",
|
||||
featureFlags: [],
|
||||
yesFlagSet: false,
|
||||
noFlagSet: false,
|
||||
},
|
||||
{
|
||||
name: "Lua feature flag enabled, with new CLI",
|
||||
version: "2.10.0",
|
||||
featureFlags: [feature_flags_1.FeatureFlag.LuaTracerConfigEnabled],
|
||||
yesFlagSet: true,
|
||||
noFlagSet: false,
|
||||
},
|
||||
{
|
||||
name: "Lua feature flag disabled, with new CLI",
|
||||
version: "2.10.0",
|
||||
featureFlags: [],
|
||||
yesFlagSet: false,
|
||||
noFlagSet: true,
|
||||
},
|
||||
]) {
|
||||
(0, ava_1.default)(`createdDBForScannedLanguages() ${options.name}`, async (t) => {
|
||||
const runnerConstructorStub = (0, codeql_test_1.stubToolRunnerConstructor)();
|
||||
const codeqlObject = await (0, codeql_1.getCodeQLForTesting)("codeql/for-testing");
|
||||
sinon.stub(codeqlObject, "getVersion").resolves(options.version);
|
||||
const promise = (0, analyze_1.createdDBForScannedLanguages)(codeqlObject, stubConfig, (0, logging_1.getRunnerLogger)(true), (0, feature_flags_1.createFeatureFlags)(options.featureFlags));
|
||||
// call listener on `codeql resolve extractor`
|
||||
const mockToolRunner = runnerConstructorStub.getCall(0);
|
||||
mockToolRunner.args[2].listeners.stdout('"/path/to/extractor"');
|
||||
await promise;
|
||||
if (options.yesFlagSet)
|
||||
t.true(runnerConstructorStub.secondCall.args[1].includes("--internal-use-lua-tracing"), "--internal-use-lua-tracing should be present, but it is absent");
|
||||
else
|
||||
t.false(runnerConstructorStub.secondCall.args[1].includes("--internal-use-lua-tracing"), "--internal-use-lua-tracing should be absent, but it is present");
|
||||
if (options.noFlagSet)
|
||||
t.true(runnerConstructorStub.secondCall.args[1].includes("--no-internal-use-lua-tracing"), "--no-internal-use-lua-tracing should be present, but it is absent");
|
||||
else
|
||||
t.false(runnerConstructorStub.secondCall.args[1].includes("--no-internal-use-lua-tracing"), "--no-internal-use-lua-tracing should be absent, but it is present");
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=analyze.test.js.map
|
||||
File diff suppressed because one or more lines are too long
16
lib/codeql.js
generated
16
lib/codeql.js
generated
|
|
@ -384,8 +384,8 @@ exports.getCachedCodeQL = getCachedCodeQL;
|
|||
* a non-existent placeholder codeql command, so tests that use this function
|
||||
* should also stub the toolrunner.ToolRunner constructor.
|
||||
*/
|
||||
async function getCodeQLForTesting() {
|
||||
return getCodeQLForCmd("codeql-for-testing", false);
|
||||
async function getCodeQLForTesting(cmd = "codeql-for-testing") {
|
||||
return getCodeQLForCmd(cmd, false);
|
||||
}
|
||||
exports.getCodeQLForTesting = getCodeQLForTesting;
|
||||
/**
|
||||
|
|
@ -510,7 +510,7 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
|||
].join(" ");
|
||||
await runTool(autobuildCmd);
|
||||
},
|
||||
async extractScannedLanguage(databasePath, language) {
|
||||
async extractScannedLanguage(databasePath, language, featureFlags) {
|
||||
// Get extractor location
|
||||
let extractorPath = "";
|
||||
await new toolrunner.ToolRunner(cmd, [
|
||||
|
|
@ -533,10 +533,20 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
|||
// Set trace command
|
||||
const ext = process.platform === "win32" ? ".cmd" : ".sh";
|
||||
const traceCommand = path.resolve(JSON.parse(extractorPath), "tools", `autobuild${ext}`);
|
||||
const extraArgs = [];
|
||||
if (await util.codeQlVersionAbove(this, CODEQL_VERSION_LUA_TRACER_CONFIG)) {
|
||||
if (await featureFlags.getValue(feature_flags_1.FeatureFlag.LuaTracerConfigEnabled)) {
|
||||
extraArgs.push("--internal-use-lua-tracing");
|
||||
}
|
||||
else {
|
||||
extraArgs.push("--no-internal-use-lua-tracing");
|
||||
}
|
||||
}
|
||||
// Run trace command
|
||||
await (0, toolrunner_error_catcher_1.toolrunnerErrorCatcher)(cmd, [
|
||||
"database",
|
||||
"trace-command",
|
||||
...extraArgs,
|
||||
...getExtraOptionsFromEnv(["database", "trace-command"]),
|
||||
databasePath,
|
||||
"--",
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
2
lib/codeql.test.js
generated
2
lib/codeql.test.js
generated
|
|
@ -22,6 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.stubToolRunnerConstructor = void 0;
|
||||
const path = __importStar(require("path"));
|
||||
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
||||
const toolcache = __importStar(require("@actions/tool-cache"));
|
||||
|
|
@ -291,4 +292,5 @@ function stubToolRunnerConstructor() {
|
|||
runnerConstructorStub.returns(runnerObjectStub);
|
||||
return runnerConstructorStub;
|
||||
}
|
||||
exports.stubToolRunnerConstructor = stubToolRunnerConstructor;
|
||||
//# sourceMappingURL=codeql.test.js.map
|
||||
File diff suppressed because one or more lines are too long
23
lib/config-utils.js
generated
23
lib/config-utils.js
generated
|
|
@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getConfig = exports.getPathToParsedConfigFile = exports.initConfig = exports.parsePacks = exports.validatePacksSpecification = exports.parsePacksFromConfig = exports.getDefaultConfig = exports.getUnknownLanguagesError = exports.getNoLanguagesError = exports.getConfigFileDirectoryGivenMessage = exports.getConfigFileFormatInvalidMessage = exports.getConfigFileRepoFormatInvalidMessage = exports.getConfigFileDoesNotExistErrorMessage = exports.getConfigFileOutsideWorkspaceErrorMessage = exports.getLocalPathDoesNotExist = exports.getLocalPathOutsideOfRepository = exports.getPacksStrInvalid = exports.getPacksInvalid = exports.getPacksInvalidSplit = exports.getPacksRequireLanguage = exports.getPathsInvalid = exports.getPathsIgnoreInvalid = exports.getQueryUsesInvalid = exports.getQueriesInvalid = exports.getDisableDefaultQueriesInvalid = exports.getNameInvalid = exports.validateAndSanitisePath = void 0;
|
||||
exports.getConfig = exports.getPathToParsedConfigFile = exports.initConfig = exports.parsePacks = exports.validatePacksSpecification = exports.parsePacksFromConfig = exports.getDefaultConfig = exports.getUnknownLanguagesError = exports.getNoLanguagesError = exports.getConfigFileDirectoryGivenMessage = exports.getConfigFileFormatInvalidMessage = exports.getConfigFileRepoFormatInvalidMessage = exports.getConfigFileDoesNotExistErrorMessage = exports.getConfigFileOutsideWorkspaceErrorMessage = exports.getLocalPathDoesNotExist = exports.getLocalPathOutsideOfRepository = exports.getPacksStrInvalid = exports.getPacksInvalid = exports.getPacksInvalidSplit = exports.getPathsInvalid = exports.getPathsIgnoreInvalid = exports.getQueryUsesInvalid = exports.getQueriesInvalid = exports.getDisableDefaultQueriesInvalid = exports.getNameInvalid = exports.validateAndSanitisePath = void 0;
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
const yaml = __importStar(require("js-yaml"));
|
||||
|
|
@ -306,9 +306,8 @@ function getPathsInvalid(configFile) {
|
|||
}
|
||||
exports.getPathsInvalid = getPathsInvalid;
|
||||
function getPacksRequireLanguage(lang, configFile) {
|
||||
return getConfigFilePropertyError(configFile, PACKS_PROPERTY, `has "${lang}", but it is not one of the languages to analyze`);
|
||||
return getConfigFilePropertyError(configFile, PACKS_PROPERTY, `has "${lang}", but it is not a valid language.`);
|
||||
}
|
||||
exports.getPacksRequireLanguage = getPacksRequireLanguage;
|
||||
function getPacksInvalidSplit(configFile) {
|
||||
return getConfigFilePropertyError(configFile, PACKS_PROPERTY, "must split packages by language");
|
||||
}
|
||||
|
|
@ -542,7 +541,7 @@ async function loadConfig(languagesInput, queriesInput, packsInput, configFile,
|
|||
if (!disableDefaultQueries) {
|
||||
await addDefaultQueries(codeQL, languages, queries);
|
||||
}
|
||||
const packs = parsePacks((_a = parsedYAML[PACKS_PROPERTY]) !== null && _a !== void 0 ? _a : {}, packsInput, languages, configFile);
|
||||
const packs = parsePacks((_a = parsedYAML[PACKS_PROPERTY]) !== null && _a !== void 0 ? _a : {}, packsInput, languages, configFile, logger);
|
||||
// If queries were provided using `with` in the action configuration,
|
||||
// they should take precedence over the queries in the config file
|
||||
// unless they're prefixed with "+", in which case they supplement those
|
||||
|
|
@ -616,7 +615,7 @@ const PACK_IDENTIFIER_PATTERN = (function () {
|
|||
return new RegExp(`^${component}/${component}$`);
|
||||
})();
|
||||
// Exported for testing
|
||||
function parsePacksFromConfig(packsByLanguage, languages, configFile) {
|
||||
function parsePacksFromConfig(packsByLanguage, languages, configFile, logger) {
|
||||
const packs = {};
|
||||
if (Array.isArray(packsByLanguage)) {
|
||||
if (languages.length === 1) {
|
||||
|
|
@ -636,7 +635,15 @@ function parsePacksFromConfig(packsByLanguage, languages, configFile) {
|
|||
throw new Error(getPacksInvalid(configFile));
|
||||
}
|
||||
if (!languages.includes(lang)) {
|
||||
throw new Error(getPacksRequireLanguage(lang, configFile));
|
||||
// This particular language is not being analyzed in this run.
|
||||
if (languages_1.Language[lang]) {
|
||||
logger.info(`Ignoring packs for ${lang} since this language is not being analyzed in this run.`);
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
// This language is invalid, probably a misspelling
|
||||
throw new Error(getPacksRequireLanguage(configFile, lang));
|
||||
}
|
||||
}
|
||||
packs[lang] = [];
|
||||
for (const packStr of packsArr) {
|
||||
|
|
@ -734,9 +741,9 @@ function validatePacksSpecification(packStr, configFile) {
|
|||
}
|
||||
exports.validatePacksSpecification = validatePacksSpecification;
|
||||
// exported for testing
|
||||
function parsePacks(rawPacksFromConfig, rawPacksInput, languages, configFile) {
|
||||
function parsePacks(rawPacksFromConfig, rawPacksInput, languages, configFile, logger) {
|
||||
const packsFromInput = parsePacksFromInput(rawPacksInput, languages);
|
||||
const packsFomConfig = parsePacksFromConfig(rawPacksFromConfig, languages, configFile);
|
||||
const packsFomConfig = parsePacksFromConfig(rawPacksFromConfig, languages, configFile, logger);
|
||||
if (!packsFromInput) {
|
||||
return packsFomConfig;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
20
lib/config-utils.test.js
generated
20
lib/config-utils.test.js
generated
|
|
@ -749,14 +749,14 @@ const invalidPaths = ["a/***/b", "a/**b", "a/b**", "**"];
|
|||
* Test macro for ensuring the packs block is valid
|
||||
*/
|
||||
const parsePacksMacro = ava_1.default.macro({
|
||||
exec: (t, packsByLanguage, languages, expected) => t.deepEqual(configUtils.parsePacksFromConfig(packsByLanguage, languages, "/a/b"), expected),
|
||||
exec: (t, packsByLanguage, languages, expected) => t.deepEqual(configUtils.parsePacksFromConfig(packsByLanguage, languages, "/a/b", mockLogger), expected),
|
||||
title: (providedTitle = "") => `Parse Packs: ${providedTitle}`,
|
||||
});
|
||||
/**
|
||||
* Test macro for testing when the packs block is invalid
|
||||
*/
|
||||
const parsePacksErrorMacro = ava_1.default.macro({
|
||||
exec: (t, packsByLanguage, languages, expected) => t.throws(() => configUtils.parsePacksFromConfig(packsByLanguage, languages, "/a/b"), {
|
||||
exec: (t, packsByLanguage, languages, expected) => t.throws(() => configUtils.parsePacksFromConfig(packsByLanguage, languages, "/a/b", {}), {
|
||||
message: expected,
|
||||
}),
|
||||
title: (providedTitle = "") => `Parse Packs Error: ${providedTitle}`,
|
||||
|
|
@ -782,6 +782,12 @@ const invalidPackNameMacro = ava_1.default.macro({
|
|||
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
|
||||
[languages_1.Language.java]: ["d/e", "f/g@1.2.3"],
|
||||
});
|
||||
(0, ava_1.default)("two packs with unused language in config", parsePacksMacro, {
|
||||
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
|
||||
[languages_1.Language.java]: ["d/e", "f/g@1.2.3"],
|
||||
}, [languages_1.Language.cpp, languages_1.Language.csharp], {
|
||||
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
|
||||
});
|
||||
(0, ava_1.default)("packs with other valid names", parsePacksMacro, [
|
||||
// ranges are ok
|
||||
"c/d@1.0",
|
||||
|
|
@ -814,7 +820,6 @@ const invalidPackNameMacro = ava_1.default.macro({
|
|||
],
|
||||
});
|
||||
(0, ava_1.default)("no language", parsePacksErrorMacro, ["a/b@1.2.3"], [languages_1.Language.java, languages_1.Language.python], /The configuration file "\/a\/b" is invalid: property "packs" must split packages by language/);
|
||||
(0, ava_1.default)("invalid language", parsePacksErrorMacro, { [languages_1.Language.java]: ["c/d"] }, [languages_1.Language.cpp], /The configuration file "\/a\/b" is invalid: property "packs" has "java", but it is not one of the languages to analyze/);
|
||||
(0, ava_1.default)("not an array", parsePacksErrorMacro, { [languages_1.Language.cpp]: "c/d" }, [languages_1.Language.cpp], /The configuration file "\/a\/b" is invalid: property "packs" must be an array of non-empty strings/);
|
||||
(0, ava_1.default)(invalidPackNameMacro, "c"); // all packs require at least a scope and a name
|
||||
(0, ava_1.default)(invalidPackNameMacro, "c-/d");
|
||||
|
|
@ -832,12 +837,17 @@ const invalidPackNameMacro = ava_1.default.macro({
|
|||
* Test macro for testing the packs block and the packs input
|
||||
*/
|
||||
function parseInputAndConfigMacro(t, packsFromConfig, packsFromInput, languages, expected) {
|
||||
t.deepEqual(configUtils.parsePacks(packsFromConfig, packsFromInput, languages, "/a/b"), expected);
|
||||
t.deepEqual(configUtils.parsePacks(packsFromConfig, packsFromInput, languages, "/a/b", mockLogger), expected);
|
||||
}
|
||||
parseInputAndConfigMacro.title = (providedTitle) => `Parse Packs input and config: ${providedTitle}`;
|
||||
const mockLogger = {
|
||||
info: (message) => {
|
||||
console.log(message);
|
||||
},
|
||||
};
|
||||
function parseInputAndConfigErrorMacro(t, packsFromConfig, packsFromInput, languages, expected) {
|
||||
t.throws(() => {
|
||||
configUtils.parsePacks(packsFromConfig, packsFromInput, languages, "/a/b");
|
||||
configUtils.parsePacks(packsFromConfig, packsFromInput, languages, "/a/b", mockLogger);
|
||||
}, {
|
||||
message: expected,
|
||||
});
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"bundleVersion": "codeql-bundle-20220615"
|
||||
"bundleVersion": "codeql-bundle-20220623"
|
||||
}
|
||||
|
|
|
|||
2
lib/runner.js
generated
2
lib/runner.js
generated
|
|
@ -297,7 +297,7 @@ program
|
|||
}
|
||||
const threads = (0, util_1.getThreadsFlag)(cmd.threads || initEnv["CODEQL_THREADS"], logger);
|
||||
const memory = (0, util_1.getMemoryFlag)(cmd.ram || initEnv["CODEQL_RAM"]);
|
||||
await (0, analyze_1.runFinalize)(outputDir, threads, memory, config, logger);
|
||||
await (0, analyze_1.runFinalize)(outputDir, threads, memory, config, logger, (0, feature_flags_1.createFeatureFlags)([]));
|
||||
await (0, analyze_1.runQueries)(outputDir, memory, (0, util_1.getAddSnippetsFlag)(cmd.addSnippets), threads, cmd.category, config, logger);
|
||||
if (!cmd.upload) {
|
||||
logger.info("Not uploading results");
|
||||
|
|
|
|||
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",
|
||||
"version": "2.1.14",
|
||||
"version": "2.1.15",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
|
|
|||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "codeql",
|
||||
"version": "2.1.14",
|
||||
"version": "2.1.15",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "codeql",
|
||||
"version": "2.1.14",
|
||||
"version": "2.1.15",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/artifact": "^1.0.0",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "codeql",
|
||||
"version": "2.1.14",
|
||||
"version": "2.1.15",
|
||||
"private": true,
|
||||
"description": "CodeQL action",
|
||||
"scripts": {
|
||||
|
|
|
|||
3106
runner/package-lock.json
generated
3106
runner/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -7,11 +7,10 @@
|
|||
"build-runner": "webpack --mode production && pkg dist/codeql-runner.js --out-path dist"
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"pkg": "^5.3.1",
|
||||
"ts-loader": "9.2.5",
|
||||
"webpack": "^5.50.0",
|
||||
"webpack-cli": "^4.7.2"
|
||||
"ts-loader": "^9.3.1",
|
||||
"webpack": "^5.73.0",
|
||||
"webpack-cli": "^4.10.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,9 +12,11 @@ import {
|
|||
runQueries,
|
||||
runFinalize,
|
||||
} from "./analyze";
|
||||
import { getGitHubVersionActionsOnly } from "./api-client";
|
||||
import { CODEQL_VERSION_NEW_TRACING, getCodeQL } from "./codeql";
|
||||
import { Config, getConfig } from "./config-utils";
|
||||
import { uploadDatabases } from "./database-upload";
|
||||
import { GitHubFeatureFlags } from "./feature-flags";
|
||||
import { getActionsLogger } from "./logging";
|
||||
import { parseRepositoryNwo } from "./repository";
|
||||
import * as upload_lib from "./upload-lib";
|
||||
|
|
@ -112,7 +114,16 @@ async function run() {
|
|||
util.getRequiredEnvParam("GITHUB_REPOSITORY")
|
||||
);
|
||||
|
||||
await runFinalize(outputDir, threads, memory, config, logger);
|
||||
const gitHubVersion = await getGitHubVersionActionsOnly();
|
||||
|
||||
const featureFlags = new GitHubFeatureFlags(
|
||||
gitHubVersion,
|
||||
apiDetails,
|
||||
repositoryNwo,
|
||||
logger
|
||||
);
|
||||
|
||||
await runFinalize(outputDir, threads, memory, config, logger, featureFlags);
|
||||
if (actionsUtil.getRequiredInput("skip-queries") !== "true") {
|
||||
runStats = await runQueries(
|
||||
outputDir,
|
||||
|
|
|
|||
|
|
@ -5,10 +5,12 @@ import test from "ava";
|
|||
import * as yaml from "js-yaml";
|
||||
import * as sinon from "sinon";
|
||||
|
||||
import { runQueries } from "./analyze";
|
||||
import { setCodeQL } from "./codeql";
|
||||
import { runQueries, createdDBForScannedLanguages } from "./analyze";
|
||||
import { setCodeQL, getCodeQLForTesting } from "./codeql";
|
||||
import { stubToolRunnerConstructor } from "./codeql.test";
|
||||
import { Config } from "./config-utils";
|
||||
import * as count from "./count-loc";
|
||||
import { createFeatureFlags, FeatureFlag } from "./feature-flags";
|
||||
import { Language } from "./languages";
|
||||
import { getRunnerLogger } from "./logging";
|
||||
import { setupTests, setupActionsVars } from "./testing-utils";
|
||||
|
|
@ -249,3 +251,99 @@ test("status report fields and search path setting", async (t) => {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
const stubConfig: Config = {
|
||||
languages: [Language.cpp, Language.go],
|
||||
queries: {},
|
||||
pathsIgnore: [],
|
||||
paths: [],
|
||||
originalUserInput: {},
|
||||
tempDir: "",
|
||||
toolCacheDir: "",
|
||||
codeQLCmd: "",
|
||||
gitHubVersion: {
|
||||
type: util.GitHubVariant.DOTCOM,
|
||||
} as util.GitHubVersion,
|
||||
dbLocation: "",
|
||||
packs: {},
|
||||
debugMode: false,
|
||||
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME,
|
||||
debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME,
|
||||
injectedMlQueries: false,
|
||||
};
|
||||
|
||||
for (const options of [
|
||||
{
|
||||
name: "Lua feature flag enabled, but old CLI",
|
||||
version: "2.9.0",
|
||||
featureFlags: [FeatureFlag.LuaTracerConfigEnabled],
|
||||
yesFlagSet: false,
|
||||
noFlagSet: false,
|
||||
},
|
||||
{
|
||||
name: "Lua feature flag disabled, with old CLI",
|
||||
version: "2.9.0",
|
||||
featureFlags: [],
|
||||
yesFlagSet: false,
|
||||
noFlagSet: false,
|
||||
},
|
||||
{
|
||||
name: "Lua feature flag enabled, with new CLI",
|
||||
version: "2.10.0",
|
||||
featureFlags: [FeatureFlag.LuaTracerConfigEnabled],
|
||||
yesFlagSet: true,
|
||||
noFlagSet: false,
|
||||
},
|
||||
{
|
||||
name: "Lua feature flag disabled, with new CLI",
|
||||
version: "2.10.0",
|
||||
featureFlags: [],
|
||||
yesFlagSet: false,
|
||||
noFlagSet: true,
|
||||
},
|
||||
]) {
|
||||
test(`createdDBForScannedLanguages() ${options.name}`, async (t) => {
|
||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||
const codeqlObject = await getCodeQLForTesting("codeql/for-testing");
|
||||
sinon.stub(codeqlObject, "getVersion").resolves(options.version);
|
||||
|
||||
const promise = createdDBForScannedLanguages(
|
||||
codeqlObject,
|
||||
stubConfig,
|
||||
getRunnerLogger(true),
|
||||
createFeatureFlags(options.featureFlags)
|
||||
);
|
||||
// call listener on `codeql resolve extractor`
|
||||
const mockToolRunner = runnerConstructorStub.getCall(0);
|
||||
mockToolRunner.args[2].listeners.stdout('"/path/to/extractor"');
|
||||
await promise;
|
||||
if (options.yesFlagSet)
|
||||
t.true(
|
||||
runnerConstructorStub.secondCall.args[1].includes(
|
||||
"--internal-use-lua-tracing"
|
||||
),
|
||||
"--internal-use-lua-tracing should be present, but it is absent"
|
||||
);
|
||||
else
|
||||
t.false(
|
||||
runnerConstructorStub.secondCall.args[1].includes(
|
||||
"--internal-use-lua-tracing"
|
||||
),
|
||||
"--internal-use-lua-tracing should be absent, but it is present"
|
||||
);
|
||||
if (options.noFlagSet)
|
||||
t.true(
|
||||
runnerConstructorStub.secondCall.args[1].includes(
|
||||
"--no-internal-use-lua-tracing"
|
||||
),
|
||||
"--no-internal-use-lua-tracing should be present, but it is absent"
|
||||
);
|
||||
else
|
||||
t.false(
|
||||
runnerConstructorStub.secondCall.args[1].includes(
|
||||
"--no-internal-use-lua-tracing"
|
||||
),
|
||||
"--no-internal-use-lua-tracing should be absent, but it is present"
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,12 +7,14 @@ import * as yaml from "js-yaml";
|
|||
|
||||
import * as analysisPaths from "./analysis-paths";
|
||||
import {
|
||||
CodeQL,
|
||||
CODEQL_VERSION_COUNTS_LINES,
|
||||
CODEQL_VERSION_NEW_TRACING,
|
||||
getCodeQL,
|
||||
} from "./codeql";
|
||||
import * as configUtils from "./config-utils";
|
||||
import { countLoc } from "./count-loc";
|
||||
import { FeatureFlags } from "./feature-flags";
|
||||
import { isScannedLanguage, Language } from "./languages";
|
||||
import { Logger } from "./logging";
|
||||
import * as sharedEnv from "./shared-environment";
|
||||
|
|
@ -114,15 +116,16 @@ async function setupPythonExtractor(logger: Logger) {
|
|||
process.env["LGTM_PYTHON_SETUP_VERSION"] = output;
|
||||
}
|
||||
|
||||
async function createdDBForScannedLanguages(
|
||||
export async function createdDBForScannedLanguages(
|
||||
codeql: CodeQL,
|
||||
config: configUtils.Config,
|
||||
logger: Logger
|
||||
logger: Logger,
|
||||
featureFlags: FeatureFlags
|
||||
) {
|
||||
// Insert the LGTM_INDEX_X env vars at this point so they are set when
|
||||
// we extract any scanned languages.
|
||||
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
||||
|
||||
const codeql = await getCodeQL(config.codeQLCmd);
|
||||
for (const language of config.languages) {
|
||||
if (
|
||||
isScannedLanguage(language) &&
|
||||
|
|
@ -136,7 +139,8 @@ async function createdDBForScannedLanguages(
|
|||
|
||||
await codeql.extractScannedLanguage(
|
||||
util.getCodeQLDatabasePath(config, language),
|
||||
language
|
||||
language,
|
||||
featureFlags
|
||||
);
|
||||
logger.endGroup();
|
||||
}
|
||||
|
|
@ -166,11 +170,12 @@ async function finalizeDatabaseCreation(
|
|||
config: configUtils.Config,
|
||||
threadsFlag: string,
|
||||
memoryFlag: string,
|
||||
logger: Logger
|
||||
logger: Logger,
|
||||
featureFlags: FeatureFlags
|
||||
) {
|
||||
await createdDBForScannedLanguages(config, logger);
|
||||
|
||||
const codeql = await getCodeQL(config.codeQLCmd);
|
||||
await createdDBForScannedLanguages(codeql, config, logger, featureFlags);
|
||||
|
||||
for (const language of config.languages) {
|
||||
if (dbIsFinalized(config, language, logger)) {
|
||||
logger.info(
|
||||
|
|
@ -425,7 +430,8 @@ export async function runFinalize(
|
|||
threadsFlag: string,
|
||||
memoryFlag: string,
|
||||
config: configUtils.Config,
|
||||
logger: Logger
|
||||
logger: Logger,
|
||||
featureFlags: FeatureFlags
|
||||
) {
|
||||
const codeql = await getCodeQL(config.codeQLCmd);
|
||||
if (await util.codeQlVersionAbove(codeql, CODEQL_VERSION_NEW_TRACING)) {
|
||||
|
|
@ -445,7 +451,13 @@ export async function runFinalize(
|
|||
}
|
||||
await fs.promises.mkdir(outputDir, { recursive: true });
|
||||
|
||||
await finalizeDatabaseCreation(config, threadsFlag, memoryFlag, logger);
|
||||
await finalizeDatabaseCreation(
|
||||
config,
|
||||
threadsFlag,
|
||||
memoryFlag,
|
||||
logger,
|
||||
featureFlags
|
||||
);
|
||||
}
|
||||
|
||||
export async function runCleanup(
|
||||
|
|
|
|||
|
|
@ -540,7 +540,7 @@ test("databaseInitCluster() Lua feature flag disabled, compatible CLI", async (t
|
|||
);
|
||||
});
|
||||
|
||||
function stubToolRunnerConstructor(): sinon.SinonStub<
|
||||
export function stubToolRunnerConstructor(): sinon.SinonStub<
|
||||
any[],
|
||||
toolrunner.ToolRunner
|
||||
> {
|
||||
|
|
|
|||
|
|
@ -95,7 +95,11 @@ export interface CodeQL {
|
|||
* Extract code for a scanned language using 'codeql database trace-command'
|
||||
* and running the language extractor.
|
||||
*/
|
||||
extractScannedLanguage(database: string, language: Language): Promise<void>;
|
||||
extractScannedLanguage(
|
||||
database: string,
|
||||
language: Language,
|
||||
featureFlags: FeatureFlags
|
||||
): Promise<void>;
|
||||
/**
|
||||
* Finalize a database using 'codeql database finalize'.
|
||||
*/
|
||||
|
|
@ -630,8 +634,10 @@ export function getCachedCodeQL(): CodeQL {
|
|||
* a non-existent placeholder codeql command, so tests that use this function
|
||||
* should also stub the toolrunner.ToolRunner constructor.
|
||||
*/
|
||||
export async function getCodeQLForTesting(): Promise<CodeQL> {
|
||||
return getCodeQLForCmd("codeql-for-testing", false);
|
||||
export async function getCodeQLForTesting(
|
||||
cmd = "codeql-for-testing"
|
||||
): Promise<CodeQL> {
|
||||
return getCodeQLForCmd(cmd, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -789,7 +795,11 @@ async function getCodeQLForCmd(
|
|||
|
||||
await runTool(autobuildCmd);
|
||||
},
|
||||
async extractScannedLanguage(databasePath: string, language: Language) {
|
||||
async extractScannedLanguage(
|
||||
databasePath: string,
|
||||
language: Language,
|
||||
featureFlags: FeatureFlags
|
||||
) {
|
||||
// Get extractor location
|
||||
let extractorPath = "";
|
||||
await new toolrunner.ToolRunner(
|
||||
|
|
@ -821,6 +831,16 @@ async function getCodeQLForCmd(
|
|||
"tools",
|
||||
`autobuild${ext}`
|
||||
);
|
||||
const extraArgs: string[] = [];
|
||||
if (
|
||||
await util.codeQlVersionAbove(this, CODEQL_VERSION_LUA_TRACER_CONFIG)
|
||||
) {
|
||||
if (await featureFlags.getValue(FeatureFlag.LuaTracerConfigEnabled)) {
|
||||
extraArgs.push("--internal-use-lua-tracing");
|
||||
} else {
|
||||
extraArgs.push("--no-internal-use-lua-tracing");
|
||||
}
|
||||
}
|
||||
|
||||
// Run trace command
|
||||
await toolrunnerErrorCatcher(
|
||||
|
|
@ -828,6 +848,7 @@ async function getCodeQLForCmd(
|
|||
[
|
||||
"database",
|
||||
"trace-command",
|
||||
...extraArgs,
|
||||
...getExtraOptionsFromEnv(["database", "trace-command"]),
|
||||
databasePath,
|
||||
"--",
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import { getCachedCodeQL, setCodeQL } from "./codeql";
|
|||
import * as configUtils from "./config-utils";
|
||||
import { createFeatureFlags, FeatureFlag } from "./feature-flags";
|
||||
import { Language } from "./languages";
|
||||
import { getRunnerLogger } from "./logging";
|
||||
import { getRunnerLogger, Logger } from "./logging";
|
||||
import { setupTests } from "./testing-utils";
|
||||
import * as util from "./util";
|
||||
|
||||
|
|
@ -1424,7 +1424,12 @@ const parsePacksMacro = test.macro({
|
|||
expected: Partial<Record<Language, string[]>>
|
||||
) =>
|
||||
t.deepEqual(
|
||||
configUtils.parsePacksFromConfig(packsByLanguage, languages, "/a/b"),
|
||||
configUtils.parsePacksFromConfig(
|
||||
packsByLanguage,
|
||||
languages,
|
||||
"/a/b",
|
||||
mockLogger
|
||||
),
|
||||
expected
|
||||
),
|
||||
|
||||
|
|
@ -1446,7 +1451,8 @@ const parsePacksErrorMacro = test.macro({
|
|||
configUtils.parsePacksFromConfig(
|
||||
packsByLanguage as string[] | Record<string, string[]>,
|
||||
languages,
|
||||
"/a/b"
|
||||
"/a/b",
|
||||
{} as Logger
|
||||
),
|
||||
{
|
||||
message: expected,
|
||||
|
|
@ -1499,6 +1505,19 @@ test(
|
|||
}
|
||||
);
|
||||
|
||||
test(
|
||||
"two packs with unused language in config",
|
||||
parsePacksMacro,
|
||||
{
|
||||
[Language.cpp]: ["a/b", "c/d@1.2.3"],
|
||||
[Language.java]: ["d/e", "f/g@1.2.3"],
|
||||
},
|
||||
[Language.cpp, Language.csharp],
|
||||
{
|
||||
[Language.cpp]: ["a/b", "c/d@1.2.3"],
|
||||
}
|
||||
);
|
||||
|
||||
test(
|
||||
"packs with other valid names",
|
||||
parsePacksMacro,
|
||||
|
|
@ -1544,13 +1563,6 @@ test(
|
|||
[Language.java, Language.python],
|
||||
/The configuration file "\/a\/b" is invalid: property "packs" must split packages by language/
|
||||
);
|
||||
test(
|
||||
"invalid language",
|
||||
parsePacksErrorMacro,
|
||||
{ [Language.java]: ["c/d"] },
|
||||
[Language.cpp],
|
||||
/The configuration file "\/a\/b" is invalid: property "packs" has "java", but it is not one of the languages to analyze/
|
||||
);
|
||||
test(
|
||||
"not an array",
|
||||
parsePacksErrorMacro,
|
||||
|
|
@ -1583,13 +1595,25 @@ function parseInputAndConfigMacro(
|
|||
expected
|
||||
) {
|
||||
t.deepEqual(
|
||||
configUtils.parsePacks(packsFromConfig, packsFromInput, languages, "/a/b"),
|
||||
configUtils.parsePacks(
|
||||
packsFromConfig,
|
||||
packsFromInput,
|
||||
languages,
|
||||
"/a/b",
|
||||
mockLogger
|
||||
),
|
||||
expected
|
||||
);
|
||||
}
|
||||
parseInputAndConfigMacro.title = (providedTitle: string) =>
|
||||
`Parse Packs input and config: ${providedTitle}`;
|
||||
|
||||
const mockLogger = {
|
||||
info: (message: string) => {
|
||||
console.log(message);
|
||||
},
|
||||
} as Logger;
|
||||
|
||||
function parseInputAndConfigErrorMacro(
|
||||
t: ExecutionContext<unknown>,
|
||||
packsFromConfig: string[] | Record<string, string[]>,
|
||||
|
|
@ -1603,7 +1627,8 @@ function parseInputAndConfigErrorMacro(
|
|||
packsFromConfig,
|
||||
packsFromInput,
|
||||
languages,
|
||||
"/a/b"
|
||||
"/a/b",
|
||||
mockLogger
|
||||
);
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -629,14 +629,11 @@ export function getPathsInvalid(configFile: string): string {
|
|||
);
|
||||
}
|
||||
|
||||
export function getPacksRequireLanguage(
|
||||
lang: string,
|
||||
configFile: string
|
||||
): string {
|
||||
function getPacksRequireLanguage(lang: string, configFile: string): string {
|
||||
return getConfigFilePropertyError(
|
||||
configFile,
|
||||
PACKS_PROPERTY,
|
||||
`has "${lang}", but it is not one of the languages to analyze`
|
||||
`has "${lang}", but it is not a valid language.`
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -1026,7 +1023,8 @@ async function loadConfig(
|
|||
parsedYAML[PACKS_PROPERTY] ?? {},
|
||||
packsInput,
|
||||
languages,
|
||||
configFile
|
||||
configFile,
|
||||
logger
|
||||
);
|
||||
|
||||
// If queries were provided using `with` in the action configuration,
|
||||
|
|
@ -1146,7 +1144,8 @@ const PACK_IDENTIFIER_PATTERN = (function () {
|
|||
export function parsePacksFromConfig(
|
||||
packsByLanguage: string[] | Record<string, string[]>,
|
||||
languages: Language[],
|
||||
configFile: string
|
||||
configFile: string,
|
||||
logger: Logger
|
||||
): Packs {
|
||||
const packs = {};
|
||||
|
||||
|
|
@ -1168,7 +1167,16 @@ export function parsePacksFromConfig(
|
|||
throw new Error(getPacksInvalid(configFile));
|
||||
}
|
||||
if (!languages.includes(lang as Language)) {
|
||||
throw new Error(getPacksRequireLanguage(lang, configFile));
|
||||
// This particular language is not being analyzed in this run.
|
||||
if (Language[lang as Language]) {
|
||||
logger.info(
|
||||
`Ignoring packs for ${lang} since this language is not being analyzed in this run.`
|
||||
);
|
||||
continue;
|
||||
} else {
|
||||
// This language is invalid, probably a misspelling
|
||||
throw new Error(getPacksRequireLanguage(configFile, lang));
|
||||
}
|
||||
}
|
||||
packs[lang] = [];
|
||||
for (const packStr of packsArr) {
|
||||
|
|
@ -1296,13 +1304,15 @@ export function parsePacks(
|
|||
rawPacksFromConfig: string[] | Record<string, string[]>,
|
||||
rawPacksInput: string | undefined,
|
||||
languages: Language[],
|
||||
configFile: string
|
||||
configFile: string,
|
||||
logger: Logger
|
||||
) {
|
||||
const packsFromInput = parsePacksFromInput(rawPacksInput, languages);
|
||||
const packsFomConfig = parsePacksFromConfig(
|
||||
rawPacksFromConfig,
|
||||
languages,
|
||||
configFile
|
||||
configFile,
|
||||
logger
|
||||
);
|
||||
|
||||
if (!packsFromInput) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"bundleVersion": "codeql-bundle-20220615"
|
||||
"bundleVersion": "codeql-bundle-20220623"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -501,7 +501,14 @@ program
|
|||
logger
|
||||
);
|
||||
const memory = getMemoryFlag(cmd.ram || initEnv["CODEQL_RAM"]);
|
||||
await runFinalize(outputDir, threads, memory, config, logger);
|
||||
await runFinalize(
|
||||
outputDir,
|
||||
threads,
|
||||
memory,
|
||||
config,
|
||||
logger,
|
||||
createFeatureFlags([])
|
||||
);
|
||||
await runQueries(
|
||||
outputDir,
|
||||
memory,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ packs:
|
|||
- dsp-testing/codeql-pack1@1.0.0
|
||||
- dsp-testing/codeql-pack2
|
||||
- dsp-testing/codeql-pack3:other-query.ql
|
||||
ruby:
|
||||
- dsp-testing/hucairz
|
||||
- dsp-testing/i-dont-exist@1.0.0
|
||||
|
||||
paths-ignore:
|
||||
- tests
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue