mirror of
https://github.com/github/codeql.git
synced 2025-12-23 20:26:32 +01:00
Refactor UnsafeAndroidAccess
This commit is contained in:
@@ -7,9 +7,11 @@ import semmle.code.java.security.RequestForgery
|
|||||||
import semmle.code.java.security.UnsafeAndroidAccess
|
import semmle.code.java.security.UnsafeAndroidAccess
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* DEPRECATED: Use `FetchUntrustedResourceFlow` instead.
|
||||||
|
*
|
||||||
* A taint configuration tracking flow from untrusted inputs to a resource fetching call.
|
* A taint configuration tracking flow from untrusted inputs to a resource fetching call.
|
||||||
*/
|
*/
|
||||||
class FetchUntrustedResourceConfiguration extends TaintTracking::Configuration {
|
deprecated class FetchUntrustedResourceConfiguration extends TaintTracking::Configuration {
|
||||||
FetchUntrustedResourceConfiguration() { this = "FetchUntrustedResourceConfiguration" }
|
FetchUntrustedResourceConfiguration() { this = "FetchUntrustedResourceConfiguration" }
|
||||||
|
|
||||||
override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
|
override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
|
||||||
@@ -20,3 +22,13 @@ class FetchUntrustedResourceConfiguration extends TaintTracking::Configuration {
|
|||||||
sanitizer instanceof RequestForgerySanitizer
|
sanitizer instanceof RequestForgerySanitizer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private module FetchUntrustedResourceConfig implements DataFlow::ConfigSig {
|
||||||
|
predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
|
||||||
|
|
||||||
|
predicate isSink(DataFlow::Node sink) { sink instanceof UrlResourceSink }
|
||||||
|
|
||||||
|
predicate isBarrier(DataFlow::Node sanitizer) { sanitizer instanceof RequestForgerySanitizer }
|
||||||
|
}
|
||||||
|
|
||||||
|
module FetchUntrustedResourceFlow = TaintTracking::Make<FetchUntrustedResourceConfig>;
|
||||||
|
|||||||
@@ -14,9 +14,9 @@
|
|||||||
|
|
||||||
import java
|
import java
|
||||||
import semmle.code.java.security.UnsafeAndroidAccessQuery
|
import semmle.code.java.security.UnsafeAndroidAccessQuery
|
||||||
import DataFlow::PathGraph
|
import FetchUntrustedResourceFlow::PathGraph
|
||||||
|
|
||||||
from DataFlow::PathNode source, DataFlow::PathNode sink, FetchUntrustedResourceConfiguration conf
|
from FetchUntrustedResourceFlow::PathNode source, FetchUntrustedResourceFlow::PathNode sink
|
||||||
where conf.hasFlowPath(source, sink)
|
where FetchUntrustedResourceFlow::hasFlowPath(source, sink)
|
||||||
select sink.getNode(), source, sink, "Unsafe resource fetching in Android WebView due to $@.",
|
select sink.getNode(), source, sink, "Unsafe resource fetching in Android WebView due to $@.",
|
||||||
source.getNode(), sink.getNode().(UrlResourceSink).getSinkType()
|
source.getNode(), sink.getNode().(UrlResourceSink).getSinkType()
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class UnsafeAndroidAccessTest extends InlineExpectationsTest {
|
|||||||
|
|
||||||
override predicate hasActualResult(Location location, string element, string tag, string value) {
|
override predicate hasActualResult(Location location, string element, string tag, string value) {
|
||||||
tag = "hasUnsafeAndroidAccess" and
|
tag = "hasUnsafeAndroidAccess" and
|
||||||
exists(DataFlow::Node sink, FetchUntrustedResourceConfiguration conf | conf.hasFlowTo(sink) |
|
exists(DataFlow::Node sink | FetchUntrustedResourceFlow::hasFlowTo(sink) |
|
||||||
sink.getLocation() = location and
|
sink.getLocation() = location and
|
||||||
element = sink.toString() and
|
element = sink.toString() and
|
||||||
value = ""
|
value = ""
|
||||||
|
|||||||
Reference in New Issue
Block a user