Skip to content

Commit da71861

Browse files
committed
Refactor HttpsUrlsQuery.qll
1 parent c67b984 commit da71861

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import semmle.code.java.frameworks.Networking
66
import semmle.code.java.security.HttpsUrls
77

88
/**
9+
* DEPRECATED: Use `HttpsStringToUrlOpenMethodFlow` instead.
10+
*
911
* A taint tracking configuration for HTTP connections.
1012
*/
11-
class HttpStringToUrlOpenMethodFlowConfig extends TaintTracking::Configuration {
13+
deprecated class HttpStringToUrlOpenMethodFlowConfig extends TaintTracking::Configuration {
1214
HttpStringToUrlOpenMethodFlowConfig() { this = "HttpStringToUrlOpenMethodFlowConfig" }
1315

1416
override predicate isSource(DataFlow::Node src) { src.asExpr() instanceof HttpStringLiteral }
@@ -23,3 +25,25 @@ class HttpStringToUrlOpenMethodFlowConfig extends TaintTracking::Configuration {
2325
node.getType() instanceof PrimitiveType or node.getType() instanceof BoxedType
2426
}
2527
}
28+
29+
/**
30+
* A taint tracking configuration for HTTP connections.
31+
*/
32+
private module HttpStringToUrlOpenMethodFlowConfig implements DataFlow::ConfigSig {
33+
predicate isSource(DataFlow::Node src) { src.asExpr() instanceof HttpStringLiteral }
34+
35+
predicate isSink(DataFlow::Node sink) { sink instanceof UrlOpenSink }
36+
37+
predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
38+
any(HttpUrlsAdditionalTaintStep c).step(node1, node2)
39+
}
40+
41+
predicate isBarrier(DataFlow::Node node) {
42+
node.getType() instanceof PrimitiveType or node.getType() instanceof BoxedType
43+
}
44+
}
45+
46+
/**
47+
* Detect taint flow of HTTP connections.
48+
*/
49+
module HttpStringToUrlOpenMethodFlow = TaintTracking::Global<HttpStringToUrlOpenMethodFlowConfig>;

java/ql/src/Security/CWE/CWE-319/HttpsUrls.ql

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

1313
import java
1414
import semmle.code.java.security.HttpsUrlsQuery
15-
import DataFlow::PathGraph
15+
import HttpStringToUrlOpenMethodFlow::PathGraph
1616

17-
from DataFlow::PathNode source, DataFlow::PathNode sink
18-
where any(HttpStringToUrlOpenMethodFlowConfig c).hasFlowPath(source, sink)
17+
from HttpStringToUrlOpenMethodFlow::PathNode source, HttpStringToUrlOpenMethodFlow::PathNode sink
18+
where HttpStringToUrlOpenMethodFlow::flowPath(source, sink)
1919
select sink.getNode(), source, sink, "URL may have been constructed with HTTP protocol, using $@.",
2020
source.getNode(), "this HTTP URL"

0 commit comments

Comments
 (0)