Skip to content

Commit 167496e

Browse files
edvraaowen-mc
authored andcommitted
Use MethodCallNode and hasQualifiedName
1 parent 5929f66 commit 167496e

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

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

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,13 @@ class BoolToGinSetCookieTrackingConfiguration extends DataFlow::Configuration {
117117
override predicate isSource(DataFlow::Node source) { source.asExpr().getBoolValue() = false }
118118

119119
override predicate isSink(DataFlow::Node sink) {
120-
exists(CallExpr c |
121-
c.getTarget().getQualifiedName() = "github.com/gin-gonic/gin.Context.SetCookie" and
122-
c.getArgument(6) = sink.asExpr() and
120+
exists(DataFlow::MethodCallNode mcn |
121+
mcn.getTarget()
122+
.hasQualifiedName(package("github.com/gin-gonic/gin", ""), "Context", "SetCookie") and
123+
mcn.getArgument(6) = sink and
123124
exists(NameToGinSetCookieTrackingConfiguration cfg, DataFlow::Node nameArg |
124125
cfg.hasFlow(_, nameArg) and
125-
c.getArgument(0) = nameArg.asExpr()
126+
mcn.getArgument(0) = nameArg
126127
)
127128
)
128129
}
@@ -137,21 +138,23 @@ private class NameToGinSetCookieTrackingConfiguration extends DataFlow2::Configu
137138
override predicate isSource(DataFlow::Node source) { isAuthVariable(source.asExpr()) }
138139

139140
override predicate isSink(DataFlow::Node sink) {
140-
exists(CallExpr c |
141-
c.getTarget().getQualifiedName() = "github.com/gin-gonic/gin.Context.SetCookie" and
142-
c.getArgument(0) = sink.asExpr()
141+
exists(DataFlow::MethodCallNode mcn |
142+
mcn.getTarget()
143+
.hasQualifiedName(package("github.com/gin-gonic/gin", ""), "Context", "SetCookie") and
144+
mcn.getArgument(0) = sink
143145
)
144146
}
145147
}
146148

147149
/**
148-
* The base of `gorilla/sessions.Session.Save` call.
150+
* The receiver of `gorilla/sessions.Session.Save` call.
149151
*/
150152
private class GorillaSessionSaveSink extends DataFlow::Node {
151153
GorillaSessionSaveSink() {
152-
exists(CallExpr c |
153-
this.asExpr() = c.getCalleeExpr().(SelectorExpr).getBase() and
154-
c.getTarget().getQualifiedName() = "github.com/gorilla/sessions.Session.Save"
154+
exists(DataFlow::MethodCallNode mcn |
155+
this = mcn.getReceiver() and
156+
mcn.getTarget()
157+
.hasQualifiedName(package("github.com/gorilla/sessions", ""), "Session", "Save")
155158
)
156159
}
157160
}
@@ -174,8 +177,9 @@ class GorillaCookieStoreSaveTrackingConfiguration extends DataFlow::Configuratio
174177
override predicate isSink(DataFlow::Node sink) { sink instanceof GorillaSessionSaveSink }
175178

176179
override predicate isAdditionalFlowStep(DataFlow::Node pred, DataFlow::Node succ) {
177-
exists(DataFlow::CallNode cn |
178-
cn.getTarget().getQualifiedName() = "github.com/gorilla/sessions.CookieStore.Get" and
180+
exists(DataFlow::MethodCallNode cn |
181+
cn.getTarget()
182+
.hasQualifiedName(package("github.com/gorilla/sessions", ""), "CookieStore", "Get") and
179183
pred = cn.getReceiver() and
180184
succ = cn.getResult(0)
181185
)
@@ -201,7 +205,7 @@ class GorillaSessionOptionsTrackingConfiguration extends TaintTracking::Configur
201205

202206
override predicate isAdditionalTaintStep(DataFlow::Node pred, DataFlow::Node succ) {
203207
exists(Field f, DataFlow::Write w, DataFlow::Node base |
204-
f.getQualifiedName() = "github.com/gorilla/sessions.Session.Options" and
208+
f.hasQualifiedName(package("github.com/gorilla/sessions", ""), "Session", "Options") and
205209
w.writesField(base, f, pred) and
206210
succ = base
207211
)
@@ -227,7 +231,7 @@ class BoolToGorillaSessionOptionsTrackingConfiguration extends TaintTracking::Co
227231
)
228232
or
229233
exists(Field f, DataFlow::Write w, DataFlow::Node base |
230-
f.getQualifiedName() = "github.com/gorilla/sessions.Session.Options" and
234+
f.hasQualifiedName(package("github.com/gorilla/sessions", ""), "Session", "Options") and
231235
w.writesField(base, f, pred) and
232236
succ = base
233237
)

0 commit comments

Comments
 (0)