diff --git a/CHANGELOG.md b/CHANGELOG.md index 1168dd60b..d81420a0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ See the [releases page](https://github.com/github/codeql-action/releases) for th ## [UNRELEASED] -No user facing changes. +- Fix bug in PR analysis where user-provided `include` query filter fails to exclude non-included queries. [#2938](https://github.com/github/codeql-action/pull/2938) ## 3.29.0 - 11 Jun 2025 diff --git a/src/codeql.ts b/src/codeql.ts index 1de541cd8..3085c2c00 100644 --- a/src/codeql.ts +++ b/src/codeql.ts @@ -1266,8 +1266,12 @@ async function generateCodeScanningConfig( } augmentedConfig["query-filters"] = [ - ...(config.augmentationProperties.extraQueryExclusions || []), + // Ordering matters. If the first filter is an inclusion, it implicitly + // excludes all queries that are not included. If it is an exclusion, + // it implicitly includes all queries that are not excluded. So user + // filters (if any) should always be first to preserve intent. ...(augmentedConfig["query-filters"] || []), + ...(config.augmentationProperties.extraQueryExclusions || []), ]; if (augmentedConfig["query-filters"]?.length === 0) { delete augmentedConfig["query-filters"];