mirror of
https://github.com/github/codeql.git
synced 2026-02-28 21:03:50 +01:00
Java: add remote user input and taint step for Guice framework
This commit is contained in:
@@ -17,6 +17,7 @@ import semmle.code.java.frameworks.android.WebView
|
||||
import semmle.code.java.frameworks.JaxWS
|
||||
import semmle.code.java.frameworks.android.Intent
|
||||
import semmle.code.java.frameworks.SpringWeb
|
||||
import semmle.code.java.frameworks.Guice
|
||||
|
||||
/** Class for `tainted` user input. */
|
||||
abstract class UserInput extends DataFlow::Node { }
|
||||
@@ -69,6 +70,11 @@ class RemoteUserInput extends UserInput {
|
||||
)
|
||||
or
|
||||
this.asParameter().getAnAnnotation() instanceof SpringServletInputAnnotation
|
||||
or
|
||||
exists(GuiceRequestParametersAnnotation a |
|
||||
a = this.asParameter().getAnAnnotation() or
|
||||
a = this.asExpr().(FieldRead).getField().getAnAnnotation()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,6 +12,7 @@ private import DefUse
|
||||
private import semmle.code.java.security.SecurityTests
|
||||
private import semmle.code.java.security.Validation
|
||||
private import semmle.code.java.frameworks.android.Intent
|
||||
private import semmle.code.java.frameworks.Guice
|
||||
private import semmle.code.java.Maps
|
||||
|
||||
module TaintTracking {
|
||||
@@ -471,6 +472,8 @@ module TaintTracking {
|
||||
or
|
||||
m.getDeclaringType().hasQualifiedName("java.nio", "ByteBuffer") and
|
||||
m.hasName("get")
|
||||
or
|
||||
m = any(GuiceProvider gp).getAnOverridingGetMethod()
|
||||
}
|
||||
|
||||
private class StringReplaceMethod extends Method {
|
||||
|
||||
35
java/ql/src/semmle/code/java/frameworks/Guice.qll
Normal file
35
java/ql/src/semmle/code/java/frameworks/Guice.qll
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Provides classes and predicates for working with the Guice framework.
|
||||
*/
|
||||
|
||||
import java
|
||||
|
||||
/**
|
||||
* A `@com.google.inject.servlet.RequestParameters` annotation.
|
||||
*/
|
||||
class GuiceRequestParametersAnnotation extends Annotation {
|
||||
GuiceRequestParametersAnnotation() {
|
||||
this.getType().hasQualifiedName("com.google.inject.servlet", "RequestParameters")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The interface `com.google.inject.Provider`.
|
||||
*/
|
||||
class GuiceProvider extends Interface {
|
||||
GuiceProvider() { this.hasQualifiedName("com.google.inject", "Provider") }
|
||||
|
||||
/**
|
||||
* The method named `get` declared on the interface `com.google.inject.Provider`.
|
||||
*/
|
||||
Method getGetMethod() {
|
||||
result.getDeclaringType() = this and result.getName() = "get" and result.hasNoParameters()
|
||||
}
|
||||
|
||||
/**
|
||||
* A method that overrides the `get` method on the interface `com.google.inject.Provider`.
|
||||
*/
|
||||
Method getAnOverridingGetMethod() {
|
||||
exists(Method m | m.getSourceDeclaration() = getGetMethod() | result.overrides*(m))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user