Merge pull request #2572 from github/dbartol/actions-analysis
Add support for `actions` language
This commit is contained in:
commit
cbe1897960
12 changed files with 46 additions and 14 deletions
5
lib/config-utils.js
generated
5
lib/config-utils.js
generated
|
|
@ -501,8 +501,8 @@ function parseRegistries(registriesInput) {
|
|||
}
|
||||
function parseRegistriesWithoutCredentials(registriesInput) {
|
||||
return parseRegistries(registriesInput)?.map((r) => {
|
||||
const { url, packages } = r;
|
||||
return { url, packages };
|
||||
const { url, packages, kind } = r;
|
||||
return { url, packages, kind };
|
||||
});
|
||||
}
|
||||
function isLocal(configPath) {
|
||||
|
|
@ -626,6 +626,7 @@ function createRegistriesBlock(registries) {
|
|||
// ensure the url ends with a slash to avoid a bug in the CLI 2.10.4
|
||||
url: !registry?.url.endsWith("/") ? `${registry.url}/` : registry.url,
|
||||
packages: registry.packages,
|
||||
kind: registry.kind,
|
||||
}));
|
||||
const qlconfig = {
|
||||
registries: safeRegistries,
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
1
lib/languages.js
generated
1
lib/languages.js
generated
|
|
@ -7,6 +7,7 @@ exports.isScannedLanguage = isScannedLanguage;
|
|||
// All the languages supported by CodeQL
|
||||
var Language;
|
||||
(function (Language) {
|
||||
Language["actions"] = "actions";
|
||||
Language["csharp"] = "csharp";
|
||||
Language["cpp"] = "cpp";
|
||||
Language["go"] = "go";
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"languages.js","sourceRoot":"","sources":["../src/languages.ts"],"names":[],"mappings":";;;AA+BA,sCAgBC;AAED,4CAQC;AAED,8CAEC;AA7DD,wCAAwC;AACxC,IAAY,QAUX;AAVD,WAAY,QAAQ;IAClB,6BAAiB,CAAA;IACjB,uBAAW,CAAA;IACX,qBAAS,CAAA;IACT,yBAAa,CAAA;IACb,qCAAyB,CAAA;IACzB,6BAAiB,CAAA;IACjB,yBAAa,CAAA;IACb,yBAAa,CAAA;IACb,2BAAe,CAAA;AACjB,CAAC,EAVW,QAAQ,wBAA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CAAA;IACb,qCAAyB,CAAA;IACzB,6BAAiB,CAAA;IACjB,yBAAa,CAAA;IACb,yBAAa,CAAA;IACb,2BAAe,CAAA;AACjB,CAAC,EAXW,QAAQ,wBAAR,QAAQ,QAWnB;AAED,iCAAiC;AACpB,QAAA,gBAAgB,GAAiC;IAC5D,CAAC,EAAE,QAAQ,CAAC,GAAG;IACf,KAAK,EAAE,QAAQ,CAAC,GAAG;IACnB,IAAI,EAAE,QAAQ,CAAC,MAAM;IACrB,MAAM,EAAE,QAAQ,CAAC,IAAI;IACrB,UAAU,EAAE,QAAQ,CAAC,UAAU;CAChC,CAAC;AAEF;;;;;;;;GAQG;AACH,SAAgB,aAAa,CAAC,QAAgB;IAC5C,0BAA0B;IAC1B,QAAQ,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAEzC,6BAA6B;IAC7B,IAAI,QAAQ,IAAI,QAAQ,EAAE,CAAC;QACzB,OAAO,QAAoB,CAAC;IAC9B,CAAC;IAED,iEAAiE;IACjE,oCAAoC;IACpC,IAAI,QAAQ,IAAI,wBAAgB,EAAE,CAAC;QACjC,OAAO,wBAAgB,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAgB,gBAAgB,CAAC,QAAkB;IACjD,OAAO;QACL,QAAQ,CAAC,GAAG;QACZ,QAAQ,CAAC,MAAM;QACf,QAAQ,CAAC,EAAE;QACX,QAAQ,CAAC,IAAI;QACb,QAAQ,CAAC,KAAK;KACf,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACvB,CAAC;AAED,SAAgB,iBAAiB,CAAC,QAAkB;IAClD,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;AACrC,CAAC"}
|
||||
3
lib/util.js
generated
3
lib/util.js
generated
|
|
@ -78,6 +78,7 @@ const exec = __importStar(require("@actions/exec/lib/exec"));
|
|||
const check_disk_space_1 = __importDefault(require("check-disk-space"));
|
||||
const del_1 = __importDefault(require("del"));
|
||||
const get_folder_size_1 = __importDefault(require("get-folder-size"));
|
||||
const yaml = __importStar(require("js-yaml"));
|
||||
const semver = __importStar(require("semver"));
|
||||
const apiCompatibility = __importStar(require("./api-compatibility.json"));
|
||||
const environment_1 = require("./environment");
|
||||
|
|
@ -117,7 +118,7 @@ function getExtraOptionsEnvParam() {
|
|||
return {};
|
||||
}
|
||||
try {
|
||||
return JSON.parse(raw);
|
||||
return yaml.load(raw);
|
||||
}
|
||||
catch (unwrappedError) {
|
||||
const error = wrapError(unwrappedError);
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
12
lib/util.test.js
generated
12
lib/util.test.js
generated
|
|
@ -31,6 +31,7 @@ const os = __importStar(require("os"));
|
|||
const path_1 = __importDefault(require("path"));
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const ava_1 = __importDefault(require("ava"));
|
||||
const yaml = __importStar(require("js-yaml"));
|
||||
const sinon = __importStar(require("sinon"));
|
||||
const api = __importStar(require("./api-client"));
|
||||
const environment_1 = require("./environment");
|
||||
|
|
@ -136,16 +137,23 @@ for (const { input, totalMemoryMb, platform, expectedMemoryValue, reservedPercen
|
|||
t.deepEqual(util.getExtraOptionsEnvParam(), options);
|
||||
process.env.CODEQL_ACTION_EXTRA_OPTIONS = origExtraOptions;
|
||||
});
|
||||
(0, ava_1.default)("getExtraOptionsEnvParam() succeeds on valid options", (t) => {
|
||||
(0, ava_1.default)("getExtraOptionsEnvParam() succeeds on valid JSON options", (t) => {
|
||||
const origExtraOptions = process.env.CODEQL_ACTION_EXTRA_OPTIONS;
|
||||
const options = { database: { init: ["--debug"] } };
|
||||
process.env.CODEQL_ACTION_EXTRA_OPTIONS = JSON.stringify(options);
|
||||
t.deepEqual(util.getExtraOptionsEnvParam(), options);
|
||||
process.env.CODEQL_ACTION_EXTRA_OPTIONS = origExtraOptions;
|
||||
});
|
||||
(0, ava_1.default)("getExtraOptionsEnvParam() succeeds on valid YAML options", (t) => {
|
||||
const origExtraOptions = process.env.CODEQL_ACTION_EXTRA_OPTIONS;
|
||||
const options = { database: { init: ["--debug"] } };
|
||||
process.env.CODEQL_ACTION_EXTRA_OPTIONS = yaml.dump(options);
|
||||
t.deepEqual(util.getExtraOptionsEnvParam(), { ...options });
|
||||
process.env.CODEQL_ACTION_EXTRA_OPTIONS = origExtraOptions;
|
||||
});
|
||||
(0, ava_1.default)("getExtraOptionsEnvParam() fails on invalid JSON", (t) => {
|
||||
const origExtraOptions = process.env.CODEQL_ACTION_EXTRA_OPTIONS;
|
||||
process.env.CODEQL_ACTION_EXTRA_OPTIONS = "{{invalid-json}}";
|
||||
process.env.CODEQL_ACTION_EXTRA_OPTIONS = "{{invalid-json}";
|
||||
t.throws(util.getExtraOptionsEnvParam);
|
||||
process.env.CODEQL_ACTION_EXTRA_OPTIONS = origExtraOptions;
|
||||
});
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -64,6 +64,12 @@ export interface RegistryConfigNoCredentials {
|
|||
|
||||
// List of globs that determine which packs are associated with this registry.
|
||||
packages: string[] | string;
|
||||
|
||||
// Kind of registry, either "github" or "docker". Default is "docker".
|
||||
// "docker" refers specifically to the GitHub Container Registry, which is the usual way of sharing CodeQL packs.
|
||||
// "github" refers to packs published as content in a GitHub repository. This kind of registry is used in scenarios
|
||||
// where GHCR is not available, such as certain GHES environments.
|
||||
kind?: "github" | "docker";
|
||||
}
|
||||
|
||||
interface ExcludeQueryFilter {
|
||||
|
|
@ -880,8 +886,8 @@ export function parseRegistriesWithoutCredentials(
|
|||
registriesInput?: string,
|
||||
): RegistryConfigNoCredentials[] | undefined {
|
||||
return parseRegistries(registriesInput)?.map((r) => {
|
||||
const { url, packages } = r;
|
||||
return { url, packages };
|
||||
const { url, packages, kind } = r;
|
||||
return { url, packages, kind };
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -1048,6 +1054,7 @@ function createRegistriesBlock(registries: RegistryConfigWithCredentials[]): {
|
|||
// ensure the url ends with a slash to avoid a bug in the CLI 2.10.4
|
||||
url: !registry?.url.endsWith("/") ? `${registry.url}/` : registry.url,
|
||||
packages: registry.packages,
|
||||
kind: registry.kind,
|
||||
}));
|
||||
const qlconfig = {
|
||||
registries: safeRegistries,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
// All the languages supported by CodeQL
|
||||
export enum Language {
|
||||
actions = "actions",
|
||||
csharp = "csharp",
|
||||
cpp = "cpp",
|
||||
go = "go",
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import path from "path";
|
|||
|
||||
import * as core from "@actions/core";
|
||||
import test from "ava";
|
||||
import * as yaml from "js-yaml";
|
||||
import * as sinon from "sinon";
|
||||
|
||||
import * as api from "./api-client";
|
||||
|
|
@ -144,7 +145,7 @@ test("getExtraOptionsEnvParam() succeeds on valid JSON with invalid options (for
|
|||
process.env.CODEQL_ACTION_EXTRA_OPTIONS = origExtraOptions;
|
||||
});
|
||||
|
||||
test("getExtraOptionsEnvParam() succeeds on valid options", (t) => {
|
||||
test("getExtraOptionsEnvParam() succeeds on valid JSON options", (t) => {
|
||||
const origExtraOptions = process.env.CODEQL_ACTION_EXTRA_OPTIONS;
|
||||
|
||||
const options = { database: { init: ["--debug"] } };
|
||||
|
|
@ -155,10 +156,21 @@ test("getExtraOptionsEnvParam() succeeds on valid options", (t) => {
|
|||
process.env.CODEQL_ACTION_EXTRA_OPTIONS = origExtraOptions;
|
||||
});
|
||||
|
||||
test("getExtraOptionsEnvParam() succeeds on valid YAML options", (t) => {
|
||||
const origExtraOptions = process.env.CODEQL_ACTION_EXTRA_OPTIONS;
|
||||
|
||||
const options = { database: { init: ["--debug"] } };
|
||||
process.env.CODEQL_ACTION_EXTRA_OPTIONS = yaml.dump(options);
|
||||
|
||||
t.deepEqual(util.getExtraOptionsEnvParam(), { ...options });
|
||||
|
||||
process.env.CODEQL_ACTION_EXTRA_OPTIONS = origExtraOptions;
|
||||
});
|
||||
|
||||
test("getExtraOptionsEnvParam() fails on invalid JSON", (t) => {
|
||||
const origExtraOptions = process.env.CODEQL_ACTION_EXTRA_OPTIONS;
|
||||
|
||||
process.env.CODEQL_ACTION_EXTRA_OPTIONS = "{{invalid-json}}";
|
||||
process.env.CODEQL_ACTION_EXTRA_OPTIONS = "{{invalid-json}";
|
||||
t.throws(util.getExtraOptionsEnvParam);
|
||||
|
||||
process.env.CODEQL_ACTION_EXTRA_OPTIONS = origExtraOptions;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import * as exec from "@actions/exec/lib/exec";
|
|||
import checkDiskSpace from "check-disk-space";
|
||||
import del from "del";
|
||||
import getFolderSize from "get-folder-size";
|
||||
import * as yaml from "js-yaml";
|
||||
import * as semver from "semver";
|
||||
|
||||
import * as apiCompatibility from "./api-compatibility.json";
|
||||
|
|
@ -121,7 +122,7 @@ export function getExtraOptionsEnvParam(): object {
|
|||
return {};
|
||||
}
|
||||
try {
|
||||
return JSON.parse(raw) as object;
|
||||
return yaml.load(raw) as object;
|
||||
} catch (unwrappedError) {
|
||||
const error = wrapError(unwrappedError);
|
||||
throw new ConfigurationError(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue