-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Java: Add a default taint sanitizer for contains-checks on lists of constants #17901
Java: Add a default taint sanitizer for contains-checks on lists of constants #17901
Conversation
private import semmle.code.java.controlflow.Guards | ||
private import semmle.code.java.dataflow.internal.BaseSSA | ||
private import semmle.code.java.dataflow.TaintTracking | ||
private import semmle.code.java.dataflow.TypeFlow |
Check warning
Code scanning / CodeQL
Redundant import Warning
semmle.code.java.dispatch.VirtualDispatch
* Provides an implementation of universal flow using input `I`. | ||
*/ | ||
module Make<LocationSig Location, UniversalFlowInput<Location> I> { | ||
private import I |
Check warning
Code scanning / CodeQL
Redundant import Warning
I
0f99519
to
d5491ac
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious, should this also handle kotlin? Or is this java only right now?
To the extent that Kotlin calls the same methods, i.e. |
I was mostly thinking of https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/list-of.html and friends for |
m.hasQualifiedName("java.util", "Collection", ["add", "addAll"]) and | ||
m.getNumberOfParameters() = 1 and | ||
arg = 0 | ||
or | ||
m.hasQualifiedName("java.util", "List", ["add", "addAll"]) and | ||
m.getNumberOfParameters() = 2 and | ||
arg = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't expect allowlists constructions to use those, but I've added them now - it can't hurt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to include the tests from #17051, modified so they pass where you have made different decisions (e.g. allowing reads from fields that aren't static and final).
Done. I did the modification in a separate commit, so it's easy for you to see the diff. |
0925a03
to
a6fc41e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code all looks good. Test expectations need to be updated for one test. And you've added a module and a bunch of predicates without QLDocs in TypeFlow::FlowStepsInput
. (It also seems to be complaining about some that you didn't add in BaseSSA::BaseSsaSourceVariable
and BaseSSA::BaseSsaVariable
, that may be worth just fixing in this PR so the alert stops going off.)
Yes, there was a semantic merge conflict. Fixed now.
All fixed. |
Builds on top of #17863
This is a reimplementation of #17051 expressed in terms of a universal flow library.