Fix failing test and address PR comments
This commit is contained in:
parent
2314063848
commit
a09a029937
12 changed files with 28 additions and 15 deletions
5
lib/codeql.js
generated
5
lib/codeql.js
generated
|
|
@ -866,7 +866,7 @@ async function generateCodescanningConfig(codeql, config) {
|
||||||
}
|
}
|
||||||
const configLocation = path.resolve(config.tempDir, "user-config.yaml");
|
const configLocation = path.resolve(config.tempDir, "user-config.yaml");
|
||||||
// make a copy so we can modify it
|
// make a copy so we can modify it
|
||||||
const augmentedConfig = JSON.parse(JSON.stringify(config.originalUserInput));
|
const augmentedConfig = cloneObject(config.originalUserInput);
|
||||||
// Inject the queries from the input
|
// Inject the queries from the input
|
||||||
if (config.augmentationProperties.queriesInput) {
|
if (config.augmentationProperties.queriesInput) {
|
||||||
if (config.augmentationProperties.queriesInputCombines) {
|
if (config.augmentationProperties.queriesInputCombines) {
|
||||||
|
|
@ -921,4 +921,7 @@ async function generateCodescanningConfig(codeql, config) {
|
||||||
fs.writeFileSync(configLocation, yaml.dump(augmentedConfig));
|
fs.writeFileSync(configLocation, yaml.dump(augmentedConfig));
|
||||||
return configLocation;
|
return configLocation;
|
||||||
}
|
}
|
||||||
|
function cloneObject(obj) {
|
||||||
|
return JSON.parse(JSON.stringify(obj));
|
||||||
|
}
|
||||||
//# sourceMappingURL=codeql.js.map
|
//# sourceMappingURL=codeql.js.map
|
||||||
File diff suppressed because one or more lines are too long
2
lib/config-utils.js
generated
2
lib/config-utils.js
generated
|
|
@ -47,6 +47,8 @@ exports.defaultAugmentationProperties = {
|
||||||
queriesInputCombines: false,
|
queriesInputCombines: false,
|
||||||
packsInputCombines: false,
|
packsInputCombines: false,
|
||||||
injectedMlQueries: false,
|
injectedMlQueries: false,
|
||||||
|
packsInput: undefined,
|
||||||
|
queriesInput: undefined,
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* A list of queries from https://github.com/github/codeql that
|
* A list of queries from https://github.com/github/codeql that
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
3
lib/config-utils.test.js
generated
3
lib/config-utils.test.js
generated
|
|
@ -839,7 +839,8 @@ const invalidPackNameMacro = ava_1.default.macro({
|
||||||
* Test macro for testing the packs block and the packs input
|
* Test macro for testing the packs block and the packs input
|
||||||
*/
|
*/
|
||||||
function parseInputAndConfigMacro(t, packsFromConfig, packsFromInput, languages, expected) {
|
function parseInputAndConfigMacro(t, packsFromConfig, packsFromInput, languages, expected) {
|
||||||
t.deepEqual(configUtils.parsePacks(packsFromConfig, packsFromInput, !!(packsFromInput === null || packsFromInput === void 0 ? void 0 : packsFromInput.trim().startsWith("+")), languages, "/a/b", mockLogger), expected);
|
t.deepEqual(configUtils.parsePacks(packsFromConfig, packsFromInput, !!(packsFromInput === null || packsFromInput === void 0 ? void 0 : packsFromInput.trim().startsWith("+")), // coerce to boolean
|
||||||
|
languages, "/a/b", mockLogger), expected);
|
||||||
}
|
}
|
||||||
parseInputAndConfigMacro.title = (providedTitle) => `Parse Packs input and config: ${providedTitle}`;
|
parseInputAndConfigMacro.title = (providedTitle) => `Parse Packs input and config: ${providedTitle}`;
|
||||||
const mockLogger = {
|
const mockLogger = {
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
5
lib/util.js
generated
5
lib/util.js
generated
|
|
@ -649,9 +649,8 @@ exports.isInTestMode = isInTestMode;
|
||||||
* that gets passed to the CLI.
|
* that gets passed to the CLI.
|
||||||
*/
|
*/
|
||||||
async function useCodeScanningConfigInCli(codeql) {
|
async function useCodeScanningConfigInCli(codeql) {
|
||||||
return ((process.env[EnvVar.CODEQL_PASS_CONFIG_TO_CLI] === "true" &&
|
return (process.env[EnvVar.CODEQL_PASS_CONFIG_TO_CLI] === "true" &&
|
||||||
(await codeQlVersionAbove(codeql, codeql_1.CODEQL_VERSION_CONFIG_FILES))) ||
|
(await codeQlVersionAbove(codeql, codeql_1.CODEQL_VERSION_CONFIG_FILES)));
|
||||||
false);
|
|
||||||
}
|
}
|
||||||
exports.useCodeScanningConfigInCli = useCodeScanningConfigInCli;
|
exports.useCodeScanningConfigInCli = useCodeScanningConfigInCli;
|
||||||
//# sourceMappingURL=util.js.map
|
//# sourceMappingURL=util.js.map
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -1234,13 +1234,16 @@ async function runTool(cmd: string, args: string[] = []) {
|
||||||
* @param config The configuration to use.
|
* @param config The configuration to use.
|
||||||
* @returns the path to the generated user configuration file.
|
* @returns the path to the generated user configuration file.
|
||||||
*/
|
*/
|
||||||
async function generateCodescanningConfig(codeql: CodeQL, config: Config) {
|
async function generateCodescanningConfig(
|
||||||
|
codeql: CodeQL,
|
||||||
|
config: Config
|
||||||
|
): Promise<string | undefined> {
|
||||||
if (!(await util.useCodeScanningConfigInCli(codeql))) {
|
if (!(await util.useCodeScanningConfigInCli(codeql))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const configLocation = path.resolve(config.tempDir, "user-config.yaml");
|
const configLocation = path.resolve(config.tempDir, "user-config.yaml");
|
||||||
// make a copy so we can modify it
|
// make a copy so we can modify it
|
||||||
const augmentedConfig = JSON.parse(JSON.stringify(config.originalUserInput));
|
const augmentedConfig = cloneObject(config.originalUserInput);
|
||||||
|
|
||||||
// Inject the queries from the input
|
// Inject the queries from the input
|
||||||
if (config.augmentationProperties.queriesInput) {
|
if (config.augmentationProperties.queriesInput) {
|
||||||
|
|
@ -1299,3 +1302,7 @@ async function generateCodescanningConfig(codeql: CodeQL, config: Config) {
|
||||||
fs.writeFileSync(configLocation, yaml.dump(augmentedConfig));
|
fs.writeFileSync(configLocation, yaml.dump(augmentedConfig));
|
||||||
return configLocation;
|
return configLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cloneObject(obj: any) {
|
||||||
|
return JSON.parse(JSON.stringify(obj));
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1623,7 +1623,7 @@ function parseInputAndConfigMacro(
|
||||||
configUtils.parsePacks(
|
configUtils.parsePacks(
|
||||||
packsFromConfig,
|
packsFromConfig,
|
||||||
packsFromInput,
|
packsFromInput,
|
||||||
!!packsFromInput?.trim().startsWith("+"),
|
!!packsFromInput?.trim().startsWith("+"), // coerce to boolean
|
||||||
languages,
|
languages,
|
||||||
"/a/b",
|
"/a/b",
|
||||||
mockLogger
|
mockLogger
|
||||||
|
|
|
||||||
|
|
@ -198,6 +198,8 @@ export const defaultAugmentationProperties: AugmentationProperties = {
|
||||||
queriesInputCombines: false,
|
queriesInputCombines: false,
|
||||||
packsInputCombines: false,
|
packsInputCombines: false,
|
||||||
injectedMlQueries: false,
|
injectedMlQueries: false,
|
||||||
|
packsInput: undefined,
|
||||||
|
queriesInput: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Packs = Partial<Record<Language, string[]>>;
|
export type Packs = Partial<Record<Language, string[]>>;
|
||||||
|
|
|
||||||
|
|
@ -776,8 +776,7 @@ export async function useCodeScanningConfigInCli(
|
||||||
codeql: CodeQL
|
codeql: CodeQL
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
return (
|
return (
|
||||||
(process.env[EnvVar.CODEQL_PASS_CONFIG_TO_CLI] === "true" &&
|
process.env[EnvVar.CODEQL_PASS_CONFIG_TO_CLI] === "true" &&
|
||||||
(await codeQlVersionAbove(codeql, CODEQL_VERSION_CONFIG_FILES))) ||
|
(await codeQlVersionAbove(codeql, CODEQL_VERSION_CONFIG_FILES))
|
||||||
false
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue