Compare commits

..
Author SHA1 Message Date
jhutchings1 5fa6bd2622 Update autobuild and analysis path error messages. 2020-07-11 11:45:36 -07:00
jhutchings1 278f870907 Add help URL to languages error 2020-07-11 11:40:35 -07:00
42 changed files with 822 additions and 1528 deletions

No files matched your search

-25
View File
@@ -1,25 +0,0 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug AVA test file",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/ava",
"runtimeArgs": [
"${file}",
"--break",
"--serial",
"--timeout=20m"
],
"port": 9229,
"outputCapture": "std",
"skipFiles": [
"<node_internals>/**/*.js"
]
}
]
}
-2
View File
@@ -20,8 +20,6 @@ Before you start, ensure that you have a recent version of node installed. You c
* Run tests: `npm run test`. You’ll need to ensure that the JavaScript files are up-to-date first by running the command above. * Run tests: `npm run test`. You’ll need to ensure that the JavaScript files are up-to-date first by running the command above.
* Run the linter: `npm run lint`. * Run the linter: `npm run lint`.
This project also includes configuration to run tests from VSCode (with support for breakpoints) - open the test file you wish to run and choose "Debug AVA test file" from the Run menu in the Run panel.
### Running the action ### Running the action
To see the effect of your changes and to test them, push your changes in a branch and then look at the [Actions output](https://github.com/github/codeql-action/actions) for that branch. You can also exercise the code locally by running the automated tests. To see the effect of your changes and to test them, push your changes in a branch and then look at the [Actions output](https://github.com/github/codeql-action/actions) for that branch. You can also exercise the code locally by running the automated tests.
-4
View File
@@ -20,10 +20,6 @@ inputs:
description: The number of threads to be used by CodeQL. description: The number of threads to be used by CodeQL.
required: false required: false
default: "1" default: "1"
checkout_path:
description: "The path at which the analyzed repository was checked out. Used to relativeize any absolute paths in the uploaded SARIF file."
required: false
default: ${{ github.workspace }}
token: token:
default: ${{ github.token }} default: ${{ github.token }}
matrix: matrix:
-4
View File
@@ -16,10 +16,6 @@ inputs:
config-file: config-file:
description: Path of the config file to use description: Path of the config file to use
required: false required: false
setup-python-dependencies:
description: Try to auto-install your python dependencies
required: true
default: 'true'
runs: runs:
using: 'node12' using: 'node12'
main: '../lib/setup-tracer.js' main: '../lib/setup-tracer.js'
+2 -2
View File
@@ -23,7 +23,7 @@ function buildIncludeExcludeEnvVar(paths) {
} }
return paths.join('\n'); return paths.join('\n');
} }
function includeAndExcludeAnalysisPaths(config) { function includeAndExcludeAnalysisPaths(config, languages) {
// The 'LGTM_INDEX_INCLUDE' and 'LGTM_INDEX_EXCLUDE' environment variables // The 'LGTM_INDEX_INCLUDE' and 'LGTM_INDEX_EXCLUDE' environment variables
// control which files/directories are traversed when scanning. // control which files/directories are traversed when scanning.
// This allows including files that otherwise would not be scanned, or // This allows including files that otherwise would not be scanned, or
@@ -51,7 +51,7 @@ function includeAndExcludeAnalysisPaths(config) {
if ((config.paths.length !== 0 || if ((config.paths.length !== 0 ||
config.pathsIgnore.length !== 0 || config.pathsIgnore.length !== 0 ||
filters.length !== 0) && filters.length !== 0) &&
!config.languages.every(isInterpretedLanguage)) { !languages.every(isInterpretedLanguage)) {
core.warning('The "paths"/"paths-ignore" fields of the config only have effect for Javascript and Python'); core.warning('The "paths"/"paths-ignore" fields of the config only have effect for Javascript and Python');
} }
} }
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"analysis-paths.js","sourceRoot":"","sources":["../src/analysis-paths.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAItC,SAAS,qBAAqB,CAAC,QAAQ;IACrC,OAAO,QAAQ,KAAK,YAAY,IAAI,QAAQ,KAAK,QAAQ,CAAC;AAC5D,CAAC;AAED,6FAA6F;AAChF,QAAA,+BAA+B,GAAG,eAAe,CAAC;AAE/D,uFAAuF;AACvF,SAAS,yBAAyB,CAAC,KAAe;IAChD,iCAAiC;IACjC,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAA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K,CAAC,EAAE;QAC7B,IAAI,CAAC,cAAc,CAAC,oBAAoB,EAAE,yBAAyB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;KACpF;IACD,IAAI,MAAM,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;QACnC,IAAI,CAAC,cAAc,CAAC,oBAAoB,EAAE,yBAAyB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;KAC1F;IAED,yEAAyE;IACzE,6EAA6E;IAC7E,wDAAwD;IACxD,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC;IACvD,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC;IAC7D,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;QACxB,IAAI,CAAC,cAAc,CAAC,oBAAoB,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;KAC/D;IAED,oEAAoE;IACpE,sEAAsE;IACtE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;QACxB,MAAM,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC;QAC/B,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC;QACvB,CAAC,SAAS,CAAC,KAAK,CAAC,qBAAqB,CAAC,EAAE;QAC3C,IAAI,CAAC,OAAO,CAAC,4FAA4F,CAAC,CAAC;KAC5G;AACH,CAAC;AAjCD,wEAiCC"}
+7 -14
View File
@@ -12,28 +12,21 @@ var __importStar = (this && this.__importStar) || function (mod) {
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const ava_1 = __importDefault(require("ava")); const ava_1 = __importDefault(require("ava"));
const analysisPaths = __importStar(require("./analysis-paths")); const analysisPaths = __importStar(require("./analysis-paths"));
const configUtils = __importStar(require("./config-utils"));
const testing_utils_1 = require("./testing-utils"); const testing_utils_1 = require("./testing-utils");
testing_utils_1.setupTests(ava_1.default); testing_utils_1.setupTests(ava_1.default);
ava_1.default("emptyPaths", async (t) => { ava_1.default("emptyPaths", async (t) => {
const config = { let config = new configUtils.Config();
languages: [], analysisPaths.includeAndExcludeAnalysisPaths(config, []);
queries: {},
pathsIgnore: [],
paths: [],
};
analysisPaths.includeAndExcludeAnalysisPaths(config);
t.is(process.env['LGTM_INDEX_INCLUDE'], undefined); t.is(process.env['LGTM_INDEX_INCLUDE'], undefined);
t.is(process.env['LGTM_INDEX_EXCLUDE'], undefined); t.is(process.env['LGTM_INDEX_EXCLUDE'], undefined);
t.is(process.env['LGTM_INDEX_FILTERS'], undefined); t.is(process.env['LGTM_INDEX_FILTERS'], undefined);
}); });
ava_1.default("nonEmptyPaths", async (t) => { ava_1.default("nonEmptyPaths", async (t) => {
const config = { let config = new configUtils.Config();
languages: [], config.paths.push('path1', 'path2', '**/path3');
queries: {}, config.pathsIgnore.push('path4', 'path5', 'path6/**');
paths: ['path1', 'path2', '**/path3'], analysisPaths.includeAndExcludeAnalysisPaths(config, []);
pathsIgnore: ['path4', 'path5', 'path6/**'],
};
analysisPaths.includeAndExcludeAnalysisPaths(config);
t.is(process.env['LGTM_INDEX_INCLUDE'], 'path1\npath2'); t.is(process.env['LGTM_INDEX_INCLUDE'], 'path1\npath2');
t.is(process.env['LGTM_INDEX_EXCLUDE'], 'path4\npath5'); t.is(process.env['LGTM_INDEX_EXCLUDE'], 'path4\npath5');
t.is(process.env['LGTM_INDEX_FILTERS'], 'include:path1\ninclude:path2\ninclude:**/path3\nexclude:path4\nexclude:path5\nexclude:path6/**'); t.is(process.env['LGTM_INDEX_FILTERS'], 'include:path1\ninclude:path2\ninclude:**/path3\nexclude:path4\nexclude:path5\nexclude:path6/**');
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"analysis-paths.test.js","sourceRoot":"","sources":["../src/analysis-paths.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAAuB;AAEvB,gEAAkD;AAClD,mDAA2C;AAE3C,0BAAU,CAAC,aAAI,CAAC,CAAC;AAEjB,aAAI,CAAC,YAAY,EAAE,KAAK,EAAC,CAAC,EAAC,EAAE;IAC3B,MAAM,MAAM,GAAG;QACb,SAAS,EAAE,EAAE;QACb,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,EAAE;QACf,KAAK,EAAE,EAAE;KACV,CAAC;IACF,aAAa,CAAC,8BAA8B,CAAC,MAAM,CAAC,CAAC;IACrD,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,SAAS,CAAC,CAAC;IACnD,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,SAAS,CAAC,CAAC;IACnD,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,SAAS,CAAC,CAAC;AACrD,CAAC,CAAC,CAAC;AAEH,aAAI,CAAC,eAAe,EAAE,KAAK,EAAC,CAAC,EAAC,EAAE;IAC9B,MAAM,MAAM,GAAG;QACb,SAAS,EAAE,EAAE;QACb,OAAO,EAAE,EAAE;QACX,KAAK,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC;QACrC,WAAW,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC;KAC5C,CAAC;IACF,aAAa,CAAC,8BAA8B,CAAC,MAAM,CAAC,CAAC;IACrD,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,cAAc,CAAC,CAAC;IACxD,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,cAA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AE,cAAc,CAAC,CAAC;IACxD,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,cAAc,CAAC,CAAC;IACxD,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,gGAAgG,CAAC,CAAC;AAC5I,CAAC,CAAC,CAAC"}
Generated
+7 -49
View File
@@ -14,11 +14,6 @@ const fs = __importStar(require("fs"));
const path = __importStar(require("path")); const path = __importStar(require("path"));
const semver = __importStar(require("semver")); const semver = __importStar(require("semver"));
const util = __importStar(require("./util")); const util = __importStar(require("./util"));
/**
* Stores the CodeQL object, and is populated by `setupCodeQL` or `getCodeQL`.
* Can be overridden in tests using `setCodeQL`.
*/
let cachedCodeQL = undefined;
/** /**
* Environment variable used to store the location of the CodeQL CLI executable. * Environment variable used to store the location of the CodeQL CLI executable.
* Value is set by setupCodeQL and read by getCodeQL. * Value is set by setupCodeQL and read by getCodeQL.
@@ -44,9 +39,8 @@ async function setupCodeQL() {
else if (process.platform !== 'linux' && process.platform !== 'darwin') { else if (process.platform !== 'linux' && process.platform !== 'darwin') {
throw new Error("Unsupported plaform: " + process.platform); throw new Error("Unsupported plaform: " + process.platform);
} }
cachedCodeQL = getCodeQLForCmd(codeqlCmd);
core.exportVariable(CODEQL_ACTION_CMD, codeqlCmd); core.exportVariable(CODEQL_ACTION_CMD, codeqlCmd);
return cachedCodeQL; return getCodeQLForCmd(codeqlCmd);
} }
catch (e) { catch (e) {
core.error(e); core.error(e);
@@ -72,42 +66,10 @@ function getCodeQLURLVersion(url) {
} }
exports.getCodeQLURLVersion = getCodeQLURLVersion; exports.getCodeQLURLVersion = getCodeQLURLVersion;
function getCodeQL() { function getCodeQL() {
if (cachedCodeQL === undefined) { const codeqlCmd = util.getRequiredEnvParam(CODEQL_ACTION_CMD);
const codeqlCmd = util.getRequiredEnvParam(CODEQL_ACTION_CMD); return getCodeQLForCmd(codeqlCmd);
cachedCodeQL = getCodeQLForCmd(codeqlCmd);
}
return cachedCodeQL;
} }
exports.getCodeQL = getCodeQL; exports.getCodeQL = getCodeQL;
function resolveFunction(partialCodeql, methodName) {
if (typeof partialCodeql[methodName] !== 'function') {
const dummyMethod = () => {
throw new Error('CodeQL ' + methodName + ' method not correctly defined');
};
return dummyMethod;
}
return partialCodeql[methodName];
}
/**
* Set the functionality for CodeQL methods. Only for use in tests.
*
* Accepts a partial object and any undefined methods will be implemented
* to immediately throw an exception indicating which method is missing.
*/
function setCodeQL(partialCodeql) {
cachedCodeQL = {
getDir: resolveFunction(partialCodeql, 'getDir'),
printVersion: resolveFunction(partialCodeql, 'printVersion'),
getTracerEnv: resolveFunction(partialCodeql, 'getTracerEnv'),
databaseInit: resolveFunction(partialCodeql, 'databaseInit'),
runAutobuild: resolveFunction(partialCodeql, 'runAutobuild'),
extractScannedLanguage: resolveFunction(partialCodeql, 'extractScannedLanguage'),
finalizeDatabase: resolveFunction(partialCodeql, 'finalizeDatabase'),
resolveQueries: resolveFunction(partialCodeql, 'resolveQueries'),
databaseAnalyze: resolveFunction(partialCodeql, 'databaseAnalyze')
};
}
exports.setCodeQL = setCodeQL;
function getCodeQLForCmd(cmd) { function getCodeQLForCmd(cmd) {
return { return {
getDir: function () { getDir: function () {
@@ -188,18 +150,14 @@ function getCodeQLForCmd(cmd) {
databasePath databasePath
]); ]);
}, },
resolveQueries: async function (queries, extraSearchPath) { resolveQueries: async function (queries) {
const codeqlArgs = [ let output = '';
await exec.exec(cmd, [
'resolve', 'resolve',
'queries', 'queries',
...queries, ...queries,
'--format=bylanguage' '--format=bylanguage'
]; ], {
if (extraSearchPath !== undefined) {
codeqlArgs.push('--search-path', extraSearchPath);
}
let output = '';
await exec.exec(cmd, codeqlArgs, {
listeners: { listeners: {
stdout: (data) => { stdout: (data) => {
output += data.toString(); output += data.toString();
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"codeql.js","sourceRoot":"","sources":["../src/codeql.ts"],"names":[],"mappings":";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AS;gBACT,GAAG,OAAO;gBACV,qBAAqB;aACtB,EACD;gBACE,SAAS,EAAE;oBACT,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;wBACvB,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;oBAC5B,CAAC;iBACF;aACF,CAAC,CAAC;YAEL,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;QACD,eAAe,EAAE,KAAK,WAAU,YAAoB,EAAE,SAAiB,EAAE,UAAkB;YACzF,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE;gBACnB,UAAU;gBACV,SAAS;gBACT,IAAI,CAAC,aAAa,EAAE;gBACpB,IAAI,CAAC,cAAc,EAAE;gBACrB,YAAY;gBACZ,uBAAuB;gBACvB,WAAW,GAAG,SAAS;gBACvB,yBAAyB;gBACzB,Line truncated
+117 -308
View File
@@ -13,168 +13,98 @@ const fs = __importStar(require("fs"));
const yaml = __importStar(require("js-yaml")); const yaml = __importStar(require("js-yaml"));
const path = __importStar(require("path")); const path = __importStar(require("path"));
const api = __importStar(require("./api-client")); const api = __importStar(require("./api-client"));
const codeql_1 = require("./codeql");
const externalQueries = __importStar(require("./external-queries"));
const util = __importStar(require("./util")); const util = __importStar(require("./util"));
// Property names from the user-supplied config file.
const NAME_PROPERTY = 'name'; const NAME_PROPERTY = 'name';
const DISABLE_DEFAULT_QUERIES_PROPERTY = 'disable-default-queries'; const DISPLAY_DEFAULT_QUERIES_PROPERTY = 'disable-default-queries';
const QUERIES_PROPERTY = 'queries'; const QUERIES_PROPERTY = 'queries';
const QUERIES_USES_PROPERTY = 'uses'; const QUERIES_USES_PROPERTY = 'uses';
const PATHS_IGNORE_PROPERTY = 'paths-ignore'; const PATHS_IGNORE_PROPERTY = 'paths-ignore';
const PATHS_PROPERTY = 'paths'; const PATHS_PROPERTY = 'paths';
/** class ExternalQuery {
* A list of queries from https://github.com/github/codeql that constructor(repository, ref) {
* we don't want to run. Disabling them here is a quicker alternative to this.path = '';
* disabling them in the code scanning query suites. Queries should also this.repository = repository;
* be disabled in the suites, and removed from this list here once the this.ref = ref;
* bundle is updated to make those suite changes live.
*
* Format is a map from language to an array of path suffixes of .ql files.
*/
const DISABLED_BUILTIN_QUERIES = {
'csharp': [
'ql/src/Security Features/CWE-937/VulnerablePackage.ql',
'ql/src/Security Features/CWE-451/MissingXFrameOptions.ql',
]
};
function queryIsDisabled(language, query) {
return (DISABLED_BUILTIN_QUERIES[language] || [])
.some(disabledQuery => query.endsWith(disabledQuery));
}
/**
* Asserts that the noDeclaredLanguage and multipleDeclaredLanguages fields are
* both empty and errors if they are not.
*/
function validateQueries(resolvedQueries) {
const noDeclaredLanguage = resolvedQueries.noDeclaredLanguage;
const noDeclaredLanguageQueries = Object.keys(noDeclaredLanguage);
if (noDeclaredLanguageQueries.length !== 0) {
throw new Error('The following queries do not declare a language. ' +
'Their qlpack.yml files are either missing or is invalid.\n' +
noDeclaredLanguageQueries.join('\n'));
}
const multipleDeclaredLanguages = resolvedQueries.multipleDeclaredLanguages;
const multipleDeclaredLanguagesQueries = Object.keys(multipleDeclaredLanguages);
if (multipleDeclaredLanguagesQueries.length !== 0) {
throw new Error('The following queries declare multiple languages. ' +
'Their qlpack.yml files are either missing or is invalid.\n' +
multipleDeclaredLanguagesQueries.join('\n'));
} }
} }
/** exports.ExternalQuery = ExternalQuery;
* Run 'codeql resolve queries' and add the results to resultMap
*/
async function runResolveQueries(resultMap, toResolve, extraSearchPath, errorOnInvalidQueries) {
const codeQl = codeql_1.getCodeQL();
const resolvedQueries = await codeQl.resolveQueries(toResolve, extraSearchPath);
for (const [language, queries] of Object.entries(resolvedQueries.byLanguage)) {
if (resultMap[language] === undefined) {
resultMap[language] = [];
}
resultMap[language].push(...Object.keys(queries).filter(q => !queryIsDisabled(language, q)));
}
if (errorOnInvalidQueries) {
validateQueries(resolvedQueries);
}
}
/**
* Get the set of queries included by default.
*/
async function addDefaultQueries(languages, resultMap) {
const suites = languages.map(l => l + '-code-scanning.qls');
await runResolveQueries(resultMap, suites, undefined, false);
}
// The set of acceptable values for built-in suites from the codeql bundle // The set of acceptable values for built-in suites from the codeql bundle
const builtinSuites = ['security-extended', 'security-and-quality']; const builtinSuites = ['security-extended', 'security-and-quality'];
/** class Config {
* Determine the set of queries associated with suiteName's suites and add them to resultMap. constructor() {
* Throws an error if suiteName is not a valid builtin suite. this.name = "";
*/ this.disableDefaultQueries = false;
async function addBuiltinSuiteQueries(configFile, languages, resultMap, suiteName) { this.additionalQueries = [];
const suite = builtinSuites.find((suite) => suite === suiteName); this.externalQueries = [];
if (!suite) { this.additionalSuites = [];
throw new Error(getQueryUsesInvalid(configFile, suiteName)); this.pathsIgnore = [];
this.paths = [];
} }
const suites = languages.map(l => l + '-' + suiteName + '.qls'); addQuery(configFile, queryUses) {
await runResolveQueries(resultMap, suites, undefined, false); // The logic for parsing the string is based on what actions does for
} // parsing the 'uses' actions in the workflow file
/** queryUses = queryUses.trim();
* Retrieve the set of queries at localQueryPath and add them to resultMap. if (queryUses === "") {
*/ throw new Error(getQueryUsesInvalid(configFile));
async function addLocalQueries(configFile, resultMap, localQueryPath) { }
// Resolve the local path against the workspace so that when this is // Check for the local path case before we start trying to parse the repository name
// passed to codeql it resolves to exactly the path we expect it to resolve to. if (queryUses.startsWith("./")) {
const workspacePath = fs.realpathSync(util.getRequiredEnvParam('GITHUB_WORKSPACE')); const localQueryPath = queryUses.slice(2);
let absoluteQueryPath = path.join(workspacePath, localQueryPath); // Resolve the local path against the workspace so that when this is
// Check the file exists // passed to codeql it resolves to exactly the path we expect it to resolve to.
if (!fs.existsSync(absoluteQueryPath)) { const workspacePath = fs.realpathSync(util.getRequiredEnvParam('GITHUB_WORKSPACE'));
throw new Error(getLocalPathDoesNotExist(configFile, localQueryPath)); let absoluteQueryPath = path.join(workspacePath, localQueryPath);
// Check the file exists
if (!fs.existsSync(absoluteQueryPath)) {
throw new Error(getLocalPathDoesNotExist(configFile, localQueryPath));
}
// Call this after checking file exists, because it'll fail if file doesn't exist
absoluteQueryPath = fs.realpathSync(absoluteQueryPath);
// Check the local path doesn't jump outside the repo using '..' or symlinks
if (!(absoluteQueryPath + path.sep).startsWith(workspacePath + path.sep)) {
throw new Error(getLocalPathOutsideOfRepository(configFile, localQueryPath));
}
this.additionalQueries.push(absoluteQueryPath);
return;
}
// Check for one of the builtin suites
if (queryUses.indexOf('/') === -1 && queryUses.indexOf('@') === -1) {
const suite = builtinSuites.find((suite) => suite === queryUses);
if (suite) {
this.additionalSuites.push(suite);
return;
}
else {
throw new Error(getQueryUsesInvalid(configFile, queryUses));
}
}
let tok = queryUses.split('@');
if (tok.length !== 2) {
throw new Error(getQueryUsesInvalid(configFile, queryUses));
}
const ref = tok[1];
tok = tok[0].split('/');
// The first token is the owner
// The second token is the repo
// The rest is a path, if there is more than one token combine them to form the full path
if (tok.length < 2) {
throw new Error(getQueryUsesInvalid(configFile, queryUses));
}
if (tok.length > 3) {
tok = [tok[0], tok[1], tok.slice(2).join('/')];
}
// Check none of the parts of the repository name are empty
if (tok[0].trim() === '' || tok[1].trim() === '') {
throw new Error(getQueryUsesInvalid(configFile, queryUses));
}
let external = new ExternalQuery(tok[0] + '/' + tok[1], ref);
if (tok.length === 3) {
external.path = tok[2];
}
this.externalQueries.push(external);
} }
// Call this after checking file exists, because it'll fail if file doesn't exist
absoluteQueryPath = fs.realpathSync(absoluteQueryPath);
// Check the local path doesn't jump outside the repo using '..' or symlinks
if (!(absoluteQueryPath + path.sep).startsWith(workspacePath + path.sep)) {
throw new Error(getLocalPathOutsideOfRepository(configFile, localQueryPath));
}
// Get the root of the current repo to use when resolving query dependencies
const rootOfRepo = util.getRequiredEnvParam('GITHUB_WORKSPACE');
await runResolveQueries(resultMap, [absoluteQueryPath], rootOfRepo, true);
}
/**
* Retrieve the set of queries at the referenced remote repo and add them to resultMap.
*/
async function addRemoteQueries(configFile, resultMap, queryUses) {
let tok = queryUses.split('@');
if (tok.length !== 2) {
throw new Error(getQueryUsesInvalid(configFile, queryUses));
}
const ref = tok[1];
tok = tok[0].split('/');
// The first token is the owner
// The second token is the repo
// The rest is a path, if there is more than one token combine them to form the full path
if (tok.length < 2) {
throw new Error(getQueryUsesInvalid(configFile, queryUses));
}
// Check none of the parts of the repository name are empty
if (tok[0].trim() === '' || tok[1].trim() === '') {
throw new Error(getQueryUsesInvalid(configFile, queryUses));
}
const nwo = tok[0] + '/' + tok[1];
// Checkout the external repository
const rootOfRepo = await externalQueries.checkoutExternalRepository(nwo, ref);
const queryPath = tok.length > 2
? path.join(rootOfRepo, tok.slice(2).join('/'))
: rootOfRepo;
await runResolveQueries(resultMap, [queryPath], rootOfRepo, true);
}
/**
* Parse a query 'uses' field to a discrete set of query files and update resultMap.
*
* The logic for parsing the string is based on what actions does for
* parsing the 'uses' actions in the workflow file. So it can handle
* local paths starting with './', or references to remote repos, or
* a finite set of hardcoded terms for builtin suites.
*/
async function parseQueryUses(configFile, languages, resultMap, queryUses) {
queryUses = queryUses.trim();
if (queryUses === "") {
throw new Error(getQueryUsesInvalid(configFile));
}
// Check for the local path case before we start trying to parse the repository name
if (queryUses.startsWith("./")) {
await addLocalQueries(configFile, resultMap, queryUses.slice(2));
return;
}
// Check for one of the builtin suites
if (queryUses.indexOf('/') === -1 && queryUses.indexOf('@') === -1) {
await addBuiltinSuiteQueries(configFile, languages, resultMap, queryUses);
return;
}
// Otherwise, must be a reference to another repo
await addRemoteQueries(configFile, resultMap, queryUses);
} }
exports.Config = Config;
// Regex validating stars in paths or paths-ignore entries. // Regex validating stars in paths or paths-ignore entries.
// The intention is to only allow ** to appear when immediately // The intention is to only allow ** to appear when immediately
// preceded and followed by a slash. // preceded and followed by a slash.
@@ -226,7 +156,7 @@ function getNameInvalid(configFile) {
} }
exports.getNameInvalid = getNameInvalid; exports.getNameInvalid = getNameInvalid;
function getDisableDefaultQueriesInvalid(configFile) { function getDisableDefaultQueriesInvalid(configFile) {
return getConfigFilePropertyError(configFile, DISABLE_DEFAULT_QUERIES_PROPERTY, 'must be a boolean'); return getConfigFilePropertyError(configFile, DISPLAY_DEFAULT_QUERIES_PROPERTY, 'must be a boolean');
} }
exports.getDisableDefaultQueriesInvalid = getDisableDefaultQueriesInvalid; exports.getDisableDefaultQueriesInvalid = getDisableDefaultQueriesInvalid;
function getQueriesInvalid(configFile) { function getQueriesInvalid(configFile) {
@@ -280,88 +210,14 @@ exports.getConfigFileDirectoryGivenMessage = getConfigFileDirectoryGivenMessage;
function getConfigFilePropertyError(configFile, property, error) { function getConfigFilePropertyError(configFile, property, error) {
return 'The configuration file "' + configFile + '" is invalid: property "' + property + '" ' + error; return 'The configuration file "' + configFile + '" is invalid: property "' + property + '" ' + error;
} }
/** async function initConfig() {
* Gets the set of languages in the current repository let configFile = core.getInput('config-file');
*/ const config = new Config();
async function getLanguagesInRepo() { // If no config file was provided create an empty one
var _a; if (configFile === '') {
// Translate between GitHub's API names for languages and ours core.debug('No configuration file was provided');
const codeqlLanguages = { return config;
'C': 'cpp',
'C++': 'cpp',
'C#': 'csharp',
'Go': 'go',
'Java': 'java',
'JavaScript': 'javascript',
'TypeScript': 'javascript',
'Python': 'python',
};
let repo_nwo = (_a = process.env['GITHUB_REPOSITORY']) === null || _a === void 0 ? void 0 : _a.split("/");
if (repo_nwo) {
let owner = repo_nwo[0];
let repo = repo_nwo[1];
core.debug(`GitHub repo ${owner} ${repo}`);
const response = await api.getApiClient().request("GET /repos/:owner/:repo/languages", ({
owner,
repo
}));
core.debug("Languages API response: " + JSON.stringify(response));
// The GitHub API is going to return languages in order of popularity,
// When we pick a language to autobuild we want to pick the most popular traced language
// Since sets in javascript maintain insertion order, using a set here and then splatting it
// into an array gives us an array of languages ordered by popularity
let languages = new Set();
for (let lang in response.data) {
if (lang in codeqlLanguages) {
languages.add(codeqlLanguages[lang]);
}
}
return [...languages];
} }
else {
return [];
}
}
/**
* Get the languages to analyse.
*
* The result is obtained from the action input parameter 'languages' if that
* has been set, otherwise it is deduced as all languages in the repo that
* can be analysed.
*/
async function getLanguages() {
// Obtain from action input 'languages' if set
let languages = core.getInput('languages', { required: false })
.split(',')
.map(x => x.trim())
.filter(x => x.length > 0);
core.info("Languages from configuration: " + JSON.stringify(languages));
if (languages.length === 0) {
// Obtain languages as all languages in the repo that can be analysed
languages = await getLanguagesInRepo();
core.info("Automatically detected languages: " + JSON.stringify(languages));
}
return languages;
}
/**
* Get the default config for when the user has not supplied one.
*/
async function getDefaultConfig() {
const languages = await getLanguages();
const queries = {};
await addDefaultQueries(languages, queries);
return {
languages: languages,
queries: queries,
pathsIgnore: [],
paths: []
};
}
exports.getDefaultConfig = getDefaultConfig;
/**
* Load the config from the given file.
*/
async function loadConfig(configFile) {
let parsedYAML; let parsedYAML;
if (isLocal(configFile)) { if (isLocal(configFile)) {
// Treat the config file as relative to the workspace // Treat the config file as relative to the workspace
@@ -372,8 +228,6 @@ async function loadConfig(configFile) {
else { else {
parsedYAML = await getRemoteConfig(configFile); parsedYAML = await getRemoteConfig(configFile);
} }
// Validate that the 'name' property is syntactically correct,
// even though we don't use the value yet.
if (NAME_PROPERTY in parsedYAML) { if (NAME_PROPERTY in parsedYAML) {
if (typeof parsedYAML[NAME_PROPERTY] !== "string") { if (typeof parsedYAML[NAME_PROPERTY] !== "string") {
throw new Error(getNameInvalid(configFile)); throw new Error(getNameInvalid(configFile));
@@ -381,36 +235,24 @@ async function loadConfig(configFile) {
if (parsedYAML[NAME_PROPERTY].length === 0) { if (parsedYAML[NAME_PROPERTY].length === 0) {
throw new Error(getNameInvalid(configFile)); throw new Error(getNameInvalid(configFile));
} }
config.name = parsedYAML[NAME_PROPERTY];
} }
const languages = await getLanguages(); if (DISPLAY_DEFAULT_QUERIES_PROPERTY in parsedYAML) {
// If the languages parameter was not given and no languages were if (typeof parsedYAML[DISPLAY_DEFAULT_QUERIES_PROPERTY] !== "boolean") {
// detected then fail here as this is a workflow configuration error.
if (languages.length === 0) {
throw new Error("Did not detect any languages to analyze. Please update input in workflow.");
}
const queries = {};
const pathsIgnore = [];
const paths = [];
let disableDefaultQueries = false;
if (DISABLE_DEFAULT_QUERIES_PROPERTY in parsedYAML) {
if (typeof parsedYAML[DISABLE_DEFAULT_QUERIES_PROPERTY] !== "boolean") {
throw new Error(getDisableDefaultQueriesInvalid(configFile)); throw new Error(getDisableDefaultQueriesInvalid(configFile));
} }
disableDefaultQueries = parsedYAML[DISABLE_DEFAULT_QUERIES_PROPERTY]; config.disableDefaultQueries = parsedYAML[DISPLAY_DEFAULT_QUERIES_PROPERTY];
}
if (!disableDefaultQueries) {
await addDefaultQueries(languages, queries);
} }
if (QUERIES_PROPERTY in parsedYAML) { if (QUERIES_PROPERTY in parsedYAML) {
if (!(parsedYAML[QUERIES_PROPERTY] instanceof Array)) { if (!(parsedYAML[QUERIES_PROPERTY] instanceof Array)) {
throw new Error(getQueriesInvalid(configFile)); throw new Error(getQueriesInvalid(configFile));
} }
for (const query of parsedYAML[QUERIES_PROPERTY]) { parsedYAML[QUERIES_PROPERTY].forEach(query => {
if (!(QUERIES_USES_PROPERTY in query) || typeof query[QUERIES_USES_PROPERTY] !== "string") { if (!(QUERIES_USES_PROPERTY in query) || typeof query[QUERIES_USES_PROPERTY] !== "string") {
throw new Error(getQueryUsesInvalid(configFile)); throw new Error(getQueryUsesInvalid(configFile));
} }
await parseQueryUses(configFile, languages, queries, query[QUERIES_USES_PROPERTY]); config.addQuery(configFile, query[QUERIES_USES_PROPERTY]);
} });
} }
if (PATHS_IGNORE_PROPERTY in parsedYAML) { if (PATHS_IGNORE_PROPERTY in parsedYAML) {
if (!(parsedYAML[PATHS_IGNORE_PROPERTY] instanceof Array)) { if (!(parsedYAML[PATHS_IGNORE_PROPERTY] instanceof Array)) {
@@ -420,7 +262,7 @@ async function loadConfig(configFile) {
if (typeof path !== "string" || path === '') { if (typeof path !== "string" || path === '') {
throw new Error(getPathsIgnoreInvalid(configFile)); throw new Error(getPathsIgnoreInvalid(configFile));
} }
pathsIgnore.push(validateAndSanitisePath(path, PATHS_IGNORE_PROPERTY, configFile)); config.pathsIgnore.push(validateAndSanitisePath(path, PATHS_IGNORE_PROPERTY, configFile));
}); });
} }
if (PATHS_PROPERTY in parsedYAML) { if (PATHS_PROPERTY in parsedYAML) {
@@ -431,33 +273,11 @@ async function loadConfig(configFile) {
if (typeof path !== "string" || path === '') { if (typeof path !== "string" || path === '') {
throw new Error(getPathsInvalid(configFile)); throw new Error(getPathsInvalid(configFile));
} }
paths.push(validateAndSanitisePath(path, PATHS_PROPERTY, configFile)); config.paths.push(validateAndSanitisePath(path, PATHS_PROPERTY, configFile));
}); });
} }
return { languages, queries, pathsIgnore, paths };
}
/**
* Load and return the config.
*
* 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.
*/
async function initConfig() {
const configFile = core.getInput('config-file');
let config;
// If no config file was provided create an empty one
if (configFile === '') {
core.debug('No configuration file was provided');
config = await getDefaultConfig();
}
else {
config = await loadConfig(configFile);
}
// Save the config so we can easily access it again in the future
await saveConfig(config);
return config; return config;
} }
exports.initConfig = initConfig;
function isLocal(configPath) { function isLocal(configPath) {
// If the path starts with ./, look locally // If the path starts with ./, look locally
if (configPath.indexOf("./") === 0) { if (configPath.indexOf("./") === 0) {
@@ -502,46 +322,35 @@ async function getRemoteConfig(configFile) {
} }
return yaml.safeLoad(Buffer.from(fileContents, 'base64').toString('binary')); return yaml.safeLoad(Buffer.from(fileContents, 'base64').toString('binary'));
} }
/** function getConfigFolder() {
* Get the directory where the parsed config will be stored.
*/
function getPathToParsedConfigFolder() {
return util.getRequiredEnvParam('RUNNER_TEMP'); return util.getRequiredEnvParam('RUNNER_TEMP');
} }
/** function getConfigFile() {
* Get the file path where the parsed config will be stored. return path.join(getConfigFolder(), 'config');
*/
function getPathToParsedConfigFile() {
return path.join(getPathToParsedConfigFolder(), 'config');
} }
exports.getPathToParsedConfigFile = getPathToParsedConfigFile; exports.getConfigFile = getConfigFile;
/**
* Store the given config to the path returned from getPathToParsedConfigFile.
*/
async function saveConfig(config) { async function saveConfig(config) {
const configString = JSON.stringify(config); const configString = JSON.stringify(config);
await io.mkdirP(getPathToParsedConfigFolder()); await io.mkdirP(getConfigFolder());
fs.writeFileSync(getPathToParsedConfigFile(), configString, 'utf8'); fs.writeFileSync(getConfigFile(), configString, 'utf8');
core.debug('Saved config:'); core.debug('Saved config:');
core.debug(configString); core.debug(configString);
} }
/** async function loadConfig() {
* Get the config. const configFile = getConfigFile();
* if (fs.existsSync(configFile)) {
* If this is the first time in a workflow that this is being called then const configString = fs.readFileSync(configFile, 'utf8');
* this will parse the config from the user input. The parsed config is then core.debug('Loaded config:');
* stored to a known location. On the second and further calls, this will core.debug(configString);
* return the contents of the parsed config from the known location. return JSON.parse(configString);
*/ }
async function getConfig() { else {
const configFile = getPathToParsedConfigFile(); const config = await initConfig();
if (!fs.existsSync(configFile)) { core.debug('Initialized config:');
throw new Error("Config file could not be found at expected location. Has the 'init' action been called?"); core.debug(JSON.stringify(config));
await saveConfig(config);
return config;
} }
const configString = fs.readFileSync(configFile, 'utf8');
core.debug('Loaded config:');
core.debug(configString);
return JSON.parse(configString);
} }
exports.getConfig = getConfig; exports.loadConfig = loadConfig;
//# sourceMappingURL=config-utils.js.map //# sourceMappingURL=config-utils.js.map
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"config-utils.js","sourceRoot":"","sources":["../src/config-utils.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AACtC,gDAAkC;AAClC,uCAAyB;AACzB,8CAAgC;AAChC,2CAA6B;AAE7B,kDAAoC;AACpC,qCAA2D;AAC3D,oEAAsD;AACtD,6CAA+B;AAE/B,qDAAqD;AACrD,MAAM,aAAa,GAAG,MAAM,CAAC;AAC7B,MAAM,gCAAgC,GAAG,yBAAyB,CAAC;AACnE,MAAM,gBAAgB,GAAG,SAAS,CAAC;AACnC,MAAM,qBAAqB,GAAG,MAAM,CAAC;AACrC,MAAM,qBAAqB,GAAG,cAAc,CAAC;AAC7C,MAAM,cAAc,GAAG,OAAO,CAA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AAkB;IAClD,OAAO,0BAA0B,CAAC,UAAU,EAAE,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;AACtF,CAAC;AAFD,8CAEC;AAED,SAAgB,mBAAmB,CAAC,UAALine truncated
+52 -151
View File
@@ -16,7 +16,6 @@ const fs = __importStar(require("fs"));
const path = __importStar(require("path")); const path = __importStar(require("path"));
const sinon_1 = __importDefault(require("sinon")); const sinon_1 = __importDefault(require("sinon"));
const api = __importStar(require("./api-client")); const api = __importStar(require("./api-client"));
const CodeQL = __importStar(require("./codeql"));
const configUtils = __importStar(require("./config-utils")); const configUtils = __importStar(require("./config-utils"));
const testing_utils_1 = require("./testing-utils"); const testing_utils_1 = require("./testing-utils");
const util = __importStar(require("./util")); const util = __importStar(require("./util"));
@@ -47,45 +46,22 @@ ava_1.default("load empty config", async (t) => {
process.env['RUNNER_TEMP'] = tmpDir; process.env['RUNNER_TEMP'] = tmpDir;
process.env['GITHUB_WORKSPACE'] = tmpDir; process.env['GITHUB_WORKSPACE'] = tmpDir;
setInput('config-file', undefined); setInput('config-file', undefined);
setInput('languages', 'javascript,python'); const config = await configUtils.loadConfig();
CodeQL.setCodeQL({ t.deepEqual(config, new configUtils.Config());
resolveQueries: async function () {
return {
byLanguage: {},
noDeclaredLanguage: {},
multipleDeclaredLanguages: {},
};
},
});
const config = await configUtils.initConfig();
t.deepEqual(config, await configUtils.getDefaultConfig());
}); });
}); });
ava_1.default("loading config saves config", async (t) => { ava_1.default("loading config saves config", async (t) => {
return await util.withTmpDir(async (tmpDir) => { return await util.withTmpDir(async (tmpDir) => {
process.env['RUNNER_TEMP'] = tmpDir; process.env['RUNNER_TEMP'] = tmpDir;
process.env['GITHUB_WORKSPACE'] = tmpDir; process.env['GITHUB_WORKSPACE'] = tmpDir;
setInput('config-file', undefined); const configFile = configUtils.getConfigFile();
setInput('languages', 'javascript,python');
CodeQL.setCodeQL({
resolveQueries: async function () {
return {
byLanguage: {},
noDeclaredLanguage: {},
multipleDeclaredLanguages: {},
};
},
});
// Sanity check the saved config file does not already exist // Sanity check the saved config file does not already exist
t.false(fs.existsSync(configUtils.getPathToParsedConfigFile())); t.false(fs.existsSync(configFile));
// Sanity check that getConfig throws before we have called initConfig const config = await configUtils.loadConfig();
await t.throwsAsync(configUtils.getConfig);
const config1 = await configUtils.initConfig();
// The saved config file should now exist // The saved config file should now exist
t.true(fs.existsSync(configUtils.getPathToParsedConfigFile())); t.true(fs.existsSync(configFile));
// And that same newly-initialised config should now be returned by getConfig // And the contents should parse correctly to the config that was returned
const config2 = await configUtils.getConfig(); t.deepEqual(fs.readFileSync(configFile, 'utf8'), JSON.stringify(config));
t.deepEqual(config1, config2);
}); });
}); });
ava_1.default("load input outside of workspace", async (t) => { ava_1.default("load input outside of workspace", async (t) => {
@@ -94,8 +70,8 @@ ava_1.default("load input outside of workspace", async (t) => {
process.env['GITHUB_WORKSPACE'] = tmpDir; process.env['GITHUB_WORKSPACE'] = tmpDir;
setInput('config-file', '../input'); setInput('config-file', '../input');
try { try {
await configUtils.initConfig(); await configUtils.loadConfig();
throw new Error('initConfig did not throw error'); throw new Error('loadConfig did not throw error');
} }
catch (err) { catch (err) {
t.deepEqual(err, new Error(configUtils.getConfigFileOutsideWorkspaceErrorMessage(path.join(tmpDir, '../input')))); t.deepEqual(err, new Error(configUtils.getConfigFileOutsideWorkspaceErrorMessage(path.join(tmpDir, '../input'))));
@@ -109,8 +85,8 @@ 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
setInput('config-file', 'octo-org/codeql-config@main'); setInput('config-file', 'octo-org/codeql-config@main');
try { try {
await configUtils.initConfig(); await configUtils.loadConfig();
throw new Error('initConfig did not throw error'); throw new Error('loadConfig did not throw error');
} }
catch (err) { catch (err) {
t.deepEqual(err, new Error(configUtils.getConfigFileRepoFormatInvalidMessage('octo-org/codeql-config@main'))); t.deepEqual(err, new Error(configUtils.getConfigFileRepoFormatInvalidMessage('octo-org/codeql-config@main')));
@@ -123,10 +99,9 @@ ava_1.default("load non-existent input", async (t) => {
process.env['GITHUB_WORKSPACE'] = tmpDir; process.env['GITHUB_WORKSPACE'] = tmpDir;
t.false(fs.existsSync(path.join(tmpDir, 'input'))); t.false(fs.existsSync(path.join(tmpDir, 'input')));
setInput('config-file', 'input'); setInput('config-file', 'input');
setInput('languages', 'javascript');
try { try {
await configUtils.initConfig(); await configUtils.loadConfig();
throw new Error('initConfig did not throw error'); throw new Error('loadConfig did not throw error');
} }
catch (err) { catch (err) {
t.deepEqual(err, new Error(configUtils.getConfigFileDoesNotExistErrorMessage(path.join(tmpDir, 'input')))); t.deepEqual(err, new Error(configUtils.getConfigFileDoesNotExistErrorMessage(path.join(tmpDir, 'input'))));
@@ -137,102 +112,10 @@ ava_1.default("load non-empty input", async (t) => {
return await util.withTmpDir(async (tmpDir) => { return await util.withTmpDir(async (tmpDir) => {
process.env['RUNNER_TEMP'] = tmpDir; process.env['RUNNER_TEMP'] = tmpDir;
process.env['GITHUB_WORKSPACE'] = tmpDir; process.env['GITHUB_WORKSPACE'] = tmpDir;
CodeQL.setCodeQL({
resolveQueries: async function () {
return {
byLanguage: {
'javascript': {
'/foo/a.ql': {},
'/bar/b.ql': {},
},
},
noDeclaredLanguage: {},
multipleDeclaredLanguages: {},
};
},
});
// Just create a generic config object with non-default values for all fields // Just create a generic config object with non-default values for all fields
const inputFileContents = ` const inputFileContents = `
name: my config name: my config
disable-default-queries: true disable-default-queries: true
queries:
- uses: ./foo
paths-ignore:
- a
- b
paths:
- c/d`;
fs.mkdirSync(path.join(tmpDir, 'foo'));
// And the config we expect it to parse to
const expectedConfig = {
languages: ['javascript'],
queries: { 'javascript': ['/foo/a.ql', '/bar/b.ql'] },
pathsIgnore: ['a', 'b'],
paths: ['c/d'],
};
fs.writeFileSync(path.join(tmpDir, 'input'), inputFileContents, 'utf8');
setInput('config-file', 'input');
setInput('languages', 'javascript');
const actualConfig = await configUtils.initConfig();
// Should exactly equal the object we constructed earlier
t.deepEqual(actualConfig, expectedConfig);
});
});
ava_1.default("default queries are used", async (t) => {
return await util.withTmpDir(async (tmpDir) => {
process.env['RUNNER_TEMP'] = tmpDir;
process.env['GITHUB_WORKSPACE'] = tmpDir;
// Check that the default behaviour is to add the default queries.
// In this case if a config file is specified but does not include
// the disable-default-queries field.
// We determine this by whether CodeQL.resolveQueries is called
// with the correct arguments.
const resolveQueriesArgs = [];
CodeQL.setCodeQL({
resolveQueries: async function (queries, extraSearchPath) {
resolveQueriesArgs.push({ queries, extraSearchPath });
return {
byLanguage: {
'javascript': {},
},
noDeclaredLanguage: {},
multipleDeclaredLanguages: {},
};
},
});
// The important point of this config is that it doesn't specify
// the disable-default-queries field.
// Any other details are hopefully irrelevant for this tetst.
const inputFileContents = `
paths:
- foo`;
fs.mkdirSync(path.join(tmpDir, 'foo'));
fs.writeFileSync(path.join(tmpDir, 'input'), inputFileContents, 'utf8');
setInput('config-file', 'input');
setInput('languages', 'javascript');
await configUtils.initConfig();
// Check resolve queries was called correctly
t.deepEqual(resolveQueriesArgs.length, 1);
t.deepEqual(resolveQueriesArgs[0].queries, ['javascript-code-scanning.qls']);
t.deepEqual(resolveQueriesArgs[0].extraSearchPath, undefined);
});
});
ava_1.default("API client used when reading remote config", async (t) => {
return await util.withTmpDir(async (tmpDir) => {
process.env['RUNNER_TEMP'] = tmpDir;
process.env['GITHUB_WORKSPACE'] = tmpDir;
CodeQL.setCodeQL({
resolveQueries: async function () {
return {
byLanguage: {},
noDeclaredLanguage: {},
multipleDeclaredLanguages: {},
};
},
});
const inputFileContents = `
name: my config
disable-default-queries: true
queries: queries:
- uses: ./ - uses: ./
- uses: ./foo - uses: ./foo
@@ -240,17 +123,45 @@ ava_1.default("API client used when reading remote config", async (t) => {
paths-ignore: paths-ignore:
- a - a
- b - b
paths:
- c/d`;
fs.mkdirSync(path.join(tmpDir, 'foo'));
// And the config we expect it to parse to
const expectedConfig = new configUtils.Config();
expectedConfig.name = 'my config';
expectedConfig.disableDefaultQueries = true;
expectedConfig.additionalQueries.push(fs.realpathSync(tmpDir));
expectedConfig.additionalQueries.push(fs.realpathSync(path.join(tmpDir, 'foo')));
expectedConfig.externalQueries = [new configUtils.ExternalQuery('foo/bar', 'dev')];
expectedConfig.pathsIgnore = ['a', 'b'];
expectedConfig.paths = ['c/d'];
fs.writeFileSync(path.join(tmpDir, 'input'), inputFileContents, 'utf8');
setInput('config-file', 'input');
const actualConfig = await configUtils.loadConfig();
// Should exactly equal the object we constructed earlier
t.deepEqual(actualConfig, expectedConfig);
});
});
ava_1.default("API client used when reading remote config", async (t) => {
return await util.withTmpDir(async (tmpDir) => {
process.env['RUNNER_TEMP'] = tmpDir;
process.env['GITHUB_WORKSPACE'] = tmpDir;
const inputFileContents = `
name: my config
disable-default-queries: true
queries:
- uses: ./
paths-ignore:
- a
- b
paths: paths:
- c/d`; - c/d`;
const dummyResponse = { const dummyResponse = {
content: Buffer.from(inputFileContents).toString("base64"), content: Buffer.from(inputFileContents).toString("base64"),
}; };
const spyGetContents = mockGetContents(dummyResponse); const spyGetContents = mockGetContents(dummyResponse);
// Create checkout directory for remote queries repository
fs.mkdirSync(path.join(tmpDir, 'foo/bar'), { recursive: true });
setInput('config-file', 'octo-org/codeql-config/config.yaml@main'); setInput('config-file', 'octo-org/codeql-config/config.yaml@main');
setInput('languages', 'javascript'); await configUtils.loadConfig();
await configUtils.initConfig();
t.assert(spyGetContents.called); t.assert(spyGetContents.called);
}); });
}); });
@@ -263,8 +174,8 @@ ava_1.default("Remote config handles the case where a directory is provided", as
const repoReference = 'octo-org/codeql-config/config.yaml@main'; const repoReference = 'octo-org/codeql-config/config.yaml@main';
setInput('config-file', repoReference); setInput('config-file', repoReference);
try { try {
await configUtils.initConfig(); await configUtils.loadConfig();
throw new Error('initConfig did not throw error'); throw new Error('loadConfig did not throw error');
} }
catch (err) { catch (err) {
t.deepEqual(err, new Error(configUtils.getConfigFileDirectoryGivenMessage(repoReference))); t.deepEqual(err, new Error(configUtils.getConfigFileDirectoryGivenMessage(repoReference)));
@@ -282,8 +193,8 @@ ava_1.default("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';
setInput('config-file', repoReference); setInput('config-file', repoReference);
try { try {
await configUtils.initConfig(); await configUtils.loadConfig();
throw new Error('initConfig did not throw error'); throw new Error('loadConfig did not throw error');
} }
catch (err) { catch (err) {
t.deepEqual(err, new Error(configUtils.getConfigFileFormatInvalidMessage(repoReference))); t.deepEqual(err, new Error(configUtils.getConfigFileFormatInvalidMessage(repoReference)));
@@ -295,22 +206,12 @@ function doInvalidInputTest(testName, inputFileContents, expectedErrorMessageGen
return await util.withTmpDir(async (tmpDir) => { return await util.withTmpDir(async (tmpDir) => {
process.env['RUNNER_TEMP'] = tmpDir; process.env['RUNNER_TEMP'] = tmpDir;
process.env['GITHUB_WORKSPACE'] = tmpDir; process.env['GITHUB_WORKSPACE'] = tmpDir;
CodeQL.setCodeQL({
resolveQueries: async function () {
return {
byLanguage: {},
noDeclaredLanguage: {},
multipleDeclaredLanguages: {},
};
},
});
const inputFile = path.join(tmpDir, 'input'); const inputFile = path.join(tmpDir, 'input');
fs.writeFileSync(inputFile, inputFileContents, 'utf8'); fs.writeFileSync(inputFile, inputFileContents, 'utf8');
setInput('config-file', 'input'); setInput('config-file', 'input');
setInput('languages', 'javascript');
try { try {
await configUtils.initConfig(); await configUtils.loadConfig();
throw new Error('initConfig did not throw error'); throw new Error('loadConfig did not throw error');
} }
catch (err) { catch (err) {
t.deepEqual(err, new Error(expectedErrorMessageGenerator(inputFile))); t.deepEqual(err, new Error(expectedErrorMessageGenerator(inputFile)));
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"config-utils.test.js","sourceRoot":"","sources":["../src/config-utils.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wDAA0C;AAC1C,8CAAuB;AACvB,uCAAyB;AACzB,2CAA6B;AAC7B,kDAA0B;AAE1B,kDAAoC;AACp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KAAK,CAAC,CAAC;QAE/B,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,EAAE,MAAM,CAAC,CAAC;QACxE,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QAEjC,MAAM,YAAY,GAAG,MAAM,WAAW,CAAC,UAAU,EAAE,CAAC;QAEpD,yDAAyD;QACzD,CAAC,CAAC,SAAS,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,aAAI,CAAC,4CAA4C,EAAE,KAAK,EAAC,CAAC,EAAC,EAAE;IAC3D,OAAO,MAAM,IAAI,CAAC,Line truncated
+15 -16
View File
@@ -12,23 +12,22 @@ const exec = __importStar(require("@actions/exec"));
const fs = __importStar(require("fs")); const fs = __importStar(require("fs"));
const path = __importStar(require("path")); const path = __importStar(require("path"));
const util = __importStar(require("./util")); const util = __importStar(require("./util"));
/** async function checkoutExternalQueries(config) {
* Check out repository at the given ref, and return the directory of the checkout.
*/
async function checkoutExternalRepository(repository, ref) {
const folder = util.getRequiredEnvParam('RUNNER_TEMP'); const folder = util.getRequiredEnvParam('RUNNER_TEMP');
core.info('Checking out ' + repository); for (const externalQuery of config.externalQueries) {
const checkoutLocation = path.join(folder, repository); core.info('Checking out ' + externalQuery.repository);
if (!fs.existsSync(checkoutLocation)) { const checkoutLocation = path.join(folder, externalQuery.repository);
const repoURL = 'https://github.com/' + repository + '.git'; if (!fs.existsSync(checkoutLocation)) {
await exec.exec('git', ['clone', repoURL, checkoutLocation]); const repoURL = 'https://github.com/' + externalQuery.repository + '.git';
await exec.exec('git', [ await exec.exec('git', ['clone', repoURL, checkoutLocation]);
'--work-tree=' + checkoutLocation, await exec.exec('git', [
'--git-dir=' + checkoutLocation + '/.git', '--work-tree=' + checkoutLocation,
'checkout', ref, '--git-dir=' + checkoutLocation + '/.git',
]); 'checkout', externalQuery.ref,
]);
}
config.additionalQueries.push(path.join(checkoutLocation, externalQuery.path));
} }
return checkoutLocation;
} }
exports.checkoutExternalRepository = checkoutExternalRepository; exports.checkoutExternalQueries = checkoutExternalQueries;
//# sourceMappingURL=external-queries.js.map //# sourceMappingURL=external-queries.js.map
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"external-queries.js","sourceRoot":"","sources":["../src/external-queries.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AACtC,oDAAsC;AACtC,uCAAyB;AACzB,2CAA6B;AAE7B,6CAA+B;AAE/B;;GAEG;AACI,KAAK,UAAU,0BAA0B,CAAC,UAAkB,EAAE,GAAW;IAC9E,MAAM,MAAM,GAAG,IAAI,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;IAEvD,IAAI,CAAC,IAAI,CAAC,eAAe,GAAG,UAAU,CAAC,CAAC;IAExC,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACvD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;QACpC,MAAM,OAAO,GAAG,qBAAqB,GAAG,UAAU,GAAG,MAAM,CAAC;QAC5D,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC;QAC7D,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACrB,cAAc,GAAG,gBAAgB;YACjC,YAAY,GAAG,gBAAgB,GAAG,OAAO;YACzC,UAAU,EAAE,GAAG;SAChB,CAAC,CAAC;KACJ;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAjBD,gEAiBC"} {"version":3,"file":"external-queries.js","sourceRoot":"","sources":["../src/external-queries.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AACtC,oDAAsC;AACtC,uCAAyB;AACzB,2CAA6B;AAG7B,6CAA+B;AAExB,KAAK,UAAU,uBAAuB,CAAC,MAA0B;IACtE,MAAM,MAAM,GAAG,IAAI,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;IAEvD,KAAK,MAAM,aAAa,IAAI,MAAM,CAAC,eAAe,EAAE;QAClD,IAAI,CAAC,IAAI,CAAC,eAAe,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC;QAEtD,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;QACrE,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;YACpC,MAAM,OAAO,GAAG,qBAAqB,GAAG,aAAa,CAAC,UAAU,GAAG,MAAM,CAAC;YAC1E,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC;YAC7D,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;gBACrB,cAAc,GAAG,gBAAgB;gBACjC,YAAY,GAAG,gBAAgB,GAAG,OAAO;gBACzC,UAAU,EAAE,aAAa,CAAC,GAAG;aAC9B,CAAC,CAAC;SACJ;QAED,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;KAChF;AACH,CAAC;AAnBD,0DAmBC"}
+7 -2
View File
@@ -13,15 +13,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
const ava_1 = __importDefault(require("ava")); const ava_1 = __importDefault(require("ava"));
const fs = __importStar(require("fs")); const fs = __importStar(require("fs"));
const path = __importStar(require("path")); const path = __importStar(require("path"));
const configUtils = __importStar(require("./config-utils"));
const externalQueries = __importStar(require("./external-queries")); const externalQueries = __importStar(require("./external-queries"));
const testing_utils_1 = require("./testing-utils"); const testing_utils_1 = require("./testing-utils");
const util = __importStar(require("./util")); const util = __importStar(require("./util"));
testing_utils_1.setupTests(ava_1.default); testing_utils_1.setupTests(ava_1.default);
ava_1.default("checkoutExternalQueries", async (t) => { ava_1.default("checkoutExternalQueries", async (t) => {
let config = new configUtils.Config();
config.externalQueries = [
new configUtils.ExternalQuery("github/codeql-go", "df4c6869212341b601005567381944ed90906b6b"),
];
await util.withTmpDir(async (tmpDir) => { await util.withTmpDir(async (tmpDir) => {
process.env["RUNNER_TEMP"] = tmpDir; process.env["RUNNER_TEMP"] = tmpDir;
await externalQueries.checkoutExternalRepository("github/codeql-go", "df4c6869212341b601005567381944ed90906b6b"); await externalQueries.checkoutExternalQueries(config);
// COPYRIGHT file existed in df4c6869212341b601005567381944ed90906b6b but not in the default branch // COPYRIGHT file existed in df4c6869212341b601005567381944ed90906b6b but not in master
t.true(fs.existsSync(path.join(tmpDir, "github", "codeql-go", "COPYRIGHT"))); t.true(fs.existsSync(path.join(tmpDir, "github", "codeql-go", "COPYRIGHT")));
}); });
}); });
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"external-queries.test.js","sourceRoot":"","sources":["../src/external-queries.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAAuB;AACvB,uCAAyB;AACzB,2CAA6B;AAE7B,oEAAsD;AACtD,mDAA2C;AAC3C,6CAA+B;AAE/B,0BAAU,CAAC,aAAI,CAAC,CAAC;AAEjB,aAAI,CAAC,yBAAyB,EAAE,KAAK,EAAC,CAAC,EAAC,EAAE;IACxC,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAC,MAAM,EAAC,EAAE;QACnC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,MAAM,CAAC;QACpC,MAAM,eAAe,CAAC,0BAA0B,CAAC,kBAAkB,EAAE,0CAA0C,CAAC,CAAC;QAEjH,mGAAmG;QACnG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IAC/E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} {"version":3,"file":"external-queries.test.js","sourceRoot":"","sources":["../src/external-queries.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAAuB;AACvB,uCAAyB;AACzB,2CAA6B;AAE7B,4DAA8C;AAC9C,oEAAsD;AACtD,mDAA2C;AAC3C,6CAA+B;AAE/B,0BAAU,CAAC,aAAI,CAAC,CAAC;AAEjB,aAAI,CAAC,yBAAyB,EAAE,KAAK,EAAC,CAAC,EAAC,EAAE;IACxC,IAAI,MAAM,GAAG,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;IACtC,MAAM,CAAC,eAAe,GAAG;QACvB,IAAI,WAAW,CAAC,aAAa,CAAC,kBAAkB,EAAE,0CAA0C,CAAC;KAC9F,CAAC;IAEF,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAC,MAAM,EAAC,EAAE;QACnC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,MAAM,CAAC;QACpC,MAAM,eAAe,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;QAEtD,uFAAuF;QACvF,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IAC/E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
+69 -30
View File
@@ -8,36 +8,33 @@ var __importStar = (this && this.__importStar) || function (mod) {
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core")); const core = __importStar(require("@actions/core"));
const exec = __importStar(require("@actions/exec"));
const io = __importStar(require("@actions/io")); const io = __importStar(require("@actions/io"));
const fs = __importStar(require("fs")); const fs = __importStar(require("fs"));
const path = __importStar(require("path")); const path = __importStar(require("path"));
const codeql_1 = require("./codeql"); const codeql_1 = require("./codeql");
const configUtils = __importStar(require("./config-utils")); const configUtils = __importStar(require("./config-utils"));
const externalQueries = __importStar(require("./external-queries"));
const sharedEnv = __importStar(require("./shared-environment")); const sharedEnv = __importStar(require("./shared-environment"));
const upload_lib = __importStar(require("./upload-lib")); const upload_lib = __importStar(require("./upload-lib"));
const util = __importStar(require("./util")); const util = __importStar(require("./util"));
async function setupPythonExtractor() { /**
const codeqlPython = process.env["CODEQL_PYTHON"]; * A list of queries from https://github.com/github/codeql that
if (codeqlPython === undefined || codeqlPython.length === 0) { * we don't want to run. Disabling them here is a quicker alternative to
// If CODEQL_PYTHON is not set, no dependencies were installed, so we don't need to do anything * disabling them in the code scanning query suites. Queries should also
return; * be disabled in the suites, and removed from this list here once the
} * bundle is updated to make those suite changes live.
let output = ''; *
const options = { * Format is a map from language to an array of path suffixes of .ql files.
listeners: { */
stdout: (data) => { const DISABLED_BUILTIN_QUERIES = {
output += data.toString(); 'csharp': [
} 'ql/src/Security Features/CWE-937/VulnerablePackage.ql',
} 'ql/src/Security Features/CWE-451/MissingXFrameOptions.ql',
}; ]
await exec.exec(codeqlPython, ['-c', 'import os; import pip; print(os.path.dirname(os.path.dirname(pip.__file__)))'], options); };
core.info('Setting LGTM_INDEX_IMPORT_PATH=' + output); function queryIsDisabled(language, query) {
process.env['LGTM_INDEX_IMPORT_PATH'] = output; return (DISABLED_BUILTIN_QUERIES[language] || [])
output = ''; .some(disabledQuery => query.endsWith(disabledQuery));
await exec.exec(codeqlPython, ['-c', 'import sys; print(sys.version_info[0])'], options);
core.info('Setting LGTM_PYTHON_SETUP_VERSION=' + output);
process.env['LGTM_PYTHON_SETUP_VERSION'] = output;
} }
async function createdDBForScannedLanguages(databaseFolder) { async function createdDBForScannedLanguages(databaseFolder) {
const scannedLanguages = process.env[sharedEnv.CODEQL_ACTION_SCANNED_LANGUAGES]; const scannedLanguages = process.env[sharedEnv.CODEQL_ACTION_SCANNED_LANGUAGES];
@@ -45,29 +42,70 @@ async function createdDBForScannedLanguages(databaseFolder) {
const codeql = codeql_1.getCodeQL(); const codeql = codeql_1.getCodeQL();
for (const language of scannedLanguages.split(',')) { for (const language of scannedLanguages.split(',')) {
core.startGroup('Extracting ' + language); core.startGroup('Extracting ' + language);
if (language === 'python') {
await setupPythonExtractor();
}
await codeql.extractScannedLanguage(path.join(databaseFolder, language), language); await codeql.extractScannedLanguage(path.join(databaseFolder, language), language);
core.endGroup(); core.endGroup();
} }
} }
} }
async function finalizeDatabaseCreation(databaseFolder, config) { async function finalizeDatabaseCreation(databaseFolder) {
await createdDBForScannedLanguages(databaseFolder); await createdDBForScannedLanguages(databaseFolder);
const languages = process.env[sharedEnv.CODEQL_ACTION_LANGUAGES] || '';
const codeql = codeql_1.getCodeQL(); const codeql = codeql_1.getCodeQL();
for (const language of config.languages) { for (const language of languages.split(',')) {
core.startGroup('Finalizing ' + language); core.startGroup('Finalizing ' + language);
await codeql.finalizeDatabase(path.join(databaseFolder, language)); await codeql.finalizeDatabase(path.join(databaseFolder, language));
core.endGroup(); core.endGroup();
} }
} }
async function resolveQueryLanguages(config) {
let res = new Map();
const codeql = codeql_1.getCodeQL();
if (!config.disableDefaultQueries || config.additionalSuites.length !== 0) {
const suites = [];
for (const language of await util.getLanguages()) {
if (!config.disableDefaultQueries) {
suites.push(language + '-code-scanning.qls');
}
for (const additionalSuite of config.additionalSuites) {
suites.push(language + '-' + additionalSuite + '.qls');
}
}
const resolveQueriesOutputObject = await codeql.resolveQueries(suites);
for (const [language, queries] of Object.entries(resolveQueriesOutputObject.byLanguage)) {
if (res[language] === undefined) {
res[language] = [];
}
res[language].push(...Object.keys(queries).filter(q => !queryIsDisabled(language, q)));
}
}
if (config.additionalQueries.length !== 0) {
const resolveQueriesOutputObject = await codeql.resolveQueries(config.additionalQueries);
for (const [language, queries] of Object.entries(resolveQueriesOutputObject.byLanguage)) {
if (res[language] === undefined) {
res[language] = [];
}
res[language].push(...Object.keys(queries));
}
const noDeclaredLanguage = resolveQueriesOutputObject.noDeclaredLanguage;
const noDeclaredLanguageQueries = Object.keys(noDeclaredLanguage);
if (noDeclaredLanguageQueries.length !== 0) {
throw new Error('Some queries do not declare a language, their qlpack.yml file is missing or is invalid');
}
const multipleDeclaredLanguages = resolveQueriesOutputObject.multipleDeclaredLanguages;
const multipleDeclaredLanguagesQueries = Object.keys(multipleDeclaredLanguages);
if (multipleDeclaredLanguagesQueries.length !== 0) {
throw new Error('Some queries declare multiple languages, their qlpack.yml file is missing or is invalid');
}
}
return res;
}
// Runs queries and creates sarif files in the given folder // Runs queries and creates sarif files in the given folder
async function runQueries(databaseFolder, sarifFolder, config) { async function runQueries(databaseFolder, sarifFolder, config) {
const queriesPerLanguage = await resolveQueryLanguages(config);
const codeql = codeql_1.getCodeQL(); const codeql = codeql_1.getCodeQL();
for (let database of fs.readdirSync(databaseFolder)) { for (let database of fs.readdirSync(databaseFolder)) {
core.startGroup('Analyzing ' + database); core.startGroup('Analyzing ' + database);
const queries = config.queries[database] || []; const queries = queriesPerLanguage[database] || [];
if (queries.length === 0) { if (queries.length === 0) {
throw new Error('Unable to analyse ' + database + ' as no queries were selected for this language'); throw new Error('Unable to analyse ' + database + ' as no queries were selected for this language');
} }
@@ -88,14 +126,15 @@ async function run() {
if (util.should_abort('finish', true) || !await util.reportActionStarting('finish')) { if (util.should_abort('finish', true) || !await util.reportActionStarting('finish')) {
return; return;
} }
const config = await configUtils.getConfig(); const config = await configUtils.loadConfig();
core.exportVariable(sharedEnv.ODASA_TRACER_CONFIGURATION, ''); core.exportVariable(sharedEnv.ODASA_TRACER_CONFIGURATION, '');
delete process.env[sharedEnv.ODASA_TRACER_CONFIGURATION]; delete process.env[sharedEnv.ODASA_TRACER_CONFIGURATION];
const databaseFolder = util.getRequiredEnvParam(sharedEnv.CODEQL_ACTION_DATABASE_DIR); const databaseFolder = util.getRequiredEnvParam(sharedEnv.CODEQL_ACTION_DATABASE_DIR);
const sarifFolder = core.getInput('output'); const sarifFolder = core.getInput('output');
await io.mkdirP(sarifFolder); await io.mkdirP(sarifFolder);
core.info('Finalizing database creation'); core.info('Finalizing database creation');
await finalizeDatabaseCreation(databaseFolder, config); await finalizeDatabaseCreation(databaseFolder);
await externalQueries.checkoutExternalQueries(config);
core.info('Analyzing database'); core.info('Analyzing database');
await runQueries(databaseFolder, sarifFolder, config); await runQueries(databaseFolder, sarifFolder, config);
if ('true' === core.getInput('upload')) { if ('true' === core.getInput('upload')) {
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"finalize-db.js","sourceRoot":"","sources":["../src/finalize-db.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AACtC,oDAAsC;AACtC,gDAAkC;AAClC,uCAAyB;AACzB,2CAA6B;AAE7B,qCAAqC;AACrC,4DAA8C;AAC9C,gEAAkD;AAClD,yDAA2C;AAC3C,6CAA+B;AAG/B,KAAK,UAAU,oBAAoB;IACjC,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAClD,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE;QAC3D,+FAA+F;QAC/F,OAAO;KACR;IAED,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,MAAM,OAAO,GAAG;QACd,SAAS,EAAE;YACT,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;gBACvB,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC5B,CAAC;SACF;KACF,CAAC;IAEF,MAAM,IAAI,CAAC,IAAI,CACb,YAAY,EACZ,CAAC,IAAI,EAAE,8EAA8E,CAAC,EACtF,OAAO,CAAC,CAAC;IACX,IAAI,CAAC,IAAI,CAAC,iCAAiC,GAAG,MAAM,CAAC,CAAC;IACtD,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,GAAG,MAAM,CAAC;IAE/C,MAAM,GAAG,EAAE,CAAC;IACZ,MAAM,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE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CAAC,EAAELine truncated
+14 -49
View File
@@ -10,7 +10,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core")); const core = __importStar(require("@actions/core"));
const exec = __importStar(require("@actions/exec")); const exec = __importStar(require("@actions/exec"));
const io = __importStar(require("@actions/io")); const io = __importStar(require("@actions/io"));
const toolcache = __importStar(require("@actions/tool-cache"));
const fs = __importStar(require("fs")); const fs = __importStar(require("fs"));
const path = __importStar(require("path")); const path = __importStar(require("path"));
const analysisPaths = __importStar(require("./analysis-paths")); const analysisPaths = __importStar(require("./analysis-paths"));
@@ -122,55 +121,21 @@ function concatTracerConfigs(configs) {
fs.writeFileSync(envPath, buffer); fs.writeFileSync(envPath, buffer);
return { env, spec }; return { env, spec };
} }
async function installPythonDeps(codeql) {
core.startGroup('Setup Python dependencies');
let scriptsFolder = '';
try {
const repoPath = await toolcache.downloadTool('https://github.com/Daverlo/codeql-python-autobuild/archive/master.zip');
const extracted = await toolcache.extractZip(repoPath);
scriptsFolder = path.join(extracted, 'codeql-python-autobuild-master');
}
catch (e) {
// The download should not fail, but in case it fails we just abort trying to setup the python deps
core.warning('Unable to download and extract the scripts needed for installing the python dependecies');
core.endGroup();
return;
}
// Setup tools
try {
await exec.exec(path.join(scriptsFolder, 'install_tools.sh'));
}
catch (e) {
// This script tries to install some needed tools in the runner. It should not fail, but if it does
// we just abort the process without failing the action
core.warning('Unable to download and extract the scripts needed for installing the python dependecies');
core.endGroup();
return;
}
// Install dependencies
try {
await exec.exec(path.join(scriptsFolder, 'auto_install_packages.py'), [codeql.getDir()]);
}
catch (e) {
core.endGroup();
throw new Error('We were unable to install your python dependencies. You can call this action with "setup-python-dependencies: false" to disable this process');
}
core.endGroup();
}
async function run() { async function run() {
let config; let languages;
let codeql;
try { try {
if (util.should_abort('init', false) || !await util.reportActionStarting('init')) { if (util.should_abort('init', false) || !await util.reportActionStarting('init')) {
return; return;
} }
core.startGroup('Setup CodeQL tools');
codeql = await codeql_1.setupCodeQL();
await codeql.printVersion();
core.endGroup();
core.startGroup('Load language configuration'); core.startGroup('Load language configuration');
config = await configUtils.initConfig(); const config = await configUtils.loadConfig();
analysisPaths.includeAndExcludeAnalysisPaths(config); languages = await util.getLanguages();
// If the languages parameter was not given and no languages were
// detected then fail here as this is a workflow configuration error.
if (languages.length === 0) {
throw new Error("Did not detect any languages to analyze. Please update input in workflow.");
}
analysisPaths.includeAndExcludeAnalysisPaths(config, languages);
core.endGroup(); core.endGroup();
} }
catch (e) { catch (e) {
@@ -180,16 +145,16 @@ async function run() {
} }
try { try {
const sourceRoot = path.resolve(); const sourceRoot = path.resolve();
core.startGroup('Setup CodeQL tools');
const codeql = await codeql_1.setupCodeQL();
await codeql.printVersion();
core.endGroup();
// Forward Go flags // Forward Go flags
const goFlags = process.env['GOFLAGS']; const goFlags = process.env['GOFLAGS'];
if (goFlags) { if (goFlags) {
core.exportVariable('GOFLAGS', goFlags); core.exportVariable('GOFLAGS', goFlags);
core.warning("Passing the GOFLAGS env parameter to the init action is deprecated. Please move this to the analyze action."); core.warning("Passing the GOFLAGS env parameter to the init action is deprecated. Please move this to the analyze action.");
} }
const setupPythonDependencies = core.getInput('setup-python-dependencies', { required: true });
if (config.languages.includes('python') && setupPythonDependencies === 'true') {
await installPythonDeps(codeql);
}
// Setup CODEQL_RAM flag (todo improve this https://github.com/github/dsp-code-scanning/issues/935) // Setup CODEQL_RAM flag (todo improve this https://github.com/github/dsp-code-scanning/issues/935)
const codeqlRam = process.env['CODEQL_RAM'] || '6500'; const codeqlRam = process.env['CODEQL_RAM'] || '6500';
core.exportVariable('CODEQL_RAM', codeqlRam); core.exportVariable('CODEQL_RAM', codeqlRam);
@@ -198,7 +163,7 @@ async function run() {
let tracedLanguages = {}; let tracedLanguages = {};
let scannedLanguages = []; let scannedLanguages = [];
// TODO: replace this code once CodeQL supports multi-language tracing // TODO: replace this code once CodeQL supports multi-language tracing
for (let language of config.languages) { for (let language of languages) {
const languageDatabase = path.join(databaseFolder, language); const languageDatabase = path.join(databaseFolder, language);
// Init language database // Init language database
await codeql.databaseInit(languageDatabase, language, sourceRoot); await codeql.databaseInit(languageDatabase, language, sourceRoot);
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"setup-tracer.js","sourceRoot":"","sources":["../src/setup-tracer.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AACtC,oDAAsC;AACtC,gDAAkC;AAClC,+DAAiD;AACjD,uCAAyB;AACzB,2CAA6B;AAE7B,gEAAkD;AAClD,qCAA+C;AAC/C,4DAA8C;AAC9C,gEAAkD;AAClD,6CAA+B;AAO/B,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAClC,CAAC,yBAAyB;IACxB,AADyB;IACvB,eAAe;IACjB,AADkB;IAChB,8BAA8B;IAChC,AADiC;IAC/B,wBAAwB;IAC1B,AAD2B;IACzB,0BAA0B;CAC7B,CAAC,CAAC;AAEL,KAAK,UAAU,YAAY,CACzB,MAAc,EACd,QAAgB,EAChB,YAAqB;IAErB,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IAE9D,MAAM,MAAM,GAAG,GAAG,CAAC,4BAA4B,CAAC,CAAC;IACjD,MAAM,IAAI,GAAiB,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;IAErD,yDAAyD;IACzD,KAAK,IAAI,KAAK,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACrC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACrB,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACvB,8DAA8D;QAC9D,IAAI,GAAG,KAAK,4BAA4B,EAAE;YACxC,SAAS;SACV;QACD,wBAAwB;QACxB,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;YAChC,SAAS;SACV;QACD,mFAAmF;QACnF,iCAAiC;QACjC,IAAI,OAAO,OA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AAC;QAEhE,IAAI,CAAC,QAAQ,EAAE,CAAC;KAEjB;IAAC,OAAO,CAAC,EAAE;QACV,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC1B,MAAM,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;QAClD,OAAO;KACR;IAED,IAAI;QAEF,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAElC,IAAI,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;QACtC,MAAM,MAAM,GAAG,MAAM,oBAAW,EAAE,CAAC;QACnC,MAAM,MAAM,CAAC,YAAY,EAAE,CAAC;QAC5B,IAAI,CAAC,QAAQ,EAAE,CAAC;QAEhB,mBAAmB;QACnB,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACvC,IAAI,OAAO,EAAE;YACX,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YACxC,IAAI,CAAC,OAAO,CAAC,6GAA6G,CALine truncated
+1
View File
@@ -1,6 +1,7 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.CODEQL_ACTION_DATABASE_DIR = 'CODEQL_ACTION_DATABASE_DIR'; exports.CODEQL_ACTION_DATABASE_DIR = 'CODEQL_ACTION_DATABASE_DIR';
exports.CODEQL_ACTION_LANGUAGES = 'CODEQL_ACTION_LANGUAGES';
exports.CODEQL_ACTION_ANALYSIS_KEY = 'CODEQL_ACTION_ANALYSIS_KEY'; exports.CODEQL_ACTION_ANALYSIS_KEY = 'CODEQL_ACTION_ANALYSIS_KEY';
exports.ODASA_TRACER_CONFIGURATION = 'ODASA_TRACER_CONFIGURATION'; exports.ODASA_TRACER_CONFIGURATION = 'ODASA_TRACER_CONFIGURATION';
exports.CODEQL_ACTION_SCANNED_LANGUAGES = 'CODEQL_ACTION_SCANNED_LANGUAGES'; exports.CODEQL_ACTION_SCANNED_LANGUAGES = 'CODEQL_ACTION_SCANNED_LANGUAGES';
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"shared-environment.js","sourceRoot":"","sources":["../src/shared-environment.ts"],"names":[],"mappings":";;AAAa,QAAA,0BAA0B,GAAG,4BAA4B,CAAC;AAC1D,QAAA,0BAA0B,GAAG,4BAA4B,CAAC;AAC1D,QAAA,0BAA0B,GAAG,4BAA4B,CAAC;AAC1D,QAAA,+BAA+B,GAAG,iCAAiC,CAAC;AACpE,QAAA,8BAA8B,GAAG,gCAAgC,CAAC;AAC/E,wEAAwE;AACxE,2EAA2E;AAC3E,4EAA4E;AAC5E,2EAA2E;AAC3E,+BAA+B;AAClB,QAAA,wBAAwB,GAAG,0BAA0B,CAAC;AACnE,wDAAwD;AAC3C,QAAA,4BAA4B,GAAG,8BAA8B,CAAC"} {"version":3,"file":"shared-environment.js","sourceRoot":"","sources":["../src/shared-environment.ts"],"names":[],"mappings":";;AAAa,QAAA,0BAA0B,GAAG,4BAA4B,CAAC;AAC1D,QAAA,uBAAuB,GAAG,yBAAyB,CAAC;AACpD,QAAA,0BAA0B,GAAG,4BAA4B,CAAC;AAC1D,QAAA,0BAA0B,GAAG,4BAA4B,CAAC;AAC1D,QAAA,+BAA+B,GAAG,iCAAiC,CAAC;AACpE,QAAA,8BAA8B,GAAG,gCAAgC,CAAC;AAC/E,wEAAwE;AACxE,2EAA2E;AAC3E,4EAA4E;AAC5E,2EAA2E;AAC3E,+BAA+B;AAClB,QAAA,wBAAwB,GAAG,0BAA0B,CAAC;AACnE,wDAAwD;AAC3C,QAAA,4BAA4B,GAAG,8BAA8B,CAAC"}
+2 -22
View File
@@ -2,16 +2,8 @@
var __importDefault = (this && this.__importDefault) || function (mod) { var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const sinon_1 = __importDefault(require("sinon")); const sinon_1 = __importDefault(require("sinon"));
const CodeQL = __importStar(require("./codeql"));
function wrapOutput(context) { function wrapOutput(context) {
// Function signature taken from Socket.write. // Function signature taken from Socket.write.
// Note there are two overloads: // Note there are two overloads:
@@ -40,10 +32,6 @@ function wrapOutput(context) {
function setupTests(test) { function setupTests(test) {
const typedTest = test; const typedTest = test;
typedTest.beforeEach(t => { typedTest.beforeEach(t => {
// Set an empty CodeQL object so that all method calls will fail
// unless the test explicitly sets one up.
CodeQL.setCodeQL({});
// Replace stdout and stderr so we can record output during tests
t.context.testOutput = ""; t.context.testOutput = "";
const processStdoutWrite = process.stdout.write.bind(process.stdout); const processStdoutWrite = process.stdout.write.bind(process.stdout);
t.context.stdoutWrite = processStdoutWrite; t.context.stdoutWrite = processStdoutWrite;
@@ -51,24 +39,16 @@ function setupTests(test) {
const processStderrWrite = process.stderr.write.bind(process.stderr); const processStderrWrite = process.stderr.write.bind(process.stderr);
t.context.stderrWrite = processStderrWrite; t.context.stderrWrite = processStderrWrite;
process.stderr.write = wrapOutput(t.context); process.stderr.write = wrapOutput(t.context);
// Many tests modify environment variables. Take a copy now so that
// we reset them after the test to keep tests independent of each other.
// process.env only has strings fields, so a shallow copy is fine.
t.context.env = {};
Object.assign(t.context.env, process.env);
}); });
typedTest.afterEach.always(t => { typedTest.afterEach.always(t => {
// Restore stdout and stderr
// The captured output is only replayed if the test failed
process.stdout.write = t.context.stdoutWrite; process.stdout.write = t.context.stdoutWrite;
process.stderr.write = t.context.stderrWrite; process.stderr.write = t.context.stderrWrite;
if (!t.passed) { if (!t.passed) {
process.stdout.write(t.context.testOutput); process.stdout.write(t.context.testOutput);
} }
// Undo any modifications made by sinon });
typedTest.afterEach.always(() => {
sinon_1.default.restore(); sinon_1.default.restore();
// Undo any modifications to the env
process.env = t.context.env;
}); });
} }
exports.setupTests = setupTests; exports.setupTests = setupTests;
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"testing-utils.js","sourceRoot":"","sources":["../src/testing-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,kDAA0B;AAE1B,iDAAmC;AAInC,SAAS,UAAU,CAAC,OAAoB;IACtC,8CAA8C;IAC9C,gCAAgC;IAChC,2EAA2E;IAC3E,2FAA2F;IAC3F,OAAO,CAAC,KAA0B,EAAE,QAAiB,EAAE,EAA0B,EAAW,EAAE;QAC5F,2CAA2C;QAC3C,IAAI,EAAE,KAAK,SAAS,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE;YACtD,EAAE,GAAG,QAAQ,CAAC;YACd,QAAQ,GAAG,SAAS,CAAC;SACtB;QAED,oBAAoB;QACpB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,OAAO,CAAC,UAAU,IAAI,KAAK,CAAC;SAC7B;aAAM;YACL,OAAO,CAAC,UAAU,IAAI,IAAI,WAAW,CAAC,QAAQ,IAAI,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SAC1E;QAED,iDAAiD;QACjD,IAAI,EAAE,KAAK,SAAS,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE;YAChD,EAAE,EAAE,CAAC;SACN;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,UAAU,CAAC,IAAwB;IACjD,MAAM,SAAS,GAAG,IAAkC,CAAC;IAErD,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE;QACvB,gEAAgE;QAChE,0CAA0C;QAC1C,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QAErB,iEAAiE;QACjE,CAAC,CAAC,OAAO,CAAC,UAAU,GAAG,EAAE,CAAC;QAC1B,M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,CAAQ,CAAC;QAEpD,MAAM,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACrE,CAAC,CAAC,OAAO,CAAC,WAAW,GAAG,kBAAkB,CAAC;QAC3C,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,OAAO,CAAQ,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;QAC7B,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC;QAC7C,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC;QAE7C,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE;YACb,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;SAC5C;IACH,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,EAAE;QAC9B,eAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;AA3BD,gCA2BC"}
Generated
+78 -14
View File
@@ -13,7 +13,6 @@ const fs = __importStar(require("fs"));
const os = __importStar(require("os")); const os = __importStar(require("os"));
const path = __importStar(require("path")); const path = __importStar(require("path"));
const api = __importStar(require("./api-client")); const api = __importStar(require("./api-client"));
const configUtils = __importStar(require("./config-utils"));
const sharedEnv = __importStar(require("./shared-environment")); const sharedEnv = __importStar(require("./shared-environment"));
/** /**
* Should the current action be aborted? * Should the current action be aborted?
@@ -49,6 +48,83 @@ function getRequiredEnvParam(paramName) {
return value; return value;
} }
exports.getRequiredEnvParam = getRequiredEnvParam; exports.getRequiredEnvParam = getRequiredEnvParam;
/**
* Gets the set of languages in the current repository
*/
async function getLanguagesInRepo() {
var _a;
// Translate between GitHub's API names for languages and ours
const codeqlLanguages = {
'C': 'cpp',
'C++': 'cpp',
'C#': 'csharp',
'Go': 'go',
'Java': 'java',
'JavaScript': 'javascript',
'TypeScript': 'javascript',
'Python': 'python',
};
let repo_nwo = (_a = process.env['GITHUB_REPOSITORY']) === null || _a === void 0 ? void 0 : _a.split("/");
if (repo_nwo) {
let owner = repo_nwo[0];
let repo = repo_nwo[1];
core.debug(`GitHub repo ${owner} ${repo}`);
const response = await api.getApiClient().request("GET /repos/:owner/:repo/languages", ({
owner,
repo
}));
core.debug("Languages API response: " + JSON.stringify(response));
// The GitHub API is going to return languages in order of popularity,
// When we pick a language to autobuild we want to pick the most popular traced language
// Since sets in javascript maintain insertion order, using a set here and then splatting it
// into an array gives us an array of languages ordered by popularity
let languages = new Set();
for (let lang in response.data) {
if (lang in codeqlLanguages) {
languages.add(codeqlLanguages[lang]);
}
}
return [...languages];
}
else {
return [];
}
}
/**
* Get the languages to analyse.
*
* The result is obtained from the environment parameter CODEQL_ACTION_LANGUAGES
* if that has been set, otherwise it is obtained from the action input parameter
* 'languages' if that has been set, otherwise it is deduced as all languages in the
* repo that can be analysed.
*
* If the languages are obtained from either of the second choices, the
* CODEQL_ACTION_LANGUAGES environment variable will be exported with the
* deduced list.
*/
async function getLanguages() {
// Obtain from CODEQL_ACTION_LANGUAGES if set
const langsVar = process.env[sharedEnv.CODEQL_ACTION_LANGUAGES];
if (langsVar) {
return langsVar.split(',')
.map(x => x.trim())
.filter(x => x.length > 0);
}
// Obtain from action input 'languages' if set
let languages = core.getInput('languages', { required: false })
.split(',')
.map(x => x.trim())
.filter(x => x.length > 0);
core.info("Languages from configuration: " + JSON.stringify(languages));
if (languages.length === 0) {
// Obtain languages as all languages in the repo that can be analysed
languages = await getLanguagesInRepo();
core.info("Automatically detected languages: " + JSON.stringify(languages));
}
core.exportVariable(sharedEnv.CODEQL_ACTION_LANGUAGES, languages.join(','));
return languages;
}
exports.getLanguages = getLanguages;
/** /**
* Gets the SHA of the commit that is currently checked out. * Gets the SHA of the commit that is currently checked out.
*/ */
@@ -143,18 +219,6 @@ exports.getRef = getRef;
* @param exception Exception (only supply if status is 'failure') * @param exception Exception (only supply if status is 'failure')
*/ */
async function createStatusReport(actionName, status, cause, exception) { async function createStatusReport(actionName, status, cause, exception) {
var _a, _b;
// If this is not the init action starting up or aborting then try to load the config.
// If it fails then carry because it's important to still send the status report.
let config = undefined;
if (actionName !== 'init' || (status !== 'starting' && status !== 'aborted')) {
try {
config = await configUtils.getConfig();
}
catch (e) {
core.error('Unable to load config: ' + e);
}
}
const commitOid = process.env['GITHUB_SHA'] || ''; const commitOid = process.env['GITHUB_SHA'] || '';
const ref = getRef(); const ref = getRef();
const workflowRunIDStr = process.env['GITHUB_RUN_ID']; const workflowRunIDStr = process.env['GITHUB_RUN_ID'];
@@ -165,7 +229,7 @@ async function createStatusReport(actionName, status, cause, exception) {
const workflowName = process.env['GITHUB_WORKFLOW'] || ''; const workflowName = process.env['GITHUB_WORKFLOW'] || '';
const jobName = process.env['GITHUB_JOB'] || ''; const jobName = process.env['GITHUB_JOB'] || '';
const analysis_key = await getAnalysisKey(); const analysis_key = await getAnalysisKey();
const languages = ((_b = (_a = config) === null || _a === void 0 ? void 0 : _a.languages) === null || _b === void 0 ? void 0 : _b.join(',')) || ""; const languages = (await getLanguages()).sort().join(',');
const startedAt = process.env[sharedEnv.CODEQL_ACTION_STARTED_AT] || new Date().toISOString(); const startedAt = process.env[sharedEnv.CODEQL_ACTION_STARTED_AT] || new Date().toISOString();
core.exportVariable(sharedEnv.CODEQL_ACTION_STARTED_AT, startedAt); core.exportVariable(sharedEnv.CODEQL_ACTION_STARTED_AT, startedAt);
let statusReport = { let statusReport = {
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AACtC,oDAAsC;AACtC,uCAAyB;AACzB,uCAAyB;AACzB,2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DAA0D;IAC1D,6DAA6D;IAC7D,MAAM,GAAG,GAAG,mBAAmB,CAAC,YAAY,CAAC,CAAC;IAE9C,gEAAgE;IAChE,yDAAyD;IACzD,iEAAiE;IACjE,2DAA2D;IAC3D,MAAM,cAAc,GAAG,0BAA0B,CAAC;IAClD,IAAI,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAC5B,OAAO,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,mBAAmB,CAAC,CAAC;KACzD;SAAM;QACL,OAAO,GAAG,CAAC;KACZ;AACH,CAAC;AAfD,wBAeC;AAoBD;;;;;;;GAOG;AACH,KAAK,UAAU,kBAAkB,CAC/B,UAAkB,EAClB,MAAc,EACd,KAAc,EACdLine truncated
+2 -40
View File
@@ -9,17 +9,11 @@
import javascript import javascript
/**
* A declaration of a github action, including its inputs and entrypoint.
*/
class ActionDeclaration extends File { class ActionDeclaration extends File {
ActionDeclaration() { ActionDeclaration() {
getRelativePath().matches("%/action.yml") getRelativePath().matches("%/action.yml")
} }
/**
* The name of the action.
*/
string getName() { string getName() {
result = getRelativePath().regexpCapture("(.*)/action.yml", 1) result = getRelativePath().regexpCapture("(.*)/action.yml", 1)
} }
@@ -28,16 +22,10 @@ class ActionDeclaration extends File {
result.getFile() = this result.getFile() = this
} }
/**
* The name of any input to this action.
*/
string getAnInput() { string getAnInput() {
result = getRootNode().(YAMLMapping).lookup("inputs").(YAMLMapping).getKey(_).(YAMLString).getValue() result = getRootNode().(YAMLMapping).lookup("inputs").(YAMLMapping).getKey(_).(YAMLString).getValue()
} }
/**
* The function that is the entrypoint to this action.
*/
FunctionDeclStmt getEntrypoint() { FunctionDeclStmt getEntrypoint() {
result.getFile().getRelativePath() = getRootNode(). result.getFile().getRelativePath() = getRootNode().
(YAMLMapping).lookup("runs"). (YAMLMapping).lookup("runs").
@@ -47,21 +35,6 @@ class ActionDeclaration extends File {
} }
} }
/**
* A function declared on CodeQL interface from codeql.ts
*/
class CodeQLFunction extends Function {
CodeQLFunction() {
exists(Function getCodeQLForCmd, ObjectExpr obj |
getCodeQLForCmd.getName() = "getCodeQLForCmd" and
obj = getCodeQLForCmd.getAStmt().(ReturnStmt).getExpr() and
obj.getAProperty().getInit() = this)
}
}
/**
* Any expr that is a transitive child of the given function.
*/
Expr getAFunctionChildExpr(Function f) { Expr getAFunctionChildExpr(Function f) {
result.getContainer() = f result.getContainer() = f
} }
@@ -72,25 +45,14 @@ Expr getAFunctionChildExpr(Function f) {
Function calledBy(Function f) { Function calledBy(Function f) {
result = getAFunctionChildExpr(f).(InvokeExpr).getResolvedCallee() result = getAFunctionChildExpr(f).(InvokeExpr).getResolvedCallee()
or or
// Assume outer function causes inner function to be called, result.getEnclosingContainer() = f // assume outer function causes inner function to be called
// except for the special case of the CodeQL functions.
(result.getEnclosingContainer() = f and not result instanceof CodeQLFunction)
or
// Handle calls to CodeQL functions by name
getAFunctionChildExpr(f).(InvokeExpr).getCalleeName() = result.(CodeQLFunction).getName()
} }
/**
* A call to the core.getInput method.
*/
class GetInputMethodCallExpr extends MethodCallExpr { class GetInputMethodCallExpr extends MethodCallExpr {
GetInputMethodCallExpr() { GetInputMethodCallExpr() {
getMethodName() = "getInput" getMethodName() = "getInput"
} }
/**
* The name of the input being accessed.
*/
string getInputName() { string getInputName() {
result = getArgument(0).(StringLiteral).getValue() result = getArgument(0).(StringLiteral).getValue()
} }
@@ -100,4 +62,4 @@ from ActionDeclaration action, GetInputMethodCallExpr getInputCall, string input
where getAFunctionChildExpr(calledBy*(action.getEntrypoint())) = getInputCall and where getAFunctionChildExpr(calledBy*(action.getEntrypoint())) = getInputCall and
inputName = getInputCall.getInputName() and inputName = getInputCall.getInputName() and
not inputName = action.getAnInput() not inputName = action.getAnInput()
select getInputCall, "The $@ input is not defined for the $@ action", inputName, inputName, action, action.getName() select getInputCall, "The $@ input is not defined for the $@ action", inputName, inputName, action, action.getName()
+7 -14
View File
@@ -1,31 +1,24 @@
import test from 'ava'; import test from 'ava';
import * as analysisPaths from './analysis-paths'; import * as analysisPaths from './analysis-paths';
import * as configUtils from './config-utils';
import {setupTests} from './testing-utils'; import {setupTests} from './testing-utils';
setupTests(test); setupTests(test);
test("emptyPaths", async t => { test("emptyPaths", async t => {
const config = { let config = new configUtils.Config();
languages: [], analysisPaths.includeAndExcludeAnalysisPaths(config, []);
queries: {},
pathsIgnore: [],
paths: [],
};
analysisPaths.includeAndExcludeAnalysisPaths(config);
t.is(process.env['LGTM_INDEX_INCLUDE'], undefined); t.is(process.env['LGTM_INDEX_INCLUDE'], undefined);
t.is(process.env['LGTM_INDEX_EXCLUDE'], undefined); t.is(process.env['LGTM_INDEX_EXCLUDE'], undefined);
t.is(process.env['LGTM_INDEX_FILTERS'], undefined); t.is(process.env['LGTM_INDEX_FILTERS'], undefined);
}); });
test("nonEmptyPaths", async t => { test("nonEmptyPaths", async t => {
const config = { let config = new configUtils.Config();
languages: [], config.paths.push('path1', 'path2', '**/path3');
queries: {}, config.pathsIgnore.push('path4', 'path5', 'path6/**');
paths: ['path1', 'path2', '**/path3'], analysisPaths.includeAndExcludeAnalysisPaths(config, []);
pathsIgnore: ['path4', 'path5', 'path6/**'],
};
analysisPaths.includeAndExcludeAnalysisPaths(config);
t.is(process.env['LGTM_INDEX_INCLUDE'], 'path1\npath2'); t.is(process.env['LGTM_INDEX_INCLUDE'], 'path1\npath2');
t.is(process.env['LGTM_INDEX_EXCLUDE'], 'path4\npath5'); t.is(process.env['LGTM_INDEX_EXCLUDE'], 'path4\npath5');
t.is(process.env['LGTM_INDEX_FILTERS'], 'include:path1\ninclude:path2\ninclude:**/path3\nexclude:path4\nexclude:path5\nexclude:path6/**'); t.is(process.env['LGTM_INDEX_FILTERS'], 'include:path1\ninclude:path2\ninclude:**/path3\nexclude:path4\nexclude:path5\nexclude:path6/**');
+3 -3
View File
@@ -22,7 +22,7 @@ function buildIncludeExcludeEnvVar(paths: string[]): string {
return paths.join('\n'); return paths.join('\n');
} }
export function includeAndExcludeAnalysisPaths(config: configUtils.Config) { export function includeAndExcludeAnalysisPaths(config: configUtils.Config, languages: string[]) {
// The 'LGTM_INDEX_INCLUDE' and 'LGTM_INDEX_EXCLUDE' environment variables // The 'LGTM_INDEX_INCLUDE' and 'LGTM_INDEX_EXCLUDE' environment variables
// control which files/directories are traversed when scanning. // control which files/directories are traversed when scanning.
// This allows including files that otherwise would not be scanned, or // This allows including files that otherwise would not be scanned, or
@@ -52,7 +52,7 @@ export function includeAndExcludeAnalysisPaths(config: configUtils.Config) {
if ((config.paths.length !== 0 || if ((config.paths.length !== 0 ||
config.pathsIgnore.length !== 0 || config.pathsIgnore.length !== 0 ||
filters.length !== 0) && filters.length !== 0) &&
!config.languages.every(isInterpretedLanguage)) { !languages.every(isInterpretedLanguage)) {
core.warning('The "paths"/"paths-ignore" fields of the config only have effect for Javascript and Python'); core.warning('The "paths"/"paths-ignore" fields of the configuration only effect Javascript and Python analysis. [Learn more](https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#specifying-directories-to-scan) about modifying the directories to scan. );
} }
} }
+1 -1
View File
@@ -35,7 +35,7 @@ async function run() {
core.endGroup(); core.endGroup();
} catch (error) { } catch (error) {
core.setFailed("We were unable to automatically build your code. Please replace the call to the autobuild action with your custom build steps. " + error.message); core.setFailed(`We were unable to automatically build your ${language} code. Please replace the call to the autobuild action with your custom build steps. \n` + error.message);
await util.reportActionFailed('autobuild', error.message, error.stack); await util.reportActionFailed('autobuild', error.message, error.stack);
return; return;
} }
+19 -60
View File
@@ -41,7 +41,7 @@ export interface CodeQL {
/** /**
* Run 'codeql resolve queries'. * Run 'codeql resolve queries'.
*/ */
resolveQueries(queries: string[], extraSearchPath: string | undefined): Promise<ResolveQueriesOutput>; resolveQueries(queries: string[]): Promise<ResolveQueriesOutput>;
/** /**
* Run 'codeql database analyze'. * Run 'codeql database analyze'.
*/ */
@@ -62,12 +62,6 @@ export interface ResolveQueriesOutput {
}; };
} }
/**
* Stores the CodeQL object, and is populated by `setupCodeQL` or `getCodeQL`.
* Can be overridden in tests using `setCodeQL`.
*/
let cachedCodeQL: CodeQL | undefined = undefined;
/** /**
* Environment variable used to store the location of the CodeQL CLI executable. * Environment variable used to store the location of the CodeQL CLI executable.
* Value is set by setupCodeQL and read by getCodeQL. * Value is set by setupCodeQL and read by getCodeQL.
@@ -95,9 +89,8 @@ export async function setupCodeQL(): Promise<CodeQL> {
throw new Error("Unsupported plaform: " + process.platform); throw new Error("Unsupported plaform: " + process.platform);
} }
cachedCodeQL = getCodeQLForCmd(codeqlCmd);
core.exportVariable(CODEQL_ACTION_CMD, codeqlCmd); core.exportVariable(CODEQL_ACTION_CMD, codeqlCmd);
return cachedCodeQL; return getCodeQLForCmd(codeqlCmd);
} catch (e) { } catch (e) {
core.error(e); core.error(e);
@@ -128,41 +121,8 @@ export function getCodeQLURLVersion(url: string): string {
} }
export function getCodeQL(): CodeQL { export function getCodeQL(): CodeQL {
if (cachedCodeQL === undefined) { const codeqlCmd = util.getRequiredEnvParam(CODEQL_ACTION_CMD);
const codeqlCmd = util.getRequiredEnvParam(CODEQL_ACTION_CMD); return getCodeQLForCmd(codeqlCmd);
cachedCodeQL = getCodeQLForCmd(codeqlCmd);
}
return cachedCodeQL;
}
function resolveFunction<T>(partialCodeql: Partial<CodeQL>, methodName: string): T {
if (typeof partialCodeql[methodName] !== 'function') {
const dummyMethod = () => {
throw new Error('CodeQL ' + methodName + ' method not correctly defined');
};
return dummyMethod as any;
}
return partialCodeql[methodName];
}
/**
* Set the functionality for CodeQL methods. Only for use in tests.
*
* Accepts a partial object and any undefined methods will be implemented
* to immediately throw an exception indicating which method is missing.
*/
export function setCodeQL(partialCodeql: Partial<CodeQL>) {
cachedCodeQL = {
getDir: resolveFunction(partialCodeql, 'getDir'),
printVersion: resolveFunction(partialCodeql, 'printVersion'),
getTracerEnv: resolveFunction(partialCodeql, 'getTracerEnv'),
databaseInit: resolveFunction(partialCodeql, 'databaseInit'),
runAutobuild: resolveFunction(partialCodeql, 'runAutobuild'),
extractScannedLanguage: resolveFunction(partialCodeql, 'extractScannedLanguage'),
finalizeDatabase: resolveFunction(partialCodeql, 'finalizeDatabase'),
resolveQueries: resolveFunction(partialCodeql, 'resolveQueries'),
databaseAnalyze: resolveFunction(partialCodeql, 'databaseAnalyze')
};
} }
function getCodeQLForCmd(cmd: string): CodeQL { function getCodeQLForCmd(cmd: string): CodeQL {
@@ -252,24 +212,23 @@ function getCodeQLForCmd(cmd: string): CodeQL {
databasePath databasePath
]); ]);
}, },
resolveQueries: async function(queries: string[], extraSearchPath: string | undefined) { resolveQueries: async function(queries: string[]) {
const codeqlArgs = [
'resolve',
'queries',
...queries,
'--format=bylanguage'
];
if (extraSearchPath !== undefined) {
codeqlArgs.push('--search-path', extraSearchPath);
}
let output = ''; let output = '';
await exec.exec(cmd, codeqlArgs, { await exec.exec(
listeners: { cmd,
stdout: (data: Buffer) => { [
output += data.toString(); 'resolve',
'queries',
...queries,
'--format=bylanguage'
],
{
listeners: {
stdout: (data: Buffer) => {
output += data.toString();
}
} }
} });
});
return JSON.parse(output); return JSON.parse(output);
}, },
+59 -176
View File
@@ -5,7 +5,6 @@ import * as path from 'path';
import sinon from 'sinon'; import sinon from 'sinon';
import * as api from './api-client'; import * as api from './api-client';
import * as CodeQL from './codeql';
import * as configUtils from './config-utils'; import * as configUtils from './config-utils';
import {setupTests} from './testing-utils'; import {setupTests} from './testing-utils';
import * as util from './util'; import * as util from './util';
@@ -42,21 +41,10 @@ test("load empty config", async t => {
process.env['GITHUB_WORKSPACE'] = tmpDir; process.env['GITHUB_WORKSPACE'] = tmpDir;
setInput('config-file', undefined); setInput('config-file', undefined);
setInput('languages', 'javascript,python');
CodeQL.setCodeQL({ const config = await configUtils.loadConfig();
resolveQueries: async function() {
return {
byLanguage: {},
noDeclaredLanguage: {},
multipleDeclaredLanguages: {},
};
},
});
const config = await configUtils.initConfig(); t.deepEqual(config, new configUtils.Config());
t.deepEqual(config, await configUtils.getDefaultConfig());
}); });
}); });
@@ -65,34 +53,17 @@ test("loading config saves config", async t => {
process.env['RUNNER_TEMP'] = tmpDir; process.env['RUNNER_TEMP'] = tmpDir;
process.env['GITHUB_WORKSPACE'] = tmpDir; process.env['GITHUB_WORKSPACE'] = tmpDir;
setInput('config-file', undefined); const configFile = configUtils.getConfigFile();
setInput('languages', 'javascript,python');
CodeQL.setCodeQL({
resolveQueries: async function() {
return {
byLanguage: {},
noDeclaredLanguage: {},
multipleDeclaredLanguages: {},
};
},
});
// Sanity check the saved config file does not already exist // Sanity check the saved config file does not already exist
t.false(fs.existsSync(configUtils.getPathToParsedConfigFile())); t.false(fs.existsSync(configFile));
// Sanity check that getConfig throws before we have called initConfig const config = await configUtils.loadConfig();
await t.throwsAsync(configUtils.getConfig);
const config1 = await configUtils.initConfig();
// The saved config file should now exist // The saved config file should now exist
t.true(fs.existsSync(configUtils.getPathToParsedConfigFile())); t.true(fs.existsSync(configFile));
// And that same newly-initialised config should now be returned by getConfig // And the contents should parse correctly to the config that was returned
const config2 = await configUtils.getConfig(); t.deepEqual(fs.readFileSync(configFile, 'utf8'), JSON.stringify(config));
t.deepEqual(config1, config2);
}); });
}); });
@@ -104,8 +75,8 @@ test("load input outside of workspace", async t => {
setInput('config-file', '../input'); setInput('config-file', '../input');
try { try {
await configUtils.initConfig(); await configUtils.loadConfig();
throw new Error('initConfig did not throw error'); throw new Error('loadConfig did not throw error');
} catch (err) { } catch (err) {
t.deepEqual(err, new Error(configUtils.getConfigFileOutsideWorkspaceErrorMessage(path.join(tmpDir, '../input')))); t.deepEqual(err, new Error(configUtils.getConfigFileOutsideWorkspaceErrorMessage(path.join(tmpDir, '../input'))));
} }
@@ -121,8 +92,8 @@ test("load non-local input with invalid repo syntax", async t => {
setInput('config-file', 'octo-org/codeql-config@main'); setInput('config-file', 'octo-org/codeql-config@main');
try { try {
await configUtils.initConfig(); await configUtils.loadConfig();
throw new Error('initConfig did not throw error'); throw new Error('loadConfig did not throw error');
} catch (err) { } catch (err) {
t.deepEqual(err, new Error(configUtils.getConfigFileRepoFormatInvalidMessage('octo-org/codeql-config@main'))); t.deepEqual(err, new Error(configUtils.getConfigFileRepoFormatInvalidMessage('octo-org/codeql-config@main')));
} }
@@ -136,11 +107,10 @@ test("load non-existent input", async t => {
t.false(fs.existsSync(path.join(tmpDir, 'input'))); t.false(fs.existsSync(path.join(tmpDir, 'input')));
setInput('config-file', 'input'); setInput('config-file', 'input');
setInput('languages', 'javascript');
try { try {
await configUtils.initConfig(); await configUtils.loadConfig();
throw new Error('initConfig did not throw error'); throw new Error('loadConfig did not throw error');
} catch (err) { } catch (err) {
t.deepEqual(err, new Error(configUtils.getConfigFileDoesNotExistErrorMessage(path.join(tmpDir, 'input')))); t.deepEqual(err, new Error(configUtils.getConfigFileDoesNotExistErrorMessage(path.join(tmpDir, 'input'))));
} }
@@ -152,116 +122,7 @@ test("load non-empty input", async t => {
process.env['RUNNER_TEMP'] = tmpDir; process.env['RUNNER_TEMP'] = tmpDir;
process.env['GITHUB_WORKSPACE'] = tmpDir; process.env['GITHUB_WORKSPACE'] = tmpDir;
CodeQL.setCodeQL({
resolveQueries: async function() {
return {
byLanguage: {
'javascript': {
'/foo/a.ql': {},
'/bar/b.ql': {},
},
},
noDeclaredLanguage: {},
multipleDeclaredLanguages: {},
};
},
});
// Just create a generic config object with non-default values for all fields // Just create a generic config object with non-default values for all fields
const inputFileContents = `
name: my config
disable-default-queries: true
queries:
- uses: ./foo
paths-ignore:
- a
- b
paths:
- c/d`;
fs.mkdirSync(path.join(tmpDir, 'foo'));
// And the config we expect it to parse to
const expectedConfig: configUtils.Config = {
languages: ['javascript'],
queries: {'javascript': ['/foo/a.ql', '/bar/b.ql']},
pathsIgnore: ['a', 'b'],
paths: ['c/d'],
};
fs.writeFileSync(path.join(tmpDir, 'input'), inputFileContents, 'utf8');
setInput('config-file', 'input');
setInput('languages', 'javascript');
const actualConfig = await configUtils.initConfig();
// Should exactly equal the object we constructed earlier
t.deepEqual(actualConfig, expectedConfig);
});
});
test("default queries are used", async t => {
return await util.withTmpDir(async tmpDir => {
process.env['RUNNER_TEMP'] = tmpDir;
process.env['GITHUB_WORKSPACE'] = tmpDir;
// Check that the default behaviour is to add the default queries.
// In this case if a config file is specified but does not include
// the disable-default-queries field.
// We determine this by whether CodeQL.resolveQueries is called
// with the correct arguments.
const resolveQueriesArgs: {queries: string[], extraSearchPath: string | undefined}[] = [];
CodeQL.setCodeQL({
resolveQueries: async function(queries: string[], extraSearchPath: string | undefined) {
resolveQueriesArgs.push({queries, extraSearchPath});
return {
byLanguage: {
'javascript': {},
},
noDeclaredLanguage: {},
multipleDeclaredLanguages: {},
};
},
});
// The important point of this config is that it doesn't specify
// the disable-default-queries field.
// Any other details are hopefully irrelevant for this tetst.
const inputFileContents = `
paths:
- foo`;
fs.mkdirSync(path.join(tmpDir, 'foo'));
fs.writeFileSync(path.join(tmpDir, 'input'), inputFileContents, 'utf8');
setInput('config-file', 'input');
setInput('languages', 'javascript');
await configUtils.initConfig();
// Check resolve queries was called correctly
t.deepEqual(resolveQueriesArgs.length, 1);
t.deepEqual(resolveQueriesArgs[0].queries, ['javascript-code-scanning.qls']);
t.deepEqual(resolveQueriesArgs[0].extraSearchPath, undefined);
});
});
test("API client used when reading remote config", async t => {
return await util.withTmpDir(async tmpDir => {
process.env['RUNNER_TEMP'] = tmpDir;
process.env['GITHUB_WORKSPACE'] = tmpDir;
CodeQL.setCodeQL({
resolveQueries: async function() {
return {
byLanguage: {},
noDeclaredLanguage: {},
multipleDeclaredLanguages: {},
};
},
});
const inputFileContents = ` const inputFileContents = `
name: my config name: my config
disable-default-queries: true disable-default-queries: true
@@ -274,18 +135,51 @@ test("API client used when reading remote config", async t => {
- b - b
paths: paths:
- c/d`; - c/d`;
fs.mkdirSync(path.join(tmpDir, 'foo'));
// And the config we expect it to parse to
const expectedConfig = new configUtils.Config();
expectedConfig.name = 'my config';
expectedConfig.disableDefaultQueries = true;
expectedConfig.additionalQueries.push(fs.realpathSync(tmpDir));
expectedConfig.additionalQueries.push(fs.realpathSync(path.join(tmpDir, 'foo')));
expectedConfig.externalQueries = [new configUtils.ExternalQuery('foo/bar', 'dev')];
expectedConfig.pathsIgnore = ['a', 'b'];
expectedConfig.paths = ['c/d'];
fs.writeFileSync(path.join(tmpDir, 'input'), inputFileContents, 'utf8');
setInput('config-file', 'input');
const actualConfig = await configUtils.loadConfig();
// Should exactly equal the object we constructed earlier
t.deepEqual(actualConfig, expectedConfig);
});
});
test("API client used when reading remote config", async t => {
return await util.withTmpDir(async tmpDir => {
process.env['RUNNER_TEMP'] = tmpDir;
process.env['GITHUB_WORKSPACE'] = tmpDir;
const inputFileContents = `
name: my config
disable-default-queries: true
queries:
- uses: ./
paths-ignore:
- a
- b
paths:
- c/d`;
const dummyResponse = { const dummyResponse = {
content: Buffer.from(inputFileContents).toString("base64"), content: Buffer.from(inputFileContents).toString("base64"),
}; };
const spyGetContents = mockGetContents(dummyResponse); const spyGetContents = mockGetContents(dummyResponse);
// Create checkout directory for remote queries repository
fs.mkdirSync(path.join(tmpDir, 'foo/bar'), { recursive: true });
setInput('config-file', 'octo-org/codeql-config/config.yaml@main'); setInput('config-file', 'octo-org/codeql-config/config.yaml@main');
setInput('languages', 'javascript'); await configUtils.loadConfig();
await configUtils.initConfig();
t.assert(spyGetContents.called); t.assert(spyGetContents.called);
}); });
}); });
@@ -301,8 +195,8 @@ 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';
setInput('config-file', repoReference); setInput('config-file', repoReference);
try { try {
await configUtils.initConfig(); await configUtils.loadConfig();
throw new Error('initConfig did not throw error'); throw new Error('loadConfig did not throw error');
} catch (err) { } catch (err) {
t.deepEqual(err, new Error(configUtils.getConfigFileDirectoryGivenMessage(repoReference))); t.deepEqual(err, new Error(configUtils.getConfigFileDirectoryGivenMessage(repoReference)));
} }
@@ -322,8 +216,8 @@ 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';
setInput('config-file', repoReference); setInput('config-file', repoReference);
try { try {
await configUtils.initConfig(); await configUtils.loadConfig();
throw new Error('initConfig did not throw error'); throw new Error('loadConfig did not throw error');
} catch (err) { } catch (err) {
t.deepEqual(err, new Error(configUtils.getConfigFileFormatInvalidMessage(repoReference))); t.deepEqual(err, new Error(configUtils.getConfigFileFormatInvalidMessage(repoReference)));
} }
@@ -340,24 +234,13 @@ function doInvalidInputTest(
process.env['RUNNER_TEMP'] = tmpDir; process.env['RUNNER_TEMP'] = tmpDir;
process.env['GITHUB_WORKSPACE'] = tmpDir; process.env['GITHUB_WORKSPACE'] = tmpDir;
CodeQL.setCodeQL({
resolveQueries: async function() {
return {
byLanguage: {},
noDeclaredLanguage: {},
multipleDeclaredLanguages: {},
};
},
});
const inputFile = path.join(tmpDir, 'input'); const inputFile = path.join(tmpDir, 'input');
fs.writeFileSync(inputFile, inputFileContents, 'utf8'); fs.writeFileSync(inputFile, inputFileContents, 'utf8');
setInput('config-file', 'input'); setInput('config-file', 'input');
setInput('languages', 'javascript');
try { try {
await configUtils.initConfig(); await configUtils.loadConfig();
throw new Error('initConfig did not throw error'); throw new Error('loadConfig did not throw error');
} catch (err) { } catch (err) {
t.deepEqual(err, new Error(expectedErrorMessageGenerator(inputFile))); t.deepEqual(err, new Error(expectedErrorMessageGenerator(inputFile)));
} }
+125 -378
View File
@@ -5,238 +5,112 @@ import * as yaml from 'js-yaml';
import * as path from 'path'; import * as path from 'path';
import * as api from './api-client'; import * as api from './api-client';
import { getCodeQL, ResolveQueriesOutput } from './codeql';
import * as externalQueries from "./external-queries";
import * as util from './util'; import * as util from './util';
// Property names from the user-supplied config file.
const NAME_PROPERTY = 'name'; const NAME_PROPERTY = 'name';
const DISABLE_DEFAULT_QUERIES_PROPERTY = 'disable-default-queries'; const DISPLAY_DEFAULT_QUERIES_PROPERTY = 'disable-default-queries';
const QUERIES_PROPERTY = 'queries'; const QUERIES_PROPERTY = 'queries';
const QUERIES_USES_PROPERTY = 'uses'; const QUERIES_USES_PROPERTY = 'uses';
const PATHS_IGNORE_PROPERTY = 'paths-ignore'; const PATHS_IGNORE_PROPERTY = 'paths-ignore';
const PATHS_PROPERTY = 'paths'; const PATHS_PROPERTY = 'paths';
/** export class ExternalQuery {
* Format of the parsed config file. public repository: string;
*/ public ref: string;
export interface Config { public path = '';
/**
* Set of languages to run analysis for.
*/
languages: string[];
/**
* Map from language to query files.
* Will only contain .ql files and not other kinds of files,
* and all file paths will be absolute.
*/
queries: { [language: string]: string[] };
/**
* List of paths to ignore from analysis.
*/
pathsIgnore: string[];
/**
* List of paths to include in analysis.
*/
paths: string[];
}
/** constructor(repository: string, ref: string) {
* A list of queries from https://github.com/github/codeql that this.repository = repository;
* we don't want to run. Disabling them here is a quicker alternative to this.ref = ref;
* disabling them in the code scanning query suites. Queries should also
* be disabled in the suites, and removed from this list here once the
* bundle is updated to make those suite changes live.
*
* Format is a map from language to an array of path suffixes of .ql files.
*/
const DISABLED_BUILTIN_QUERIES: {[language: string]: string[]} = {
'csharp': [
'ql/src/Security Features/CWE-937/VulnerablePackage.ql',
'ql/src/Security Features/CWE-451/MissingXFrameOptions.ql',
]
};
function queryIsDisabled(language, query): boolean {
return (DISABLED_BUILTIN_QUERIES[language] || [])
.some(disabledQuery => query.endsWith(disabledQuery));
}
/**
* Asserts that the noDeclaredLanguage and multipleDeclaredLanguages fields are
* both empty and errors if they are not.
*/
function validateQueries(resolvedQueries: ResolveQueriesOutput) {
const noDeclaredLanguage = resolvedQueries.noDeclaredLanguage;
const noDeclaredLanguageQueries = Object.keys(noDeclaredLanguage);
if (noDeclaredLanguageQueries.length !== 0) {
throw new Error('The following queries do not declare a language. ' +
'Their qlpack.yml files are either missing or is invalid.\n' +
noDeclaredLanguageQueries.join('\n'));
} }
const multipleDeclaredLanguages = resolvedQueries.multipleDeclaredLanguages;
const multipleDeclaredLanguagesQueries = Object.keys(multipleDeclaredLanguages);
if (multipleDeclaredLanguagesQueries.length !== 0) {
throw new Error('The following queries declare multiple languages. ' +
'Their qlpack.yml files are either missing or is invalid.\n' +
multipleDeclaredLanguagesQueries.join('\n'));
}
}
/**
* Run 'codeql resolve queries' and add the results to resultMap
*/
async function runResolveQueries(
resultMap: { [language: string]: string[] },
toResolve: string[],
extraSearchPath: string | undefined,
errorOnInvalidQueries: boolean) {
const codeQl = getCodeQL();
const resolvedQueries = await codeQl.resolveQueries(toResolve, extraSearchPath);
for (const [language, queries] of Object.entries(resolvedQueries.byLanguage)) {
if (resultMap[language] === undefined) {
resultMap[language] = [];
}
resultMap[language].push(...Object.keys(queries).filter(q => !queryIsDisabled(language, q)));
}
if (errorOnInvalidQueries) {
validateQueries(resolvedQueries);
}
}
/**
* Get the set of queries included by default.
*/
async function addDefaultQueries(languages: string[], resultMap: { [language: string]: string[] }) {
const suites = languages.map(l => l + '-code-scanning.qls');
await runResolveQueries(resultMap, suites, undefined, false);
} }
// The set of acceptable values for built-in suites from the codeql bundle // The set of acceptable values for built-in suites from the codeql bundle
const builtinSuites = ['security-extended', 'security-and-quality'] as const; const builtinSuites = ['security-extended', 'security-and-quality'] as const;
// Derive the union type from the array values
type BuiltInSuite = typeof builtinSuites[number];
/** export class Config {
* Determine the set of queries associated with suiteName's suites and add them to resultMap. public name = "";
* Throws an error if suiteName is not a valid builtin suite. public disableDefaultQueries = false;
*/ public additionalQueries: string[] = [];
async function addBuiltinSuiteQueries( public externalQueries: ExternalQuery[] = [];
configFile: string, public additionalSuites: BuiltInSuite[] = [];
languages: string[], public pathsIgnore: string[] = [];
resultMap: { [language: string]: string[] }, public paths: string[] = [];
suiteName: string) {
const suite = builtinSuites.find((suite) => suite === suiteName); public addQuery(configFile: string, queryUses: string) {
if (!suite) { // The logic for parsing the string is based on what actions does for
throw new Error(getQueryUsesInvalid(configFile, suiteName)); // parsing the 'uses' actions in the workflow file
queryUses = queryUses.trim();
if (queryUses === "") {
throw new Error(getQueryUsesInvalid(configFile));
}
// Check for the local path case before we start trying to parse the repository name
if (queryUses.startsWith("./")) {
const localQueryPath = queryUses.slice(2);
// Resolve the local path against the workspace so that when this is
// passed to codeql it resolves to exactly the path we expect it to resolve to.
const workspacePath = fs.realpathSync(util.getRequiredEnvParam('GITHUB_WORKSPACE'));
let absoluteQueryPath = path.join(workspacePath, localQueryPath);
// Check the file exists
if (!fs.existsSync(absoluteQueryPath)) {
throw new Error(getLocalPathDoesNotExist(configFile, localQueryPath));
}
// Call this after checking file exists, because it'll fail if file doesn't exist
absoluteQueryPath = fs.realpathSync(absoluteQueryPath);
// Check the local path doesn't jump outside the repo using '..' or symlinks
if (!(absoluteQueryPath + path.sep).startsWith(workspacePath + path.sep)) {
throw new Error(getLocalPathOutsideOfRepository(configFile, localQueryPath));
}
this.additionalQueries.push(absoluteQueryPath);
return;
}
// Check for one of the builtin suites
if (queryUses.indexOf('/') === -1 && queryUses.indexOf('@') === -1) {
const suite = builtinSuites.find((suite) => suite === queryUses);
if (suite) {
this.additionalSuites.push(suite);
return;
} else {
throw new Error(getQueryUsesInvalid(configFile, queryUses));
}
}
let tok = queryUses.split('@');
if (tok.length !== 2) {
throw new Error(getQueryUsesInvalid(configFile, queryUses));
}
const ref = tok[1];
tok = tok[0].split('/');
// The first token is the owner
// The second token is the repo
// The rest is a path, if there is more than one token combine them to form the full path
if (tok.length < 2) {
throw new Error(getQueryUsesInvalid(configFile, queryUses));
}
if (tok.length > 3) {
tok = [tok[0], tok[1], tok.slice(2).join('/')];
}
// Check none of the parts of the repository name are empty
if (tok[0].trim() === '' || tok[1].trim() === '') {
throw new Error(getQueryUsesInvalid(configFile, queryUses));
}
let external = new ExternalQuery(tok[0] + '/' + tok[1], ref);
if (tok.length === 3) {
external.path = tok[2];
}
this.externalQueries.push(external);
} }
const suites = languages.map(l => l + '-' + suiteName + '.qls');
await runResolveQueries(resultMap, suites, undefined, false);
}
/**
* Retrieve the set of queries at localQueryPath and add them to resultMap.
*/
async function addLocalQueries(
configFile: string,
resultMap: { [language: string]: string[] },
localQueryPath: string) {
// Resolve the local path against the workspace so that when this is
// passed to codeql it resolves to exactly the path we expect it to resolve to.
const workspacePath = fs.realpathSync(util.getRequiredEnvParam('GITHUB_WORKSPACE'));
let absoluteQueryPath = path.join(workspacePath, localQueryPath);
// Check the file exists
if (!fs.existsSync(absoluteQueryPath)) {
throw new Error(getLocalPathDoesNotExist(configFile, localQueryPath));
}
// Call this after checking file exists, because it'll fail if file doesn't exist
absoluteQueryPath = fs.realpathSync(absoluteQueryPath);
// Check the local path doesn't jump outside the repo using '..' or symlinks
if (!(absoluteQueryPath + path.sep).startsWith(workspacePath + path.sep)) {
throw new Error(getLocalPathOutsideOfRepository(configFile, localQueryPath));
}
// Get the root of the current repo to use when resolving query dependencies
const rootOfRepo = util.getRequiredEnvParam('GITHUB_WORKSPACE');
await runResolveQueries(resultMap, [absoluteQueryPath], rootOfRepo, true);
}
/**
* Retrieve the set of queries at the referenced remote repo and add them to resultMap.
*/
async function addRemoteQueries(configFile: string, resultMap: { [language: string]: string[] }, queryUses: string) {
let tok = queryUses.split('@');
if (tok.length !== 2) {
throw new Error(getQueryUsesInvalid(configFile, queryUses));
}
const ref = tok[1];
tok = tok[0].split('/');
// The first token is the owner
// The second token is the repo
// The rest is a path, if there is more than one token combine them to form the full path
if (tok.length < 2) {
throw new Error(getQueryUsesInvalid(configFile, queryUses));
}
// Check none of the parts of the repository name are empty
if (tok[0].trim() === '' || tok[1].trim() === '') {
throw new Error(getQueryUsesInvalid(configFile, queryUses));
}
const nwo = tok[0] + '/' + tok[1];
// Checkout the external repository
const rootOfRepo = await externalQueries.checkoutExternalRepository(nwo, ref);
const queryPath = tok.length > 2
? path.join(rootOfRepo, tok.slice(2).join('/'))
: rootOfRepo;
await runResolveQueries(resultMap, [queryPath], rootOfRepo, true);
}
/**
* Parse a query 'uses' field to a discrete set of query files and update resultMap.
*
* The logic for parsing the string is based on what actions does for
* parsing the 'uses' actions in the workflow file. So it can handle
* local paths starting with './', or references to remote repos, or
* a finite set of hardcoded terms for builtin suites.
*/
async function parseQueryUses(
configFile: string,
languages: string[],
resultMap: { [language: string]: string[] },
queryUses: string) {
queryUses = queryUses.trim();
if (queryUses === "") {
throw new Error(getQueryUsesInvalid(configFile));
}
// Check for the local path case before we start trying to parse the repository name
if (queryUses.startsWith("./")) {
await addLocalQueries(configFile, resultMap, queryUses.slice(2));
return;
}
// Check for one of the builtin suites
if (queryUses.indexOf('/') === -1 && queryUses.indexOf('@') === -1) {
await addBuiltinSuiteQueries(configFile, languages, resultMap, queryUses);
return;
}
// Otherwise, must be a reference to another repo
await addRemoteQueries(configFile, resultMap, queryUses);
} }
// Regex validating stars in paths or paths-ignore entries. // Regex validating stars in paths or paths-ignore entries.
@@ -315,7 +189,7 @@ export function getNameInvalid(configFile: string): string {
} }
export function getDisableDefaultQueriesInvalid(configFile: string): string { export function getDisableDefaultQueriesInvalid(configFile: string): string {
return getConfigFilePropertyError(configFile, DISABLE_DEFAULT_QUERIES_PROPERTY, 'must be a boolean'); return getConfigFilePropertyError(configFile, DISPLAY_DEFAULT_QUERIES_PROPERTY, 'must be a boolean');
} }
export function getQueriesInvalid(configFile: string): string { export function getQueriesInvalid(configFile: string): string {
@@ -380,94 +254,17 @@ function getConfigFilePropertyError(configFile: string, property: string, error:
return 'The configuration file "' + configFile + '" is invalid: property "' + property + '" ' + error; return 'The configuration file "' + configFile + '" is invalid: property "' + property + '" ' + error;
} }
/** async function initConfig(): Promise<Config> {
* Gets the set of languages in the current repository let configFile = core.getInput('config-file');
*/
async function getLanguagesInRepo(): Promise<string[]> {
// Translate between GitHub's API names for languages and ours
const codeqlLanguages = {
'C': 'cpp',
'C++': 'cpp',
'C#': 'csharp',
'Go': 'go',
'Java': 'java',
'JavaScript': 'javascript',
'TypeScript': 'javascript',
'Python': 'python',
};
let repo_nwo = process.env['GITHUB_REPOSITORY']?.split("/");
if (repo_nwo) {
let owner = repo_nwo[0];
let repo = repo_nwo[1];
core.debug(`GitHub repo ${owner} ${repo}`); const config = new Config();
const response = await api.getApiClient().request("GET /repos/:owner/:repo/languages", ({
owner,
repo
}));
core.debug("Languages API response: " + JSON.stringify(response)); // If no config file was provided create an empty one
if (configFile === '') {
// The GitHub API is going to return languages in order of popularity, core.debug('No configuration file was provided');
// When we pick a language to autobuild we want to pick the most popular traced language return config;
// Since sets in javascript maintain insertion order, using a set here and then splatting it
// into an array gives us an array of languages ordered by popularity
let languages: Set<string> = new Set();
for (let lang in response.data) {
if (lang in codeqlLanguages) {
languages.add(codeqlLanguages[lang]);
}
}
return [...languages];
} else {
return [];
}
}
/**
* Get the languages to analyse.
*
* The result is obtained from the action input parameter 'languages' if that
* has been set, otherwise it is deduced as all languages in the repo that
* can be analysed.
*/
async function getLanguages(): Promise<string[]> {
// Obtain from action input 'languages' if set
let languages = core.getInput('languages', { required: false })
.split(',')
.map(x => x.trim())
.filter(x => x.length > 0);
core.info("Languages from configuration: " + JSON.stringify(languages));
if (languages.length === 0) {
// Obtain languages as all languages in the repo that can be analysed
languages = await getLanguagesInRepo();
core.info("Automatically detected languages: " + JSON.stringify(languages));
} }
return languages;
}
/**
* Get the default config for when the user has not supplied one.
*/
export async function getDefaultConfig(): Promise<Config> {
const languages = await getLanguages();
const queries = {};
await addDefaultQueries(languages, queries);
return {
languages: languages,
queries: queries,
pathsIgnore: [],
paths: []
};
}
/**
* Load the config from the given file.
*/
async function loadConfig(configFile: string): Promise<Config> {
let parsedYAML; let parsedYAML;
if (isLocal(configFile)) { if (isLocal(configFile)) {
@@ -480,8 +277,6 @@ async function loadConfig(configFile: string): Promise<Config> {
parsedYAML = await getRemoteConfig(configFile); parsedYAML = await getRemoteConfig(configFile);
} }
// Validate that the 'name' property is syntactically correct,
// even though we don't use the value yet.
if (NAME_PROPERTY in parsedYAML) { if (NAME_PROPERTY in parsedYAML) {
if (typeof parsedYAML[NAME_PROPERTY] !== "string") { if (typeof parsedYAML[NAME_PROPERTY] !== "string") {
throw new Error(getNameInvalid(configFile)); throw new Error(getNameInvalid(configFile));
@@ -489,40 +284,26 @@ async function loadConfig(configFile: string): Promise<Config> {
if (parsedYAML[NAME_PROPERTY].length === 0) { if (parsedYAML[NAME_PROPERTY].length === 0) {
throw new Error(getNameInvalid(configFile)); throw new Error(getNameInvalid(configFile));
} }
config.name = parsedYAML[NAME_PROPERTY];
} }
const languages = await getLanguages(); if (DISPLAY_DEFAULT_QUERIES_PROPERTY in parsedYAML) {
// If the languages parameter was not given and no languages were if (typeof parsedYAML[DISPLAY_DEFAULT_QUERIES_PROPERTY] !== "boolean") {
// detected then fail here as this is a workflow configuration error.
if (languages.length === 0) {
throw new Error("Did not detect any languages to analyze. Please update input in workflow.");
}
const queries = {};
const pathsIgnore: string[] = [];
const paths: string[] = [];
let disableDefaultQueries = false;
if (DISABLE_DEFAULT_QUERIES_PROPERTY in parsedYAML) {
if (typeof parsedYAML[DISABLE_DEFAULT_QUERIES_PROPERTY] !== "boolean") {
throw new Error(getDisableDefaultQueriesInvalid(configFile)); throw new Error(getDisableDefaultQueriesInvalid(configFile));
} }
disableDefaultQueries = parsedYAML[DISABLE_DEFAULT_QUERIES_PROPERTY]; config.disableDefaultQueries = parsedYAML[DISPLAY_DEFAULT_QUERIES_PROPERTY];
}
if (!disableDefaultQueries) {
await addDefaultQueries(languages, queries);
} }
if (QUERIES_PROPERTY in parsedYAML) { if (QUERIES_PROPERTY in parsedYAML) {
if (!(parsedYAML[QUERIES_PROPERTY] instanceof Array)) { if (!(parsedYAML[QUERIES_PROPERTY] instanceof Array)) {
throw new Error(getQueriesInvalid(configFile)); throw new Error(getQueriesInvalid(configFile));
} }
for (const query of parsedYAML[QUERIES_PROPERTY]) { parsedYAML[QUERIES_PROPERTY].forEach(query => {
if (!(QUERIES_USES_PROPERTY in query) || typeof query[QUERIES_USES_PROPERTY] !== "string") { if (!(QUERIES_USES_PROPERTY in query) || typeof query[QUERIES_USES_PROPERTY] !== "string") {
throw new Error(getQueryUsesInvalid(configFile)); throw new Error(getQueryUsesInvalid(configFile));
} }
await parseQueryUses(configFile, languages, queries, query[QUERIES_USES_PROPERTY]); config.addQuery(configFile, query[QUERIES_USES_PROPERTY]);
} });
} }
if (PATHS_IGNORE_PROPERTY in parsedYAML) { if (PATHS_IGNORE_PROPERTY in parsedYAML) {
@@ -533,7 +314,7 @@ async function loadConfig(configFile: string): Promise<Config> {
if (typeof path !== "string" || path === '') { if (typeof path !== "string" || path === '') {
throw new Error(getPathsIgnoreInvalid(configFile)); throw new Error(getPathsIgnoreInvalid(configFile));
} }
pathsIgnore.push(validateAndSanitisePath(path, PATHS_IGNORE_PROPERTY, configFile)); config.pathsIgnore.push(validateAndSanitisePath(path, PATHS_IGNORE_PROPERTY, configFile));
}); });
} }
@@ -545,33 +326,10 @@ async function loadConfig(configFile: string): Promise<Config> {
if (typeof path !== "string" || path === '') { if (typeof path !== "string" || path === '') {
throw new Error(getPathsInvalid(configFile)); throw new Error(getPathsInvalid(configFile));
} }
paths.push(validateAndSanitisePath(path, PATHS_PROPERTY, configFile)); config.paths.push(validateAndSanitisePath(path, PATHS_PROPERTY, configFile));
}); });
} }
return {languages, queries, pathsIgnore, paths};
}
/**
* Load and return the config.
*
* 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.
*/
export async function initConfig(): Promise<Config> {
const configFile = core.getInput('config-file');
let config: Config;
// If no config file was provided create an empty one
if (configFile === '') {
core.debug('No configuration file was provided');
config = await getDefaultConfig();
} else {
config = await loadConfig(configFile);
}
// Save the config so we can easily access it again in the future
await saveConfig(config);
return config; return config;
} }
@@ -626,46 +384,35 @@ async function getRemoteConfig(configFile: string): Promise<any> {
return yaml.safeLoad(Buffer.from(fileContents, 'base64').toString('binary')); return yaml.safeLoad(Buffer.from(fileContents, 'base64').toString('binary'));
} }
/** function getConfigFolder(): string {
* Get the directory where the parsed config will be stored.
*/
function getPathToParsedConfigFolder(): string {
return util.getRequiredEnvParam('RUNNER_TEMP'); return util.getRequiredEnvParam('RUNNER_TEMP');
} }
/** export function getConfigFile(): string {
* Get the file path where the parsed config will be stored. return path.join(getConfigFolder(), 'config');
*/
export function getPathToParsedConfigFile(): string {
return path.join(getPathToParsedConfigFolder(), 'config');
} }
/**
* Store the given config to the path returned from getPathToParsedConfigFile.
*/
async function saveConfig(config: Config) { async function saveConfig(config: Config) {
const configString = JSON.stringify(config); const configString = JSON.stringify(config);
await io.mkdirP(getPathToParsedConfigFolder()); await io.mkdirP(getConfigFolder());
fs.writeFileSync(getPathToParsedConfigFile(), configString, 'utf8'); fs.writeFileSync(getConfigFile(), configString, 'utf8');
core.debug('Saved config:'); core.debug('Saved config:');
core.debug(configString); core.debug(configString);
} }
/** export async function loadConfig(): Promise<Config> {
* Get the config. const configFile = getConfigFile();
* if (fs.existsSync(configFile)) {
* If this is the first time in a workflow that this is being called then const configString = fs.readFileSync(configFile, 'utf8');
* this will parse the config from the user input. The parsed config is then core.debug('Loaded config:');
* stored to a known location. On the second and further calls, this will core.debug(configString);
* return the contents of the parsed config from the known location. return JSON.parse(configString);
*/
export async function getConfig(): Promise<Config> { } else {
const configFile = getPathToParsedConfigFile(); const config = await initConfig();
if (!fs.existsSync(configFile)) { core.debug('Initialized config:');
throw new Error("Config file could not be found at expected location. Has the 'init' action been called?"); core.debug(JSON.stringify(config));
await saveConfig(config);
return config;
} }
const configString = fs.readFileSync(configFile, 'utf8');
core.debug('Loaded config:');
core.debug(configString);
return JSON.parse(configString);
} }
+8 -2
View File
@@ -2,6 +2,7 @@ import test from 'ava';
import * as fs from "fs"; import * as fs from "fs";
import * as path from "path"; import * as path from "path";
import * as configUtils from "./config-utils";
import * as externalQueries from "./external-queries"; import * as externalQueries from "./external-queries";
import {setupTests} from './testing-utils'; import {setupTests} from './testing-utils';
import * as util from "./util"; import * as util from "./util";
@@ -9,11 +10,16 @@ import * as util from "./util";
setupTests(test); setupTests(test);
test("checkoutExternalQueries", async t => { test("checkoutExternalQueries", async t => {
let config = new configUtils.Config();
config.externalQueries = [
new configUtils.ExternalQuery("github/codeql-go", "df4c6869212341b601005567381944ed90906b6b"),
];
await util.withTmpDir(async tmpDir => { await util.withTmpDir(async tmpDir => {
process.env["RUNNER_TEMP"] = tmpDir; process.env["RUNNER_TEMP"] = tmpDir;
await externalQueries.checkoutExternalRepository("github/codeql-go", "df4c6869212341b601005567381944ed90906b6b"); await externalQueries.checkoutExternalQueries(config);
// COPYRIGHT file existed in df4c6869212341b601005567381944ed90906b6b but not in the default branch // COPYRIGHT file existed in df4c6869212341b601005567381944ed90906b6b but not in master
t.true(fs.existsSync(path.join(tmpDir, "github", "codeql-go", "COPYRIGHT"))); t.true(fs.existsSync(path.join(tmpDir, "github", "codeql-go", "COPYRIGHT")));
}); });
}); });
+16 -16
View File
@@ -3,26 +3,26 @@ import * as exec from '@actions/exec';
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
import * as configUtils from './config-utils';
import * as util from './util'; import * as util from './util';
/** export async function checkoutExternalQueries(config: configUtils.Config) {
* Check out repository at the given ref, and return the directory of the checkout.
*/
export async function checkoutExternalRepository(repository: string, ref: string): Promise<string> {
const folder = util.getRequiredEnvParam('RUNNER_TEMP'); const folder = util.getRequiredEnvParam('RUNNER_TEMP');
core.info('Checking out ' + repository); for (const externalQuery of config.externalQueries) {
core.info('Checking out ' + externalQuery.repository);
const checkoutLocation = path.join(folder, repository); const checkoutLocation = path.join(folder, externalQuery.repository);
if (!fs.existsSync(checkoutLocation)) { if (!fs.existsSync(checkoutLocation)) {
const repoURL = 'https://github.com/' + repository + '.git'; const repoURL = 'https://github.com/' + externalQuery.repository + '.git';
await exec.exec('git', ['clone', repoURL, checkoutLocation]); await exec.exec('git', ['clone', repoURL, checkoutLocation]);
await exec.exec('git', [ await exec.exec('git', [
'--work-tree=' + checkoutLocation, '--work-tree=' + checkoutLocation,
'--git-dir=' + checkoutLocation + '/.git', '--git-dir=' + checkoutLocation + '/.git',
'checkout', ref, 'checkout', externalQuery.ref,
]); ]);
}
config.additionalQueries.push(path.join(checkoutLocation, externalQuery.path));
} }
return checkoutLocation;
} }
+80 -38
View File
@@ -1,43 +1,34 @@
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as exec from '@actions/exec';
import * as io from '@actions/io'; import * as io from '@actions/io';
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
import { getCodeQL } from './codeql'; import { getCodeQL } from './codeql';
import * as configUtils from './config-utils'; import * as configUtils from './config-utils';
import * as externalQueries from "./external-queries";
import * as sharedEnv from './shared-environment'; import * as sharedEnv from './shared-environment';
import * as upload_lib from './upload-lib'; import * as upload_lib from './upload-lib';
import * as util from './util'; import * as util from './util';
/**
* A list of queries from https://github.com/github/codeql that
* we don't want to run. Disabling them here is a quicker alternative to
* disabling them in the code scanning query suites. Queries should also
* be disabled in the suites, and removed from this list here once the
* bundle is updated to make those suite changes live.
*
* Format is a map from language to an array of path suffixes of .ql files.
*/
const DISABLED_BUILTIN_QUERIES: {[language: string]: string[]} = {
'csharp': [
'ql/src/Security Features/CWE-937/VulnerablePackage.ql',
'ql/src/Security Features/CWE-451/MissingXFrameOptions.ql',
]
};
async function setupPythonExtractor() { function queryIsDisabled(language, query): boolean {
const codeqlPython = process.env["CODEQL_PYTHON"]; return (DISABLED_BUILTIN_QUERIES[language] || [])
if (codeqlPython === undefined || codeqlPython.length === 0) { .some(disabledQuery => query.endsWith(disabledQuery));
// If CODEQL_PYTHON is not set, no dependencies were installed, so we don't need to do anything
return;
}
let output = '';
const options = {
listeners: {
stdout: (data: Buffer) => {
output += data.toString();
}
}
};
await exec.exec(
codeqlPython,
['-c', 'import os; import pip; print(os.path.dirname(os.path.dirname(pip.__file__)))'],
options);
core.info('Setting LGTM_INDEX_IMPORT_PATH=' + output);
process.env['LGTM_INDEX_IMPORT_PATH'] = output;
output = '';
await exec.exec(codeqlPython, ['-c', 'import sys; print(sys.version_info[0])'], options);
core.info('Setting LGTM_PYTHON_SETUP_VERSION=' + output);
process.env['LGTM_PYTHON_SETUP_VERSION'] = output;
} }
async function createdDBForScannedLanguages(databaseFolder: string) { async function createdDBForScannedLanguages(databaseFolder: string) {
@@ -46,35 +37,84 @@ async function createdDBForScannedLanguages(databaseFolder: string) {
const codeql = getCodeQL(); const codeql = getCodeQL();
for (const language of scannedLanguages.split(',')) { for (const language of scannedLanguages.split(',')) {
core.startGroup('Extracting ' + language); core.startGroup('Extracting ' + language);
if (language === 'python') {
await setupPythonExtractor();
}
await codeql.extractScannedLanguage(path.join(databaseFolder, language), language); await codeql.extractScannedLanguage(path.join(databaseFolder, language), language);
core.endGroup(); core.endGroup();
} }
} }
} }
async function finalizeDatabaseCreation(databaseFolder: string, config: configUtils.Config) { async function finalizeDatabaseCreation(databaseFolder: string) {
await createdDBForScannedLanguages(databaseFolder); await createdDBForScannedLanguages(databaseFolder);
const languages = process.env[sharedEnv.CODEQL_ACTION_LANGUAGES] || '';
const codeql = getCodeQL(); const codeql = getCodeQL();
for (const language of config.languages) { for (const language of languages.split(',')) {
core.startGroup('Finalizing ' + language); core.startGroup('Finalizing ' + language);
await codeql.finalizeDatabase(path.join(databaseFolder, language)); await codeql.finalizeDatabase(path.join(databaseFolder, language));
core.endGroup(); core.endGroup();
} }
} }
async function resolveQueryLanguages(config: configUtils.Config): Promise<Map<string, string[]>> {
let res = new Map();
const codeql = getCodeQL();
if (!config.disableDefaultQueries || config.additionalSuites.length !== 0) {
const suites: string[] = [];
for (const language of await util.getLanguages()) {
if (!config.disableDefaultQueries) {
suites.push(language + '-code-scanning.qls');
}
for (const additionalSuite of config.additionalSuites) {
suites.push(language + '-' + additionalSuite + '.qls');
}
}
const resolveQueriesOutputObject = await codeql.resolveQueries(suites);
for (const [language, queries] of Object.entries(resolveQueriesOutputObject.byLanguage)) {
if (res[language] === undefined) {
res[language] = [];
}
res[language].push(...Object.keys(queries).filter(q => !queryIsDisabled(language, q)));
}
}
if (config.additionalQueries.length !== 0) {
const resolveQueriesOutputObject = await codeql.resolveQueries(config.additionalQueries);
for (const [language, queries] of Object.entries(resolveQueriesOutputObject.byLanguage)) {
if (res[language] === undefined) {
res[language] = [];
}
res[language].push(...Object.keys(queries));
}
const noDeclaredLanguage = resolveQueriesOutputObject.noDeclaredLanguage;
const noDeclaredLanguageQueries = Object.keys(noDeclaredLanguage);
if (noDeclaredLanguageQueries.length !== 0) {
throw new Error('Some queries do not declare a language, their qlpack.yml file is missing or is invalid');
}
const multipleDeclaredLanguages = resolveQueriesOutputObject.multipleDeclaredLanguages;
const multipleDeclaredLanguagesQueries = Object.keys(multipleDeclaredLanguages);
if (multipleDeclaredLanguagesQueries.length !== 0) {
throw new Error('Some queries declare multiple languages, their qlpack.yml file is missing or is invalid');
}
}
return res;
}
// Runs queries and creates sarif files in the given folder // Runs queries and creates sarif files in the given folder
async function runQueries(databaseFolder: string, sarifFolder: string, config: configUtils.Config) { async function runQueries(databaseFolder: string, sarifFolder: string, config: configUtils.Config) {
const queriesPerLanguage = await resolveQueryLanguages(config);
const codeql = getCodeQL(); const codeql = getCodeQL();
for (let database of fs.readdirSync(databaseFolder)) { for (let database of fs.readdirSync(databaseFolder)) {
core.startGroup('Analyzing ' + database); core.startGroup('Analyzing ' + database);
const queries = config.queries[database] || []; const queries = queriesPerLanguage[database] || [];
if (queries.length === 0) { if (queries.length === 0) {
throw new Error('Unable to analyse ' + database + ' as no queries were selected for this language'); throw new Error('Unable to analyse ' + database + ' as no queries were selected for this language');
} }
@@ -100,7 +140,7 @@ async function run() {
if (util.should_abort('finish', true) || !await util.reportActionStarting('finish')) { if (util.should_abort('finish', true) || !await util.reportActionStarting('finish')) {
return; return;
} }
const config = await configUtils.getConfig(); const config = await configUtils.loadConfig();
core.exportVariable(sharedEnv.ODASA_TRACER_CONFIGURATION, ''); core.exportVariable(sharedEnv.ODASA_TRACER_CONFIGURATION, '');
delete process.env[sharedEnv.ODASA_TRACER_CONFIGURATION]; delete process.env[sharedEnv.ODASA_TRACER_CONFIGURATION];
@@ -111,7 +151,9 @@ async function run() {
await io.mkdirP(sarifFolder); await io.mkdirP(sarifFolder);
core.info('Finalizing database creation'); core.info('Finalizing database creation');
await finalizeDatabaseCreation(databaseFolder, config); await finalizeDatabaseCreation(databaseFolder);
await externalQueries.checkoutExternalQueries(config);
core.info('Analyzing database'); core.info('Analyzing database');
await runQueries(databaseFolder, sarifFolder, config); await runQueries(databaseFolder, sarifFolder, config);
+20 -52
View File
@@ -1,7 +1,6 @@
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as exec from '@actions/exec'; import * as exec from '@actions/exec';
import * as io from '@actions/io'; import * as io from '@actions/io';
import * as toolcache from '@actions/tool-cache';
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
@@ -132,59 +131,28 @@ function concatTracerConfigs(configs: { [lang: string]: TracerConfig }): TracerC
return { env, spec }; return { env, spec };
} }
async function installPythonDeps(codeql: CodeQL) {
core.startGroup('Setup Python dependencies');
let scriptsFolder = '';
try {
const repoPath = await toolcache.downloadTool('https://github.com/Daverlo/codeql-python-autobuild/archive/master.zip');
const extracted = await toolcache.extractZip(repoPath);
scriptsFolder = path.join(extracted, 'codeql-python-autobuild-master');
} catch (e) {
// The download should not fail, but in case it fails we just abort trying to setup the python deps
core.warning('Unable to download and extract the scripts needed for installing the python dependecies');
core.endGroup();
return;
}
// Setup tools
try {
await exec.exec(path.join(scriptsFolder, 'install_tools.sh'));
} catch (e) {
// This script tries to install some needed tools in the runner. It should not fail, but if it does
// we just abort the process without failing the action
core.warning('Unable to download and extract the scripts needed for installing the python dependecies');
core.endGroup();
return;
}
// Install dependencies
try {
await exec.exec(path.join(scriptsFolder, 'auto_install_packages.py'), [codeql.getDir()]);
} catch (e) {
core.endGroup();
throw new Error('We were unable to install your python dependencies. You can call this action with "setup-python-dependencies: false" to disable this process');
}
core.endGroup();
}
async function run() { async function run() {
let config: configUtils.Config; let languages: string[];
let codeql: CodeQL;
try { try {
if (util.should_abort('init', false) || !await util.reportActionStarting('init')) { if (util.should_abort('init', false) || !await util.reportActionStarting('init')) {
return; return;
} }
core.startGroup('Setup CodeQL tools');
codeql = await setupCodeQL();
await codeql.printVersion();
core.endGroup();
core.startGroup('Load language configuration'); core.startGroup('Load language configuration');
config = await configUtils.initConfig();
analysisPaths.includeAndExcludeAnalysisPaths(config); const config = await configUtils.loadConfig();
languages = await util.getLanguages();
// If the languages parameter was not given and no languages were
// detected then fail here as this is a workflow configuration error.
if (languages.length === 0) {
throw new Error("Did not detect any languages to analyze. Please [update the languages property](https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection) in your workflow definition.");
}
analysisPaths.includeAndExcludeAnalysisPaths(config, languages);
core.endGroup(); core.endGroup();
} catch (e) { } catch (e) {
@@ -197,6 +165,11 @@ async function run() {
const sourceRoot = path.resolve(); const sourceRoot = path.resolve();
core.startGroup('Setup CodeQL tools');
const codeql = await setupCodeQL();
await codeql.printVersion();
core.endGroup();
// Forward Go flags // Forward Go flags
const goFlags = process.env['GOFLAGS']; const goFlags = process.env['GOFLAGS'];
if (goFlags) { if (goFlags) {
@@ -204,11 +177,6 @@ async function run() {
core.warning("Passing the GOFLAGS env parameter to the init action is deprecated. Please move this to the analyze action."); core.warning("Passing the GOFLAGS env parameter to the init action is deprecated. Please move this to the analyze action.");
} }
const setupPythonDependencies = core.getInput('setup-python-dependencies', { required: true });
if (config.languages.includes('python') && setupPythonDependencies === 'true') {
await installPythonDeps(codeql);
}
// Setup CODEQL_RAM flag (todo improve this https://github.com/github/dsp-code-scanning/issues/935) // Setup CODEQL_RAM flag (todo improve this https://github.com/github/dsp-code-scanning/issues/935)
const codeqlRam = process.env['CODEQL_RAM'] || '6500'; const codeqlRam = process.env['CODEQL_RAM'] || '6500';
core.exportVariable('CODEQL_RAM', codeqlRam); core.exportVariable('CODEQL_RAM', codeqlRam);
@@ -219,7 +187,7 @@ async function run() {
let tracedLanguages: { [key: string]: TracerConfig } = {}; let tracedLanguages: { [key: string]: TracerConfig } = {};
let scannedLanguages: string[] = []; let scannedLanguages: string[] = [];
// TODO: replace this code once CodeQL supports multi-language tracing // TODO: replace this code once CodeQL supports multi-language tracing
for (let language of config.languages) { for (let language of languages) {
const languageDatabase = path.join(databaseFolder, language); const languageDatabase = path.join(databaseFolder, language);
// Init language database // Init language database
@@ -275,6 +243,6 @@ async function run() {
} }
run().catch(e => { run().catch(e => {
core.setFailed("init action failed: " + e); core.setFailed("Init action failed: " + e);
console.log(e); console.log(e);
}); });
+1
View File
@@ -1,4 +1,5 @@
export const CODEQL_ACTION_DATABASE_DIR = 'CODEQL_ACTION_DATABASE_DIR'; export const CODEQL_ACTION_DATABASE_DIR = 'CODEQL_ACTION_DATABASE_DIR';
export const CODEQL_ACTION_LANGUAGES = 'CODEQL_ACTION_LANGUAGES';
export const CODEQL_ACTION_ANALYSIS_KEY = 'CODEQL_ACTION_ANALYSIS_KEY'; export const CODEQL_ACTION_ANALYSIS_KEY = 'CODEQL_ACTION_ANALYSIS_KEY';
export const ODASA_TRACER_CONFIGURATION = 'ODASA_TRACER_CONFIGURATION'; export const ODASA_TRACER_CONFIGURATION = 'ODASA_TRACER_CONFIGURATION';
export const CODEQL_ACTION_SCANNED_LANGUAGES = 'CODEQL_ACTION_SCANNED_LANGUAGES'; export const CODEQL_ACTION_SCANNED_LANGUAGES = 'CODEQL_ACTION_SCANNED_LANGUAGES';
+6 -20
View File
@@ -1,9 +1,7 @@
import {TestInterface} from 'ava'; import {TestInterface} from 'ava';
import sinon from 'sinon'; import sinon from 'sinon';
import * as CodeQL from './codeql'; type TestContext = {stdoutWrite: any, stderrWrite: any, testOutput: string};
type TestContext = {stdoutWrite: any, stderrWrite: any, testOutput: string, env: NodeJS.ProcessEnv};
function wrapOutput(context: TestContext) { function wrapOutput(context: TestContext) {
// Function signature taken from Socket.write. // Function signature taken from Socket.write.
@@ -37,39 +35,27 @@ export function setupTests(test: TestInterface<any>) {
const typedTest = test as TestInterface<TestContext>; const typedTest = test as TestInterface<TestContext>;
typedTest.beforeEach(t => { typedTest.beforeEach(t => {
// Set an empty CodeQL object so that all method calls will fail
// unless the test explicitly sets one up.
CodeQL.setCodeQL({});
// Replace stdout and stderr so we can record output during tests
t.context.testOutput = ""; t.context.testOutput = "";
const processStdoutWrite = process.stdout.write.bind(process.stdout); const processStdoutWrite = process.stdout.write.bind(process.stdout);
t.context.stdoutWrite = processStdoutWrite; t.context.stdoutWrite = processStdoutWrite;
process.stdout.write = wrapOutput(t.context) as any; process.stdout.write = wrapOutput(t.context) as any;
const processStderrWrite = process.stderr.write.bind(process.stderr); const processStderrWrite = process.stderr.write.bind(process.stderr);
t.context.stderrWrite = processStderrWrite; t.context.stderrWrite = processStderrWrite;
process.stderr.write = wrapOutput(t.context) as any; process.stderr.write = wrapOutput(t.context) as any;
// Many tests modify environment variables. Take a copy now so that
// we reset them after the test to keep tests independent of each other.
// process.env only has strings fields, so a shallow copy is fine.
t.context.env = {};
Object.assign(t.context.env, process.env);
}); });
typedTest.afterEach.always(t => { typedTest.afterEach.always(t => {
// Restore stdout and stderr
// The captured output is only replayed if the test failed
process.stdout.write = t.context.stdoutWrite; process.stdout.write = t.context.stdoutWrite;
process.stderr.write = t.context.stderrWrite; process.stderr.write = t.context.stderrWrite;
if (!t.passed) { if (!t.passed) {
process.stdout.write(t.context.testOutput); process.stdout.write(t.context.testOutput);
} }
});
// Undo any modifications made by sinon typedTest.afterEach.always(() => {
sinon.restore(); sinon.restore();
// Undo any modifications to the env
process.env = t.context.env;
}); });
} }
+92 -24
View File
@@ -5,7 +5,6 @@ import * as os from 'os';
import * as path from 'path'; import * as path from 'path';
import * as api from './api-client'; import * as api from './api-client';
import * as configUtils from './config-utils';
import * as sharedEnv from './shared-environment'; import * as sharedEnv from './shared-environment';
/** /**
@@ -45,6 +44,89 @@ export function getRequiredEnvParam(paramName: string): string {
return value; return value;
} }
/**
* Gets the set of languages in the current repository
*/
async function getLanguagesInRepo(): Promise<string[]> {
// Translate between GitHub's API names for languages and ours
const codeqlLanguages = {
'C': 'cpp',
'C++': 'cpp',
'C#': 'csharp',
'Go': 'go',
'Java': 'java',
'JavaScript': 'javascript',
'TypeScript': 'javascript',
'Python': 'python',
};
let repo_nwo = process.env['GITHUB_REPOSITORY']?.split("/");
if (repo_nwo) {
let owner = repo_nwo[0];
let repo = repo_nwo[1];
core.debug(`GitHub repo ${owner} ${repo}`);
const response = await api.getApiClient().request("GET /repos/:owner/:repo/languages", ({
owner,
repo
}));
core.debug("Languages API response: " + JSON.stringify(response));
// The GitHub API is going to return languages in order of popularity,
// When we pick a language to autobuild we want to pick the most popular traced language
// Since sets in javascript maintain insertion order, using a set here and then splatting it
// into an array gives us an array of languages ordered by popularity
let languages: Set<string> = new Set();
for (let lang in response.data) {
if (lang in codeqlLanguages) {
languages.add(codeqlLanguages[lang]);
}
}
return [...languages];
} else {
return [];
}
}
/**
* Get the languages to analyse.
*
* The result is obtained from the environment parameter CODEQL_ACTION_LANGUAGES
* if that has been set, otherwise it is obtained from the action input parameter
* 'languages' if that has been set, otherwise it is deduced as all languages in the
* repo that can be analysed.
*
* If the languages are obtained from either of the second choices, the
* CODEQL_ACTION_LANGUAGES environment variable will be exported with the
* deduced list.
*/
export async function getLanguages(): Promise<string[]> {
// Obtain from CODEQL_ACTION_LANGUAGES if set
const langsVar = process.env[sharedEnv.CODEQL_ACTION_LANGUAGES];
if (langsVar) {
return langsVar.split(',')
.map(x => x.trim())
.filter(x => x.length > 0);
}
// Obtain from action input 'languages' if set
let languages = core.getInput('languages', { required: false })
.split(',')
.map(x => x.trim())
.filter(x => x.length > 0);
core.info("Languages from configuration: " + JSON.stringify(languages));
if (languages.length === 0) {
// Obtain languages as all languages in the repo that can be analysed
languages = await getLanguagesInRepo();
core.info("Automatically detected languages: " + JSON.stringify(languages));
}
core.exportVariable(sharedEnv.CODEQL_ACTION_LANGUAGES, languages.join(','));
return languages;
}
/** /**
* Gets the SHA of the commit that is currently checked out. * Gets the SHA of the commit that is currently checked out.
*/ */
@@ -135,9 +217,6 @@ export function getRef(): string {
} }
} }
type ActionName = 'init' | 'autobuild' | 'finish' | 'upload-sarif';
type ActionStatus = 'starting' | 'aborted' | 'success' | 'failure';
interface StatusReport { interface StatusReport {
"workflow_run_id": number; "workflow_run_id": number;
"workflow_name": string; "workflow_name": string;
@@ -147,11 +226,11 @@ interface StatusReport {
"languages": string; "languages": string;
"commit_oid": string; "commit_oid": string;
"ref": string; "ref": string;
"action_name": ActionName; "action_name": string;
"action_oid": string; "action_oid": string;
"started_at": string; "started_at": string;
"completed_at"?: string; "completed_at"?: string;
"status": ActionStatus; "status": string;
"cause"?: string; "cause"?: string;
"exception"?: string; "exception"?: string;
} }
@@ -165,23 +244,12 @@ interface StatusReport {
* @param exception Exception (only supply if status is 'failure') * @param exception Exception (only supply if status is 'failure')
*/ */
async function createStatusReport( async function createStatusReport(
actionName: ActionName, actionName: string,
status: ActionStatus, status: string,
cause?: string, cause?: string,
exception?: string): exception?: string):
Promise<StatusReport> { Promise<StatusReport> {
// If this is not the init action starting up or aborting then try to load the config.
// If it fails then carry because it's important to still send the status report.
let config: configUtils.Config | undefined = undefined;
if (actionName !== 'init' || (status !== 'starting' && status !== 'aborted')) {
try {
config = await configUtils.getConfig();
} catch (e) {
core.error('Unable to load config: ' + e);
}
}
const commitOid = process.env['GITHUB_SHA'] || ''; const commitOid = process.env['GITHUB_SHA'] || '';
const ref = getRef(); const ref = getRef();
const workflowRunIDStr = process.env['GITHUB_RUN_ID']; const workflowRunIDStr = process.env['GITHUB_RUN_ID'];
@@ -192,7 +260,7 @@ async function createStatusReport(
const workflowName = process.env['GITHUB_WORKFLOW'] || ''; const workflowName = process.env['GITHUB_WORKFLOW'] || '';
const jobName = process.env['GITHUB_JOB'] || ''; const jobName = process.env['GITHUB_JOB'] || '';
const analysis_key = await getAnalysisKey(); const analysis_key = await getAnalysisKey();
const languages = config?.languages?.join(',') || ""; const languages = (await getLanguages()).sort().join(',');
const startedAt = process.env[sharedEnv.CODEQL_ACTION_STARTED_AT] || new Date().toISOString(); const startedAt = process.env[sharedEnv.CODEQL_ACTION_STARTED_AT] || new Date().toISOString();
core.exportVariable(sharedEnv.CODEQL_ACTION_STARTED_AT, startedAt); core.exportVariable(sharedEnv.CODEQL_ACTION_STARTED_AT, startedAt);
@@ -256,7 +324,7 @@ async function sendStatusReport(statusReport: StatusReport): Promise<number> {
* *
* Returns true unless a problem occurred and the action should abort. * Returns true unless a problem occurred and the action should abort.
*/ */
export async function reportActionStarting(action: ActionName): Promise<boolean> { export async function reportActionStarting(action: string): Promise<boolean> {
const statusCode = await sendStatusReport(await createStatusReport(action, 'starting')); const statusCode = await sendStatusReport(await createStatusReport(action, 'starting'));
// If the status report request fails with a 403 or a 404, then this is a deliberate // If the status report request fails with a 403 or a 404, then this is a deliberate
@@ -283,7 +351,7 @@ export async function reportActionStarting(action: ActionName): Promise<boolean>
* Note that the started_at date is always that of the `init` action, since * Note that the started_at date is always that of the `init` action, since
* this is likely to give a more useful duration when inspecting events. * this is likely to give a more useful duration when inspecting events.
*/ */
export async function reportActionFailed(action: ActionName, cause?: string, exception?: string) { export async function reportActionFailed(action: string, cause?: string, exception?: string) {
await sendStatusReport(await createStatusReport(action, 'failure', cause, exception)); await sendStatusReport(await createStatusReport(action, 'failure', cause, exception));
} }
@@ -293,7 +361,7 @@ export async function reportActionFailed(action: ActionName, cause?: string, exc
* Note that the started_at date is always that of the `init` action, since * Note that the started_at date is always that of the `init` action, since
* this is likely to give a more useful duration when inspecting events. * this is likely to give a more useful duration when inspecting events.
*/ */
export async function reportActionSucceeded(action: ActionName) { export async function reportActionSucceeded(action: string) {
await sendStatusReport(await createStatusReport(action, 'success')); await sendStatusReport(await createStatusReport(action, 'success'));
} }
@@ -303,7 +371,7 @@ export async function reportActionSucceeded(action: ActionName) {
* Note that the started_at date is always that of the `init` action, since * Note that the started_at date is always that of the `init` action, since
* this is likely to give a more useful duration when inspecting events. * this is likely to give a more useful duration when inspecting events.
*/ */
export async function reportActionAborted(action: ActionName, cause?: string) { export async function reportActionAborted(action: string, cause?: string) {
await sendStatusReport(await createStatusReport(action, 'aborted', cause)); await sendStatusReport(await createStatusReport(action, 'aborted', cause));
} }