fix linter

This commit is contained in:
Marco Gario
2020-09-15 15:50:23 +02:00
parent b9e8fa6371
commit 4d836f4b5a
24 changed files with 464 additions and 364 deletions
Generated
+17 -13
View File
@@ -73,14 +73,16 @@ async function getCodeQLBundleDownloadURL(bundleNames, githubAuth, githubUrl, mo
}
const [repositoryOwner, repositoryName] = repository.split("/");
try {
const release = await api.getApiClient(githubAuth, githubUrl).repos.getReleaseByTag({
const release = await api
.getApiClient(githubAuth, githubUrl)
.repos.getReleaseByTag({
owner: repositoryOwner,
repo: repositoryName,
tag: CODEQL_BUNDLE_VERSION
tag: CODEQL_BUNDLE_VERSION,
});
// See if any of the bundles appears in the assets list
for (let bundleName of bundleNames) {
for (let asset of release.data.assets) {
for (const bundleName of bundleNames) {
for (const asset of release.data.assets) {
if (asset.name === bundleName) {
logger.info(`Found CodeQL bundle in ${downloadSource[1]} on ${downloadSource[0]} with URL ${asset.url}.`);
return asset.url;
@@ -132,17 +134,17 @@ async function setupCodeQL(codeqlURL, languages, githubAuth, githubUrl, tempDir,
// - If multiple languages are being anlyzed, use the full bundle
let plVersion = undefined;
let platform;
if (process.platform === 'win32') {
if (process.platform === "win32") {
platform = "win64";
}
else if (process.platform === 'linux') {
else if (process.platform === "linux") {
platform = "linux64";
}
else if (process.platform === 'darwin') {
else if (process.platform === "darwin") {
platform = "osx64";
}
else {
throw new Error("Unsupported platform: " + process.platform);
throw new Error(`Unsupported platform: ${process.platform}`);
}
if (languages.length === 1) {
plVersion = `${platform}-${languages[0]}`;
@@ -152,23 +154,25 @@ async function setupCodeQL(codeqlURL, languages, githubAuth, githubUrl, tempDir,
let codeqlFolder;
logger.debug(`PL Version ${plVersion}`);
if (plVersion) {
codeqlFolder = toolcache.find('CodeQL', `${codeqlURLVersion}-${plVersion}`);
codeqlFolder = toolcache.find("CodeQL", `${codeqlURLVersion}-${plVersion}`);
if (codeqlFolder) {
logger.debug(`CodeQL found in cache ${codeqlFolder}`);
}
}
if (!codeqlFolder) {
codeqlFolder = toolcache.find('CodeQL', codeqlURLVersion);
codeqlFolder = toolcache.find("CodeQL", codeqlURLVersion);
if (codeqlFolder) {
logger.debug(`CodeQL found in cache ${codeqlFolder}`);
}
}
if (!codeqlFolder) {
const codeqlToolcacheVersion = plVersion ? `${codeqlURLVersion}-${plVersion}` : codeqlURLVersion;
const codeqlToolcacheVersion = plVersion
? `${codeqlURLVersion}-${plVersion}`
: codeqlURLVersion;
logger.debug(`CodeQL not found in cache`);
if (!codeqlURL) {
// Provide a few options, from smaller to bigger
let bundles = [];
const bundles = [];
if (plVersion) {
bundles.push(CODEQL_BUNDLE_NAME.replace("-bundle", `-bundle-${plVersion}`));
}
@@ -193,7 +197,7 @@ async function setupCodeQL(codeqlURL, languages, githubAuth, githubUrl, tempDir,
logger.debug(`CodeQL bundle download to ${codeqlPath} complete.`);
const codeqlExtracted = await toolcache.extractTar(codeqlPath);
logger.debug(`Caching ${codeqlToolcacheVersion}`);
codeqlFolder = await toolcache.cacheDir(codeqlExtracted, 'CodeQL', codeqlToolcacheVersion);
codeqlFolder = await toolcache.cacheDir(codeqlExtracted, "CodeQL", codeqlToolcacheVersion);
}
let codeqlCmd = path.join(codeqlFolder, "codeql", "codeql");
if (process.platform === "win32") {
+1 -1
View File
File diff suppressed because one or more lines are too long
+75 -57
View File
@@ -24,121 +24,139 @@ const logging_1 = require("./logging");
const testing_utils_1 = require("./testing-utils");
const util = __importStar(require("./util"));
testing_utils_1.setupTests(ava_1.default);
ava_1.default('download and populate codeql bundle cache', async (t) => {
ava_1.default("download and populate codeql bundle cache", async (t) => {
await util.withTmpDir(async (tmpDir) => {
const versions = ['20200601', '20200610'];
const versions = ["20200601", "20200610"];
const languages = [
[languages_1.Language.cpp],
[languages_1.Language.cpp, languages_1.Language.python] // Multi-language requires the full bundle
[languages_1.Language.cpp, languages_1.Language.python],
];
const platform = process.platform === 'win32' ? 'win64' :
process.platform === 'linux' ? 'linux64' :
process.platform === 'darwin' ? 'osx64' : undefined;
const platform = process.platform === "win32"
? "win64"
: process.platform === "linux"
? "linux64"
: process.platform === "darwin"
? "osx64"
: undefined;
for (let i = 0; i < versions.length; i++) {
for (let j = 0; j < languages.length; j++) {
const version = versions[i];
const plVersion = (languages[j].length === 1) ? `${platform}-${languages[j][0]}` : undefined;
nock_1.default('https://example.com')
const plVersion = languages[j].length === 1
? `${platform}-${languages[j][0]}`
: undefined;
nock_1.default("https://example.com")
.get(`/download/codeql-bundle-${version}/codeql-bundle.tar.gz`)
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
await codeql.setupCodeQL(`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`, languages[j], 'token', 'https://github.example.com', tmpDir, tmpDir, 'runner', logging_1.getRunnerLogger(true));
const toolcacheVersion = plVersion ? `0.0.0-${version}-${plVersion}` : `0.0.0-${version}`;
t.assert(toolcache.find('CodeQL', toolcacheVersion), `Looking for ${toolcacheVersion}`);
await codeql.setupCodeQL(`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`, languages[j], "token", "https://github.example.com", tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
const toolcacheVersion = plVersion
? `0.0.0-${version}-${plVersion}`
: `0.0.0-${version}`;
t.assert(toolcache.find("CodeQL", toolcacheVersion), `Looking for ${toolcacheVersion}`);
}
}
const cachedVersions = toolcache.findAllVersions('CodeQL');
const cachedVersions = toolcache.findAllVersions("CodeQL");
t.is(cachedVersions.length, 4);
});
});
ava_1.default('download small codeql bundle if analyzing only one language', async (t) => {
ava_1.default("download small codeql bundle if analyzing only one language", async (t) => {
// Note: We do not specify a codeqlURL in this test, thus testing that
// the logic for constructing the URL takes into account the
// language being analyzed
await util.withTmpDir(async (tmpDir) => {
const languages = [
[languages_1.Language.cpp],
[languages_1.Language.cpp, languages_1.Language.python] // Multi-language requires the full bundle
[languages_1.Language.cpp, languages_1.Language.python],
];
const platform = process.platform === 'win32' ? 'win64' :
process.platform === 'linux' ? 'linux64' :
process.platform === 'darwin' ? 'osx64' : undefined;
const platform = process.platform === "win32"
? "win64"
: process.platform === "linux"
? "linux64"
: process.platform === "darwin"
? "osx64"
: undefined;
for (let i = 0; i < languages.length; i++) {
const plVersion = (languages[i].length === 1) ? `${platform}-${languages[i][0]}` : undefined;
const pkg = plVersion ? `codeql-bundle-${plVersion}.tar.gz` : 'codeql-bundle.tar.gz';
const plVersion = languages[i].length === 1
? `${platform}-${languages[i][0]}`
: undefined;
const pkg = plVersion
? `codeql-bundle-${plVersion}.tar.gz`
: "codeql-bundle.tar.gz";
// Mock the API client
let client = new github.GitHub('123');
const client = new github.GitHub("123");
const response = {
data: {
'assets': [
assets: [
{
'name': `codeql-bundle-${platform}-cpp.tar.gz`,
'url': `https://github.example.com/url/codeql-bundle-${platform}-cpp.tar.gz`
name: `codeql-bundle-${platform}-cpp.tar.gz`,
url: `https://github.example.com/url/codeql-bundle-${platform}-cpp.tar.gz`,
},
{
'name': 'codeql-bundle.tar.gz',
'url': 'https://github.example.com/url/codeql-bundle.tar.gz'
name: "codeql-bundle.tar.gz",
url: "https://github.example.com/url/codeql-bundle.tar.gz",
},
]
],
},
};
sinon_1.default.stub(client.repos, "getReleaseByTag").resolves(response);
sinon_1.default.stub(api, "getApiClient").value(() => client);
nock_1.default('https://github.example.com')
nock_1.default("https://github.example.com")
.get(`/url/${pkg}`)
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
await codeql.setupCodeQL(undefined, languages[i], 'token', 'https://github.example.com', tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
await codeql.setupCodeQL(undefined, languages[i], "token", "https://github.example.com", tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
const parsedVersion = codeql.getCodeQLURLVersion(`/${defaults.bundleVersion}/`, logging_1.getRunnerLogger(true));
const toolcacheVersion = plVersion ? `${parsedVersion}-${plVersion}` : parsedVersion;
t.assert(toolcache.find('CodeQL', toolcacheVersion), `Looking for ${toolcacheVersion} - ${plVersion}`);
const toolcacheVersion = plVersion
? `${parsedVersion}-${plVersion}`
: parsedVersion;
t.assert(toolcache.find("CodeQL", toolcacheVersion), `Looking for ${toolcacheVersion} - ${plVersion}`);
}
const cachedVersions = toolcache.findAllVersions('CodeQL');
const cachedVersions = toolcache.findAllVersions("CodeQL");
t.is(cachedVersions.length, 2);
});
});
ava_1.default('use full codeql bundle cache if smaller bundle is not available', async (t) => {
ava_1.default("use full codeql bundle cache if smaller bundle is not available", async (t) => {
// If we look for a platform-language version but find the full bundle in the cache,
// we use the full bundle
await util.withTmpDir(async (tmpDir) => {
const version = '20200601';
nock_1.default('https://example.com')
const version = "20200601";
nock_1.default("https://example.com")
.get(`/download/codeql-bundle-${version}/codeql-bundle.tar.gz`)
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
await codeql.setupCodeQL(`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`, [], 'token', 'https://github.example.com', tmpDir, tmpDir, 'runner', logging_1.getRunnerLogger(true));
t.assert(toolcache.find('CodeQL', `0.0.0-${version}`));
t.is(toolcache.findAllVersions('CodeQL').length, 1);
await codeql.setupCodeQL(`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`, [], "token", "https://github.example.com", tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
t.is(toolcache.findAllVersions("CodeQL").length, 1);
// Now try to request the cpp version, and see that we do not change the cache
await codeql.setupCodeQL(`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`, [languages_1.Language.cpp], 'token', 'https://github.example.com', tmpDir, tmpDir, 'runner', logging_1.getRunnerLogger(true));
t.assert(toolcache.find('CodeQL', `0.0.0-${version}`));
t.is(toolcache.findAllVersions('CodeQL').length, 1);
await codeql.setupCodeQL(`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`, [languages_1.Language.cpp], "token", "https://github.example.com", tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
t.is(toolcache.findAllVersions("CodeQL").length, 1);
});
});
ava_1.default('use larger bundles if smaller ones are not released', async (t) => {
ava_1.default("use larger bundles if smaller ones are not released", async (t) => {
// Mock the API client
let client = new github.GitHub('123');
const client = new github.GitHub("123");
const response = {
data: {
'assets': [
{ 'name': 'full-bundle', 'url': 'url/file.gz' },
]
assets: [{ name: "full-bundle", url: "url/file.gz" }],
},
};
let getReleaseByTagMock = sinon_1.default.stub(client.repos, "getReleaseByTag").resolves(response);
const getReleaseByTagMock = sinon_1.default
.stub(client.repos, "getReleaseByTag")
.resolves(response);
sinon_1.default.stub(api, "getApiClient").value(() => client);
// Setting this env is required by a dependency of getCodeQLBundleDownloadURL
process.env['RUNNER_TEMP'] = "abc";
let codeqlURL = await codeql.getCodeQLBundleDownloadURL(['small-bundle', 'full-bundle'], "", "", 'actions', logging_1.getRunnerLogger(true));
t.deepEqual(codeqlURL, 'url/file.gz');
process.env["RUNNER_TEMP"] = "abc";
const codeqlURL = await codeql.getCodeQLBundleDownloadURL(["small-bundle", "full-bundle"], "", "", "actions", logging_1.getRunnerLogger(true));
t.deepEqual(codeqlURL, "url/file.gz");
t.assert(getReleaseByTagMock.called);
});
ava_1.default('parse codeql bundle url version', t => {
ava_1.default("parse codeql bundle url version", (t) => {
const tests = {
'20200601': '0.0.0-20200601',
'20200601.0': '0.0.0-20200601.0',
'20200601.0.0': '20200601.0.0',
'1.2.3': '1.2.3',
'1.2.3-alpha': '1.2.3-alpha',
'1.2.3-beta.1': '1.2.3-beta.1',
'20200601-linux64-python': '0.0.0-20200601-linux64-python',
"20200601": "0.0.0-20200601",
"20200601.0": "0.0.0-20200601.0",
"20200601.0.0": "20200601.0.0",
"1.2.3": "1.2.3",
"1.2.3-alpha": "1.2.3-alpha",
"1.2.3-beta.1": "1.2.3-beta.1",
"20200601-linux64-python": "0.0.0-20200601-linux64-python",
};
for (const [version, expectedVersion] of Object.entries(tests)) {
const url = `https://github.com/.../codeql-bundle-${version}/...`;
File diff suppressed because one or more lines are too long
+1
View File
@@ -12,6 +12,7 @@ const yaml = __importStar(require("js-yaml"));
const path = __importStar(require("path"));
const api = __importStar(require("./api-client"));
const externalQueries = __importStar(require("./external-queries"));
// Property names from the user-supplied config file.
const NAME_PROPERTY = "name";
const DISABLE_DEFAULT_QUERIES_PROPERTY = "disable-default-queries";
const QUERIES_PROPERTY = "queries";
File diff suppressed because one or more lines are too long
+13 -13
View File
@@ -66,8 +66,8 @@ ava_1.default("load empty config", async (t) => {
};
},
});
const config = await configUtils.initConfig(languages, undefined, undefined, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logger);
t.deepEqual(config, await configUtils.getDefaultConfig(languages, undefined, tmpDir, tmpDir, codeQL, tmpDir, 'https://github.example.com', logger));
const config = await configUtils.initConfig(languages, undefined, undefined, tmpDir, tmpDir, codeQL, tmpDir, "token", "https://github.example.com", logger);
t.deepEqual(config, await configUtils.getDefaultConfig(languages, undefined, tmpDir, tmpDir, codeQL, tmpDir, "https://github.example.com", logger));
});
});
ava_1.default("loading config saves config", async (t) => {
@@ -97,7 +97,7 @@ ava_1.default("loading config saves config", async (t) => {
ava_1.default("load input outside of workspace", async (t) => {
return await util.withTmpDir(async (tmpDir) => {
try {
await configUtils.initConfig([], undefined, '../input', tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, "token", "https://github.example.com", logging_1.getRunnerLogger(true));
await configUtils.initConfig([], undefined, "../input", tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, "token", "https://github.example.com", logging_1.getRunnerLogger(true));
throw new Error("initConfig did not throw error");
}
catch (err) {
@@ -121,7 +121,7 @@ ava_1.default("load non-local input with invalid repo syntax", async (t) => {
ava_1.default("load non-existent input", async (t) => {
return await util.withTmpDir(async (tmpDir) => {
const languages = [languages_1.Language.javascript];
const configFile = 'input';
const configFile = "input";
t.false(fs.existsSync(path.join(tmpDir, configFile)));
try {
await configUtils.initConfig(languages, undefined, configFile, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, "token", "https://github.example.com", logging_1.getRunnerLogger(true));
@@ -406,7 +406,7 @@ ava_1.default("Queries in workflow file can be added to the set of queries witho
});
ava_1.default("Invalid queries in workflow file handled correctly", async (t) => {
return await util.withTmpDir(async (tmpDir) => {
const queries = 'foo/bar@v1@v3';
const queries = "foo/bar@v1@v3";
const languages = [languages_1.Language.javascript];
// This function just needs to be type-correct; it doesn't need to do anything,
// since we're deliberately passing in invalid data
@@ -463,7 +463,7 @@ ava_1.default("API client used when reading remote config", async (t) => {
const spyGetContents = mockGetContents(dummyResponse);
// Create checkout directory for remote queries repository
fs.mkdirSync(path.join(tmpDir, "foo/bar/dev"), { recursive: true });
const configFile = 'octo-org/codeql-config/config.yaml@main';
const configFile = "octo-org/codeql-config/config.yaml@main";
const languages = [languages_1.Language.javascript];
await configUtils.initConfig(languages, undefined, configFile, tmpDir, tmpDir, codeQL, tmpDir, "token", "https://github.example.com", logging_1.getRunnerLogger(true));
t.assert(spyGetContents.called);
@@ -502,21 +502,21 @@ ava_1.default("Invalid format of remote config handled correctly", async (t) =>
ava_1.default("No detected languages", async (t) => {
mockListLanguages([]);
try {
await languages_1.getLanguages(undefined, { owner: 'github', repo: 'example ' }, 'token', 'https://github.example.com', logging_1.getRunnerLogger(true));
throw new Error('initConfig did not throw error');
await languages_1.getLanguages(undefined, { owner: "github", repo: "example " }, "token", "https://github.example.com", logging_1.getRunnerLogger(true));
throw new Error("initConfig did not throw error");
}
catch (err) {
t.deepEqual(err, new Error(languages_1.getNoLanguagesError()));
}
});
ava_1.default("Unknown languages", async (t) => {
const languages = 'ruby,english';
const languages = "ruby,english";
try {
await languages_1.getLanguages(languages, { owner: 'github', repo: 'example ' }, 'token', 'https://github.example.com', logging_1.getRunnerLogger(true));
throw new Error('initConfig did not throw error');
await languages_1.getLanguages(languages, { owner: "github", repo: "example " }, "token", "https://github.example.com", logging_1.getRunnerLogger(true));
throw new Error("initConfig did not throw error");
}
catch (err) {
t.deepEqual(err, new Error(languages_1.getUnknownLanguagesError(['ruby', 'english'])));
t.deepEqual(err, new Error(languages_1.getUnknownLanguagesError(["ruby", "english"])));
}
});
function doInvalidInputTest(testName, inputFileContents, expectedErrorMessageGenerator) {
@@ -532,7 +532,7 @@ function doInvalidInputTest(testName, inputFileContents, expectedErrorMessageGen
},
});
const languages = [languages_1.Language.javascript];
const configFile = 'input';
const configFile = "input";
const inputFile = path.join(tmpDir, configFile);
fs.writeFileSync(inputFile, inputFileContents, "utf8");
try {
File diff suppressed because one or more lines are too long
+4 -4
View File
@@ -46,10 +46,10 @@ async function run() {
if (!(await util.sendStatusReport(await util.createStatusReportBase("init", "starting", startedAt), true))) {
return;
}
const repositoryNWO = repository_1.parseRepositoryNwo(util.getRequiredEnvParam('GITHUB_REPOSITORY'));
const languages = await languages_1.getLanguages(core.getInput('languages'), repositoryNWO, core.getInput('token'), util.getRequiredEnvParam('GITHUB_SERVER_URL'), logger);
codeql = await init_1.initCodeQL(core.getInput('tools'), languages, core.getInput('token'), util.getRequiredEnvParam('GITHUB_SERVER_URL'), util.getRequiredEnvParam('RUNNER_TEMP'), util.getRequiredEnvParam('RUNNER_TOOL_CACHE'), 'actions', logger);
config = await init_1.initConfig(languages, core.getInput('queries'), core.getInput('config-file'), util.getRequiredEnvParam('RUNNER_TEMP'), util.getRequiredEnvParam('RUNNER_TOOL_CACHE'), codeql, util.getRequiredEnvParam("GITHUB_WORKSPACE"), core.getInput("token"), util.getRequiredEnvParam("GITHUB_SERVER_URL"), logger);
const repositoryNWO = repository_1.parseRepositoryNwo(util.getRequiredEnvParam("GITHUB_REPOSITORY"));
const languages = await languages_1.getLanguages(core.getInput("languages"), repositoryNWO, core.getInput("token"), util.getRequiredEnvParam("GITHUB_SERVER_URL"), logger);
codeql = await init_1.initCodeQL(core.getInput("tools"), languages, core.getInput("token"), util.getRequiredEnvParam("GITHUB_SERVER_URL"), util.getRequiredEnvParam("RUNNER_TEMP"), util.getRequiredEnvParam("RUNNER_TOOL_CACHE"), "actions", logger);
config = await init_1.initConfig(languages, core.getInput("queries"), core.getInput("config-file"), util.getRequiredEnvParam("RUNNER_TEMP"), util.getRequiredEnvParam("RUNNER_TOOL_CACHE"), codeql, util.getRequiredEnvParam("GITHUB_WORKSPACE"), core.getInput("token"), util.getRequiredEnvParam("GITHUB_SERVER_URL"), logger);
}
catch (e) {
core.setFailed(e.message);
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"init-action.js","sourceRoot":"","sources":["../src/init-action.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAKtC,iCAA8E;AAC9E,2CAA2C;AAC3C,uCAA6C;AAC7C,6CAAkD;AAClD,6CAA+B;AA0B/B,KAAK,UAAU,uBAAuB,CACpC,SAAe,EACf,MAA0B;IAE1B,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,sBAAsB,CACxD,MAAM,EACN,SAAS,EACT,SAAS,CACV,CAAC;IAEF,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7C,MAAM,iBAAiB,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1E,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/D,MAAM,WAAW,GAAG,CAAC,MAAM,CAAC,iBAAiB,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CACvE,GAAG,CACJ,CAAC;IACF,MAAM,qBAAqB,GAAG,MAAM,CAAC,iBAAiB,CACpD,yBAAyB,CAC1B;QACC,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,EAAE,CAAC;IACP,MAAM,OAAO,GAAG,CAAC,MAAM,CAAC,iBAAiB,CAAC,OA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AC,CAAC;QACnB,MAAM,IAAI,CAAC,gBAAgB,CACzB,MAAM,IAAI,CAAC,sBAAsB,CAC/B,MAAM,EACN,SAAS,EACT,SAAS,EACT,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,KAAK,CACZ,CACF,CAAC;QACF,OAAO;KACR;IACD,MAAM,uBAAuB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;AACnD,CAAC;AAED,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;IAChB,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC,EAAE,CAAC,CAAC;IAC3C,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC,CAAC,CAAC"}
Generated
+1 -1
View File
@@ -16,7 +16,7 @@ const configUtils = __importStar(require("./config-utils"));
const tracer_config_1 = require("./tracer-config");
const util = __importStar(require("./util"));
async function initCodeQL(codeqlURL, languages, githubAuth, githubUrl, tempDir, toolsDir, mode, logger) {
logger.startGroup('Setup CodeQL tools');
logger.startGroup("Setup CodeQL tools");
const codeql = await codeql_1.setupCodeQL(codeqlURL, languages, githubAuth, githubUrl, tempDir, toolsDir, mode, logger);
await codeql.printVersion();
logger.endGroup();
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":";;;;;;;;;AACA,0EAA4D;AAC5D,uCAAyB;AACzB,2CAA6B;AAE7B,gEAAkD;AAClD,qCAA+C;AAC/C,4DAA8C;AAG9C,mDAAwE;AACxE,6CAA+B;AAgBxB,KAAK,UAAU,UAAU,CAC9B,SAA6B,EAC7B,SAAqB,EACrB,UAAkB,EAClB,SAAiB,EACjB,OAAe,EACf,QAAgB,EAChB,IAAe,EAEf,MAAc;IAEd,MAAM,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;IAOxC,MAAM,MAAM,GAAG,MAAM,oBAAW,CAC9B,SAAS,EACT,SAAS,EACT,UAAU,EACV,SAA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C,OAAO,EAAE,CAAC,EAC9B,OAAO,EACP,OAAO,EACP,YAAY,CACb;KACF,EACD,EAAE,GAAG,EAAE,EAAE,0BAA0B,EAAE,YAAY,CAAC,IAAI,EAAE,EAAE,CAC3D,CAAC,IAAI,EAAE,CAAC;AACX,CAAC;AAxFD,kDAwFC"}
+17 -15
View File
@@ -49,12 +49,12 @@ function isScannedLanguage(language) {
}
exports.isScannedLanguage = isScannedLanguage;
function getNoLanguagesError() {
return "Did not detect any languages to analyze. " +
"Please update input in workflow or check that GitHub detects the correct languages in your repository.";
return ("Did not detect any languages to analyze. " +
"Please update input in workflow or check that GitHub detects the correct languages in your repository.");
}
exports.getNoLanguagesError = getNoLanguagesError;
function getUnknownLanguagesError(languages) {
return "Did not recognise the following languages: " + languages.join(', ');
return `Did not recognise the following languages: ${languages.join(", ")}`;
}
exports.getUnknownLanguagesError = getUnknownLanguagesError;
/**
@@ -70,14 +70,14 @@ exports.getUnknownLanguagesError = getUnknownLanguagesError;
async function getLanguages(languagesInput, repository, githubAuth, githubUrl, logger) {
// Obtain from action input 'languages' if set
let languages = (languagesInput || "")
.split(',')
.map(x => x.trim())
.filter(x => x.length > 0);
logger.info("Languages from configuration: " + JSON.stringify(languages));
.split(",")
.map((x) => x.trim())
.filter((x) => x.length > 0);
logger.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(repository, githubAuth, githubUrl, logger);
logger.info("Automatically detected languages: " + JSON.stringify(languages));
logger.info(`Automatically detected languages: ${JSON.stringify(languages)}`);
}
// If the languages parameter was not given and no languages were
// detected then fail here as this is a workflow configuration error.
@@ -87,7 +87,7 @@ async function getLanguages(languagesInput, repository, githubAuth, githubUrl, l
// Make sure they are supported
const parsedLanguages = [];
const unknownLanguages = [];
for (let language of languages) {
for (const language of languages) {
const parsedLanguage = parseLanguage(language);
if (parsedLanguage === undefined) {
unknownLanguages.push(language);
@@ -107,18 +107,20 @@ exports.getLanguages = getLanguages;
*/
async function getLanguagesInRepo(repository, githubAuth, githubUrl, logger) {
logger.debug(`GitHub repo ${repository.owner} ${repository.repo}`);
const response = await api.getApiClient(githubAuth, githubUrl, true).repos.listLanguages({
const response = await api
.getApiClient(githubAuth, githubUrl, true)
.repos.listLanguages({
owner: repository.owner,
repo: repository.repo
repo: repository.repo,
});
logger.debug("Languages API response: " + JSON.stringify(response));
logger.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 of Object.keys(response.data)) {
let parsedLang = parseLanguage(lang);
const languages = new Set();
for (const lang of Object.keys(response.data)) {
const parsedLang = parseLanguage(lang);
if (parsedLang !== undefined) {
languages.add(parsedLang);
}
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"languages.js","sourceRoot":"","sources":["../src/languages.ts"],"names":[],"mappings":";;;;;;;;;AAAA,kDAAoC;AAMpC,wCAAwC;AACxC,IAAY,QAOX;AAPD,WAAY,QAAQ;IAClB,6BAAiB,CAAA;IACjB,uBAAW,CAAA;IACX,qBAAS,CAAA;IACT,yBAAa,CAAA;IACb,qCAAyB,CAAA;IACzB,6BAAiB,CAAA;AACnB,CAAC,EAPW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAOnB;AAED,iCAAiC;AACjC,MAAM,gBAAgB,GAAiC;IACrD,CAAC,EAAE,QAAQ,CAAC,GAAG;IACf,KAAK,EAAE,QAAQ,CAAC,GAAG;IACnB,IAAI,EAAE,QAAQ,CAAC,MAAM;IACrB,UAAU,EAAE,QAAQ,CAAC,UAAU;CAChC,CAAC;AAEF,gGAAgG;AAChG,SAAgB,aAAa,CAAC,QAAgB;IAC5C,0BAA0B;IAC1B,QAAQ,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IAElC,6BAA6B;IAC7B,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AAK,EAAE,UAAU,CAAC,KAAK;QACvB,IAAI,EAAE,UAAU,CAAC,IAAI;KACtB,CAAC,CAAC;IAEL,MAAM,CAAC,KAAK,CAAC,2BAA2B,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAEpE,sEAAsE;IACtE,wFAAwF;IACxF,4FAA4F;IAC5F,qEAAqE;IACrE,MAAM,SAAS,GAAkB,IAAI,GAAG,EAAE,CAAC;IAC3C,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;QAC7C,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,UAAU,KAAK,SAAS,EAAE;YAC5B,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;SAC3B;KACF;IACD,OAAO,CAAC,GAAG,SAAS,CAAC,CAAC;AACxB,CAAC"}
Generated
+2 -2
View File
@@ -129,7 +129,7 @@ program
else {
codeql = await init_1.initCodeQL(undefined, languages, cmd.githubAuth, githubUrl, tempDir, toolsDir, "runner", logger);
}
const config = await init_1.initConfig(languages, cmd.queries, cmd.configFile, tempDir, toolsDir, codeql, cmd.checkoutPath || process.cwd(), cmd.githubAuth, githubUrl, logger);
const config = await init_1.initConfig(languages, cmd.queries, cmd.configFile, tempDir, toolsDir, codeql, cmd.checkoutPath || process.cwd(), cmd.githubAuth, parseGithubUrl(cmd.githubUrl), logger);
const tracerConfig = await init_1.runInit(codeql, config);
if (tracerConfig === undefined) {
return;
@@ -238,7 +238,7 @@ program
throw new Error("Config file could not be found at expected location. " +
"Was the 'init' command run with the same '--temp-dir' argument as this command.");
}
await analyze_1.runAnalyze(repository_1.parseRepositoryNwo(cmd.repository), cmd.commit, parseRef(cmd.ref), undefined, undefined, undefined, cmd.checkoutPath || process.cwd(), undefined, cmd.githubAuth, parseGithubUrl(cmd.githubUrl), cmd.upload, "runner", outputDir, util_1.getMemoryFlag(cmd.ram), getAddSnippetsFlag(cmd.addSnippets), util_1.getThreadsFlag(cmd.threads, logger), config, logger);
await analyze_1.runAnalyze(repository_1.parseRepositoryNwo(cmd.repository), cmd.commit, parseRef(cmd.ref), undefined, undefined, undefined, cmd.checkoutPath || process.cwd(), undefined, cmd.githubAuth, parseGithubUrl(cmd.githubUrl), cmd.upload, "runner", outputDir, util_1.getMemoryFlag(cmd.ram), util_1.getAddSnippetsFlag(cmd.addSnippets), util_1.getThreadsFlag(cmd.threads, logger), config, logger);
}
catch (e) {
logger.error("Analyze failed");
+1 -1
View File
File diff suppressed because one or more lines are too long
+133 -97
View File
@@ -1,206 +1,242 @@
import * as github from "@actions/github";
import * as toolcache from '@actions/tool-cache';
import test from 'ava';
import nock from 'nock';
import * as path from 'path';
import sinon from 'sinon';
import * as api from './api-client';
import * as codeql from './codeql';
import * as defaults from './defaults.json'; // Referenced from codeql-action-sync-tool!
import { Language } from './languages';
import { getRunnerLogger } from './logging';
import {setupTests} from './testing-utils';
import * as util from './util';
import * as toolcache from "@actions/tool-cache";
import test from "ava";
import nock from "nock";
import * as path from "path";
import sinon from "sinon";
import * as api from "./api-client";
import * as codeql from "./codeql";
import * as defaults from "./defaults.json"; // Referenced from codeql-action-sync-tool!
import { Language } from "./languages";
import { getRunnerLogger } from "./logging";
import { setupTests } from "./testing-utils";
import * as util from "./util";
setupTests(test);
test('download and populate codeql bundle cache', async t => {
await util.withTmpDir(async tmpDir => {
const versions = ['20200601', '20200610'];
test("download and populate codeql bundle cache", async (t) => {
await util.withTmpDir(async (tmpDir) => {
const versions = ["20200601", "20200610"];
const languages: Language[][] = [
[Language.cpp],
[Language.cpp, Language.python] // Multi-language requires the full bundle
[Language.cpp, Language.python], // Multi-language requires the full bundle
];
const platform = process.platform === 'win32' ? 'win64' :
process.platform === 'linux' ? 'linux64' :
process.platform === 'darwin' ? 'osx64' : undefined;
const platform =
process.platform === "win32"
? "win64"
: process.platform === "linux"
? "linux64"
: process.platform === "darwin"
? "osx64"
: undefined;
for (let i = 0; i < versions.length; i++) {
for (let j = 0; j < languages.length; j++) {
const version = versions[i];
const plVersion = (languages[j].length === 1) ? `${platform}-${languages[j][0]}` : undefined;
const plVersion =
languages[j].length === 1
? `${platform}-${languages[j][0]}`
: undefined;
nock('https://example.com')
nock("https://example.com")
.get(`/download/codeql-bundle-${version}/codeql-bundle.tar.gz`)
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
.replyWithFile(
200,
path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`)
);
await codeql.setupCodeQL(
`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`,
languages[j],
'token',
'https://github.example.com',
"token",
"https://github.example.com",
tmpDir,
tmpDir,
'runner',
getRunnerLogger(true));
"runner",
getRunnerLogger(true)
);
const toolcacheVersion = plVersion ? `0.0.0-${version}-${plVersion}` : `0.0.0-${version}`;
t.assert(toolcache.find('CodeQL', toolcacheVersion), `Looking for ${toolcacheVersion}`);
const toolcacheVersion = plVersion
? `0.0.0-${version}-${plVersion}`
: `0.0.0-${version}`;
t.assert(
toolcache.find("CodeQL", toolcacheVersion),
`Looking for ${toolcacheVersion}`
);
}
}
const cachedVersions = toolcache.findAllVersions('CodeQL');
const cachedVersions = toolcache.findAllVersions("CodeQL");
t.is(cachedVersions.length, 4);
});
});
test('download small codeql bundle if analyzing only one language', async t => {
test("download small codeql bundle if analyzing only one language", async (t) => {
// Note: We do not specify a codeqlURL in this test, thus testing that
// the logic for constructing the URL takes into account the
// language being analyzed
await util.withTmpDir(async tmpDir => {
await util.withTmpDir(async (tmpDir) => {
const languages: Language[][] = [
[Language.cpp],
[Language.cpp, Language.python] // Multi-language requires the full bundle
[Language.cpp, Language.python], // Multi-language requires the full bundle
];
const platform = process.platform === 'win32' ? 'win64' :
process.platform === 'linux' ? 'linux64' :
process.platform === 'darwin' ? 'osx64' : undefined;
const platform =
process.platform === "win32"
? "win64"
: process.platform === "linux"
? "linux64"
: process.platform === "darwin"
? "osx64"
: undefined;
for (let i = 0; i < languages.length; i++) {
const plVersion = (languages[i].length === 1) ? `${platform}-${languages[i][0]}` : undefined;
const pkg = plVersion ? `codeql-bundle-${plVersion}.tar.gz` : 'codeql-bundle.tar.gz';
const plVersion =
languages[i].length === 1
? `${platform}-${languages[i][0]}`
: undefined;
const pkg = plVersion
? `codeql-bundle-${plVersion}.tar.gz`
: "codeql-bundle.tar.gz";
// Mock the API client
let client = new github.GitHub('123');
const client = new github.GitHub("123");
const response = {
data: {
'assets': [
assets: [
{
'name': `codeql-bundle-${platform}-cpp.tar.gz`,
'url': `https://github.example.com/url/codeql-bundle-${platform}-cpp.tar.gz`
name: `codeql-bundle-${platform}-cpp.tar.gz`,
url: `https://github.example.com/url/codeql-bundle-${platform}-cpp.tar.gz`,
},
{
'name': 'codeql-bundle.tar.gz',
'url': 'https://github.example.com/url/codeql-bundle.tar.gz'
name: "codeql-bundle.tar.gz",
url: "https://github.example.com/url/codeql-bundle.tar.gz",
},
]
],
},
};
sinon.stub(client.repos, "getReleaseByTag").resolves(response as any);
sinon.stub(api, "getApiClient").value(() => client);
nock('https://github.example.com')
nock("https://github.example.com")
.get(`/url/${pkg}`)
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
.replyWithFile(
200,
path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`)
);
await codeql.setupCodeQL(
undefined,
languages[i],
'token',
'https://github.example.com',
"token",
"https://github.example.com",
tmpDir,
tmpDir,
"runner",
getRunnerLogger(true)
);
const parsedVersion = codeql.getCodeQLURLVersion(`/${defaults.bundleVersion}/`, getRunnerLogger(true));
const toolcacheVersion = plVersion ? `${parsedVersion}-${plVersion}` : parsedVersion;
t.assert(toolcache.find('CodeQL', toolcacheVersion), `Looking for ${toolcacheVersion} - ${plVersion}`);
const parsedVersion = codeql.getCodeQLURLVersion(
`/${defaults.bundleVersion}/`,
getRunnerLogger(true)
);
const toolcacheVersion = plVersion
? `${parsedVersion}-${plVersion}`
: parsedVersion;
t.assert(
toolcache.find("CodeQL", toolcacheVersion),
`Looking for ${toolcacheVersion} - ${plVersion}`
);
}
const cachedVersions = toolcache.findAllVersions('CodeQL');
const cachedVersions = toolcache.findAllVersions("CodeQL");
t.is(cachedVersions.length, 2);
});
});
test('use full codeql bundle cache if smaller bundle is not available', async t => {
test("use full codeql bundle cache if smaller bundle is not available", async (t) => {
// If we look for a platform-language version but find the full bundle in the cache,
// we use the full bundle
await util.withTmpDir(async tmpDir => {
const version = '20200601';
await util.withTmpDir(async (tmpDir) => {
const version = "20200601";
nock('https://example.com')
nock("https://example.com")
.get(`/download/codeql-bundle-${version}/codeql-bundle.tar.gz`)
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
.replyWithFile(
200,
path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`)
);
await codeql.setupCodeQL(
`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`,
[],
'token',
'https://github.example.com',
"token",
"https://github.example.com",
tmpDir,
tmpDir,
'runner',
getRunnerLogger(true));
"runner",
getRunnerLogger(true)
);
t.assert(toolcache.find('CodeQL', `0.0.0-${version}`));
t.is(toolcache.findAllVersions('CodeQL').length, 1);
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
t.is(toolcache.findAllVersions("CodeQL").length, 1);
// Now try to request the cpp version, and see that we do not change the cache
await codeql.setupCodeQL(
`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`,
[Language.cpp],
'token',
'https://github.example.com',
"token",
"https://github.example.com",
tmpDir,
tmpDir,
'runner',
getRunnerLogger(true));
t.assert(toolcache.find('CodeQL', `0.0.0-${version}`));
t.is(toolcache.findAllVersions('CodeQL').length, 1);
"runner",
getRunnerLogger(true)
);
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
t.is(toolcache.findAllVersions("CodeQL").length, 1);
});
});
test('use larger bundles if smaller ones are not released', async t => {
test("use larger bundles if smaller ones are not released", async (t) => {
// Mock the API client
let client = new github.GitHub('123');
const client = new github.GitHub("123");
const response = {
data: {
'assets': [
{ 'name': 'full-bundle', 'url': 'url/file.gz' },
]
assets: [{ name: "full-bundle", url: "url/file.gz" }],
},
};
let getReleaseByTagMock = sinon.stub(client.repos, "getReleaseByTag").resolves(response as any);
const getReleaseByTagMock = sinon
.stub(client.repos, "getReleaseByTag")
.resolves(response as any);
sinon.stub(api, "getApiClient").value(() => client);
// Setting this env is required by a dependency of getCodeQLBundleDownloadURL
process.env['RUNNER_TEMP'] = "abc";
process.env["RUNNER_TEMP"] = "abc";
let codeqlURL = await codeql.getCodeQLBundleDownloadURL(
['small-bundle', 'full-bundle'],
const codeqlURL = await codeql.getCodeQLBundleDownloadURL(
["small-bundle", "full-bundle"],
"",
"",
'actions',
getRunnerLogger(true));
"actions",
getRunnerLogger(true)
);
t.deepEqual(codeqlURL, 'url/file.gz');
t.deepEqual(codeqlURL, "url/file.gz");
t.assert(getReleaseByTagMock.called);
});
test('parse codeql bundle url version', t => {
test("parse codeql bundle url version", (t) => {
const tests = {
'20200601': '0.0.0-20200601',
'20200601.0': '0.0.0-20200601.0',
'20200601.0.0': '20200601.0.0',
'1.2.3': '1.2.3',
'1.2.3-alpha': '1.2.3-alpha',
'1.2.3-beta.1': '1.2.3-beta.1',
'20200601-linux64-python': '0.0.0-20200601-linux64-python',
"20200601": "0.0.0-20200601",
"20200601.0": "0.0.0-20200601.0",
"20200601.0.0": "20200601.0.0",
"1.2.3": "1.2.3",
"1.2.3-alpha": "1.2.3-alpha",
"1.2.3-beta.1": "1.2.3-beta.1",
"20200601-linux64-python": "0.0.0-20200601-linux64-python",
};
for (const [version, expectedVersion] of Object.entries(tests)) {
+43 -20
View File
@@ -172,16 +172,20 @@ export async function getCodeQLBundleDownloadURL(
}
const [repositoryOwner, repositoryName] = repository.split("/");
try {
const release = await api.getApiClient(githubAuth, githubUrl).repos.getReleaseByTag({
owner: repositoryOwner,
repo: repositoryName,
tag: CODEQL_BUNDLE_VERSION
});
const release = await api
.getApiClient(githubAuth, githubUrl)
.repos.getReleaseByTag({
owner: repositoryOwner,
repo: repositoryName,
tag: CODEQL_BUNDLE_VERSION,
});
// See if any of the bundles appears in the assets list
for (let bundleName of bundleNames) {
for (let asset of release.data.assets) {
for (const bundleName of bundleNames) {
for (const asset of release.data.assets) {
if (asset.name === bundleName) {
logger.info(`Found CodeQL bundle in ${downloadSource[1]} on ${downloadSource[0]} with URL ${asset.url}.`);
logger.info(
`Found CodeQL bundle in ${downloadSource[1]} on ${downloadSource[0]} with URL ${asset.url}.`
);
return asset.url;
}
}
@@ -250,14 +254,14 @@ export async function setupCodeQL(
// - If multiple languages are being anlyzed, use the full bundle
let plVersion: string | undefined = undefined;
let platform: string;
if (process.platform === 'win32') {
if (process.platform === "win32") {
platform = "win64";
} else if (process.platform === 'linux') {
} else if (process.platform === "linux") {
platform = "linux64";
} else if (process.platform === 'darwin') {
} else if (process.platform === "darwin") {
platform = "osx64";
} else {
throw new Error("Unsupported platform: " + process.platform);
throw new Error(`Unsupported platform: ${process.platform}`);
}
if (languages.length === 1) {
plVersion = `${platform}-${languages[0]}`;
@@ -273,32 +277,47 @@ export async function setupCodeQL(
logger.debug(`PL Version ${plVersion}`);
if (plVersion) {
codeqlFolder = toolcache.find('CodeQL', `${codeqlURLVersion}-${plVersion}`);
codeqlFolder = toolcache.find(
"CodeQL",
`${codeqlURLVersion}-${plVersion}`
);
if (codeqlFolder) {
logger.debug(`CodeQL found in cache ${codeqlFolder}`);
}
}
if (!codeqlFolder) {
codeqlFolder = toolcache.find('CodeQL', codeqlURLVersion);
codeqlFolder = toolcache.find("CodeQL", codeqlURLVersion);
if (codeqlFolder) {
logger.debug(`CodeQL found in cache ${codeqlFolder}`);
}
}
if (!codeqlFolder) {
const codeqlToolcacheVersion = plVersion ? `${codeqlURLVersion}-${plVersion}` : codeqlURLVersion;
const codeqlToolcacheVersion = plVersion
? `${codeqlURLVersion}-${plVersion}`
: codeqlURLVersion;
logger.debug(`CodeQL not found in cache`);
if (!codeqlURL) {
// Provide a few options, from smaller to bigger
let bundles: string[] = [];
const bundles: string[] = [];
if (plVersion) {
bundles.push(CODEQL_BUNDLE_NAME.replace("-bundle", `-bundle-${plVersion}`));
bundles.push(
CODEQL_BUNDLE_NAME.replace("-bundle", `-bundle-${plVersion}`)
);
}
bundles.push(CODEQL_BUNDLE_NAME.replace("-bundle", `-bundle-${platform}`));
bundles.push(
CODEQL_BUNDLE_NAME.replace("-bundle", `-bundle-${platform}`)
);
bundles.push(CODEQL_BUNDLE_NAME);
codeqlURL = await getCodeQLBundleDownloadURL(bundles, githubAuth, githubUrl, mode, logger);
codeqlURL = await getCodeQLBundleDownloadURL(
bundles,
githubAuth,
githubUrl,
mode,
logger
);
}
logger.debug(`Using CodeQL URL: ${codeqlURL}`);
@@ -325,7 +344,11 @@ export async function setupCodeQL(
const codeqlExtracted = await toolcache.extractTar(codeqlPath);
logger.debug(`Caching ${codeqlToolcacheVersion}`);
codeqlFolder = await toolcache.cacheDir(codeqlExtracted, 'CodeQL', codeqlToolcacheVersion);
codeqlFolder = await toolcache.cacheDir(
codeqlExtracted,
"CodeQL",
codeqlToolcacheVersion
);
}
let codeqlCmd = path.join(codeqlFolder, "codeql", "codeql");
+58 -47
View File
@@ -1,16 +1,21 @@
import * as github from "@actions/github";
import test from 'ava';
import * as fs from 'fs';
import * as path from 'path';
import sinon from 'sinon';
import test from "ava";
import * as fs from "fs";
import * as path from "path";
import sinon from "sinon";
import * as api from './api-client';
import { getCachedCodeQL, setCodeQL } from './codeql';
import * as configUtils from './config-utils';
import { getLanguages, getNoLanguagesError, getUnknownLanguagesError, Language } from './languages';
import { getRunnerLogger } from './logging';
import {setupTests} from './testing-utils';
import * as util from './util';
import * as api from "./api-client";
import { getCachedCodeQL, setCodeQL } from "./codeql";
import * as configUtils from "./config-utils";
import {
getLanguages,
getNoLanguagesError,
getUnknownLanguagesError,
Language,
} from "./languages";
import { getRunnerLogger } from "./logging";
import { setupTests } from "./testing-utils";
import * as util from "./util";
setupTests(test);
@@ -74,19 +79,24 @@ test("load empty config", async (t) => {
tmpDir,
codeQL,
tmpDir,
'token',
'https://github.example.com',
logger);
"token",
"https://github.example.com",
logger
);
t.deepEqual(config, await configUtils.getDefaultConfig(
languages,
undefined,
tmpDir,
tmpDir,
codeQL,
tmpDir,
'https://github.example.com',
logger));
t.deepEqual(
config,
await configUtils.getDefaultConfig(
languages,
undefined,
tmpDir,
tmpDir,
codeQL,
tmpDir,
"https://github.example.com",
logger
)
);
});
});
@@ -138,7 +148,7 @@ test("load input outside of workspace", async (t) => {
await configUtils.initConfig(
[],
undefined,
'../input',
"../input",
tmpDir,
tmpDir,
getCachedCodeQL(),
@@ -193,10 +203,10 @@ test("load non-local input with invalid repo syntax", async (t) => {
});
});
test("load non-existent input", async t => {
return await util.withTmpDir(async tmpDir => {
test("load non-existent input", async (t) => {
return await util.withTmpDir(async (tmpDir) => {
const languages = [Language.javascript];
const configFile = 'input';
const configFile = "input";
t.false(fs.existsSync(path.join(tmpDir, configFile)));
try {
@@ -667,9 +677,9 @@ test("Queries in workflow file can be added to the set of queries without overri
});
});
test("Invalid queries in workflow file handled correctly", async t => {
return await util.withTmpDir(async tmpDir => {
const queries = 'foo/bar@v1@v3';
test("Invalid queries in workflow file handled correctly", async (t) => {
return await util.withTmpDir(async (tmpDir) => {
const queries = "foo/bar@v1@v3";
const languages = [Language.javascript];
// This function just needs to be type-correct; it doesn't need to do anything,
@@ -748,7 +758,7 @@ test("API client used when reading remote config", async (t) => {
// Create checkout directory for remote queries repository
fs.mkdirSync(path.join(tmpDir, "foo/bar/dev"), { recursive: true });
const configFile = 'octo-org/codeql-config/config.yaml@main';
const configFile = "octo-org/codeql-config/config.yaml@main";
const languages = [Language.javascript];
await configUtils.initConfig(
@@ -827,35 +837,36 @@ test("Invalid format of remote config handled correctly", async (t) => {
});
});
test("No detected languages", async t => {
test("No detected languages", async (t) => {
mockListLanguages([]);
try {
await getLanguages(
undefined,
{ owner: 'github', repo: 'example ' },
'token',
'https://github.example.com',
getRunnerLogger(true));
throw new Error('initConfig did not throw error');
{ owner: "github", repo: "example " },
"token",
"https://github.example.com",
getRunnerLogger(true)
);
throw new Error("initConfig did not throw error");
} catch (err) {
t.deepEqual(err, new Error(getNoLanguagesError()));
}
});
test("Unknown languages", async t => {
const languages = 'ruby,english';
test("Unknown languages", async (t) => {
const languages = "ruby,english";
try {
await getLanguages(
languages,
{ owner: 'github', repo: 'example ' },
'token',
'https://github.example.com',
getRunnerLogger(true));
throw new Error('initConfig did not throw error');
{ owner: "github", repo: "example " },
"token",
"https://github.example.com",
getRunnerLogger(true)
);
throw new Error("initConfig did not throw error");
} catch (err) {
t.deepEqual(err, new Error(getUnknownLanguagesError(['ruby', 'english'])));
t.deepEqual(err, new Error(getUnknownLanguagesError(["ruby", "english"])));
}
});
@@ -877,7 +888,7 @@ function doInvalidInputTest(
});
const languages = [Language.javascript];
const configFile = 'input';
const configFile = "input";
const inputFile = path.join(tmpDir, configFile);
fs.writeFileSync(inputFile, inputFileContents, "utf8");
+4 -6
View File
@@ -5,9 +5,8 @@ import * as path from "path";
import * as api from "./api-client";
import { CodeQL, ResolveQueriesOutput } from "./codeql";
import * as externalQueries from "./external-queries";
import { Language } from './languages';
import { Logger } from './logging';
import { Language } from "./languages";
import { Logger } from "./logging";
// Property names from the user-supplied config file.
const NAME_PROPERTY = "name";
@@ -602,8 +601,8 @@ export async function getDefaultConfig(
codeQL: CodeQL,
checkoutPath: string,
githubUrl: string,
logger: Logger): Promise<Config> {
logger: Logger
): Promise<Config> {
const queries = {};
await addDefaultQueries(codeQL, languages, queries);
if (queriesInput) {
@@ -925,4 +924,3 @@ export async function getConfig(
logger.debug(configString);
return JSON.parse(configString);
}
+27 -23
View File
@@ -1,12 +1,12 @@
import * as core from "@actions/core";
import { CodeQL } from './codeql';
import * as configUtils from './config-utils';
import { initCodeQL, initConfig, injectWindowsTracer, runInit } from './init';
import { getLanguages } from './languages';
import { getActionsLogger } from './logging';
import { parseRepositoryNwo } from './repository';
import * as util from './util';
import { CodeQL } from "./codeql";
import * as configUtils from "./config-utils";
import { initCodeQL, initConfig, injectWindowsTracer, runInit } from "./init";
import { getLanguages } from "./languages";
import { getActionsLogger } from "./logging";
import { parseRepositoryNwo } from "./repository";
import * as util from "./util";
interface InitSuccessStatusReport extends util.StatusReportBase {
// Comma-separated list of languages that analysis was run for
@@ -78,31 +78,35 @@ async function run() {
) {
return;
}
const repositoryNWO = parseRepositoryNwo(util.getRequiredEnvParam('GITHUB_REPOSITORY'));
const repositoryNWO = parseRepositoryNwo(
util.getRequiredEnvParam("GITHUB_REPOSITORY")
);
const languages = await getLanguages(
core.getInput('languages'),
core.getInput("languages"),
repositoryNWO,
core.getInput('token'),
util.getRequiredEnvParam('GITHUB_SERVER_URL'),
logger);
core.getInput("token"),
util.getRequiredEnvParam("GITHUB_SERVER_URL"),
logger
);
codeql = await initCodeQL(
core.getInput('tools'),
core.getInput("tools"),
languages,
core.getInput('token'),
util.getRequiredEnvParam('GITHUB_SERVER_URL'),
util.getRequiredEnvParam('RUNNER_TEMP'),
util.getRequiredEnvParam('RUNNER_TOOL_CACHE'),
'actions',
logger);
core.getInput("token"),
util.getRequiredEnvParam("GITHUB_SERVER_URL"),
util.getRequiredEnvParam("RUNNER_TEMP"),
util.getRequiredEnvParam("RUNNER_TOOL_CACHE"),
"actions",
logger
);
config = await initConfig(
languages,
core.getInput('queries'),
core.getInput('config-file'),
util.getRequiredEnvParam('RUNNER_TEMP'),
util.getRequiredEnvParam('RUNNER_TOOL_CACHE'),
core.getInput("queries"),
core.getInput("config-file"),
util.getRequiredEnvParam("RUNNER_TEMP"),
util.getRequiredEnvParam("RUNNER_TOOL_CACHE"),
codeql,
util.getRequiredEnvParam("GITHUB_WORKSPACE"),
core.getInput("token"),
+13 -14
View File
@@ -1,15 +1,14 @@
import * as toolrunnner from '@actions/exec/lib/toolrunner';
import * as fs from 'fs';
import * as path from 'path';
import * as analysisPaths from './analysis-paths';
import { CodeQL, setupCodeQL } from './codeql';
import * as configUtils from './config-utils';
import {Language} from './languages';
import { Logger } from './logging';
import { getCombinedTracerConfig, TracerConfig } from './tracer-config';
import * as util from './util';
import * as toolrunnner from "@actions/exec/lib/toolrunner";
import * as fs from "fs";
import * as path from "path";
import * as analysisPaths from "./analysis-paths";
import { CodeQL, setupCodeQL } from "./codeql";
import * as configUtils from "./config-utils";
import { Language } from "./languages";
import { Logger } from "./logging";
import { getCombinedTracerConfig, TracerConfig } from "./tracer-config";
import * as util from "./util";
export async function initCodeQL(
codeqlURL: string | undefined,
@@ -19,9 +18,9 @@ export async function initCodeQL(
tempDir: string,
toolsDir: string,
mode: util.Mode,
logger: Logger): Promise<CodeQL> {
logger.startGroup('Setup CodeQL tools');
logger: Logger
): Promise<CodeQL> {
logger.startGroup("Setup CodeQL tools");
const codeql = await setupCodeQL(
codeqlURL,
+32 -29
View File
@@ -1,8 +1,6 @@
import * as api from './api-client';
import { Logger } from './logging';
import { RepositoryNwo } from './repository';
import * as api from "./api-client";
import { Logger } from "./logging";
import { RepositoryNwo } from "./repository";
// All the languages supported by CodeQL
export enum Language {
@@ -49,12 +47,14 @@ export function isScannedLanguage(language: Language): boolean {
}
export function getNoLanguagesError(): string {
return "Did not detect any languages to analyze. " +
"Please update input in workflow or check that GitHub detects the correct languages in your repository.";
return (
"Did not detect any languages to analyze. " +
"Please update input in workflow or check that GitHub detects the correct languages in your repository."
);
}
export function getUnknownLanguagesError(languages: string[]): string {
return "Did not recognise the following languages: " + languages.join(', ');
return `Did not recognise the following languages: ${languages.join(", ")}`;
}
/**
@@ -72,14 +72,14 @@ export async function getLanguages(
repository: RepositoryNwo,
githubAuth: string,
githubUrl: string,
logger: Logger): Promise<Language[]> {
logger: Logger
): Promise<Language[]> {
// Obtain from action input 'languages' if set
let languages = (languagesInput || "")
.split(',')
.map(x => x.trim())
.filter(x => x.length > 0);
logger.info("Languages from configuration: " + JSON.stringify(languages));
.split(",")
.map((x) => x.trim())
.filter((x) => x.length > 0);
logger.info(`Languages from configuration: ${JSON.stringify(languages)}`);
if (languages.length === 0) {
// Obtain languages as all languages in the repo that can be analysed
@@ -87,8 +87,11 @@ export async function getLanguages(
repository,
githubAuth,
githubUrl,
logger);
logger.info("Automatically detected languages: " + JSON.stringify(languages));
logger
);
logger.info(
`Automatically detected languages: ${JSON.stringify(languages)}`
);
}
// If the languages parameter was not given and no languages were
@@ -100,7 +103,7 @@ export async function getLanguages(
// Make sure they are supported
const parsedLanguages: Language[] = [];
const unknownLanguages: string[] = [];
for (let language of languages) {
for (const language of languages) {
const parsedLanguage = parseLanguage(language);
if (parsedLanguage === undefined) {
unknownLanguages.push(language);
@@ -115,7 +118,6 @@ export async function getLanguages(
return parsedLanguages;
}
/**
* Gets the set of languages in the current repository
*/
@@ -123,27 +125,28 @@ async function getLanguagesInRepo(
repository: RepositoryNwo,
githubAuth: string,
githubUrl: string,
logger: Logger): Promise<Language[]> {
logger: Logger
): Promise<Language[]> {
logger.debug(`GitHub repo ${repository.owner} ${repository.repo}`);
const response = await api.getApiClient(githubAuth, githubUrl, true).repos.listLanguages({
owner: repository.owner,
repo: repository.repo
});
const response = await api
.getApiClient(githubAuth, githubUrl, true)
.repos.listLanguages({
owner: repository.owner,
repo: repository.repo,
});
logger.debug("Languages API response: " + JSON.stringify(response));
logger.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<Language> = new Set();
for (let lang of Object.keys(response.data)) {
let parsedLang = parseLanguage(lang);
const languages: Set<Language> = new Set();
for (const lang of Object.keys(response.data)) {
const parsedLang = parseLanguage(lang);
if (parsedLang !== undefined) {
languages.add(parsedLang);
}
}
return [...languages];
}
+16 -15
View File
@@ -1,18 +1,18 @@
import { Command } from 'commander';
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import { Command } from "commander";
import * as fs from "fs";
import * as os from "os";
import * as path from "path";
import { runAnalyze } from './analyze';
import { determineAutobuildLanguage, runAutobuild } from './autobuild';
import { CodeQL, getCodeQL } from './codeql';
import { Config, getConfig } from './config-utils';
import { initCodeQL, initConfig, injectWindowsTracer, runInit } from './init';
import { getLanguages, Language, parseLanguage } from './languages';
import { getRunnerLogger } from './logging';
import { parseRepositoryNwo } from './repository';
import * as upload_lib from './upload-lib';
import { getMemoryFlag, getThreadsFlag, getAddSnippetsFlag } from './util';
import { runAnalyze } from "./analyze";
import { determineAutobuildLanguage, runAutobuild } from "./autobuild";
import { CodeQL, getCodeQL } from "./codeql";
import { Config, getConfig } from "./config-utils";
import { initCodeQL, initConfig, injectWindowsTracer, runInit } from "./init";
import { getLanguages, Language, parseLanguage } from "./languages";
import { getRunnerLogger } from "./logging";
import { parseRepositoryNwo } from "./repository";
import * as upload_lib from "./upload-lib";
import { getMemoryFlag, getThreadsFlag, getAddSnippetsFlag } from "./util";
const program = new Command();
program.version("0.0.1");
@@ -167,7 +167,8 @@ program
repositoryNWO,
cmd.githubAuth,
githubUrl,
logger);
logger
);
let codeql: CodeQL;
if (cmd.codeqlPath !== undefined) {