Skip to content

Shared: Model generator cleanup. #19311

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

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

michaelnebel
Copy link
Contributor

@michaelnebel michaelnebel commented Apr 15, 2025

In this PR we

  • Re-factor the shared model generator implementation and put the heuristic queries in its own module.
  • Change the queries */utils/modelgenerator/summary-models to use the implementation from */utils/modelgenerator/mixed-summary-models and then delete the */utils/modelgenerator/mixed-summary-models queries. Also make the same change to the neutral capturing queries.
  • Remove the --with-mixed-* flags from the model generator python script.
  • Re-factor the model generator tests to use explicit summary model tags and change the neutral tests to use the combined neutral generation query.

This effectively means that when genering models with the GenerateFlowModels.py script using the flags --with-summaries and --with-neutrals now generates combined (or mixed as we used to call them) models based on both the content based and heuristic based data flow model generation.

@github-actions github-actions bot added C# Java Rust Pull requests that update Rust code labels Apr 15, 2025
@michaelnebel michaelnebel force-pushed the csharp/generatorcleanup branch from cf40d2d to 3809598 Compare April 16, 2025 09:05
@michaelnebel michaelnebel force-pushed the csharp/generatorcleanup branch from 3809598 to 3ef0f89 Compare April 16, 2025 09:12
@michaelnebel michaelnebel marked this pull request as ready for review April 16, 2025 11:49
@Copilot Copilot AI review requested due to automatic review settings April 16, 2025 11:49
@michaelnebel michaelnebel requested review from a team as code owners April 16, 2025 11:49
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 refactors the shared model generator by isolating heuristic queries into their own module, updating query annotations in test files, and removing legacy mixed-model queries and flags. Key changes include:

  • Replacing "summary" annotations with "heuristic-summary" in query comments across various test files.
  • Updating change note files to reflect the switch from mixed to combined (heuristic/content-based) models.
  • Removing deprecated flags from the model generator script.

Reviewed Changes

Copilot reviewed 49 out of 64 changed files in this pull request and generated no comments.

File Description
java/ql/src/change-notes/2025-04-16-model-generation.md Updated change note reflecting the query switch for Java models.
csharp/ql/test/utils/modelgenerator/dataflow/Summaries.cs Replaced legacy "summary" tags with "heuristic-summary" where appropriate.
csharp/ql/src/change-notes/2025-04-16-model-generation.md Updated change note reflecting the query switch for C# models.
Files not reviewed (15)
  • csharp/ql/src/utils/modelgenerator/CaptureMixedNeutralModels.ql: Language not supported
  • csharp/ql/src/utils/modelgenerator/CaptureMixedSummaryModels.ql: Language not supported
  • csharp/ql/src/utils/modelgenerator/CaptureNeutralModels.ql: Language not supported
  • csharp/ql/src/utils/modelgenerator/CaptureSinkModels.ql: Language not supported
  • csharp/ql/src/utils/modelgenerator/CaptureSourceModels.ql: Language not supported
  • csharp/ql/src/utils/modelgenerator/CaptureSummaryModels.ql: Language not supported
  • csharp/ql/src/utils/modelgenerator/debug/CaptureSummaryModelsPartialPath.ql: Language not supported
  • csharp/ql/src/utils/modelgenerator/debug/CaptureSummaryModelsPath.ql: Language not supported
  • csharp/ql/test/utils/modelgenerator/dataflow/CaptureHeuristicSummaryModels.ql: Language not supported
  • csharp/ql/test/utils/modelgenerator/dataflow/CaptureNeutralModels.ql: Language not supported
  • csharp/ql/test/utils/modelgenerator/dataflow/CaptureSinkModels.ql: Language not supported
  • csharp/ql/test/utils/modelgenerator/dataflow/CaptureSourceModels.ql: Language not supported
  • java/ql/src/utils/modelgenerator/CaptureMixedNeutralModels.ql: Language not supported
  • java/ql/src/utils/modelgenerator/CaptureMixedSummaryModels.ql: Language not supported
  • java/ql/src/utils/modelgenerator/CaptureNeutralModels.ql: Language not supported
Comments suppressed due to low confidence (2)

java/ql/src/change-notes/2025-04-16-model-generation.md:4

  • [nitpick] There appears to be a potential naming inconsistency: the change note references 'GenerateFlowModel.py', while the PR description uses 'GenerateFlowModels.py'. Consider standardizing the script name for clarity.
* Changes to the MaD model generation infrastructure: Changed the query `java/utils/modelgenerator/summary-models` to use the implementation from `java/utils/modelgenerator/mixed-summary-models`. Removed the now-redundant `java/utils/modelgenerator/mixed-summary-models` query. Similar replacement was made for `java/utils/modelgenerator/neutral-models`. That is, if `GenerateFlowModel.py` is provided with `--with-summaries` combined/mixed models are now generated instead of heuristic models (and similar for `--with-neutrals`).

csharp/ql/src/change-notes/2025-04-16-model-generation.md:4

  • [nitpick] There appears to be a potential naming inconsistency: the change note references 'GenerateFlowModel.py', while the PR description uses 'GenerateFlowModels.py'. Consider standardizing the script name for clarity.
* Changes to the MaD model generation infrastructure: Changed the query `cs/utils/modelgenerator/summary-models` to use the implementation from `cs/utils/modelgenerator/mixed-summary-models`. Removed the now-redundant `cs/utils/modelgenerator/mixed-summary-models` query. Similar replacement was made for `cs/utils/modelgenerator/neutral-models`. That is, if `GenerateFlowModel.py` is provided with `--with-summaries` combined/mixed models are now generated instead of heuristic models (and similar for `--with-neutrals`).

Copy link
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

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

@paldepind FYI as you've been using this in Rust.

---
category: minorAnalysis
---
* Changes to the MaD model generation infrastructure: Changed the query `rust/utils/modelgenerator/summary-models` to use the implementation from `rust/utils/modelgenerator/mixed-summary-models`. Removed the now-redundant `rust/utils/modelgenerator/mixed-summary-models` query. Similar replacement was made for `rust/utils/modelgenerator/neutral-models`. That is, if `GenerateFlowModel.py` is provided with `--with-summaries` combined/mixed models are now generated instead of heuristic models (and similar for `--with-neutrals`).
Copy link
Contributor

Choose a reason for hiding this comment

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

We're not actually doing change notes for Rust yet, because we're still in preview - though the symmetry with other languages is nice and I can't see this one doing any harm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C# documentation Java Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants