Add new packs input to init action
This input allows users to specify which packs to run. It works in unison with the packs block of the config file and it is similar to how `queries` works. They both use `+` in the same way. Note that the `#TODO` in the pr check is still around, but the CLI is available. I will remove the TODO in the next commit.
This commit is contained in:
parent
7729b51956
commit
6e577cfca3
18 changed files with 535 additions and 59 deletions
46
.github/workflows/pr-checks.yml
vendored
46
.github/workflows/pr-checks.yml
vendored
|
|
@ -101,7 +101,7 @@ jobs:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Packaging test that runs against a javascript database
|
# Packaging test that runs against a javascript database
|
||||||
test-packaging-javascript:
|
test-packaging-javascript-config:
|
||||||
needs: [check-js, check-node-modules]
|
needs: [check-js, check-node-modules]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
|
@ -143,6 +143,50 @@ jobs:
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# tests that we can run packages through actions inputs
|
||||||
|
test-packaging-javascript-inputs:
|
||||||
|
needs: [check-js, check-node-modules]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Move codeql-action
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir ../action
|
||||||
|
mv * .github ../action/
|
||||||
|
mv ../action/tests/multi-language-repo/{*,.github} .
|
||||||
|
mv ../action/.github/workflows .github
|
||||||
|
- uses: ./../action/init
|
||||||
|
with:
|
||||||
|
config-file: ".github/codeql/codeql-config-packaging2.yml"
|
||||||
|
languages: javascript
|
||||||
|
packs: dsp-testing/codeql-pack1@0.0.4, dsp-testing/codeql-pack2
|
||||||
|
# TODO: this can be removed when cli v2.5.6 is released and available in the tool cache
|
||||||
|
tools: https://github.com/dsp-testing/aeisenberg-codeql-action-packaging/releases/download/codeql-bundle-20210615/codeql-bundle-linux64.tar.gz
|
||||||
|
|
||||||
|
- name: Build code
|
||||||
|
shell: bash
|
||||||
|
run: ./build.sh
|
||||||
|
- uses: ./../action/analyze
|
||||||
|
with:
|
||||||
|
output: "${{ runner.temp }}/results"
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
- name: Assert Results
|
||||||
|
run: |
|
||||||
|
cd "$RUNNER_TEMP/results"
|
||||||
|
# We should have 3 hits from these rules
|
||||||
|
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/two-block"
|
||||||
|
|
||||||
|
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
|
||||||
|
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n" " " | xargs)"
|
||||||
|
echo "Found matching rules '$RULES'"
|
||||||
|
if [ "$RULES" != "$EXPECTED_RULES" ]; then
|
||||||
|
echo "Did not match expected rules '$EXPECTED_RULES'."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Identify the CodeQL tool versions to integration test against.
|
# Identify the CodeQL tool versions to integration test against.
|
||||||
check-codeql-versions:
|
check-codeql-versions:
|
||||||
needs: [check-js, check-node-modules]
|
needs: [check-js, check-node-modules]
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,14 @@ inputs:
|
||||||
queries:
|
queries:
|
||||||
description: Comma-separated list of additional queries to run. By default, this overrides the same setting in a configuration file; prefix with "+" to use both sets of queries.
|
description: Comma-separated list of additional queries to run. By default, this overrides the same setting in a configuration file; prefix with "+" to use both sets of queries.
|
||||||
required: false
|
required: false
|
||||||
|
packs:
|
||||||
|
description: >-
|
||||||
|
Comma-separated list of packs to run. Reference a pack in the format `scope/name[@version]`. If `version` is not
|
||||||
|
specified, then the latest version of the pack is used. By default, this overrides the same setting in a
|
||||||
|
configuration file; prefix with "+" to use both sets of packs.
|
||||||
|
|
||||||
|
This input is only available in single-language analyses.
|
||||||
|
required: false
|
||||||
external-repository-token:
|
external-repository-token:
|
||||||
description: A token for fetching external config files and queries if they reside in a private repository.
|
description: A token for fetching external config files and queries if they reside in a private repository.
|
||||||
required: false
|
required: false
|
||||||
|
|
|
||||||
82
lib/config-utils.js
generated
82
lib/config-utils.js
generated
|
|
@ -269,7 +269,9 @@ function getPacksInvalid(configFile) {
|
||||||
}
|
}
|
||||||
exports.getPacksInvalid = getPacksInvalid;
|
exports.getPacksInvalid = getPacksInvalid;
|
||||||
function getPacksStrInvalid(packStr, configFile) {
|
function getPacksStrInvalid(packStr, configFile) {
|
||||||
return getConfigFilePropertyError(configFile, PACKS_PROPERTY, `"${packStr}" is not a valid pack`);
|
return configFile
|
||||||
|
? getConfigFilePropertyError(configFile, PACKS_PROPERTY, `"${packStr}" is not a valid pack`)
|
||||||
|
: `"${packStr}" is not a valid pack`;
|
||||||
}
|
}
|
||||||
exports.getPacksStrInvalid = getPacksStrInvalid;
|
exports.getPacksStrInvalid = getPacksStrInvalid;
|
||||||
function getLocalPathOutsideOfRepository(configFile, localPath) {
|
function getLocalPathOutsideOfRepository(configFile, localPath) {
|
||||||
|
|
@ -409,7 +411,8 @@ function shouldAddConfigFileQueries(queriesInput) {
|
||||||
/**
|
/**
|
||||||
* Get the default config for when the user has not supplied one.
|
* Get the default config for when the user has not supplied one.
|
||||||
*/
|
*/
|
||||||
async function getDefaultConfig(languagesInput, queriesInput, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger) {
|
async function getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger) {
|
||||||
|
var _a;
|
||||||
const languages = await getLanguages(codeQL, languagesInput, repository, apiDetails, logger);
|
const languages = await getLanguages(codeQL, languagesInput, repository, apiDetails, logger);
|
||||||
const queries = {};
|
const queries = {};
|
||||||
for (const language of languages) {
|
for (const language of languages) {
|
||||||
|
|
@ -422,12 +425,13 @@ async function getDefaultConfig(languagesInput, queriesInput, dbLocation, reposi
|
||||||
if (queriesInput) {
|
if (queriesInput) {
|
||||||
await addQueriesFromWorkflow(codeQL, queriesInput, languages, queries, tempDir, checkoutPath, apiDetails, logger);
|
await addQueriesFromWorkflow(codeQL, queriesInput, languages, queries, tempDir, checkoutPath, apiDetails, logger);
|
||||||
}
|
}
|
||||||
|
const packs = (_a = parsePacksInput(packsInput, languages), (_a !== null && _a !== void 0 ? _a : {}));
|
||||||
return {
|
return {
|
||||||
languages,
|
languages,
|
||||||
queries,
|
queries,
|
||||||
pathsIgnore: [],
|
pathsIgnore: [],
|
||||||
paths: [],
|
paths: [],
|
||||||
packs: {},
|
packs,
|
||||||
originalUserInput: {},
|
originalUserInput: {},
|
||||||
tempDir,
|
tempDir,
|
||||||
toolCacheDir,
|
toolCacheDir,
|
||||||
|
|
@ -440,7 +444,7 @@ exports.getDefaultConfig = getDefaultConfig;
|
||||||
/**
|
/**
|
||||||
* Load the config from the given file.
|
* Load the config from the given file.
|
||||||
*/
|
*/
|
||||||
async function loadConfig(languagesInput, queriesInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger) {
|
async function loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger) {
|
||||||
var _a;
|
var _a;
|
||||||
let parsedYAML;
|
let parsedYAML;
|
||||||
if (isLocal(configFile)) {
|
if (isLocal(configFile)) {
|
||||||
|
|
@ -524,7 +528,7 @@ async function loadConfig(languagesInput, queriesInput, configFile, dbLocation,
|
||||||
paths.push(validateAndSanitisePath(includePath, PATHS_PROPERTY, configFile, logger));
|
paths.push(validateAndSanitisePath(includePath, PATHS_PROPERTY, configFile, logger));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const packs = parsePacks((_a = parsedYAML[PACKS_PROPERTY], (_a !== null && _a !== void 0 ? _a : {})), languages, configFile);
|
const packs = parsePacks((_a = parsedYAML[PACKS_PROPERTY], (_a !== null && _a !== void 0 ? _a : {})), packsInput, languages, configFile);
|
||||||
return {
|
return {
|
||||||
languages,
|
languages,
|
||||||
queries,
|
queries,
|
||||||
|
|
@ -550,7 +554,7 @@ const PACK_IDENTIFIER_PATTERN = (function () {
|
||||||
return new RegExp(`^${component}/${component}$`);
|
return new RegExp(`^${component}/${component}$`);
|
||||||
})();
|
})();
|
||||||
// Exported for testing
|
// Exported for testing
|
||||||
function parsePacks(packsByLanguage, languages, configFile) {
|
function parsePacksFromConfig(packsByLanguage, languages, configFile) {
|
||||||
const packs = {};
|
const packs = {};
|
||||||
if (Array.isArray(packsByLanguage)) {
|
if (Array.isArray(packsByLanguage)) {
|
||||||
if (languages.length === 1) {
|
if (languages.length === 1) {
|
||||||
|
|
@ -579,12 +583,37 @@ function parsePacks(packsByLanguage, languages, configFile) {
|
||||||
}
|
}
|
||||||
return packs;
|
return packs;
|
||||||
}
|
}
|
||||||
exports.parsePacks = parsePacks;
|
exports.parsePacksFromConfig = parsePacksFromConfig;
|
||||||
|
function parsePacksInput(packsInput, languages) {
|
||||||
|
var _a;
|
||||||
|
if (!((_a = packsInput) === null || _a === void 0 ? void 0 : _a.trim())) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
if (languages.length > 1) {
|
||||||
|
throw new Error("Cannot specify a 'packs' input in a multi-language analysis. Use a codeql-config.yml file instead and specify packs by library.");
|
||||||
|
}
|
||||||
|
else if (languages.length === 0) {
|
||||||
|
throw new Error("No languages specified. Cannot process the packs input.");
|
||||||
|
}
|
||||||
|
packsInput = packsInput.trim();
|
||||||
|
if (packsInput.startsWith("+")) {
|
||||||
|
packsInput = packsInput.substring(1).trim();
|
||||||
|
if (!packsInput) {
|
||||||
|
throw new Error("Remove the '+' from the packs input.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
[languages[0]]: packsInput.split(",").reduce((packs, pack) => {
|
||||||
|
packs.push(toPackWithVersion(pack, ""));
|
||||||
|
return packs;
|
||||||
|
}, []),
|
||||||
|
};
|
||||||
|
}
|
||||||
function toPackWithVersion(packStr, configFile) {
|
function toPackWithVersion(packStr, configFile) {
|
||||||
if (typeof packStr !== "string") {
|
if (typeof packStr !== "string") {
|
||||||
throw new Error(getPacksStrInvalid(packStr, configFile));
|
throw new Error(getPacksStrInvalid(packStr, configFile));
|
||||||
}
|
}
|
||||||
const nameWithVersion = packStr.split("@");
|
const nameWithVersion = packStr.trim().split("@");
|
||||||
let version;
|
let version;
|
||||||
if (nameWithVersion.length > 2 ||
|
if (nameWithVersion.length > 2 ||
|
||||||
!PACK_IDENTIFIER_PATTERN.test(nameWithVersion[0])) {
|
!PACK_IDENTIFIER_PATTERN.test(nameWithVersion[0])) {
|
||||||
|
|
@ -597,10 +626,39 @@ function toPackWithVersion(packStr, configFile) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
packName: nameWithVersion[0],
|
packName: nameWithVersion[0].trim(),
|
||||||
version,
|
version,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
// exported for testing
|
||||||
|
function parsePacks(rawPacksFromConfig, rawPacksInput, languages, configFile) {
|
||||||
|
const packsFromInput = parsePacksInput(rawPacksInput, languages);
|
||||||
|
const packsFomConfig = parsePacksFromConfig(rawPacksFromConfig, languages, configFile);
|
||||||
|
if (!packsFromInput) {
|
||||||
|
return packsFomConfig;
|
||||||
|
}
|
||||||
|
if (!shouldCombinePacks(rawPacksInput)) {
|
||||||
|
return packsFromInput;
|
||||||
|
}
|
||||||
|
return combinePacks(packsFromInput, packsFomConfig);
|
||||||
|
}
|
||||||
|
exports.parsePacks = parsePacks;
|
||||||
|
function shouldCombinePacks(packsInput) {
|
||||||
|
var _a;
|
||||||
|
return !!((_a = packsInput) === null || _a === void 0 ? void 0 : _a.trim().startsWith("+"));
|
||||||
|
}
|
||||||
|
function combinePacks(packs1, packs2) {
|
||||||
|
const packs = {};
|
||||||
|
for (const lang of Object.keys(packs1)) {
|
||||||
|
packs[lang] = packs1[lang].concat(packs2[lang] || []);
|
||||||
|
}
|
||||||
|
for (const lang of Object.keys(packs2)) {
|
||||||
|
if (!packs[lang]) {
|
||||||
|
packs[lang] = packs2[lang];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return packs;
|
||||||
|
}
|
||||||
function dbLocationOrDefault(dbLocation, tempDir) {
|
function dbLocationOrDefault(dbLocation, tempDir) {
|
||||||
return dbLocation || path.resolve(tempDir, "codeql_databases");
|
return dbLocation || path.resolve(tempDir, "codeql_databases");
|
||||||
}
|
}
|
||||||
|
|
@ -610,16 +668,16 @@ function dbLocationOrDefault(dbLocation, tempDir) {
|
||||||
* This will parse the config from the user input if present, or generate
|
* This will parse the config from the user input if present, or generate
|
||||||
* a default config. The parsed config is then stored to a known location.
|
* a default config. The parsed config is then stored to a known location.
|
||||||
*/
|
*/
|
||||||
async function initConfig(languagesInput, queriesInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger) {
|
async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger) {
|
||||||
var _a, _b, _c;
|
var _a, _b, _c;
|
||||||
let config;
|
let config;
|
||||||
// If no config file was provided create an empty one
|
// If no config file was provided create an empty one
|
||||||
if (!configFile) {
|
if (!configFile) {
|
||||||
logger.debug("No configuration file was provided");
|
logger.debug("No configuration file was provided");
|
||||||
config = await getDefaultConfig(languagesInput, queriesInput, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger);
|
config = await getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
config = await loadConfig(languagesInput, queriesInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger);
|
config = await loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger);
|
||||||
}
|
}
|
||||||
// The list of queries should not be empty for any language. If it is then
|
// The list of queries should not be empty for any language. If it is then
|
||||||
// it is a user configuration error.
|
// it is a user configuration error.
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
113
lib/config-utils.test.js
generated
113
lib/config-utils.test.js
generated
|
|
@ -76,8 +76,8 @@ ava_1.default("load empty config", async (t) => {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const config = await configUtils.initConfig(languages, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logger);
|
const config = await configUtils.initConfig(languages, undefined, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logger);
|
||||||
t.deepEqual(config, await configUtils.getDefaultConfig(languages, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logger));
|
t.deepEqual(config, await configUtils.getDefaultConfig(languages, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logger));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("loading config saves config", async (t) => {
|
ava_1.default("loading config saves config", async (t) => {
|
||||||
|
|
@ -99,7 +99,7 @@ ava_1.default("loading config saves config", async (t) => {
|
||||||
t.false(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
|
t.false(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
|
||||||
// Sanity check that getConfig returns undefined before we have called initConfig
|
// Sanity check that getConfig returns undefined before we have called initConfig
|
||||||
t.deepEqual(await configUtils.getConfig(tmpDir, logger), undefined);
|
t.deepEqual(await configUtils.getConfig(tmpDir, logger), undefined);
|
||||||
const config1 = await configUtils.initConfig("javascript,python", undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logger);
|
const config1 = await configUtils.initConfig("javascript,python", undefined, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logger);
|
||||||
// The saved config file should now exist
|
// The saved config file should now exist
|
||||||
t.true(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
|
t.true(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
|
||||||
// And that same newly-initialised config should now be returned by getConfig
|
// And that same newly-initialised config should now be returned by getConfig
|
||||||
|
|
@ -110,7 +110,7 @@ ava_1.default("loading config saves config", async (t) => {
|
||||||
ava_1.default("load input outside of workspace", async (t) => {
|
ava_1.default("load input outside of workspace", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, "../input", undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(undefined, undefined, undefined, "../input", undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -123,7 +123,7 @@ ava_1.default("load non-local input with invalid repo syntax", async (t) => {
|
||||||
// no filename given, just a repo
|
// no filename given, just a repo
|
||||||
const configFile = "octo-org/codeql-config@main";
|
const configFile = "octo-org/codeql-config@main";
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, configFile, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(undefined, undefined, undefined, configFile, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -137,7 +137,7 @@ ava_1.default("load non-existent input", async (t) => {
|
||||||
const configFile = "input";
|
const configFile = "input";
|
||||||
t.false(fs.existsSync(path.join(tmpDir, configFile)));
|
t.false(fs.existsSync(path.join(tmpDir, configFile)));
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, undefined, configFile, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -205,7 +205,7 @@ ava_1.default("load non-empty input", async (t) => {
|
||||||
};
|
};
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
||||||
const actualConfig = await configUtils.initConfig(languages, undefined, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
const actualConfig = await configUtils.initConfig(languages, undefined, undefined, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
// Should exactly equal the object we constructed earlier
|
// Should exactly equal the object we constructed earlier
|
||||||
t.deepEqual(actualConfig, expectedConfig);
|
t.deepEqual(actualConfig, expectedConfig);
|
||||||
});
|
});
|
||||||
|
|
@ -241,7 +241,7 @@ ava_1.default("Default queries are used", async (t) => {
|
||||||
fs.mkdirSync(path.join(tmpDir, "foo"));
|
fs.mkdirSync(path.join(tmpDir, "foo"));
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
||||||
await configUtils.initConfig(languages, undefined, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(languages, undefined, undefined, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
// Check resolve queries was called correctly
|
// Check resolve queries was called correctly
|
||||||
t.deepEqual(resolveQueriesArgs.length, 1);
|
t.deepEqual(resolveQueriesArgs.length, 1);
|
||||||
t.deepEqual(resolveQueriesArgs[0].queries, [
|
t.deepEqual(resolveQueriesArgs[0].queries, [
|
||||||
|
|
@ -284,7 +284,7 @@ ava_1.default("Queries can be specified in config file", async (t) => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, undefined, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
const config = await configUtils.initConfig(languages, undefined, undefined, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
// Check resolveQueries was called correctly
|
// Check resolveQueries was called correctly
|
||||||
// It'll be called once for the default queries
|
// It'll be called once for the default queries
|
||||||
// and once for `./foo` from the config file.
|
// and once for `./foo` from the config file.
|
||||||
|
|
@ -317,7 +317,7 @@ ava_1.default("Queries from config file can be overridden in workflow file", asy
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, testQueries, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
const config = await configUtils.initConfig(languages, testQueries, undefined, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
// Check resolveQueries was called correctly
|
// Check resolveQueries was called correctly
|
||||||
// It'll be called once for the default queries and once for `./override`,
|
// It'll be called once for the default queries and once for `./override`,
|
||||||
// but won't be called for './foo' from the config file.
|
// but won't be called for './foo' from the config file.
|
||||||
|
|
@ -349,7 +349,7 @@ ava_1.default("Queries in workflow file can be used in tandem with the 'disable
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, testQueries, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
const config = await configUtils.initConfig(languages, testQueries, undefined, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
// Check resolveQueries was called correctly
|
// Check resolveQueries was called correctly
|
||||||
// It'll be called once for `./workflow-query`,
|
// It'll be called once for `./workflow-query`,
|
||||||
// but won't be called for the default one since that was disabled
|
// but won't be called for the default one since that was disabled
|
||||||
|
|
@ -375,7 +375,7 @@ ava_1.default("Multiple queries can be specified in workflow file, no config fil
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, testQueries, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
const config = await configUtils.initConfig(languages, testQueries, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
// Check resolveQueries was called correctly:
|
// Check resolveQueries was called correctly:
|
||||||
// It'll be called once for the default queries,
|
// It'll be called once for the default queries,
|
||||||
// and then once for each of the two queries from the workflow
|
// and then once for each of the two queries from the workflow
|
||||||
|
|
@ -414,7 +414,7 @@ ava_1.default("Queries in workflow file can be added to the set of queries witho
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, testQueries, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
const config = await configUtils.initConfig(languages, testQueries, undefined, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
// Check resolveQueries was called correctly
|
// Check resolveQueries was called correctly
|
||||||
// It'll be called once for the default queries,
|
// It'll be called once for the default queries,
|
||||||
// once for each of additional1 and additional2,
|
// once for each of additional1 and additional2,
|
||||||
|
|
@ -453,7 +453,7 @@ ava_1.default("Invalid queries in workflow file handled correctly", async (t) =>
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, queries, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(languages, queries, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
t.fail("initConfig did not throw error");
|
t.fail("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -496,7 +496,7 @@ ava_1.default("API client used when reading remote config", async (t) => {
|
||||||
fs.mkdirSync(path.join(tmpDir, "foo/bar/dev"), { recursive: true });
|
fs.mkdirSync(path.join(tmpDir, "foo/bar/dev"), { recursive: true });
|
||||||
const configFile = "octo-org/codeql-config/config.yaml@main";
|
const configFile = "octo-org/codeql-config/config.yaml@main";
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
await configUtils.initConfig(languages, undefined, configFile, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
t.assert(spyGetContents.called);
|
t.assert(spyGetContents.called);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -506,7 +506,7 @@ ava_1.default("Remote config handles the case where a directory is provided", as
|
||||||
mockGetContents(dummyResponse);
|
mockGetContents(dummyResponse);
|
||||||
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, repoReference, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(undefined, undefined, undefined, repoReference, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -522,7 +522,7 @@ ava_1.default("Invalid format of remote config handled correctly", async (t) =>
|
||||||
mockGetContents(dummyResponse);
|
mockGetContents(dummyResponse);
|
||||||
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, repoReference, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(undefined, undefined, undefined, repoReference, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -539,7 +539,7 @@ ava_1.default("No detected languages", async (t) => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(undefined, undefined, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -551,7 +551,7 @@ ava_1.default("Unknown languages", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
const languages = "rubbish,english";
|
const languages = "rubbish,english";
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(languages, undefined, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -579,7 +579,7 @@ ava_1.default("Config specifies packages", async (t) => {
|
||||||
const configFile = path.join(tmpDir, "codeql-config.yaml");
|
const configFile = path.join(tmpDir, "codeql-config.yaml");
|
||||||
fs.writeFileSync(configFile, inputFileContents);
|
fs.writeFileSync(configFile, inputFileContents);
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const { packs } = await configUtils.initConfig(languages, undefined, configFile, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
const { packs } = await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
t.deepEqual(packs, {
|
t.deepEqual(packs, {
|
||||||
[languages_1.Language.javascript]: [
|
[languages_1.Language.javascript]: [
|
||||||
{
|
{
|
||||||
|
|
@ -618,7 +618,7 @@ ava_1.default("Config specifies packages for multiple languages", async (t) => {
|
||||||
fs.writeFileSync(configFile, inputFileContents);
|
fs.writeFileSync(configFile, inputFileContents);
|
||||||
fs.mkdirSync(path.join(tmpDir, "foo"));
|
fs.mkdirSync(path.join(tmpDir, "foo"));
|
||||||
const languages = "javascript,python,cpp";
|
const languages = "javascript,python,cpp";
|
||||||
const { packs, queries } = await configUtils.initConfig(languages, undefined, configFile, undefined, { owner: "github", repo: "example" }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
const { packs, queries } = await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, { owner: "github", repo: "example" }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
t.deepEqual(packs, {
|
t.deepEqual(packs, {
|
||||||
[languages_1.Language.javascript]: [
|
[languages_1.Language.javascript]: [
|
||||||
{
|
{
|
||||||
|
|
@ -671,7 +671,7 @@ function doInvalidInputTest(testName, inputFileContents, expectedErrorMessageGen
|
||||||
const inputFile = path.join(tmpDir, configFile);
|
const inputFile = path.join(tmpDir, configFile);
|
||||||
fs.writeFileSync(inputFile, inputFileContents, "utf8");
|
fs.writeFileSync(inputFile, inputFileContents, "utf8");
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, undefined, configFile, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -745,7 +745,7 @@ ava_1.default("path sanitisation", (t) => {
|
||||||
* Test macro for ensuring the packs block is valid
|
* Test macro for ensuring the packs block is valid
|
||||||
*/
|
*/
|
||||||
function parsePacksMacro(t, packsByLanguage, languages, expected) {
|
function parsePacksMacro(t, packsByLanguage, languages, expected) {
|
||||||
t.deepEqual(configUtils.parsePacks(packsByLanguage, languages, "/a/b"), expected);
|
t.deepEqual(configUtils.parsePacksFromConfig(packsByLanguage, languages, "/a/b"), expected);
|
||||||
}
|
}
|
||||||
parsePacksMacro.title = (providedTitle) => `Parse Packs: ${providedTitle}`;
|
parsePacksMacro.title = (providedTitle) => `Parse Packs: ${providedTitle}`;
|
||||||
/**
|
/**
|
||||||
|
|
@ -753,12 +753,15 @@ parsePacksMacro.title = (providedTitle) => `Parse Packs: ${providedTitle}`;
|
||||||
*/
|
*/
|
||||||
function parsePacksErrorMacro(t, packsByLanguage, languages, expected) {
|
function parsePacksErrorMacro(t, packsByLanguage, languages, expected) {
|
||||||
t.throws(() => {
|
t.throws(() => {
|
||||||
configUtils.parsePacks(packsByLanguage, languages, "/a/b");
|
configUtils.parsePacksFromConfig(packsByLanguage, languages, "/a/b");
|
||||||
}, {
|
}, {
|
||||||
message: expected,
|
message: expected,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
parsePacksErrorMacro.title = (providedTitle) => `Parse Packs Error: ${providedTitle}`;
|
parsePacksErrorMacro.title = (providedTitle) => `Parse Packs Error: ${providedTitle}`;
|
||||||
|
/**
|
||||||
|
* Test macro for testing when the packs block is invalid
|
||||||
|
*/
|
||||||
function invalidPackNameMacro(t, name) {
|
function invalidPackNameMacro(t, name) {
|
||||||
parsePacksErrorMacro(t, { [languages_1.Language.cpp]: [name] }, [languages_1.Language.cpp], new RegExp(`The configuration file "/a/b" is invalid: property "packs" "${name}" is not a valid pack`));
|
parsePacksErrorMacro(t, { [languages_1.Language.cpp]: [name] }, [languages_1.Language.cpp], new RegExp(`The configuration file "/a/b" is invalid: property "packs" "${name}" is not a valid pack`));
|
||||||
}
|
}
|
||||||
|
|
@ -770,6 +773,12 @@ ava_1.default("two packs", parsePacksMacro, ["a/b", "c/d@1.2.3"], [languages_1.L
|
||||||
{ packName: "c/d", version: semver_1.clean("1.2.3") },
|
{ packName: "c/d", version: semver_1.clean("1.2.3") },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
ava_1.default("two packs with spaces", parsePacksMacro, [" a/b ", " c/d@1.2.3 "], [languages_1.Language.cpp], {
|
||||||
|
[languages_1.Language.cpp]: [
|
||||||
|
{ packName: "a/b", version: undefined },
|
||||||
|
{ packName: "c/d", version: semver_1.clean("1.2.3") },
|
||||||
|
],
|
||||||
|
});
|
||||||
ava_1.default("two packs with language", parsePacksMacro, {
|
ava_1.default("two packs with language", parsePacksMacro, {
|
||||||
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
|
[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.java]: ["d/e", "f/g@1.2.3"],
|
||||||
|
|
@ -791,4 +800,60 @@ ava_1.default(invalidPackNameMacro, "c-/d");
|
||||||
ava_1.default(invalidPackNameMacro, "-c/d");
|
ava_1.default(invalidPackNameMacro, "-c/d");
|
||||||
ava_1.default(invalidPackNameMacro, "c/d_d");
|
ava_1.default(invalidPackNameMacro, "c/d_d");
|
||||||
ava_1.default(invalidPackNameMacro, "c/d@x");
|
ava_1.default(invalidPackNameMacro, "c/d@x");
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
parseInputAndConfigMacro.title = (providedTitle) => `Parse Packs input and config: ${providedTitle}`;
|
||||||
|
function parseInputAndConfigErrorMacro(t, packsFromConfig, packsFromInput, languages, expected) {
|
||||||
|
t.throws(() => {
|
||||||
|
configUtils.parsePacks(packsFromConfig, packsFromInput, languages, "/a/b");
|
||||||
|
}, {
|
||||||
|
message: expected,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
parseInputAndConfigErrorMacro.title = (providedTitle) => `Parse Packs input and config Error: ${providedTitle}`;
|
||||||
|
ava_1.default("input only", parseInputAndConfigMacro, {}, " c/d ", [languages_1.Language.cpp], {
|
||||||
|
[languages_1.Language.cpp]: [{ packName: "c/d", version: undefined }],
|
||||||
|
});
|
||||||
|
ava_1.default("input only with multiple", parseInputAndConfigMacro, {}, "a/b , c/d@1.2.3", [languages_1.Language.cpp], {
|
||||||
|
[languages_1.Language.cpp]: [
|
||||||
|
{ packName: "a/b", version: undefined },
|
||||||
|
{ packName: "c/d", version: "1.2.3" },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
ava_1.default("input only with +", parseInputAndConfigMacro, {}, " + a/b , c/d@1.2.3 ", [languages_1.Language.cpp], {
|
||||||
|
[languages_1.Language.cpp]: [
|
||||||
|
{ packName: "a/b", version: undefined },
|
||||||
|
{ packName: "c/d", version: "1.2.3" },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
ava_1.default("config only", parseInputAndConfigMacro, ["a/b", "c/d"], " ", [languages_1.Language.cpp], {
|
||||||
|
[languages_1.Language.cpp]: [
|
||||||
|
{ packName: "a/b", version: undefined },
|
||||||
|
{ packName: "c/d", version: undefined },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
ava_1.default("input overrides", parseInputAndConfigMacro, ["a/b", "c/d"], " e/f, g/h@1.2.3 ", [languages_1.Language.cpp], {
|
||||||
|
[languages_1.Language.cpp]: [
|
||||||
|
{ packName: "e/f", version: undefined },
|
||||||
|
{ packName: "g/h", version: "1.2.3" },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
ava_1.default("input and config", parseInputAndConfigMacro, ["a/b", "c/d"], " +e/f, g/h@1.2.3 ", [languages_1.Language.cpp], {
|
||||||
|
[languages_1.Language.cpp]: [
|
||||||
|
{ packName: "e/f", version: undefined },
|
||||||
|
{ packName: "g/h", version: "1.2.3" },
|
||||||
|
{ packName: "a/b", version: undefined },
|
||||||
|
{ packName: "c/d", version: undefined },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
ava_1.default("input with no language", parseInputAndConfigErrorMacro, {}, "c/d", [], /No languages specified/);
|
||||||
|
ava_1.default("input with two languages", parseInputAndConfigErrorMacro, {}, "c/d", [languages_1.Language.cpp, languages_1.Language.csharp], /multi-language analysis/);
|
||||||
|
ava_1.default("input with + only", parseInputAndConfigErrorMacro, {}, " + ", [languages_1.Language.cpp], /Remove the '\+'/);
|
||||||
|
ava_1.default("input with invalid pack name", parseInputAndConfigErrorMacro, {}, " xxx", [languages_1.Language.cpp], /"xxx" is not a valid pack/);
|
||||||
|
// errors
|
||||||
|
// input w invalid pack name
|
||||||
//# sourceMappingURL=config-utils.test.js.map
|
//# sourceMappingURL=config-utils.test.js.map
|
||||||
File diff suppressed because one or more lines are too long
2
lib/init-action.js
generated
2
lib/init-action.js
generated
|
|
@ -72,7 +72,7 @@ async function run() {
|
||||||
const initCodeQLResult = await init_1.initCodeQL(actions_util_1.getOptionalInput("tools"), apiDetails, actions_util_1.getTemporaryDirectory(), actions_util_1.getToolCacheDirectory(), gitHubVersion.type, logger);
|
const initCodeQLResult = await init_1.initCodeQL(actions_util_1.getOptionalInput("tools"), apiDetails, actions_util_1.getTemporaryDirectory(), actions_util_1.getToolCacheDirectory(), gitHubVersion.type, logger);
|
||||||
codeql = initCodeQLResult.codeql;
|
codeql = initCodeQLResult.codeql;
|
||||||
toolsVersion = initCodeQLResult.toolsVersion;
|
toolsVersion = initCodeQLResult.toolsVersion;
|
||||||
config = await init_1.initConfig(actions_util_1.getOptionalInput("languages"), actions_util_1.getOptionalInput("queries"), actions_util_1.getOptionalInput("config-file"), actions_util_1.getOptionalInput("db-location"), repository_1.parseRepositoryNwo(util_1.getRequiredEnvParam("GITHUB_REPOSITORY")), actions_util_1.getTemporaryDirectory(), util_1.getRequiredEnvParam("RUNNER_TOOL_CACHE"), codeql, util_1.getRequiredEnvParam("GITHUB_WORKSPACE"), gitHubVersion, apiDetails, logger);
|
config = await init_1.initConfig(actions_util_1.getOptionalInput("languages"), actions_util_1.getOptionalInput("queries"), actions_util_1.getOptionalInput("packs"), actions_util_1.getOptionalInput("config-file"), actions_util_1.getOptionalInput("db-location"), repository_1.parseRepositoryNwo(util_1.getRequiredEnvParam("GITHUB_REPOSITORY")), actions_util_1.getTemporaryDirectory(), util_1.getRequiredEnvParam("RUNNER_TOOL_CACHE"), codeql, util_1.getRequiredEnvParam("GITHUB_WORKSPACE"), gitHubVersion, apiDetails, logger);
|
||||||
if (config.languages.includes(languages_1.Language.python) &&
|
if (config.languages.includes(languages_1.Language.python) &&
|
||||||
actions_util_1.getRequiredInput("setup-python-dependencies") === "true") {
|
actions_util_1.getRequiredInput("setup-python-dependencies") === "true") {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"init-action.js","sourceRoot":"","sources":["../src/init-action.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAEtC,iDASwB;AAGxB,iCAMgB;AAChB,2CAAuC;AACvC,uCAA6C;AAC7C,6CAAkD;AAClD,iCAMgB;AAEhB,8CAA8C;AAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAsBvC,KAAK,UAAU,uBAAuB,CACpC,SAAe,EACf,MAA0B,EAC1B,YAAoB;;IAEpB,MAAM,gBAAgB,GAAG,MAAM,qCAAsB,CACnD,MAAM,EACN,SAAS,EACT,SAAS,CACV,CAAC;IAEF,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7C,MAAM,iBAAiB,GAAG,+BAAgB,CAAC,WAAW,CAAC,CAAC;IACxD,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/D,MAAM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,CACF,CAAC;QACF,OAAO;KACR;IACD,MAAM,uBAAuB,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;AACjE,CAAC;AAED,KAAK,UAAU,UAAU;IACvB,IAAI;QACF,MAAM,GAAG,EAAE,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,uBAAuB,KAAK,EAAE,CAAC,CAAC;QAC/C,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
||||||
4
lib/init.js
generated
4
lib/init.js
generated
|
|
@ -24,9 +24,9 @@ async function initCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant,
|
||||||
return { codeql, toolsVersion };
|
return { codeql, toolsVersion };
|
||||||
}
|
}
|
||||||
exports.initCodeQL = initCodeQL;
|
exports.initCodeQL = initCodeQL;
|
||||||
async function initConfig(languagesInput, queriesInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger) {
|
async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger) {
|
||||||
logger.startGroup("Load language configuration");
|
logger.startGroup("Load language configuration");
|
||||||
const config = await configUtils.initConfig(languagesInput, queriesInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger);
|
const config = await configUtils.initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger);
|
||||||
analysisPaths.printPathFiltersWarning(config, logger);
|
analysisPaths.printPathFiltersWarning(config, logger);
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
return config;
|
return config;
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src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O,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,+IAA+I,CAChJ,CAAC;QACF,OAAO;KACR;IACD,MAAM,CAAC,QAAQ,EAAE,CAAC;AACpB,CAAC;AAnDD,8CAmDC"}
|
||||||
7
lib/runner.js
generated
7
lib/runner.js
generated
|
|
@ -90,6 +90,11 @@ program
|
||||||
.option("--github-auth-stdin", "Read GitHub Apps token or personal access token from stdin.")
|
.option("--github-auth-stdin", "Read GitHub Apps token or personal access token from stdin.")
|
||||||
.option("--languages <languages>", "Comma-separated list of languages to analyze. Otherwise detects and analyzes all supported languages from the repo.")
|
.option("--languages <languages>", "Comma-separated list of languages to analyze. Otherwise detects and analyzes all supported languages from the repo.")
|
||||||
.option("--queries <queries>", "Comma-separated list of additional queries to run. This overrides the same setting in a configuration file.")
|
.option("--queries <queries>", "Comma-separated list of additional queries to run. This overrides the same setting in a configuration file.")
|
||||||
|
.option("--packs <packs>", `Comma-separated list of packs to run. Reference a pack in the format scope/name[@version]. If version is not
|
||||||
|
specified, then the latest version of the pack is used. By default, this overrides the same setting in a
|
||||||
|
configuration file; prefix with "+" to use both sets of packs.
|
||||||
|
|
||||||
|
This option is only available in single-language analyses.`)
|
||||||
.option("--config-file <file>", "Path to config file.")
|
.option("--config-file <file>", "Path to config file.")
|
||||||
.option("--codeql-path <path>", "Path to a copy of the CodeQL CLI executable to use. Otherwise downloads a copy.")
|
.option("--codeql-path <path>", "Path to a copy of the CodeQL CLI executable to use. Otherwise downloads a copy.")
|
||||||
.option("--temp-dir <dir>", 'Directory to use for temporary files. Default is "./codeql-runner".')
|
.option("--temp-dir <dir>", 'Directory to use for temporary files. Default is "./codeql-runner".')
|
||||||
|
|
@ -122,7 +127,7 @@ program
|
||||||
else {
|
else {
|
||||||
codeql = (await init_1.initCodeQL(undefined, apiDetails, tempDir, toolsDir, gitHubVersion.type, logger)).codeql;
|
codeql = (await init_1.initCodeQL(undefined, apiDetails, tempDir, toolsDir, gitHubVersion.type, logger)).codeql;
|
||||||
}
|
}
|
||||||
const config = await init_1.initConfig(cmd.languages, cmd.queries, cmd.configFile, undefined, repository_1.parseRepositoryNwo(cmd.repository), tempDir, toolsDir, codeql, cmd.checkoutPath || process.cwd(), gitHubVersion, apiDetails, logger);
|
const config = await init_1.initConfig(cmd.languages, cmd.queries, cmd.packs, cmd.configFile, undefined, repository_1.parseRepositoryNwo(cmd.repository), tempDir, toolsDir, codeql, cmd.checkoutPath || process.cwd(), gitHubVersion, apiDetails, logger);
|
||||||
const tracerConfig = await init_1.runInit(codeql, config);
|
const tracerConfig = await init_1.runInit(codeql, config);
|
||||||
if (tracerConfig === undefined) {
|
if (tracerConfig === undefined) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -84,6 +84,7 @@ test("load empty config", async (t) => {
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
|
undefined,
|
||||||
{ owner: "github", repo: "example " },
|
{ owner: "github", repo: "example " },
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
|
|
@ -100,6 +101,7 @@ test("load empty config", async (t) => {
|
||||||
languages,
|
languages,
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
|
undefined,
|
||||||
{ owner: "github", repo: "example " },
|
{ owner: "github", repo: "example " },
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
|
|
@ -141,6 +143,7 @@ test("loading config saves config", async (t) => {
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
|
undefined,
|
||||||
{ owner: "github", repo: "example " },
|
{ owner: "github", repo: "example " },
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
|
|
@ -164,6 +167,7 @@ test("load input outside of workspace", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(
|
await configUtils.initConfig(
|
||||||
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
"../input",
|
"../input",
|
||||||
|
|
@ -198,6 +202,7 @@ test("load non-local input with invalid repo syntax", async (t) => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(
|
await configUtils.initConfig(
|
||||||
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
configFile,
|
configFile,
|
||||||
|
|
@ -235,6 +240,7 @@ test("load non-existent input", async (t) => {
|
||||||
await configUtils.initConfig(
|
await configUtils.initConfig(
|
||||||
languages,
|
languages,
|
||||||
undefined,
|
undefined,
|
||||||
|
undefined,
|
||||||
configFile,
|
configFile,
|
||||||
undefined,
|
undefined,
|
||||||
{ owner: "github", repo: "example " },
|
{ owner: "github", repo: "example " },
|
||||||
|
|
@ -328,6 +334,7 @@ test("load non-empty input", async (t) => {
|
||||||
const actualConfig = await configUtils.initConfig(
|
const actualConfig = await configUtils.initConfig(
|
||||||
languages,
|
languages,
|
||||||
undefined,
|
undefined,
|
||||||
|
undefined,
|
||||||
configFilePath,
|
configFilePath,
|
||||||
undefined,
|
undefined,
|
||||||
{ owner: "github", repo: "example " },
|
{ owner: "github", repo: "example " },
|
||||||
|
|
@ -390,6 +397,7 @@ test("Default queries are used", async (t) => {
|
||||||
await configUtils.initConfig(
|
await configUtils.initConfig(
|
||||||
languages,
|
languages,
|
||||||
undefined,
|
undefined,
|
||||||
|
undefined,
|
||||||
configFilePath,
|
configFilePath,
|
||||||
undefined,
|
undefined,
|
||||||
{ owner: "github", repo: "example " },
|
{ owner: "github", repo: "example " },
|
||||||
|
|
@ -460,6 +468,7 @@ test("Queries can be specified in config file", async (t) => {
|
||||||
const config = await configUtils.initConfig(
|
const config = await configUtils.initConfig(
|
||||||
languages,
|
languages,
|
||||||
undefined,
|
undefined,
|
||||||
|
undefined,
|
||||||
configFilePath,
|
configFilePath,
|
||||||
undefined,
|
undefined,
|
||||||
{ owner: "github", repo: "example " },
|
{ owner: "github", repo: "example " },
|
||||||
|
|
@ -524,6 +533,7 @@ test("Queries from config file can be overridden in workflow file", async (t) =>
|
||||||
const config = await configUtils.initConfig(
|
const config = await configUtils.initConfig(
|
||||||
languages,
|
languages,
|
||||||
testQueries,
|
testQueries,
|
||||||
|
undefined,
|
||||||
configFilePath,
|
configFilePath,
|
||||||
undefined,
|
undefined,
|
||||||
{ owner: "github", repo: "example " },
|
{ owner: "github", repo: "example " },
|
||||||
|
|
@ -586,6 +596,7 @@ test("Queries in workflow file can be used in tandem with the 'disable default q
|
||||||
const config = await configUtils.initConfig(
|
const config = await configUtils.initConfig(
|
||||||
languages,
|
languages,
|
||||||
testQueries,
|
testQueries,
|
||||||
|
undefined,
|
||||||
configFilePath,
|
configFilePath,
|
||||||
undefined,
|
undefined,
|
||||||
{ owner: "github", repo: "example " },
|
{ owner: "github", repo: "example " },
|
||||||
|
|
@ -643,6 +654,7 @@ test("Multiple queries can be specified in workflow file, no config file require
|
||||||
testQueries,
|
testQueries,
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
|
undefined,
|
||||||
{ owner: "github", repo: "example " },
|
{ owner: "github", repo: "example " },
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
|
|
@ -717,6 +729,7 @@ test("Queries in workflow file can be added to the set of queries without overri
|
||||||
const config = await configUtils.initConfig(
|
const config = await configUtils.initConfig(
|
||||||
languages,
|
languages,
|
||||||
testQueries,
|
testQueries,
|
||||||
|
undefined,
|
||||||
configFilePath,
|
configFilePath,
|
||||||
undefined,
|
undefined,
|
||||||
{ owner: "github", repo: "example " },
|
{ owner: "github", repo: "example " },
|
||||||
|
|
@ -785,6 +798,7 @@ test("Invalid queries in workflow file handled correctly", async (t) => {
|
||||||
queries,
|
queries,
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
|
undefined,
|
||||||
{ owner: "github", repo: "example " },
|
{ owner: "github", repo: "example " },
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
|
|
@ -846,6 +860,7 @@ test("API client used when reading remote config", async (t) => {
|
||||||
await configUtils.initConfig(
|
await configUtils.initConfig(
|
||||||
languages,
|
languages,
|
||||||
undefined,
|
undefined,
|
||||||
|
undefined,
|
||||||
configFile,
|
configFile,
|
||||||
undefined,
|
undefined,
|
||||||
{ owner: "github", repo: "example " },
|
{ owner: "github", repo: "example " },
|
||||||
|
|
@ -869,6 +884,7 @@ test("Remote config handles the case where a directory is provided", async (t) =
|
||||||
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(
|
await configUtils.initConfig(
|
||||||
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
repoReference,
|
repoReference,
|
||||||
|
|
@ -902,6 +918,7 @@ test("Invalid format of remote config handled correctly", async (t) => {
|
||||||
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(
|
await configUtils.initConfig(
|
||||||
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
repoReference,
|
repoReference,
|
||||||
|
|
@ -940,6 +957,7 @@ test("No detected languages", async (t) => {
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
|
undefined,
|
||||||
{ owner: "github", repo: "example " },
|
{ owner: "github", repo: "example " },
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
|
|
@ -966,6 +984,7 @@ test("Unknown languages", async (t) => {
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
|
undefined,
|
||||||
{ owner: "github", repo: "example " },
|
{ owner: "github", repo: "example " },
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
|
|
@ -1012,6 +1031,7 @@ test("Config specifies packages", async (t) => {
|
||||||
const { packs } = await configUtils.initConfig(
|
const { packs } = await configUtils.initConfig(
|
||||||
languages,
|
languages,
|
||||||
undefined,
|
undefined,
|
||||||
|
undefined,
|
||||||
configFile,
|
configFile,
|
||||||
undefined,
|
undefined,
|
||||||
{ owner: "github", repo: "example " },
|
{ owner: "github", repo: "example " },
|
||||||
|
|
@ -1069,6 +1089,7 @@ test("Config specifies packages for multiple languages", async (t) => {
|
||||||
const { packs, queries } = await configUtils.initConfig(
|
const { packs, queries } = await configUtils.initConfig(
|
||||||
languages,
|
languages,
|
||||||
undefined,
|
undefined,
|
||||||
|
undefined,
|
||||||
configFile,
|
configFile,
|
||||||
undefined,
|
undefined,
|
||||||
{ owner: "github", repo: "example" },
|
{ owner: "github", repo: "example" },
|
||||||
|
|
@ -1142,6 +1163,7 @@ function doInvalidInputTest(
|
||||||
await configUtils.initConfig(
|
await configUtils.initConfig(
|
||||||
languages,
|
languages,
|
||||||
undefined,
|
undefined,
|
||||||
|
undefined,
|
||||||
configFile,
|
configFile,
|
||||||
undefined,
|
undefined,
|
||||||
{ owner: "github", repo: "example " },
|
{ owner: "github", repo: "example " },
|
||||||
|
|
@ -1321,7 +1343,7 @@ function parsePacksMacro(
|
||||||
expected
|
expected
|
||||||
) {
|
) {
|
||||||
t.deepEqual(
|
t.deepEqual(
|
||||||
configUtils.parsePacks(packsByLanguage, languages, "/a/b"),
|
configUtils.parsePacksFromConfig(packsByLanguage, languages, "/a/b"),
|
||||||
expected
|
expected
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -1339,7 +1361,7 @@ function parsePacksErrorMacro(
|
||||||
) {
|
) {
|
||||||
t.throws(
|
t.throws(
|
||||||
() => {
|
() => {
|
||||||
configUtils.parsePacks(packsByLanguage, languages, "/a/b");
|
configUtils.parsePacksFromConfig(packsByLanguage, languages, "/a/b");
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
message: expected,
|
message: expected,
|
||||||
|
|
@ -1349,6 +1371,9 @@ function parsePacksErrorMacro(
|
||||||
parsePacksErrorMacro.title = (providedTitle: string) =>
|
parsePacksErrorMacro.title = (providedTitle: string) =>
|
||||||
`Parse Packs Error: ${providedTitle}`;
|
`Parse Packs Error: ${providedTitle}`;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test macro for testing when the packs block is invalid
|
||||||
|
*/
|
||||||
function invalidPackNameMacro(t: ExecutionContext<unknown>, name: string) {
|
function invalidPackNameMacro(t: ExecutionContext<unknown>, name: string) {
|
||||||
parsePacksErrorMacro(
|
parsePacksErrorMacro(
|
||||||
t,
|
t,
|
||||||
|
|
@ -1369,6 +1394,18 @@ test("two packs", parsePacksMacro, ["a/b", "c/d@1.2.3"], [Language.cpp], {
|
||||||
{ packName: "c/d", version: clean("1.2.3") },
|
{ packName: "c/d", version: clean("1.2.3") },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
test(
|
||||||
|
"two packs with spaces",
|
||||||
|
parsePacksMacro,
|
||||||
|
[" a/b ", " c/d@1.2.3 "],
|
||||||
|
[Language.cpp],
|
||||||
|
{
|
||||||
|
[Language.cpp]: [
|
||||||
|
{ packName: "a/b", version: undefined },
|
||||||
|
{ packName: "c/d", version: clean("1.2.3") },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
);
|
||||||
test(
|
test(
|
||||||
"two packs with language",
|
"two packs with language",
|
||||||
parsePacksMacro,
|
parsePacksMacro,
|
||||||
|
|
@ -1416,3 +1453,160 @@ test(invalidPackNameMacro, "c-/d");
|
||||||
test(invalidPackNameMacro, "-c/d");
|
test(invalidPackNameMacro, "-c/d");
|
||||||
test(invalidPackNameMacro, "c/d_d");
|
test(invalidPackNameMacro, "c/d_d");
|
||||||
test(invalidPackNameMacro, "c/d@x");
|
test(invalidPackNameMacro, "c/d@x");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test macro for testing the packs block and the packs input
|
||||||
|
*/
|
||||||
|
function parseInputAndConfigMacro(
|
||||||
|
t: ExecutionContext<unknown>,
|
||||||
|
packsFromConfig: string[] | Record<string, string[]>,
|
||||||
|
packsFromInput: string | undefined,
|
||||||
|
languages: Language[],
|
||||||
|
expected
|
||||||
|
) {
|
||||||
|
t.deepEqual(
|
||||||
|
configUtils.parsePacks(packsFromConfig, packsFromInput, languages, "/a/b"),
|
||||||
|
expected
|
||||||
|
);
|
||||||
|
}
|
||||||
|
parseInputAndConfigMacro.title = (providedTitle: string) =>
|
||||||
|
`Parse Packs input and config: ${providedTitle}`;
|
||||||
|
|
||||||
|
function parseInputAndConfigErrorMacro(
|
||||||
|
t: ExecutionContext<unknown>,
|
||||||
|
packsFromConfig: string[] | Record<string, string[]>,
|
||||||
|
packsFromInput: string | undefined,
|
||||||
|
languages: Language[],
|
||||||
|
expected: RegExp
|
||||||
|
) {
|
||||||
|
t.throws(
|
||||||
|
() => {
|
||||||
|
configUtils.parsePacks(
|
||||||
|
packsFromConfig,
|
||||||
|
packsFromInput,
|
||||||
|
languages,
|
||||||
|
"/a/b"
|
||||||
|
);
|
||||||
|
},
|
||||||
|
{
|
||||||
|
message: expected,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
parseInputAndConfigErrorMacro.title = (providedTitle: string) =>
|
||||||
|
`Parse Packs input and config Error: ${providedTitle}`;
|
||||||
|
|
||||||
|
test("input only", parseInputAndConfigMacro, {}, " c/d ", [Language.cpp], {
|
||||||
|
[Language.cpp]: [{ packName: "c/d", version: undefined }],
|
||||||
|
});
|
||||||
|
|
||||||
|
test(
|
||||||
|
"input only with multiple",
|
||||||
|
parseInputAndConfigMacro,
|
||||||
|
{},
|
||||||
|
"a/b , c/d@1.2.3",
|
||||||
|
[Language.cpp],
|
||||||
|
{
|
||||||
|
[Language.cpp]: [
|
||||||
|
{ packName: "a/b", version: undefined },
|
||||||
|
{ packName: "c/d", version: "1.2.3" },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
test(
|
||||||
|
"input only with +",
|
||||||
|
parseInputAndConfigMacro,
|
||||||
|
{},
|
||||||
|
" + a/b , c/d@1.2.3 ",
|
||||||
|
[Language.cpp],
|
||||||
|
{
|
||||||
|
[Language.cpp]: [
|
||||||
|
{ packName: "a/b", version: undefined },
|
||||||
|
{ packName: "c/d", version: "1.2.3" },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
test(
|
||||||
|
"config only",
|
||||||
|
parseInputAndConfigMacro,
|
||||||
|
["a/b", "c/d"],
|
||||||
|
" ",
|
||||||
|
[Language.cpp],
|
||||||
|
{
|
||||||
|
[Language.cpp]: [
|
||||||
|
{ packName: "a/b", version: undefined },
|
||||||
|
{ packName: "c/d", version: undefined },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
test(
|
||||||
|
"input overrides",
|
||||||
|
parseInputAndConfigMacro,
|
||||||
|
["a/b", "c/d"],
|
||||||
|
" e/f, g/h@1.2.3 ",
|
||||||
|
[Language.cpp],
|
||||||
|
{
|
||||||
|
[Language.cpp]: [
|
||||||
|
{ packName: "e/f", version: undefined },
|
||||||
|
{ packName: "g/h", version: "1.2.3" },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
test(
|
||||||
|
"input and config",
|
||||||
|
parseInputAndConfigMacro,
|
||||||
|
["a/b", "c/d"],
|
||||||
|
" +e/f, g/h@1.2.3 ",
|
||||||
|
[Language.cpp],
|
||||||
|
{
|
||||||
|
[Language.cpp]: [
|
||||||
|
{ packName: "e/f", version: undefined },
|
||||||
|
{ packName: "g/h", version: "1.2.3" },
|
||||||
|
{ packName: "a/b", version: undefined },
|
||||||
|
{ packName: "c/d", version: undefined },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
test(
|
||||||
|
"input with no language",
|
||||||
|
parseInputAndConfigErrorMacro,
|
||||||
|
{},
|
||||||
|
"c/d",
|
||||||
|
[],
|
||||||
|
/No languages specified/
|
||||||
|
);
|
||||||
|
|
||||||
|
test(
|
||||||
|
"input with two languages",
|
||||||
|
parseInputAndConfigErrorMacro,
|
||||||
|
{},
|
||||||
|
"c/d",
|
||||||
|
[Language.cpp, Language.csharp],
|
||||||
|
/multi-language analysis/
|
||||||
|
);
|
||||||
|
|
||||||
|
test(
|
||||||
|
"input with + only",
|
||||||
|
parseInputAndConfigErrorMacro,
|
||||||
|
{},
|
||||||
|
" + ",
|
||||||
|
[Language.cpp],
|
||||||
|
/Remove the '\+'/
|
||||||
|
);
|
||||||
|
|
||||||
|
test(
|
||||||
|
"input with invalid pack name",
|
||||||
|
parseInputAndConfigErrorMacro,
|
||||||
|
{},
|
||||||
|
" xxx",
|
||||||
|
[Language.cpp],
|
||||||
|
/"xxx" is not a valid pack/
|
||||||
|
);
|
||||||
|
|
||||||
|
// errors
|
||||||
|
// input w invalid pack name
|
||||||
|
|
|
||||||
|
|
@ -585,13 +585,15 @@ export function getPacksInvalid(configFile: string): string {
|
||||||
|
|
||||||
export function getPacksStrInvalid(
|
export function getPacksStrInvalid(
|
||||||
packStr: string,
|
packStr: string,
|
||||||
configFile: string
|
configFile?: string
|
||||||
): string {
|
): string {
|
||||||
return getConfigFilePropertyError(
|
return configFile
|
||||||
configFile,
|
? getConfigFilePropertyError(
|
||||||
PACKS_PROPERTY,
|
configFile,
|
||||||
`"${packStr}" is not a valid pack`
|
PACKS_PROPERTY,
|
||||||
);
|
`"${packStr}" is not a valid pack`
|
||||||
|
)
|
||||||
|
: `"${packStr}" is not a valid pack`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getLocalPathOutsideOfRepository(
|
export function getLocalPathOutsideOfRepository(
|
||||||
|
|
@ -802,6 +804,7 @@ function shouldAddConfigFileQueries(queriesInput: string | undefined): boolean {
|
||||||
export async function getDefaultConfig(
|
export async function getDefaultConfig(
|
||||||
languagesInput: string | undefined,
|
languagesInput: string | undefined,
|
||||||
queriesInput: string | undefined,
|
queriesInput: string | undefined,
|
||||||
|
packsInput: string | undefined,
|
||||||
dbLocation: string | undefined,
|
dbLocation: string | undefined,
|
||||||
repository: RepositoryNwo,
|
repository: RepositoryNwo,
|
||||||
tempDir: string,
|
tempDir: string,
|
||||||
|
|
@ -840,12 +843,14 @@ export async function getDefaultConfig(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const packs = parsePacksInput(packsInput, languages) ?? {};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
languages,
|
languages,
|
||||||
queries,
|
queries,
|
||||||
pathsIgnore: [],
|
pathsIgnore: [],
|
||||||
paths: [],
|
paths: [],
|
||||||
packs: {},
|
packs,
|
||||||
originalUserInput: {},
|
originalUserInput: {},
|
||||||
tempDir,
|
tempDir,
|
||||||
toolCacheDir,
|
toolCacheDir,
|
||||||
|
|
@ -861,6 +866,7 @@ export async function getDefaultConfig(
|
||||||
async function loadConfig(
|
async function loadConfig(
|
||||||
languagesInput: string | undefined,
|
languagesInput: string | undefined,
|
||||||
queriesInput: string | undefined,
|
queriesInput: string | undefined,
|
||||||
|
packsInput: string | undefined,
|
||||||
configFile: string,
|
configFile: string,
|
||||||
dbLocation: string | undefined,
|
dbLocation: string | undefined,
|
||||||
repository: RepositoryNwo,
|
repository: RepositoryNwo,
|
||||||
|
|
@ -1002,6 +1008,7 @@ async function loadConfig(
|
||||||
|
|
||||||
const packs = parsePacks(
|
const packs = parsePacks(
|
||||||
parsedYAML[PACKS_PROPERTY] ?? {},
|
parsedYAML[PACKS_PROPERTY] ?? {},
|
||||||
|
packsInput,
|
||||||
languages,
|
languages,
|
||||||
configFile
|
configFile
|
||||||
);
|
);
|
||||||
|
|
@ -1033,7 +1040,7 @@ const PACK_IDENTIFIER_PATTERN = (function () {
|
||||||
})();
|
})();
|
||||||
|
|
||||||
// Exported for testing
|
// Exported for testing
|
||||||
export function parsePacks(
|
export function parsePacksFromConfig(
|
||||||
packsByLanguage: string[] | Record<string, string[]>,
|
packsByLanguage: string[] | Record<string, string[]>,
|
||||||
languages: Language[],
|
languages: Language[],
|
||||||
configFile: string
|
configFile: string
|
||||||
|
|
@ -1068,12 +1075,44 @@ export function parsePacks(
|
||||||
return packs;
|
return packs;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toPackWithVersion(packStr, configFile: string): PackWithVersion {
|
function parsePacksInput(
|
||||||
|
packsInput: string | undefined,
|
||||||
|
languages: Language[]
|
||||||
|
): Packs | undefined {
|
||||||
|
if (!packsInput?.trim()) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (languages.length > 1) {
|
||||||
|
throw new Error(
|
||||||
|
"Cannot specify a 'packs' input in a multi-language analysis. Use a codeql-config.yml file instead and specify packs by library."
|
||||||
|
);
|
||||||
|
} else if (languages.length === 0) {
|
||||||
|
throw new Error("No languages specified. Cannot process the packs input.");
|
||||||
|
}
|
||||||
|
|
||||||
|
packsInput = packsInput.trim();
|
||||||
|
if (packsInput.startsWith("+")) {
|
||||||
|
packsInput = packsInput.substring(1).trim();
|
||||||
|
if (!packsInput) {
|
||||||
|
throw new Error("Remove the '+' from the packs input.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
[languages[0]]: packsInput.split(",").reduce((packs, pack) => {
|
||||||
|
packs.push(toPackWithVersion(pack, ""));
|
||||||
|
return packs;
|
||||||
|
}, [] as PackWithVersion[]),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function toPackWithVersion(packStr, configFile?: string): PackWithVersion {
|
||||||
if (typeof packStr !== "string") {
|
if (typeof packStr !== "string") {
|
||||||
throw new Error(getPacksStrInvalid(packStr, configFile));
|
throw new Error(getPacksStrInvalid(packStr, configFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
const nameWithVersion = packStr.split("@");
|
const nameWithVersion = packStr.trim().split("@");
|
||||||
let version: string | undefined;
|
let version: string | undefined;
|
||||||
if (
|
if (
|
||||||
nameWithVersion.length > 2 ||
|
nameWithVersion.length > 2 ||
|
||||||
|
|
@ -1088,11 +1127,52 @@ function toPackWithVersion(packStr, configFile: string): PackWithVersion {
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
packName: nameWithVersion[0],
|
packName: nameWithVersion[0].trim(),
|
||||||
version,
|
version,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// exported for testing
|
||||||
|
export function parsePacks(
|
||||||
|
rawPacksFromConfig: string[] | Record<string, string[]>,
|
||||||
|
rawPacksInput: string | undefined,
|
||||||
|
languages: Language[],
|
||||||
|
configFile: string
|
||||||
|
) {
|
||||||
|
const packsFromInput = parsePacksInput(rawPacksInput, languages);
|
||||||
|
const packsFomConfig = parsePacksFromConfig(
|
||||||
|
rawPacksFromConfig,
|
||||||
|
languages,
|
||||||
|
configFile
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!packsFromInput) {
|
||||||
|
return packsFomConfig;
|
||||||
|
}
|
||||||
|
if (!shouldCombinePacks(rawPacksInput)) {
|
||||||
|
return packsFromInput;
|
||||||
|
}
|
||||||
|
|
||||||
|
return combinePacks(packsFromInput, packsFomConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
function shouldCombinePacks(packsInput?: string): boolean {
|
||||||
|
return !!packsInput?.trim().startsWith("+");
|
||||||
|
}
|
||||||
|
|
||||||
|
function combinePacks(packs1: Packs, packs2: Packs): Packs {
|
||||||
|
const packs = {};
|
||||||
|
for (const lang of Object.keys(packs1)) {
|
||||||
|
packs[lang] = packs1[lang].concat(packs2[lang] || []);
|
||||||
|
}
|
||||||
|
for (const lang of Object.keys(packs2)) {
|
||||||
|
if (!packs[lang]) {
|
||||||
|
packs[lang] = packs2[lang];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return packs;
|
||||||
|
}
|
||||||
|
|
||||||
function dbLocationOrDefault(
|
function dbLocationOrDefault(
|
||||||
dbLocation: string | undefined,
|
dbLocation: string | undefined,
|
||||||
tempDir: string
|
tempDir: string
|
||||||
|
|
@ -1109,6 +1189,7 @@ function dbLocationOrDefault(
|
||||||
export async function initConfig(
|
export async function initConfig(
|
||||||
languagesInput: string | undefined,
|
languagesInput: string | undefined,
|
||||||
queriesInput: string | undefined,
|
queriesInput: string | undefined,
|
||||||
|
packsInput: string | undefined,
|
||||||
configFile: string | undefined,
|
configFile: string | undefined,
|
||||||
dbLocation: string | undefined,
|
dbLocation: string | undefined,
|
||||||
repository: RepositoryNwo,
|
repository: RepositoryNwo,
|
||||||
|
|
@ -1128,6 +1209,7 @@ export async function initConfig(
|
||||||
config = await getDefaultConfig(
|
config = await getDefaultConfig(
|
||||||
languagesInput,
|
languagesInput,
|
||||||
queriesInput,
|
queriesInput,
|
||||||
|
packsInput,
|
||||||
dbLocation,
|
dbLocation,
|
||||||
repository,
|
repository,
|
||||||
tempDir,
|
tempDir,
|
||||||
|
|
@ -1142,6 +1224,7 @@ export async function initConfig(
|
||||||
config = await loadConfig(
|
config = await loadConfig(
|
||||||
languagesInput,
|
languagesInput,
|
||||||
queriesInput,
|
queriesInput,
|
||||||
|
packsInput,
|
||||||
configFile,
|
configFile,
|
||||||
dbLocation,
|
dbLocation,
|
||||||
repository,
|
repository,
|
||||||
|
|
|
||||||
|
|
@ -153,6 +153,7 @@ async function run() {
|
||||||
config = await initConfig(
|
config = await initConfig(
|
||||||
getOptionalInput("languages"),
|
getOptionalInput("languages"),
|
||||||
getOptionalInput("queries"),
|
getOptionalInput("queries"),
|
||||||
|
getOptionalInput("packs"),
|
||||||
getOptionalInput("config-file"),
|
getOptionalInput("config-file"),
|
||||||
getOptionalInput("db-location"),
|
getOptionalInput("db-location"),
|
||||||
parseRepositoryNwo(getRequiredEnvParam("GITHUB_REPOSITORY")),
|
parseRepositoryNwo(getRequiredEnvParam("GITHUB_REPOSITORY")),
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ export async function initCodeQL(
|
||||||
export async function initConfig(
|
export async function initConfig(
|
||||||
languagesInput: string | undefined,
|
languagesInput: string | undefined,
|
||||||
queriesInput: string | undefined,
|
queriesInput: string | undefined,
|
||||||
|
packsInput: string | undefined,
|
||||||
configFile: string | undefined,
|
configFile: string | undefined,
|
||||||
dbLocation: string | undefined,
|
dbLocation: string | undefined,
|
||||||
repository: RepositoryNwo,
|
repository: RepositoryNwo,
|
||||||
|
|
@ -53,6 +54,7 @@ export async function initConfig(
|
||||||
const config = await configUtils.initConfig(
|
const config = await configUtils.initConfig(
|
||||||
languagesInput,
|
languagesInput,
|
||||||
queriesInput,
|
queriesInput,
|
||||||
|
packsInput,
|
||||||
configFile,
|
configFile,
|
||||||
dbLocation,
|
dbLocation,
|
||||||
repository,
|
repository,
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,7 @@ function parseTraceProcessLevel(): number | undefined {
|
||||||
interface InitArgs {
|
interface InitArgs {
|
||||||
languages: string | undefined;
|
languages: string | undefined;
|
||||||
queries: string | undefined;
|
queries: string | undefined;
|
||||||
|
packs: string | undefined;
|
||||||
configFile: string | undefined;
|
configFile: string | undefined;
|
||||||
codeqlPath: string | undefined;
|
codeqlPath: string | undefined;
|
||||||
tempDir: string | undefined;
|
tempDir: string | undefined;
|
||||||
|
|
@ -129,6 +130,14 @@ program
|
||||||
"--queries <queries>",
|
"--queries <queries>",
|
||||||
"Comma-separated list of additional queries to run. This overrides the same setting in a configuration file."
|
"Comma-separated list of additional queries to run. This overrides the same setting in a configuration file."
|
||||||
)
|
)
|
||||||
|
.option(
|
||||||
|
"--packs <packs>",
|
||||||
|
`Comma-separated list of packs to run. Reference a pack in the format scope/name[@version]. If version is not
|
||||||
|
specified, then the latest version of the pack is used. By default, this overrides the same setting in a
|
||||||
|
configuration file; prefix with "+" to use both sets of packs.
|
||||||
|
|
||||||
|
This option is only available in single-language analyses.`
|
||||||
|
)
|
||||||
.option("--config-file <file>", "Path to config file.")
|
.option("--config-file <file>", "Path to config file.")
|
||||||
.option(
|
.option(
|
||||||
"--codeql-path <path>",
|
"--codeql-path <path>",
|
||||||
|
|
@ -201,6 +210,7 @@ program
|
||||||
const config = await initConfig(
|
const config = await initConfig(
|
||||||
cmd.languages,
|
cmd.languages,
|
||||||
cmd.queries,
|
cmd.queries,
|
||||||
|
cmd.packs,
|
||||||
cmd.configFile,
|
cmd.configFile,
|
||||||
undefined,
|
undefined,
|
||||||
parseRepositoryNwo(cmd.repository),
|
parseRepositoryNwo(cmd.repository),
|
||||||
|
|
|
||||||
6
tests/multi-language-repo/.github/codeql/codeql-config-packaging2.yml
vendored
Normal file
6
tests/multi-language-repo/.github/codeql/codeql-config-packaging2.yml
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
name: Pack testing in the CodeQL Action
|
||||||
|
|
||||||
|
disable-default-queries: true
|
||||||
|
paths-ignore:
|
||||||
|
- tests
|
||||||
|
- lib
|
||||||
Loading…
Add table
Add a link
Reference in a new issue