Skip to content

Commit 69b43f1

Browse files
committed
Python: Fix ql4ql alerts
The rest will be ignored.
1 parent 00ec3a2 commit 69b43f1

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowDispatch.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ private TypeTrackingNode classTracker(TypeTracker t, Class cls) {
478478
or
479479
// when a class is decorated, it's the result of the (last) decorator call that
480480
// is used
481-
result.asExpr() = cls.getParent().(ClassExpr).getADecoratorCall()
481+
result.asExpr() = cls.getParent().getADecoratorCall()
482482
or
483483
// `type(obj)`, where obj is an instance of this class
484484
result = getTypeCall() and
@@ -1102,8 +1102,8 @@ predicate normalCallArg(CallNode call, Node arg, ArgumentPosition apos) {
11021102
}
11031103

11041104
/**
1105-
* Gets the argument of `call` at position `apos`, if any, where we can resolve `call`
1106-
* to `target` with CallType `type`.
1105+
* Gets the argument `arg` of `call` at position `apos`, if any. Requires that we can
1106+
* resolve `call` to `target` with CallType `type`.
11071107
*
11081108
* It might seem like it's enough to know the CallType to resolve arguments. The reason
11091109
* we also need the `target`, is to avoid cross-talk. In the example below, assuming

python/ql/src/Security/CWE-020-ExternalAPIs/ExternalAPIs.qll

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,10 @@ class UnresolvedCall extends InterestingExternalApiCall, TUnresolvedCall {
157157

158158
/** A node representing data being passed to an external API through a call. */
159159
class ExternalApiDataNode extends DataFlow::Node {
160-
InterestingExternalApiCall call;
161-
DataFlowPrivate::ArgumentPosition apos;
162-
163160
ExternalApiDataNode() {
164-
this = call.getArgument(apos) and
161+
exists(InterestingExternalApiCall call, DataFlowPrivate::ArgumentPosition apos |
162+
this = call.getArgument(apos)
163+
) and
165164
// Not already modeled as a taint step
166165
not exists(DataFlow::Node next | TaintTrackingPrivate::defaultAdditionalTaintStep(this, next)) and
167166
// for `list.append(x)`, we have a additional taint step from x -> [post] list.

python/ql/src/meta/analysis-quality/CallGraphQuality.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ module PointsToBasedCallGraph {
8181
*/
8282
class ResolvableCallRelevantTarget extends ResolvableCall {
8383
ResolvableCallRelevantTarget() {
84-
exists(Target target | target = getTarget() |
84+
exists(Target target | target = this.getTarget() |
8585
exists(target.getLocation().getFile().getRelativePath())
8686
)
8787
}
@@ -137,7 +137,7 @@ module TypeTrackingBasedCallGraph {
137137
*/
138138
class ResolvableCallRelevantTarget extends ResolvableCall {
139139
ResolvableCallRelevantTarget() {
140-
exists(Target target | target = getTarget() |
140+
exists(Target target | target = this.getTarget() |
141141
exists(target.getLocation().getFile().getRelativePath())
142142
)
143143
}

0 commit comments

Comments
 (0)