Python: Fix some Ql4Ql violations.

This commit is contained in:
Michael Nebel
2025-09-01 15:16:25 +02:00
parent b4d6cb6e5f
commit dbd31259b3
10 changed files with 35 additions and 43 deletions

View File

@@ -613,7 +613,7 @@ DataFlowType getNodeType(Node node) {
// Extra flow
//--------
/**
* Holds if `pred` can flow to `succ`, by jumping from one callable to
* Holds if `nodeFrom` can flow to `nodeTo`, by jumping from one callable to
* another. Additional steps specified by the configuration are *not*
* taken into account.
*/
@@ -634,7 +634,7 @@ predicate jumpStep(Node nodeFrom, Node nodeTo) {
* the type-trackers as well, as that would make evaluation of type-tracking recursive
* with the new jumpsteps.
*
* Holds if `pred` can flow to `succ`, by jumping from one callable to
* Holds if `nodeFrom` can flow to `nodeTo`, by jumping from one callable to
* another. Additional steps specified by the configuration are *not*
* taken into account.
*/
@@ -657,7 +657,7 @@ predicate jumpStepSharedWithTypeTracker(Node nodeFrom, Node nodeTo) {
* the type-trackers as well, as that would make evaluation of type-tracking recursive
* with the new jumpsteps.
*
* Holds if `pred` can flow to `succ`, by jumping from one callable to
* Holds if `nodeFrom` can flow to `nodeTo`, by jumping from one callable to
* another. Additional steps specified by the configuration are *not*
* taken into account.
*/
@@ -766,7 +766,7 @@ module Orm {
abstract predicate storeStep(Node nodeFrom, Content c, Node nodeTo);
/**
* Holds if `pred` can flow to `succ`, by jumping from one callable to
* Holds if `nodeFrom` can flow to `nodeTo`, by jumping from one callable to
* another. Additional steps specified by the configuration are *not*
* taken into account.
*/

View File

@@ -3702,11 +3702,8 @@ module StdlibPrivate {
* A call to a find method on a tree or an element will execute an XPath expression.
*/
private class ElementTreeFindCall extends XML::XPathExecution::Range, DataFlow::CallCfgNode {
string methodName;
ElementTreeFindCall() {
methodName in ["find", "findall", "findtext"] and
(
exists(string methodName | methodName in ["find", "findall", "findtext"] |
this = elementTreeInstance().getMember(methodName).getACall()
or
this = elementInstance().getMember(methodName).getACall()

View File

@@ -174,9 +174,9 @@ class ObjectInternal extends TObject {
abstract int length();
/**
* Holds if the object `function` is called when this object is called and `paramOffset`
* Holds if the object `function` is called when this object is called and `offset`
* is the difference from the parameter position and the argument position.
* For a normal function `paramOffset` is 0. For classes and bound-methods it is 1.
* For a normal function `offset` is 0. For classes and bound-methods it is 1.
* This is used to implement the `CallableValue` public API.
*/
predicate functionAndOffset(CallableObjectInternal function, int offset) { none() }

View File

@@ -46,9 +46,7 @@ abstract class FunctionObject extends Object {
ControlFlowNode getACall() { result = this.theCallable().getACall() }
/** Gets a call-site from where this function is called, given the `context` */
ControlFlowNode getACall(Context caller_context) {
result = this.theCallable().getACall(caller_context)
}
ControlFlowNode getACall(Context context) { result = this.theCallable().getACall(context) }
/**
* Gets the `ControlFlowNode` that will be passed as the nth argument to `this` when called at `call`.