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#17901aschackmull merged 11 commits intogithub:mainfrom
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
| * 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
0f99519 to
d5491ac
Compare
intrigus-lgtm
left a comment
There was a problem hiding this comment.
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.
I don't expect allowlists constructions to use those, but I've added them now - it can't hurt.
Done. I did the modification in a separate commit, so it's easy for you to see the diff. |
0925a03 to
a6fc41e
Compare
owen-mc
left a comment
There was a problem hiding this comment.
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.