Skip to content

Java: Make some query libraries local.#20598

Merged
alexet merged 1 commit intomainfrom
alexet/overlay-query-libraries
Oct 27, 2025
Merged

Java: Make some query libraries local.#20598
alexet merged 1 commit intomainfrom
alexet/overlay-query-libraries

Conversation

@alexet
Copy link
Contributor

@alexet alexet commented Oct 7, 2025

This makes some expensive predicates in "query" libraries local. These all seem obviously local to me and they are all slow (mostly due to regexes, but soemtiems for other reasons)

@github-actions github-actions bot added the Java label Oct 7, 2025
@alexet alexet requested a review from kaspersv October 8, 2025 17:46
@alexet alexet marked this pull request as ready for review October 8, 2025 17:46
@alexet alexet requested a review from a team as a code owner October 8, 2025 17:46
Copilot AI review requested due to automatic review settings October 8, 2025 17:46
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 optimizes performance in Java query libraries by adding the overlay[local?] annotation to expensive predicates. The purpose is to make certain predicates local to improve query execution performance, particularly for predicates that contain slow operations like regular expressions.

Key changes:

  • Added overlay[local?] annotations to three expensive predicate classes
  • Targets predicates with known performance issues due to regex operations and other expensive computations
  • Maintains existing functionality while improving execution efficiency

Reviewed Changes

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

File Description
java/ql/lib/semmle/code/java/security/UrlForwardQuery.qll Added local overlay annotation to BarrierPrefix class
java/ql/lib/semmle/code/java/security/StaticInitializationVectorQuery.qll Added local overlay annotation to ArrayUpdate class
java/ql/lib/semmle/code/java/security/BrokenCryptoAlgorithmQuery.qll Added local overlay annotation to BrokenAlgoLiteral class

Copy link
Contributor

@kaspersv kaspersv left a comment

Choose a reason for hiding this comment

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

Did you run a DCA overlay experiment to test if these changes had any impact on overlay accuracy for these queries?

ma = this and
ma.getArgument(0) = array
|
m.getAnOverride*().hasQualifiedName("java.io", ["InputStream", "RandomAccessFile"], "read") or
Copy link
Contributor

Choose a reason for hiding this comment

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

These m.getAnOverride*() aren't file-local though they seem unlikely to matter in practice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point as these are getAnOverride so point backwards to what I thought they did.

@alexet
Copy link
Contributor Author

alexet commented Oct 10, 2025

I have a DCA experiment here; https://github.com/github/codeql-dca-main/issues/32115 . it's in progress as it failed the first time.

@kaspersv
Copy link
Contributor

You used the source suite intended for performance testing for the DCA experiment, so I'm not sure what the baseline is for overlay accuracy, but the results look pretty bad with 0% accuracy for several high-severity queries (e.g., java/sql-injection which usually has a +99% precision).

@alexet
Copy link
Contributor Author

alexet commented Oct 20, 2025

Sorry, I ran a performance check by default and forgot change it for accuracy.

Here is another run with accuracy testing settings: https://github.com/github/codeql-dca-main/issues/32285

@alexet
Copy link
Contributor Author

alexet commented Oct 21, 2025

I'm not sure about the failures, but they seem to be due to the files already existing so I think the results are mostly fine.

@kaspersv
Copy link
Contributor

I'm not sure about the failures, but they seem to be due to the files already existing so I think the results are mostly fine.

The accuracy results include data for 145 out of 146 targets. I'm assuming the missing target is the one that failed (AchoBeta__achobeta-polaris@577ffc0), which appears to have failed for unrelated reasons.

@alexet alexet added the no-change-note-required This PR does not need a change note label Oct 22, 2025
@alexet alexet merged commit 227e1fc into main Oct 27, 2025
18 of 19 checks passed
@alexet alexet deleted the alexet/overlay-query-libraries branch October 27, 2025 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

2 participants

Comments