Skip to content

Commit fa2f0db

Browse files
committed
Refactor InsecureBasicAuth
1 parent dcd46c2 commit fa2f0db

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import semmle.code.java.security.InsecureBasicAuth
66
import semmle.code.java.dataflow.TaintTracking
77

88
/**
9+
* DEPRECATED: Use `InsecureBasicAuthFlow` instead.
10+
*
911
* A taint tracking configuration for the Basic authentication scheme
1012
* being used in HTTP connections.
1113
*/
12-
class BasicAuthFlowConfig extends TaintTracking::Configuration {
14+
deprecated class BasicAuthFlowConfig extends TaintTracking::Configuration {
1315
BasicAuthFlowConfig() { this = "InsecureBasicAuth::BasicAuthFlowConfig" }
1416

1517
override predicate isSource(DataFlow::Node src) { src instanceof InsecureBasicAuthSource }
@@ -20,3 +22,22 @@ class BasicAuthFlowConfig extends TaintTracking::Configuration {
2022
any(HttpUrlsAdditionalTaintStep c).step(node1, node2)
2123
}
2224
}
25+
26+
/**
27+
* A taint tracking configuration for the Basic authentication scheme
28+
* being used in HTTP connections.
29+
*/
30+
private module BasicAuthFlowConfig implements DataFlow::ConfigSig {
31+
predicate isSource(DataFlow::Node src) { src instanceof InsecureBasicAuthSource }
32+
33+
predicate isSink(DataFlow::Node sink) { sink instanceof InsecureBasicAuthSink }
34+
35+
predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
36+
any(HttpUrlsAdditionalTaintStep c).step(node1, node2)
37+
}
38+
}
39+
40+
/**
41+
* Tracks flow for the Basic authentication scheme being used in HTTP connections.
42+
*/
43+
module InsecureBasicAuthFlow = TaintTracking::Global<BasicAuthFlowConfig>;

java/ql/src/Security/CWE/CWE-522/InsecureBasicAuth.ql

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

1717
import java
1818
import semmle.code.java.security.InsecureBasicAuthQuery
19-
import DataFlow::PathGraph
19+
import InsecureBasicAuthFlow::PathGraph
2020

21-
from DataFlow::PathNode source, DataFlow::PathNode sink, BasicAuthFlowConfig config
22-
where config.hasFlowPath(source, sink)
21+
from InsecureBasicAuthFlow::PathNode source, InsecureBasicAuthFlow::PathNode sink
22+
where InsecureBasicAuthFlow::flowPath(source, sink)
2323
select sink.getNode(), source, sink, "Insecure basic authentication from a $@.", source.getNode(),
2424
"HTTP URL"

java/ql/test/query-tests/security/CWE-522/InsecureBasicAuthTest.ql

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

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

0 commit comments

Comments
 (0)