Skip to content

Java: Introduce Modulus analysis.#301

Merged
semmle-qlci merged 9 commits into
github:masterfrom
aschackmull:java/modulus-analysis
Oct 18, 2018
Merged

Java: Introduce Modulus analysis.#301
semmle-qlci merged 9 commits into
github:masterfrom
aschackmull:java/modulus-analysis

Conversation

@aschackmull
Copy link
Copy Markdown
Contributor

This replaces the parity analysis with a more general modulus analysis. The basis of the analysis is the same Bound class as is used in the range analysis, so the inferred facts are of the form: e = b + v (mod m) where e is an expression, b is a Bound, and v and m are integers. The simple case of a constant congruence fact e = v (mod m) is then given by exprModulus(e, any(ZeroBound zb), v, m) . This allows the range analysis to strengthen bounds further. As an example, for(int i = 0; i < 3*n; i+=3) is inferred to be equivalent to for(int i = 0; i < 3*n - 2; i+=3).

The gcd predicate is currently implemented only for small numbers, but will be replaced with the built-in predicate once 1.19 is released.

The PR is structured with individually reviewable commits.

@aschackmull aschackmull requested a review from a team as a code owner October 10, 2018 13:42
@aschackmull aschackmull force-pushed the java/modulus-analysis branch from 2ac1c3a to 1a66f7e Compare October 11, 2018 09:29
@aschackmull
Copy link
Copy Markdown
Contributor Author

Added a commit including test to fix a regression relative to the ParityAnalysis when the array length is a constant.

@@ -1,4 +1,6 @@
/**
* DEPRECATED: semmle.code.java.dataflow.ModulusAnalysis instead.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing word "use" before the library name.

Ditto further below.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

@semmle-qlci semmle-qlci merged commit 3af91d5 into github:master Oct 18, 2018
@aschackmull aschackmull deleted the java/modulus-analysis branch October 18, 2018 07:24
aibaars pushed a commit that referenced this pull request Oct 14, 2021
Fix filenames in source archives
smowton added a commit to smowton/codeql that referenced this pull request Apr 16, 2022
MathiasVP pushed a commit to MathiasVP/ql that referenced this pull request Dec 16, 2025
…concat

PS: Actually require string concatenation in SQL injection query
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants