Skip to content

Commit 8110c3d

Browse files
edvraaowen-mc
authored andcommitted
Use HasFlow
1 parent d60d18a commit 8110c3d

File tree

2 files changed

+12
-24
lines changed

2 files changed

+12
-24
lines changed

ql/src/experimental/CWE-1004/AuthCookie.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class NetHttpCookieTrackingConfiguration extends TaintTracking::Configuration {
8080
override predicate isSink(DataFlow::Node sink) {
8181
sink instanceof SetCookieSink and
8282
exists(NameToNetHttpCookieTrackingConfiguration cfg, DataFlow::Node nameArg |
83-
cfg.hasFlow(_, nameArg) and
83+
cfg.hasFlowTo(nameArg) and
8484
sink.asExpr() = nameArg.asExpr()
8585
)
8686
}
@@ -137,7 +137,7 @@ class BoolToGinSetCookieTrackingConfiguration extends DataFlow::Configuration {
137137
mcn.getTarget() instanceof GinContextSetCookieMethod and
138138
mcn.getArgument(6) = sink and
139139
exists(NameToGinSetCookieTrackingConfiguration cfg, DataFlow::Node nameArg |
140-
cfg.hasFlow(_, nameArg) and
140+
cfg.hasFlowTo(nameArg) and
141141
mcn.getArgument(0) = nameArg
142142
)
143143
)

ql/src/experimental/CWE-1004/CookieWithoutHttpOnly.ql

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ predicate isNetHttpCookieFlow(DataFlow::PathNode source, DataFlow::PathNode sink
2525
source = cookieCreate and
2626
sink = setCookieSink
2727
or
28-
exists(BoolToNetHttpCookieTrackingConfiguration cfg, DataFlow::PathNode setCookieSink2 |
29-
cfg.hasFlowPath(source, setCookieSink2) and
30-
setCookieSink2.getNode() = setCookieSink.getNode() and
31-
sink = setCookieSink2
28+
exists(BoolToNetHttpCookieTrackingConfiguration cfg |
29+
cfg.hasFlow(source.getNode(), setCookieSink.getNode()) and
30+
sink = setCookieSink
3231
)
3332
)
3433
)
@@ -42,33 +41,22 @@ predicate isGorillaSessionsCookieFlow(DataFlow::PathNode source, DataFlow::PathN
4241
exists(DataFlow::PathNode cookieStoreCreate, DataFlow::PathNode sessionSave |
4342
any(GorillaCookieStoreSaveTrackingConfiguration cfg).hasFlowPath(cookieStoreCreate, sessionSave) and
4443
(
45-
not exists(GorillaSessionOptionsTrackingConfiguration cfg, DataFlow::PathNode sessionSave2 |
46-
sessionSave2.getNode() = sessionSave.getNode() and
47-
cfg.hasFlowPath(_, sessionSave2)
48-
) and
44+
not any(GorillaSessionOptionsTrackingConfiguration cfg).hasFlowTo(sessionSave.getNode()) and
4945
source = cookieStoreCreate and
5046
sink = sessionSave
5147
or
52-
exists(
53-
GorillaSessionOptionsTrackingConfiguration cfg, DataFlow::PathNode options,
54-
DataFlow::PathNode sessionSave2
55-
|
56-
cfg.hasFlowPath(options, sessionSave2) and
48+
exists(GorillaSessionOptionsTrackingConfiguration cfg, DataFlow::PathNode options |
49+
cfg.hasFlow(options.getNode(), sessionSave.getNode()) and
5750
(
5851
not exists(DataFlow::Node rhs |
5952
rhs = getValueForFieldWrite(options.getNode().asExpr(), "HttpOnly")
6053
) and
61-
sessionSave2.getNode() = sessionSave.getNode() and
62-
sink = sessionSave2 and
54+
sink = sessionSave and
6355
source = options
6456
or
65-
exists(
66-
BoolToGorillaSessionOptionsTrackingConfiguration boolCfg,
67-
DataFlow::PathNode sessionSave3
68-
|
69-
boolCfg.hasFlowPath(source, sessionSave3) and
70-
sessionSave3.getNode() = sessionSave.getNode() and
71-
sink = sessionSave3
57+
exists(BoolToGorillaSessionOptionsTrackingConfiguration boolCfg |
58+
boolCfg.hasFlow(source.getNode(), sessionSave.getNode()) and
59+
sink = sessionSave
7260
)
7361
)
7462
)

0 commit comments

Comments
 (0)