Skip to content

Commit 60fde3c

Browse files
committed
Python: Rename getARhs -> asSink
1 parent 8f259d4 commit 60fde3c

File tree

12 files changed

+25
-25
lines changed

12 files changed

+25
-25
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ module API {
128128
* ```
129129
* `x` is the right-hand side of a definition of the first parameter of `bar` from the `mypkg.foo` module.
130130
*/
131-
DataFlow::Node getARhs() { Impl::rhs(this, result) }
131+
DataFlow::Node asSink() { Impl::rhs(this, result) }
132132

133133
/**
134134
* Gets a data-flow node that may interprocedurally flow to the right-hand side of a definition
135135
* of the API component represented by this node.
136136
*/
137-
DataFlow::Node getAValueReachingRhs() { result = Impl::trackDefNode(this.getARhs()) }
137+
DataFlow::Node getAValueReachingRhs() { result = Impl::trackDefNode(this.asSink()) }
138138

139139
/**
140140
* Gets an immediate use of the API component represented by this node.
@@ -390,14 +390,14 @@ module API {
390390
* Gets an API node where a RHS of the node is the `i`th argument to this call.
391391
*/
392392
pragma[noinline]
393-
private Node getAParameterCandidate(int i) { result.getARhs() = this.getArg(i) }
393+
private Node getAParameterCandidate(int i) { result.asSink() = this.getArg(i) }
394394

395395
/** Gets the API node for a parameter of this invocation. */
396396
Node getAParameter() { result = this.getParameter(_) }
397397

398398
/** Gets the object that this method-call is being called on, if this is a method-call */
399399
Node getSelfParameter() {
400-
result.getARhs() = this.(DataFlow::MethodCallNode).getObject() and
400+
result.asSink() = this.(DataFlow::MethodCallNode).getObject() and
401401
result = callee.getSelfParameter()
402402
}
403403

@@ -417,7 +417,7 @@ module API {
417417

418418
pragma[noinline]
419419
private Node getAKeywordParameterCandidate(string name) {
420-
result.getARhs() = this.getArgByName(name)
420+
result.asSink() = this.getArgByName(name)
421421
}
422422

423423
/** Gets the API node for the return value of this call. */

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private module Aiomysql {
5353
class CursorExecuteCall extends SqlConstruction::Range, API::CallNode {
5454
CursorExecuteCall() { this = cursor().getMember("execute").getACall() }
5555

56-
override DataFlow::Node getSql() { result = this.getParameter(0, "operation").getARhs() }
56+
override DataFlow::Node getSql() { result = this.getParameter(0, "operation").asSink() }
5757
}
5858

5959
/**
@@ -94,7 +94,7 @@ private module Aiomysql {
9494
class SAConnectionExecuteCall extends SqlConstruction::Range, API::CallNode {
9595
SAConnectionExecuteCall() { this = saConnection().getMember("execute").getACall() }
9696

97-
override DataFlow::Node getSql() { result = this.getParameter(0, "query").getARhs() }
97+
override DataFlow::Node getSql() { result = this.getParameter(0, "query").asSink() }
9898
}
9999

100100
/**

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private module Aiopg {
5353
class CursorExecuteCall extends SqlConstruction::Range, API::CallNode {
5454
CursorExecuteCall() { this = cursor().getMember("execute").getACall() }
5555

56-
override DataFlow::Node getSql() { result = this.getParameter(0, "operation").getARhs() }
56+
override DataFlow::Node getSql() { result = this.getParameter(0, "operation").asSink() }
5757
}
5858

5959
/**
@@ -90,7 +90,7 @@ private module Aiopg {
9090
class SAConnectionExecuteCall extends SqlConstruction::Range, API::CallNode {
9191
SAConnectionExecuteCall() { this = saConnection().getMember("execute").getACall() }
9292

93-
override DataFlow::Node getSql() { result = this.getParameter(0, "query").getARhs() }
93+
override DataFlow::Node getSql() { result = this.getParameter(0, "query").asSink() }
9494
}
9595

9696
/**

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private module Asyncpg {
6161
this = ModelOutput::getATypeNode("asyncpg", "Connection").getMember("cursor").getACall()
6262
}
6363

64-
override DataFlow::Node getSql() { result = this.getParameter(0, "query").getARhs() }
64+
override DataFlow::Node getSql() { result = this.getParameter(0, "query").asSink() }
6565
}
6666

6767
/** The creation of a `Cursor` executes the associated query. */
@@ -78,7 +78,7 @@ private module Asyncpg {
7878
prepareCall =
7979
ModelOutput::getATypeNode("asyncpg", "Connection").getMember("prepare").getACall()
8080
|
81-
sql = prepareCall.getParameter(0, "query").getARhs() and
81+
sql = prepareCall.getParameter(0, "query").asSink() and
8282
this =
8383
prepareCall
8484
.getReturn()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private module Requests {
6161
override predicate disablesCertificateValidation(
6262
DataFlow::Node disablingNode, DataFlow::Node argumentOrigin
6363
) {
64-
disablingNode = this.getKeywordParameter("verify").getARhs() and
64+
disablingNode = this.getKeywordParameter("verify").asSink() and
6565
argumentOrigin = this.getKeywordParameter("verify").getAValueReachingRhs() and
6666
// requests treats `None` as the default and all other "falsey" values as `False`.
6767
argumentOrigin.asExpr().(ImmutableLiteral).booleanValue() = false and

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2553,7 +2553,7 @@ private module StdlibPrivate {
25532553
override DataFlow::Node getAPathArgument() {
25542554
result = super.getAPathArgument()
25552555
or
2556-
result = this.getParameter(0, "target").getARhs()
2556+
result = this.getParameter(0, "target").asSink()
25572557
}
25582558
}
25592559

@@ -2570,7 +2570,7 @@ private module StdlibPrivate {
25702570
override DataFlow::Node getAPathArgument() {
25712571
result = super.getAPathArgument()
25722572
or
2573-
result = this.getParameter(0, "target").getARhs()
2573+
result = this.getParameter(0, "target").asSink()
25742574
}
25752575
}
25762576

@@ -2585,7 +2585,7 @@ private module StdlibPrivate {
25852585
override DataFlow::Node getAPathArgument() {
25862586
result = super.getAPathArgument()
25872587
or
2588-
result = this.getParameter(0, "other_path").getARhs()
2588+
result = this.getParameter(0, "other_path").asSink()
25892589
}
25902590
}
25912591

@@ -2670,7 +2670,7 @@ private module StdlibPrivate {
26702670

26712671
override Cryptography::CryptographicAlgorithm getAlgorithm() { result.matchesName(hashName) }
26722672

2673-
override DataFlow::Node getAnInput() { result = this.getParameter(1, "data").getARhs() }
2673+
override DataFlow::Node getAnInput() { result = this.getParameter(1, "data").asSink() }
26742674

26752675
override Cryptography::BlockMode getBlockMode() { none() }
26762676
}
@@ -3433,7 +3433,7 @@ private module StdlibPrivate {
34333433
private DataFlow::Node saxParserWithFeatureExternalGesTurnedOn(DataFlow::TypeTracker t) {
34343434
t.start() and
34353435
exists(SaxParserSetFeatureCall call |
3436-
call.getFeatureArg().getARhs() =
3436+
call.getFeatureArg().asSink() =
34373437
API::moduleImport("xml")
34383438
.getMember("sax")
34393439
.getMember("handler")
@@ -3449,7 +3449,7 @@ private module StdlibPrivate {
34493449
// take account of that we can set the feature to False, which makes the parser safe again
34503450
not exists(SaxParserSetFeatureCall call |
34513451
call.getObject() = result and
3452-
call.getFeatureArg().getARhs() =
3452+
call.getFeatureArg().asSink() =
34533453
API::moduleImport("xml")
34543454
.getMember("sax")
34553455
.getMember("handler")

python/ql/lib/semmle/python/frameworks/data/ModelsAsData.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ private class RemoteFlowSourceFromCsv extends RemoteFlowSource {
3434
private predicate summaryStepNodes(DataFlow::Node pred, DataFlow::Node succ, string kind) {
3535
exists(API::Node predNode, API::Node succNode |
3636
Specific::summaryStep(predNode, succNode, kind) and
37-
pred = predNode.getARhs() and
37+
pred = predNode.asSink() and
3838
succ = succNode.getAnImmediateUse()
3939
)
4040
}

python/ql/lib/semmle/python/security/dataflow/PathInjectionCustomizations.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ module PathInjection {
6262
private import semmle.python.frameworks.data.ModelsAsData
6363

6464
private class DataAsFileSink extends Sink {
65-
DataAsFileSink() { this = ModelOutput::getASinkNode("path-injection").getARhs() }
65+
DataAsFileSink() { this = ModelOutput::getASinkNode("path-injection").asSink() }
6666
}
6767

6868
/**

python/ql/lib/semmle/python/security/dataflow/SqlInjectionCustomizations.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ module SqlInjection {
6565

6666
/** A sink for sql-injection from model data. */
6767
private class DataAsSqlSink extends Sink {
68-
DataAsSqlSink() { this = ModelOutput::getASinkNode("sql-injection").getARhs() }
68+
DataAsSqlSink() { this = ModelOutput::getASinkNode("sql-injection").asSink() }
6969
}
7070
}

python/ql/test/TestUtilities/VerifyApiGraphs.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import semmle.python.ApiGraphs
2121

2222
private DataFlow::Node getNode(API::Node nd, string kind) {
2323
kind = "def" and
24-
result = nd.getARhs()
24+
result = nd.asSink()
2525
or
2626
kind = "use" and
2727
result = nd.getAUse()

0 commit comments

Comments
 (0)