Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 20, 2025

Description

Configures CodeQL to exclude test directories from security analysis, focusing scanning on production code and reducing noise from test sources.

Resolves #399

Changes

Created .github/codeql-config.yml:

  • Excludes test paths: **/src/test/**, **/test/**, **/*Test.java, **/*Tests.java
  • Excludes build artifacts: **/target/**, **/build/**, **/.mvn/**

Updated .github/workflows/codeql.yml:

  • Added paths-ignore to push/pull_request triggers to skip workflow when only tests change
  • References custom config via config-file: ./.github/codeql-config.yml

Impact

  • 50+ test files now excluded from CodeQL analysis
  • Workflow won't trigger for test-only changes
  • Two-layer exclusion: workflow-level (triggering) and analysis-level (scanning)

Checklist:

  • Public methods are documented
  • Public methods are tested
  • New and existing tests pass when run locally
  • There are no new warnings or errors
Original prompt

This section details on the original issue you should resolve

<issue_title>[Chore]: Configure CodeQL to ignore test files and directories</issue_title>
<issue_description>### What

Update the CodeQL workflow in .github/workflows/codeql.yml to ignore test directories (such as src/test/java/). Add paths-ignore filters to the workflow trigger and/or use a custom CodeQL config file to exclude test sources from analysis.

Why

This chore is necessary to reduce analysis noise, focus security efforts on production code, and avoid reporting issues in test sources that do not impact application vulnerability.

Notes

Refer to the CodeQL documentation for excluding directories: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#excluding-directories-from-code-scanning
Also see https://github.com/github/codeql-action
Add documentation or comments in the workflow to clarify the exclusions.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: thomasturrell <1552612+thomasturrell@users.noreply.github.com>
Copilot AI changed the title [WIP] Update CodeQL workflow to ignore test files and directories Configure CodeQL to exclude test directories from security scanning Nov 20, 2025
Copilot AI requested a review from thomasturrell November 20, 2025 13:30
@sonarqubecloud
Copy link

@thomasturrell thomasturrell marked this pull request as ready for review November 20, 2025 13:48
Copilot AI review requested due to automatic review settings November 20, 2025 13:48
@thomasturrell thomasturrell merged commit 874d630 into main Nov 20, 2025
8 checks passed
@thomasturrell thomasturrell deleted the copilot/configure-codeql-ignore-tests branch November 20, 2025 13:48
Copy link
Contributor

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 configures CodeQL to exclude test directories from security scanning, focusing analysis on production code and reducing noise from test sources. It implements a two-layer exclusion strategy using both workflow triggers and analysis-level configuration.

  • Created .github/codeql-config.yml with path exclusions for test files and build artifacts
  • Updated .github/workflows/codeql.yml to use the custom config and skip workflow triggers for test-only changes

Reviewed Changes

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

File Description
.github/codeql-config.yml Defines CodeQL configuration to exclude test directories, test files, and build artifacts from security scanning
.github/workflows/codeql.yml Updated workflow to reference custom config file and added paths-ignore filters to prevent triggering on test-only changes

Comment on lines +19 to +21
- "**/target/**"
- "**/build/**"
- "**/.mvn/**"
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

YAML syntax error: Lines 19-21 are incorrectly indented under the comment on line 18. These lines should be at the same indentation level as line 13 (under paths-ignore:), not as separate items.

Suggested change
- "**/target/**"
- "**/build/**"
- "**/.mvn/**"
- "**/target/**"
- "**/build/**"
- "**/.mvn/**"

Copilot uses AI. Check for mistakes.
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.

[Chore]: Configure CodeQL to ignore test files and directories

2 participants