Skip to content

Conversation

@aschackmull
Copy link
Contributor

@aschackmull aschackmull commented Dec 11, 2025

The ExternalFlow.qll files for Java/C++/Go/C# contain a mix of copy-pasted code and language-specific code. This PR attempts to pull shared bits and pieces into a shared library. Commit-by-commit review is encouraged.

@aschackmull aschackmull force-pushed the mad/shared-externalflow branch 3 times, most recently from cabfbd0 to 2788f38 Compare December 11, 2025 15:29
@aschackmull aschackmull force-pushed the mad/shared-externalflow branch from 1bcca6b to 4b2e8c0 Compare December 12, 2025 08:18
@aschackmull aschackmull marked this pull request as ready for review December 12, 2025 09:55
@aschackmull aschackmull requested review from a team as code owners December 12, 2025 09:55
Copilot AI review requested due to automatic review settings December 12, 2025 09:55
@aschackmull aschackmull requested a review from a team as a code owner December 12, 2025 09:55
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 extracts common Models as Data (MaD) logic from language-specific ExternalFlow.qll files (Java, C++, Go, C#) into a shared library shared/mad/codeql/mad/static/MaD.qll. The refactoring eliminates duplicated code while maintaining language-specific customization through module signatures.

Key changes:

  • Created a shared ModelsAsData module with extensible signatures for language-specific implementations
  • Unified handling of model predicates (source, sink, summary, barrier, barrier guard, neutral) and model coverage calculations
  • Added barrier and barrier guard model support to Go, C#, and C++ through new extensible predicates

Reviewed changes

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

Show a summary per file
File Description
shared/mad/codeql/mad/static/MaD.qll New shared module providing signatures and generic logic for MaD models across languages
java/ql/lib/semmle/code/java/dataflow/ExternalFlow.qll Refactored to use shared MaD module, removing duplicated predicates
java/ql/lib/semmle/code/java/dataflow/internal/ExternalFlowExtensions.qll Added Extensions module implementing SharedMaD::ExtensionsSig
java/ql/lib/semmle/code/java/dataflow/internal/FlowSummaryImpl.qll Updated to use model parameter instead of madId for tracking
go/ql/lib/semmle/go/dataflow/ExternalFlow.qll Refactored to use shared MaD module
go/ql/lib/semmle/go/dataflow/internal/ExternalFlowExtensions.qll Added barrier models and Extensions module implementation
go/ql/lib/semmle/go/dataflow/internal/FlowSummaryImpl.qll Updated to use model parameter for consistency
go/ql/lib/ext/empty.model.yml Added barrier and barrier guard model extensibles
csharp/ql/lib/semmle/code/csharp/dataflow/internal/ExternalFlow.qll Refactored to use shared MaD module
csharp/ql/lib/semmle/code/csharp/dataflow/internal/ExternalFlowExtensions.qll Added barrier models and Extensions module implementation
csharp/ql/lib/semmle/code/csharp/dataflow/internal/FlowSummaryImpl.qll Updated to use model parameter
csharp/ql/lib/ext/empty.model.yml Added barrier and barrier guard model extensibles
cpp/ql/lib/semmle/code/cpp/dataflow/ExternalFlow.qll Refactored to use shared MaD module with custom summaryModel override for @ expansion
cpp/ql/lib/semmle/code/cpp/dataflow/internal/ExternalFlowExtensions.qll Added barrier, neutral models and Extensions module implementation
cpp/ql/lib/ext/empty.model.yml Added barrier and barrier guard model extensibles

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

none()
}

/** Get the separator used between namespace segments. */
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The comment should use "Gets" instead of "Get" to follow standard QLDoc conventions for predicate documentation.

Copilot generated this review using guidance from repository custom instructions.
/**
* Holds if the package `package` is part of the group `group`.
*/
predicate packageGrouping(string group, string package);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we make this namespaceGrouping? And for go we can also support the existing packageGrouping for a bit as we transition over to namespaceGrouping?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we probably should - I guess we can do two parallel extensible predicates for go as the transition solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've opted for just changing the shared part for now. Then a switch for Go with deprecation and all that can be a separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Dynamic languages have ModelsAsData.qll; I think it would be better to spell it out here as well.

@aschackmull aschackmull added the no-change-note-required This PR does not need a change note label Dec 12, 2025
Copy link
Contributor

@owen-mc owen-mc left a comment

Choose a reason for hiding this comment

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

Go LGTM. One optional comment about a parameter name.

summaryModel(p, _, _, _, _, _, _, _, _, _, _)
)
bindingset[p]
string cleanNamespace(string p) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional: Could rename parameter to ns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C# C++ Go Java no-change-note-required This PR does not need a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants