Skip to content

Commit

Permalink
Fix failing test and address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aeisenberg committed Aug 11, 2022
1 parent 2314063 commit a09a029
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 15 deletions.
5 changes: 4 additions & 1 deletion lib/codeql.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/codeql.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions lib/config-utils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/config-utils.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion lib/config-utils.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/config-utils.test.js.map

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions lib/util.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/util.js.map

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions src/codeql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1234,13 +1234,16 @@ async function runTool(cmd: string, args: string[] = []) {
* @param config The configuration to use.
* @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))) {
return;
}
const configLocation = path.resolve(config.tempDir, "user-config.yaml");
// 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
if (config.augmentationProperties.queriesInput) {
Expand Down Expand Up @@ -1299,3 +1302,7 @@ async function generateCodescanningConfig(codeql: CodeQL, config: Config) {
fs.writeFileSync(configLocation, yaml.dump(augmentedConfig));
return configLocation;
}

function cloneObject(obj: any) {
return JSON.parse(JSON.stringify(obj));
}
2 changes: 1 addition & 1 deletion src/config-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1623,7 +1623,7 @@ function parseInputAndConfigMacro(
configUtils.parsePacks(
packsFromConfig,
packsFromInput,
!!packsFromInput?.trim().startsWith("+"),
!!packsFromInput?.trim().startsWith("+"), // coerce to boolean
languages,
"/a/b",
mockLogger
Expand Down
2 changes: 2 additions & 0 deletions src/config-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ export const defaultAugmentationProperties: AugmentationProperties = {
queriesInputCombines: false,
packsInputCombines: false,
injectedMlQueries: false,
packsInput: undefined,
queriesInput: undefined,
};

export type Packs = Partial<Record<Language, string[]>>;
Expand Down
5 changes: 2 additions & 3 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -776,8 +776,7 @@ export async function useCodeScanningConfigInCli(
codeql: CodeQL
): Promise<boolean> {
return (
(process.env[EnvVar.CODEQL_PASS_CONFIG_TO_CLI] === "true" &&
(await codeQlVersionAbove(codeql, CODEQL_VERSION_CONFIG_FILES))) ||
false
process.env[EnvVar.CODEQL_PASS_CONFIG_TO_CLI] === "true" &&
(await codeQlVersionAbove(codeql, CODEQL_VERSION_CONFIG_FILES))
);
}

0 comments on commit a09a029

Please sign in to comment.