Skip to content

Keep user-provided query filters first #2938

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 19, 2025
Merged

Conversation

cklin
Copy link
Contributor

@cklin cklin commented Jun 19, 2025

This PR fixes a bug in PR analysis where user-provided include query filter fails to exclude non-included queries.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Confirm the readme has been updated if necessary.
  • Confirm the changelog has been updated if necessary.

Using defaultAugmentationProperties to generated expected test output
eliminates the need to change individual tests when we add a new field
to AugmentationProperties.
@cklin cklin marked this pull request as ready for review June 19, 2025 19:04
@Copilot Copilot AI review requested due to automatic review settings June 19, 2025 19:04
@cklin cklin requested a review from a team as a code owner June 19, 2025 19:04
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures that user-defined query filters are applied before any automatically added exclusions, fixing a bug where user “include” filters were overridden.

  • Renamed defaultQueryFilters to extraQueryExclusions across the config API.
  • Updated calculateAugmentation and generateCodeScanningConfig to use the new property and preserve user filter ordering.
  • Adjusted tests, generated JS files, and the changelog to match the renaming and logic changes.

Reviewed Changes

Copilot reviewed 9 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/config-utils.ts Renamed property and updated augmentation logic.
src/config-utils.test.ts Simplified test fixtures by spreading defaultAugmentationProperties.
src/codeql.ts reordered query-filters array and added explanatory comment.
src/codeql.test.ts Imported and used defaultAugmentationProperties in tests.
lib/config-utils.js Propagated renaming and logic updates to compiled output.
lib/codeql.js Updated filter ordering logic and comments in compiled output.
CHANGELOG.md Added release note for the bug fix.
Comments suppressed due to low confidence (1)

src/codeql.ts:1273

  • Add a unit test that verifies user-provided query filters appear before extra query exclusions in the generated CodeQL configuration.
    ...(augmentedConfig["query-filters"] || []),

cklin added 3 commits June 19, 2025 12:19
This commit renames AugmentationProperties.defaultQueryFilters to
extraQueryExclusions, and changes its type to ExcludeQueryFilter[]. It
matters whether we are adding query inclusions or exclusions, and this
renaming makes that distinction clearer.
@cklin cklin force-pushed the cklin/default-query-filters branch from 1b923a3 to 65abb79 Compare June 19, 2025 19:20
Copy link
Contributor

@aeisenberg aeisenberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. This makes sense.

@cklin cklin merged commit 66d7255 into main Jun 19, 2025
279 checks passed
@cklin cklin deleted the cklin/default-query-filters branch June 19, 2025 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants