Skip to content

Conversation

data-douser
Copy link

@data-douser data-douser commented Aug 21, 2025

Purpose

This main purpose of this PR is to improve the qlt query generate new-query subcommand in order to support the equivalent set of --language options as the qlt test init subcommand.

Summary

This PR also introduces several other improvements and updates to the CodeQL Toolkit project, focusing on modernizing dependencies, enhancing CI validation, and expanding unit test coverage. The most significant changes include updating all CodeQL pack and CLI versions to the latest releases, adding a new internal GitHub Actions workflow for validating CLI outputs across multiple languages, and introducing a robust shell script for running and validating unit tests. Additionally, the solution file now includes a new test project for feature-level testing.

Outline of Changes

Automation and Testing Improvements:

  • Added .github/workflows/internal-validate-cli-outputs.yml workflow to automate generation, validation, and end-to-end testing of the new-query CLI across multiple languages.
  • Added scripts/run-unit-tests.sh for running and validating CodeQL unit tests for generated queries, with improved logging and argument parsing.

Dependency and Configuration Updates:

  • Updated all codeql-pack.lock.yml and qlpack.yml files in the example C++ packs (customizations, stuff, stuff2) to use the latest CodeQL pack versions (e.g., codeql/cpp-all to 5.4.1) and incremented pack versions. [1] [2] [3] [4] [5] [6] [7]
  • Updated example/qlt.conf.json to reference newer CodeQL CLI and standard library versions (2.22.4).

Solution Structure:

  • Added CodeQLToolkit.Features.Tests project to CodeQLToolkit.sln and configured it for build and solution folder placement. [1] [2] [3]

Updates the `qlt query generate new-query` subcommand in
order to support the equivalent set of `--language` options
as the `qlt test init` subcommand.

Adds unit tests to ensure that template vars (i.e. language)
are defined (i.e. not empty) for subcommand templates.
Copy link

@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

Updates the qlt query generate new-query subcommand to support the same language options as the qlt test init subcommand by adding Python and Ruby language support. This includes adding template files for both languages and ensuring proper template variable resolution.

  • Adds Python language support to FromOptionString method
  • Extends supported languages array to include C#, Go, Java, Python, and Ruby
  • Adds comprehensive unit tests to validate template existence and proper variable substitution

Reviewed Changes

Copilot reviewed 43 out of 43 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/CodeQLToolkit.Shared/Utils/Language.cs Adds Python language option parsing support
src/CodeQLToolkit.Features/Query/Scaffolding/QueryScaffoldFeature.cs Expands supported languages to include all CodeQL languages
src/CodeQLToolkit.Features/Query/Scaffolding/Targets/NewQueryScaffoldTarget.cs Fixes template variable resolution by adding missing ql_language parameter
Template files Adds complete template sets for Python, Ruby, Java, Go, and C# languages
Test files Adds comprehensive unit tests for template validation and variable substitution
Comments suppressed due to low confidence (3)

src/CodeQLToolkit.Features/Templates/Query/go/new-dataflow-query.liquid:1

  • The Go dataflow template uses an outdated API pattern. Line 22 is missing the override keyword for the isSink predicate, and the template should use the newer module-based configuration pattern consistent with other language templates.
/**

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Fixes an error where cloning the `github/codeql` repo would fail
when the local environment had a git config for automatically
rewriting the URL scheme (to SSH) for any `git clone` task.
Refactors the 'query generate new-query' subcommand of the
CodeQLToolkit.Core (qlt) CLI in order to:

- Update the version of CodeQL used to 'v2.22.4' (current latest);
- Support generating new queries for all currently supported languages;
- Add support for generating `@kind path-problem` (dataflow) queries;
- Create scripts for end-to-end testing of the `new-query` subcommand;
- Create a new actions workflow for automated verification and testing
  of queries generated via `qlt query generate new-query`;
- Ensure that (liquid) template rendering fails if a required template
  var is unset. Adds unit tests to ensure template vars are not empty.
Fixes to templates used to generate new queries languages such as:

- cpp
- csharp
- go
- java
- ruby
@data-douser
Copy link
Author

This PR has more changes to more files than would generally be desired.
This repo was overdue for an update, and I could not get query testing working without updating the CodeQL version to something much newer (than v2.15.x).
Sorry for the jumbo PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant