Skip to content

Commit 1e0c681

Browse files
committed
Refactor UnsafeAndroidAccess
1 parent 807588a commit 1e0c681

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

java/ql/lib/semmle/code/java/security/UnsafeAndroidAccessQuery.qll

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import semmle.code.java.security.RequestForgery
77
import semmle.code.java.security.UnsafeAndroidAccess
88

99
/**
10+
* DEPRECATED: Use `FetchUntrustedResourceFlow` instead.
11+
*
1012
* A taint configuration tracking flow from untrusted inputs to a resource fetching call.
1113
*/
12-
class FetchUntrustedResourceConfiguration extends TaintTracking::Configuration {
14+
deprecated class FetchUntrustedResourceConfiguration extends TaintTracking::Configuration {
1315
FetchUntrustedResourceConfiguration() { this = "FetchUntrustedResourceConfiguration" }
1416

1517
override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
@@ -20,3 +22,13 @@ class FetchUntrustedResourceConfiguration extends TaintTracking::Configuration {
2022
sanitizer instanceof RequestForgerySanitizer
2123
}
2224
}
25+
26+
private module FetchUntrustedResourceConfig implements DataFlow::ConfigSig {
27+
predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
28+
29+
predicate isSink(DataFlow::Node sink) { sink instanceof UrlResourceSink }
30+
31+
predicate isBarrier(DataFlow::Node sanitizer) { sanitizer instanceof RequestForgerySanitizer }
32+
}
33+
34+
module FetchUntrustedResourceFlow = TaintTracking::Make<FetchUntrustedResourceConfig>;

java/ql/src/Security/CWE/CWE-749/UnsafeAndroidAccess.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
import java
1616
import semmle.code.java.security.UnsafeAndroidAccessQuery
17-
import DataFlow::PathGraph
17+
import FetchUntrustedResourceFlow::PathGraph
1818

19-
from DataFlow::PathNode source, DataFlow::PathNode sink, FetchUntrustedResourceConfiguration conf
20-
where conf.hasFlowPath(source, sink)
19+
from FetchUntrustedResourceFlow::PathNode source, FetchUntrustedResourceFlow::PathNode sink
20+
where FetchUntrustedResourceFlow::hasFlowPath(source, sink)
2121
select sink.getNode(), source, sink, "Unsafe resource fetching in Android WebView due to $@.",
2222
source.getNode(), sink.getNode().(UrlResourceSink).getSinkType()

java/ql/test/query-tests/security/CWE-749/UnsafeAndroidAccessTest.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class UnsafeAndroidAccessTest extends InlineExpectationsTest {
99

1010
override predicate hasActualResult(Location location, string element, string tag, string value) {
1111
tag = "hasUnsafeAndroidAccess" and
12-
exists(DataFlow::Node sink, FetchUntrustedResourceConfiguration conf | conf.hasFlowTo(sink) |
12+
exists(DataFlow::Node sink | FetchUntrustedResourceFlow::hasFlowTo(sink) |
1313
sink.getLocation() = location and
1414
element = sink.toString() and
1515
value = ""

0 commit comments

Comments
 (0)