Skip to content

Commit 8856730

Browse files
committed
Refactor CWE-614/InsecureCookie
1 parent de6959c commit 8856730

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

java/ql/src/Security/CWE/CWE-614/InsecureCookie.ql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ predicate isSafeSecureCookieSetting(Expr e) {
2626
)
2727
}
2828

29-
class SecureCookieConfiguration extends DataFlow::Configuration {
30-
SecureCookieConfiguration() { this = "SecureCookieConfiguration" }
31-
32-
override predicate isSource(DataFlow::Node source) {
29+
private module SecureCookieConfiguration implements DataFlow::ConfigSig {
30+
predicate isSource(DataFlow::Node source) {
3331
exists(MethodAccess ma, Method m | ma.getMethod() = m |
3432
m.getDeclaringType() instanceof TypeCookie and
3533
m.getName() = "setSecure" and
@@ -43,14 +41,16 @@ class SecureCookieConfiguration extends DataFlow::Configuration {
4341
)
4442
}
4543

46-
override predicate isSink(DataFlow::Node sink) {
44+
predicate isSink(DataFlow::Node sink) {
4745
sink.asExpr() =
4846
any(MethodAccess add | add.getMethod() instanceof ResponseAddCookieMethod).getArgument(0)
4947
}
5048
}
5149

50+
module SecureCookieFlow = DataFlow::Make<SecureCookieConfiguration>;
51+
5252
from MethodAccess add
5353
where
5454
add.getMethod() instanceof ResponseAddCookieMethod and
55-
not any(SecureCookieConfiguration df).hasFlowToExpr(add.getArgument(0))
55+
not SecureCookieFlow::hasFlowToExpr(add.getArgument(0))
5656
select add, "Cookie is added to response without the 'secure' flag being set."

0 commit comments

Comments
 (0)