use the new additional suites
This commit is contained in:
parent
30f7117e6a
commit
50dcaaf00d
6 changed files with 84 additions and 36 deletions
2
lib/config-utils.js
generated
2
lib/config-utils.js
generated
|
|
@ -22,7 +22,7 @@ class ExternalQuery {
|
||||||
}
|
}
|
||||||
exports.ExternalQuery = ExternalQuery;
|
exports.ExternalQuery = ExternalQuery;
|
||||||
// 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-experimental', 'security-and-quality'];
|
const builtinSuites = ['security-extended', 'security-and-quality'];
|
||||||
class Config {
|
class Config {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.name = "";
|
this.name = "";
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
45
lib/finalize-db.js
generated
45
lib/finalize-db.js
generated
|
|
@ -67,24 +67,39 @@ async function finalizeDatabaseCreation(codeqlCmd, databaseFolder) {
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
async function runResolveQueries(codeqlCmd, queries) {
|
||||||
|
let output = '';
|
||||||
|
const options = {
|
||||||
|
listeners: {
|
||||||
|
stdout: (data) => {
|
||||||
|
output += data.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
await exec.exec(codeqlCmd, [
|
||||||
|
'resolve',
|
||||||
|
'queries',
|
||||||
|
...queries,
|
||||||
|
'--format=bylanguage'
|
||||||
|
], options);
|
||||||
|
return JSON.parse(output);
|
||||||
|
}
|
||||||
async function resolveQueryLanguages(codeqlCmd, config) {
|
async function resolveQueryLanguages(codeqlCmd, config) {
|
||||||
let res = new Map();
|
let res = new Map();
|
||||||
if (config.additionalQueries.length !== 0) {
|
if (config.additionalSuites.length !== 0) {
|
||||||
let resolveQueriesOutput = '';
|
const suites = [];
|
||||||
const options = {
|
for (const language of await util.getLanguages()) {
|
||||||
listeners: {
|
for (const additionalSuite of config.additionalSuites) {
|
||||||
stdout: (data) => {
|
suites.push(language + '-' + additionalSuite + '.qls');
|
||||||
resolveQueriesOutput += data.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
await exec.exec(codeqlCmd, [
|
const resolveQueriesOutputObject = await runResolveQueries(codeqlCmd, suites);
|
||||||
'resolve',
|
for (const [language, queries] of Object.entries(resolveQueriesOutputObject.byLanguage)) {
|
||||||
'queries',
|
res[language] = Object.keys(queries);
|
||||||
...config.additionalQueries,
|
}
|
||||||
'--format=bylanguage'
|
}
|
||||||
], options);
|
if (config.additionalQueries.length !== 0) {
|
||||||
const resolveQueriesOutputObject = JSON.parse(resolveQueriesOutput);
|
const resolveQueriesOutputObject = await runResolveQueries(codeqlCmd, config.additionalQueries);
|
||||||
for (const [language, queries] of Object.entries(resolveQueriesOutputObject.byLanguage)) {
|
for (const [language, queries] of Object.entries(resolveQueriesOutputObject.byLanguage)) {
|
||||||
res[language] = Object.keys(queries);
|
res[language] = Object.keys(queries);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -18,7 +18,7 @@ export class ExternalQuery {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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-experimental', 'security-and-quality'] as const;
|
const builtinSuites = ['security-extended', 'security-and-quality'] as const;
|
||||||
// Derive the union type from the array values
|
// Derive the union type from the array values
|
||||||
type BuiltInSuite = typeof builtinSuites[number];
|
type BuiltInSuite = typeof builtinSuites[number];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,29 +69,62 @@ async function finalizeDatabaseCreation(codeqlCmd: string, databaseFolder: strin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ResolveQueriesOutput {
|
||||||
|
byLanguage: {
|
||||||
|
[language: string]: {
|
||||||
|
[queryPath: string]: {}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
noDeclaredLanguage: {
|
||||||
|
[queryPath: string]: {}
|
||||||
|
};
|
||||||
|
multipleDeclaredLanguages: {
|
||||||
|
[queryPath: string]: {}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async function runResolveQueries(codeqlCmd: string, queries: string[]): Promise<ResolveQueriesOutput> {
|
||||||
|
let output = '';
|
||||||
|
const options = {
|
||||||
|
listeners: {
|
||||||
|
stdout: (data: Buffer) => {
|
||||||
|
output += data.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
await exec.exec(
|
||||||
|
codeqlCmd, [
|
||||||
|
'resolve',
|
||||||
|
'queries',
|
||||||
|
...queries,
|
||||||
|
'--format=bylanguage'
|
||||||
|
],
|
||||||
|
options);
|
||||||
|
|
||||||
|
return JSON.parse(output);
|
||||||
|
}
|
||||||
|
|
||||||
async function resolveQueryLanguages(codeqlCmd: string, config: configUtils.Config): Promise<Map<string, string[]>> {
|
async function resolveQueryLanguages(codeqlCmd: string, config: configUtils.Config): Promise<Map<string, string[]>> {
|
||||||
let res = new Map();
|
let res = new Map();
|
||||||
|
|
||||||
if (config.additionalQueries.length !== 0) {
|
if (config.additionalSuites.length !== 0) {
|
||||||
let resolveQueriesOutput = '';
|
const suites: string[] = [];
|
||||||
const options = {
|
for (const language of await util.getLanguages()) {
|
||||||
listeners: {
|
for (const additionalSuite of config.additionalSuites) {
|
||||||
stdout: (data: Buffer) => {
|
suites.push(language + '-' + additionalSuite + '.qls');
|
||||||
resolveQueriesOutput += data.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
await exec.exec(
|
const resolveQueriesOutputObject = await runResolveQueries(codeqlCmd, suites);
|
||||||
codeqlCmd, [
|
|
||||||
'resolve',
|
|
||||||
'queries',
|
|
||||||
...config.additionalQueries,
|
|
||||||
'--format=bylanguage'
|
|
||||||
],
|
|
||||||
options);
|
|
||||||
|
|
||||||
const resolveQueriesOutputObject = JSON.parse(resolveQueriesOutput);
|
for (const [language, queries] of Object.entries(resolveQueriesOutputObject.byLanguage)) {
|
||||||
|
res[language] = Object.keys(<any>queries);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.additionalQueries.length !== 0) {
|
||||||
|
const resolveQueriesOutputObject = await runResolveQueries(codeqlCmd, config.additionalQueries);
|
||||||
|
|
||||||
for (const [language, queries] of Object.entries(resolveQueriesOutputObject.byLanguage)) {
|
for (const [language, queries] of Object.entries(resolveQueriesOutputObject.byLanguage)) {
|
||||||
res[language] = Object.keys(<any>queries);
|
res[language] = Object.keys(<any>queries);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue