Skip to content

Commit b096f9e

Browse files
committed
Python: Rename getAUse -> getAValueReachableFromSource
1 parent 181a53b commit b096f9e

File tree

25 files changed

+103
-65
lines changed

25 files changed

+103
-65
lines changed

python/ql/lib/semmle/python/ApiGraphs.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ module API {
106106
* ```
107107
* both `obj.foo` and `x` are uses of the `foo` member from `obj`.
108108
*/
109-
DataFlow::Node getAUse() {
109+
DataFlow::Node getAValueReachableFromSource() {
110110
exists(DataFlow::LocalSourceNode src | Impl::use(this, src) |
111111
Impl::trackUseNode(src).flowsTo(result)
112112
)

python/ql/lib/semmle/python/frameworks/Aiohttp.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,8 @@ module AiohttpWebModel {
626626
// and just go with the LHS
627627
this.asCfgNode() = subscript
628628
|
629-
subscript.getObject() = aiohttpResponseInstance().getMember("cookies").getAUse().asCfgNode() and
629+
subscript.getObject() =
630+
aiohttpResponseInstance().getMember("cookies").getAValueReachableFromSource().asCfgNode() and
630631
value.asCfgNode() = subscript.(DefinitionNode).getValue() and
631632
index.asCfgNode() = subscript.getIndex()
632633
)

python/ql/lib/semmle/python/frameworks/Cryptodome.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ private module CryptodomeModel {
164164
.getMember("Cipher")
165165
.getMember(cipherName)
166166
.getMember(modeName)
167-
.getAUse()
167+
.getAValueReachableFromSource()
168168
|
169169
result = modeName.splitAt("_", 1)
170170
)

python/ql/lib/semmle/python/frameworks/Cryptography.qll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ private module CryptographyModel {
145145

146146
override int getKeySizeWithOrigin(DataFlow::Node origin) {
147147
exists(API::Node n | n = Ecc::predefinedCurveClass(result) and origin = n.asSource() |
148-
this.getCurveArg() = n.getAUse()
148+
this.getCurveArg() = n.getAValueReachableFromSource()
149149
or
150-
this.getCurveArg() = n.getReturn().getAUse()
150+
this.getCurveArg() = n.getReturn().getAValueReachableFromSource()
151151
)
152152
}
153153

@@ -189,12 +189,12 @@ private module CryptographyModel {
189189
.getMember("ciphers")
190190
.getMember("Cipher")
191191
.getACall() and
192-
algorithmClassRef(algorithmName).getReturn().getAUse() in [
192+
algorithmClassRef(algorithmName).getReturn().getAValueReachableFromSource() in [
193193
call.getArg(0), call.getArgByName("algorithm")
194194
] and
195195
exists(DataFlow::Node modeArg | modeArg in [call.getArg(1), call.getArgByName("mode")] |
196-
if modeArg = modeClassRef(_).getReturn().getAUse()
197-
then modeArg = modeClassRef(modeName).getReturn().getAUse()
196+
if modeArg = modeClassRef(_).getReturn().getAValueReachableFromSource()
197+
then modeArg = modeClassRef(modeName).getReturn().getAValueReachableFromSource()
198198
else modeName = "<None or unknown>"
199199
)
200200
)
@@ -252,7 +252,7 @@ private module CryptographyModel {
252252
.getMember("hashes")
253253
.getMember("Hash")
254254
.getACall() and
255-
algorithmClassRef(algorithmName).getReturn().getAUse() in [
255+
algorithmClassRef(algorithmName).getReturn().getAValueReachableFromSource() in [
256256
call.getArg(0), call.getArgByName("algorithm")
257257
]
258258
)

python/ql/lib/semmle/python/frameworks/Django.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2799,7 +2799,7 @@ module PrivateDjango {
27992799
.getMember("decorators")
28002800
.getMember("csrf")
28012801
.getMember(decoratorName)
2802-
.getAUse() and
2802+
.getAValueReachableFromSource() and
28032803
this.asExpr() = function.getADecorator()
28042804
}
28052805

python/ql/lib/semmle/python/frameworks/Fabric.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ private module FabricV2 {
179179
DataFlow::ParameterNode {
180180
FabricTaskFirstParamConnectionInstance() {
181181
exists(Function func |
182-
func.getADecorator() = Fabric::Tasks::task().getAUse().asExpr() and
182+
func.getADecorator() = Fabric::Tasks::task().getAValueReachableFromSource().asExpr() and
183183
this.getParameter() = func.getArg(0)
184184
)
185185
}

python/ql/lib/semmle/python/frameworks/FastApi.qll

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ private module FastApi {
9090
private class PydanticModelRequestHandlerParam extends Pydantic::BaseModel::InstanceSource,
9191
DataFlow::ParameterNode {
9292
PydanticModelRequestHandlerParam() {
93-
this.getParameter().getAnnotation() = Pydantic::BaseModel::subclassRef().getAUse().asExpr() and
93+
this.getParameter().getAnnotation() =
94+
Pydantic::BaseModel::subclassRef().getAValueReachableFromSource().asExpr() and
9495
any(FastApiRouteSetup rs).getARequestHandler().getArgByName(_) = this.getParameter()
9596
}
9697
}
@@ -104,7 +105,8 @@ private module FastApi {
104105
private class WebSocketRequestHandlerParam extends Starlette::WebSocket::InstanceSource,
105106
DataFlow::ParameterNode {
106107
WebSocketRequestHandlerParam() {
107-
this.getParameter().getAnnotation() = Starlette::WebSocket::classRef().getAUse().asExpr() and
108+
this.getParameter().getAnnotation() =
109+
Starlette::WebSocket::classRef().getAValueReachableFromSource().asExpr() and
108110
any(FastApiRouteSetup rs).getARequestHandler().getArgByName(_) = this.getParameter()
109111
}
110112
}
@@ -165,7 +167,7 @@ private module FastApi {
165167
// user-defined subclasses
166168
exists(Class cls, API::Node base |
167169
base = getModeledResponseClass(_).getASubclass*() and
168-
cls.getABase() = base.getAUse().asExpr() and
170+
cls.getABase() = base.getAValueReachableFromSource().asExpr() and
169171
responseClass.asSource().asExpr() = cls.getParent()
170172
|
171173
exists(Assign assign | assign = cls.getAStmt() |
@@ -257,7 +259,7 @@ private module FastApi {
257259

258260
override string getMimetypeDefault() {
259261
exists(API::Node responseClass |
260-
responseClass.getAUse() = routeSetup.getResponseClassArg() and
262+
responseClass.getAValueReachableFromSource() = routeSetup.getResponseClassArg() and
261263
result = getDefaultMimeType(responseClass)
262264
)
263265
or
@@ -274,7 +276,7 @@ private module FastApi {
274276
FileSystemAccess::Range {
275277
FastApiRequestHandlerFileResponseReturn() {
276278
exists(API::Node responseClass |
277-
responseClass.getAUse() = routeSetup.getResponseClassArg() and
279+
responseClass.getAValueReachableFromSource() = routeSetup.getResponseClassArg() and
278280
responseClass = getModeledResponseClass("FileResponse").getASubclass*()
279281
)
280282
}
@@ -292,7 +294,7 @@ private module FastApi {
292294
HTTP::Server::HttpRedirectResponse::Range {
293295
FastApiRequestHandlerRedirectReturn() {
294296
exists(API::Node responseClass |
295-
responseClass.getAUse() = routeSetup.getResponseClassArg() and
297+
responseClass.getAValueReachableFromSource() = routeSetup.getResponseClassArg() and
296298
responseClass = getModeledResponseClass("RedirectResponse").getASubclass*()
297299
)
298300
}
@@ -311,7 +313,7 @@ private module FastApi {
311313
class RequestHandlerParam extends InstanceSource, DataFlow::ParameterNode {
312314
RequestHandlerParam() {
313315
this.getParameter().getAnnotation() =
314-
getModeledResponseClass(_).getASubclass*().getAUse().asExpr() and
316+
getModeledResponseClass(_).getASubclass*().getAValueReachableFromSource().asExpr() and
315317
any(FastApiRouteSetup rs).getARequestHandler().getArgByName(_) = this.getParameter()
316318
}
317319
}

python/ql/lib/semmle/python/frameworks/Flask.qll

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ module Flask {
305305
)
306306
or
307307
exists(FlaskViewClass vc |
308-
this.getViewArg() = vc.asViewResult().getAUse() and
308+
this.getViewArg() = vc.asViewResult().getAValueReachableFromSource() and
309309
result = vc.getARequestHandler()
310310
)
311311
}
@@ -339,7 +339,7 @@ module Flask {
339339
*/
340340
private class FlaskRequestSource extends RemoteFlowSource::Range {
341341
FlaskRequestSource() {
342-
this = request().getAUse() and
342+
this = request().getAValueReachableFromSource() and
343343
not any(Import imp).contains(this.asExpr()) and
344344
not exists(ControlFlowNode def | this.asVar().getSourceVariable().hasDefiningNode(def) |
345345
any(Import imp).contains(def.getNode())
@@ -357,7 +357,7 @@ module Flask {
357357
private class InstanceTaintSteps extends InstanceTaintStepsHelper {
358358
InstanceTaintSteps() { this = "flask.Request" }
359359

360-
override DataFlow::Node getInstance() { result = request().getAUse() }
360+
override DataFlow::Node getInstance() { result = request().getAValueReachableFromSource() }
361361

362362
override string getAttributeName() {
363363
result in [
@@ -415,12 +415,13 @@ module Flask {
415415
// be able to do something more structured for providing modeling of the members
416416
// of a container-object.
417417
exists(API::Node files | files = request().getMember("files") |
418-
this.asCfgNode().(SubscriptNode).getObject() = files.getAUse().asCfgNode()
418+
this.asCfgNode().(SubscriptNode).getObject() =
419+
files.getAValueReachableFromSource().asCfgNode()
419420
or
420421
this = files.getMember("get").getACall()
421422
or
422423
this.asCfgNode().(SubscriptNode).getObject() =
423-
files.getMember("getlist").getReturn().getAUse().asCfgNode()
424+
files.getMember("getlist").getReturn().getAValueReachableFromSource().asCfgNode()
424425
)
425426
}
426427
}

python/ql/lib/semmle/python/frameworks/Invoke.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ private module Invoke {
3939
result = InvokeModule::Context::ContextClass::classRef().getACall()
4040
or
4141
exists(Function func |
42-
func.getADecorator() = invoke().getMember("task").getAUse().asExpr() and
42+
func.getADecorator() =
43+
invoke().getMember("task").getAValueReachableFromSource().asExpr() and
4344
result.(DataFlow::ParameterNode).getParameter() = func.getArg(0)
4445
)
4546
)

python/ql/lib/semmle/python/frameworks/RuamelYaml.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private module RuamelYaml {
4444
API::moduleImport("ruamel")
4545
.getMember("yaml")
4646
.getMember(["SafeLoader", "BaseLoader", "CSafeLoader", "CBaseLoader"])
47-
.getAUse()
47+
.getAValueReachableFromSource()
4848
)
4949
}
5050

0 commit comments

Comments
 (0)