Move extraQueryExclusions out of AugmentationProperties

This commit is contained in:
Michael B. Gale
2025-09-03 12:08:11 +01:00
parent ac9b91e745
commit e9fb72dd82
13 changed files with 1131 additions and 911 deletions

View File

@@ -13,7 +13,7 @@ import {
} from "./actions-util";
import * as api from "./api-client";
import { CliError, wrapCliConfigurationError } from "./cli-errors";
import { type Config } from "./config-utils";
import { appendExtraQueryExclusions, type Config } from "./config-utils";
import { DocUrl } from "./doc-url";
import { EnvVar } from "./environment";
import {
@@ -1149,11 +1149,11 @@ async function runCli(
}
/**
* Generates a code scanning configuration that is to be used for a scan.
* Writes the code scanning configuration that is to be used by the CLI.
*
* @param codeql The CodeQL object to use.
* @param config The configuration to use.
* @returns the path to the generated user configuration file.
* @param config The CodeQL Action state to use.
* @returns The path to the generated user configuration file.
*/
async function writeCodeScanningConfigFile(
config: Config,
@@ -1161,14 +1161,24 @@ async function writeCodeScanningConfigFile(
): Promise<string> {
const codeScanningConfigFile = getGeneratedCodeScanningConfigPath(config);
// Apply the `extraQueryExclusions` from the CodeQL Action state to the CLI configuration.
// We do this here at the latest possible point before passing the CLI configuration on to
// the CLI so that the `extraQueryExclusions` appear after all user-configured `query-filters`.
// See the comment in `applyExtraQueryExclusions` for more information, as well as
// https://github.com/github/codeql-action/pull/2938
const augmentedConfig = appendExtraQueryExclusions(
config.extraQueryExclusions,
config.computedConfig,
);
logger.info(
`Writing augmented user configuration file to ${codeScanningConfigFile}`,
);
logger.startGroup("Augmented user configuration file contents");
logger.info(yaml.dump(config.computedConfig));
logger.info(yaml.dump(augmentedConfig));
logger.endGroup();
fs.writeFileSync(codeScanningConfigFile, yaml.dump(config.computedConfig));
fs.writeFileSync(codeScanningConfigFile, yaml.dump(augmentedConfig));
return codeScanningConfigFile;
}