Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cpp/ql/src/utils/modelgenerator/internal/CaptureModels.qll
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ private predicate isUninterestingForModels(Callable api) {
api = any(Cpp::LambdaExpression lambda).getLambdaFunction()
or
api.isFromUninstantiatedTemplate(_)
or
// Exclude functions in test directories (but not the ones in the CodeQL test directory)
exists(Cpp::File f |
f = api.getFile() and
f.getAbsolutePath().matches("%test%") and
Copy link
Preview

Copilot AI May 15, 2025

Choose a reason for hiding this comment

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

The pattern "%test%" may match any substring (e.g., "contest" or user paths containing "test"). Consider anchoring to directory separators (e.g., "%/test/%") or using a path-matching utility to target only "test" directories.

Suggested change
f.getAbsolutePath().matches("%test%") and
f.getAbsolutePath().matches("%/test/%") and

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not a bad suggestion! I do like simply using test though so that we also match stuff like tests, though. I could go either way on this 🤷

not f.getAbsolutePath().matches("%test/library-tests/dataflow/modelgenerator/dataflow/%")
Comment on lines +52 to +53
Copy link
Preview

Copilot AI May 15, 2025

Choose a reason for hiding this comment

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

Relying on absolute paths with OS-specific separators can reduce portability. Consider using getRelativePath() or normalizing paths with forward slashes to ensure this exception works across platforms.

Suggested change
f.getAbsolutePath().matches("%test%") and
not f.getAbsolutePath().matches("%test/library-tests/dataflow/modelgenerator/dataflow/%")
f.getRelativePath().matches("%test%") and
not f.getRelativePath().matches("%test/library-tests/dataflow/modelgenerator/dataflow/%")

Copilot uses AI. Check for mistakes.

)
}

private predicate relevant(Callable api) {
Expand Down
Loading