mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Merge pull request #7245 from erik-krogh/explicit-this-all-the-places
All langs: apply the explicit-this patch to all remaining code
This commit is contained in:
@@ -76,7 +76,7 @@ class PrintAstNode extends TPrintAstNode {
|
||||
/**
|
||||
* Gets a child of this node.
|
||||
*/
|
||||
final PrintAstNode getAChild() { result = getChild(_) }
|
||||
final PrintAstNode getAChild() { result = this.getChild(_) }
|
||||
|
||||
/**
|
||||
* Gets the parent of this node, if any.
|
||||
@@ -94,7 +94,7 @@ class PrintAstNode extends TPrintAstNode {
|
||||
*/
|
||||
string getProperty(string key) {
|
||||
key = "semmle.label" and
|
||||
result = toString()
|
||||
result = this.toString()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,7 +103,7 @@ class PrintAstNode extends TPrintAstNode {
|
||||
* this.
|
||||
*/
|
||||
string getChildEdgeLabel(int childIndex) {
|
||||
exists(getChild(childIndex)) and
|
||||
exists(this.getChild(childIndex)) and
|
||||
result = childIndex.toString()
|
||||
}
|
||||
}
|
||||
@@ -157,13 +157,13 @@ class AstElementNode extends PrintAstNode, TElementNode {
|
||||
|
||||
override PrintAstNode getChild(int childIndex) {
|
||||
exists(AstNode el | result.(AstElementNode).getAstNode() = el |
|
||||
el = this.getChildNode(childIndex) and not el = getStmtList(_, _).getAnItem()
|
||||
el = this.getChildNode(childIndex) and not el = this.getStmtList(_, _).getAnItem()
|
||||
)
|
||||
or
|
||||
// displaying all `StmtList` after the other children.
|
||||
exists(int offset | offset = 1 + max([0, any(int index | exists(this.getChildNode(index)))]) |
|
||||
exists(int index | childIndex = index + offset |
|
||||
result.(StmtListNode).getList() = getStmtList(index, _)
|
||||
result.(StmtListNode).getList() = this.getStmtList(index, _)
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -299,7 +299,7 @@ class StmtListNode extends PrintAstNode, TStmtListNode {
|
||||
|
||||
private string getLabel() { this.getList() = any(AstElementNode node).getStmtList(_, result) }
|
||||
|
||||
override string toString() { result = "(StmtList) " + getLabel() }
|
||||
override string toString() { result = "(StmtList) " + this.getLabel() }
|
||||
|
||||
override PrintAstNode getChild(int childIndex) {
|
||||
exists(AstNode el | result.(AstElementNode).getAstNode() = el | el = list.getItem(childIndex))
|
||||
|
||||
@@ -86,7 +86,7 @@ class SsaVariable extends @py_ssa_var {
|
||||
|
||||
/** Gets the incoming edges for a Phi node. */
|
||||
private BasicBlock getAPredecessorBlockForPhi() {
|
||||
exists(getAPhiInput()) and
|
||||
exists(this.getAPhiInput()) and
|
||||
result.getASuccessor() = this.getDefinition().getBasicBlock()
|
||||
}
|
||||
|
||||
|
||||
@@ -503,7 +503,7 @@ class TaintTrackingImplementation extends string {
|
||||
TaintKind kind, string edgeLabel
|
||||
) {
|
||||
exists(PythonFunctionValue init, EssaVariable self, TaintTrackingContext callee |
|
||||
instantiationCall(node.asCfgNode(), src, init, context, callee) and
|
||||
this.instantiationCall(node.asCfgNode(), src, init, context, callee) and
|
||||
this.(EssaTaintTracking).taintedDefinition(_, self.getDefinition(), callee, path, kind) and
|
||||
self.getSourceVariable().(Variable).isSelf() and
|
||||
BaseFlow::reaches_exit(self) and
|
||||
@@ -789,9 +789,9 @@ private class EssaTaintTracking extends string {
|
||||
TaintTrackingNode src, PyEdgeRefinement defn, TaintTrackingContext context, AttributePath path,
|
||||
TaintKind kind
|
||||
) {
|
||||
taintedPiNodeOneway(src, defn, context, path, kind)
|
||||
this.taintedPiNodeOneway(src, defn, context, path, kind)
|
||||
or
|
||||
taintedPiNodeBothways(src, defn, context, path, kind)
|
||||
this.taintedPiNodeBothways(src, defn, context, path, kind)
|
||||
}
|
||||
|
||||
pragma[noinline]
|
||||
@@ -802,7 +802,7 @@ private class EssaTaintTracking extends string {
|
||||
exists(DataFlow::Node srcnode, ControlFlowNode use |
|
||||
src = TTaintTrackingNode_(srcnode, context, path, kind, this) and
|
||||
not this.(TaintTracking::Configuration).isBarrierTest(defn.getTest(), defn.getSense()) and
|
||||
defn.getSense() = testEvaluates(defn, defn.getTest(), use, src)
|
||||
defn.getSense() = this.testEvaluates(defn, defn.getTest(), use, src)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -898,7 +898,7 @@ private class EssaTaintTracking extends string {
|
||||
)
|
||||
)
|
||||
or
|
||||
result = testEvaluates(defn, not_operand(test), use, src).booleanNot()
|
||||
result = this.testEvaluates(defn, not_operand(test), use, src).booleanNot()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -911,7 +911,7 @@ private class EssaTaintTracking extends string {
|
||||
use = test
|
||||
or
|
||||
exists(ControlFlowNode notuse |
|
||||
boolean_filter(test, notuse) and
|
||||
this.boolean_filter(test, notuse) and
|
||||
use = not_operand(notuse)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -89,7 +89,7 @@ class PythonFunctionObjectInternal extends CallableObjectInternal, TPythonFuncti
|
||||
origin = CfgOrigin::fromCfgNode(forigin)
|
||||
)
|
||||
or
|
||||
procedureReturnsNone(callee, obj, origin)
|
||||
this.procedureReturnsNone(callee, obj, origin)
|
||||
}
|
||||
|
||||
private predicate procedureReturnsNone(
|
||||
|
||||
@@ -27,7 +27,8 @@ class PropertyInternal extends ObjectInternal, TProperty {
|
||||
or
|
||||
// x = property(getter, setter, deleter)
|
||||
exists(ControlFlowNode setter_arg |
|
||||
setter_arg = getCallNode().getArg(1) or setter_arg = getCallNode().getArgByName("fset")
|
||||
setter_arg = this.getCallNode().getArg(1) or
|
||||
setter_arg = this.getCallNode().getArgByName("fset")
|
||||
|
|
||||
PointsToInternal::pointsTo(setter_arg, this.getContext(), result, _)
|
||||
)
|
||||
@@ -43,7 +44,8 @@ class PropertyInternal extends ObjectInternal, TProperty {
|
||||
or
|
||||
// x = property(getter, setter, deleter)
|
||||
exists(ControlFlowNode deleter_arg |
|
||||
deleter_arg = getCallNode().getArg(2) or deleter_arg = getCallNode().getArgByName("fdel")
|
||||
deleter_arg = this.getCallNode().getArg(2) or
|
||||
deleter_arg = this.getCallNode().getArgByName("fdel")
|
||||
|
|
||||
PointsToInternal::pointsTo(deleter_arg, this.getContext(), result, _)
|
||||
)
|
||||
|
||||
@@ -138,8 +138,8 @@ class Value extends TObject {
|
||||
* The result can be `none()`, but never both `true` and `false`.
|
||||
*/
|
||||
boolean getDefiniteBooleanValue() {
|
||||
result = getABooleanValue() and
|
||||
not (getABooleanValue() = true and getABooleanValue() = false)
|
||||
result = this.getABooleanValue() and
|
||||
not (this.getABooleanValue() = true and this.getABooleanValue() = false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ class ModuleValue extends Value instanceof ModuleObjectInternal {
|
||||
|
||||
/** When used (exclusively) as a script (will not include normal modules that can also be run as a script) */
|
||||
predicate isUsedAsScript() {
|
||||
not isUsedAsModule() and
|
||||
not this.isUsedAsModule() and
|
||||
(
|
||||
not this.getPath().getExtension() = "py"
|
||||
or
|
||||
|
||||
@@ -75,9 +75,9 @@ class ClassList extends TClassList {
|
||||
this = Empty() and result = ""
|
||||
or
|
||||
exists(ClassObjectInternal head | head = this.getHead() |
|
||||
this.getTail() = Empty() and result = className(head)
|
||||
this.getTail() = Empty() and result = this.className(head)
|
||||
or
|
||||
this.getTail() != Empty() and result = className(head) + ", " + this.getTail().contents()
|
||||
this.getTail() != Empty() and result = this.className(head) + ", " + this.getTail().contents()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -331,9 +331,9 @@ private class ClassListList extends TClassListList {
|
||||
|
||||
ClassObjectInternal bestMergeCandidate(int n) {
|
||||
exists(ClassObjectInternal head | head = this.getItem(n).getHead() |
|
||||
legalMergeCandidate(head) and result = head
|
||||
this.legalMergeCandidate(head) and result = head
|
||||
or
|
||||
illegalMergeCandidate(head) and result = this.bestMergeCandidate(n + 1)
|
||||
this.illegalMergeCandidate(head) and result = this.bestMergeCandidate(n + 1)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -375,7 +375,7 @@ abstract class RegexString extends Expr {
|
||||
// 32-bit hex value \Uhhhhhhhh
|
||||
this.getChar(start + 1) = "U" and end = start + 10
|
||||
or
|
||||
escapedName(start, end)
|
||||
this.escapedName(start, end)
|
||||
or
|
||||
// escape not handled above, update when adding a new case
|
||||
not this.getChar(start + 1) in ["x", "u", "U", "N"] and
|
||||
|
||||
@@ -140,9 +140,9 @@ class RegExpRoot extends RegExpTerm {
|
||||
// there is at least one repetition
|
||||
getRoot(any(InfiniteRepetitionQuantifier q)) = this and
|
||||
// is actually used as a RegExp
|
||||
isUsedAsRegExp() and
|
||||
this.isUsedAsRegExp() and
|
||||
// not excluded for library specific reasons
|
||||
not isExcluded(getRootTerm().getParent())
|
||||
not isExcluded(this.getRootTerm().getParent())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ abstract class CharacterClass extends InputSymbol {
|
||||
/**
|
||||
* Gets a character matched by this character class.
|
||||
*/
|
||||
string choose() { result = getARelevantChar() and matches(result) }
|
||||
string choose() { result = this.getARelevantChar() and this.matches(result) }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -281,19 +281,19 @@ class UrlsplitUrlparseTempSanitizer extends Sanitizer {
|
||||
or
|
||||
full_use.(AttrNode).getObject() = test.getInput().getAUse()
|
||||
|
|
||||
clears_taint(full_use, test.getTest(), test.getSense())
|
||||
this.clears_taint(full_use, test.getTest(), test.getSense())
|
||||
)
|
||||
}
|
||||
|
||||
private predicate clears_taint(ControlFlowNode tainted, ControlFlowNode test, boolean sense) {
|
||||
test_equality_with_const(test, tainted, sense)
|
||||
this.test_equality_with_const(test, tainted, sense)
|
||||
or
|
||||
test_in_const_seq(test, tainted, sense)
|
||||
this.test_in_const_seq(test, tainted, sense)
|
||||
or
|
||||
test.(UnaryExprNode).getNode().getOp() instanceof Not and
|
||||
exists(ControlFlowNode nested_test |
|
||||
nested_test = test.(UnaryExprNode).getOperand() and
|
||||
clears_taint(tainted, nested_test, sense.booleanNot())
|
||||
this.clears_taint(tainted, nested_test, sense.booleanNot())
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -33,30 +33,30 @@ class ClassObject extends Object {
|
||||
}
|
||||
|
||||
/** Gets the short (unqualified) name of this class */
|
||||
string getName() { result = theClass().getName() }
|
||||
string getName() { result = this.theClass().getName() }
|
||||
|
||||
/**
|
||||
* Gets the qualified name for this class.
|
||||
* Should return the same name as the `__qualname__` attribute on classes in Python 3.
|
||||
*/
|
||||
string getQualifiedName() {
|
||||
result = theClass().getBuiltin().getName()
|
||||
result = this.theClass().getBuiltin().getName()
|
||||
or
|
||||
result = theClass().(PythonClassObjectInternal).getScope().getQualifiedName()
|
||||
result = this.theClass().(PythonClassObjectInternal).getScope().getQualifiedName()
|
||||
}
|
||||
|
||||
/** Gets the nth base class of this class */
|
||||
Object getBaseType(int n) { result = Types::getBase(theClass(), n).getSource() }
|
||||
Object getBaseType(int n) { result = Types::getBase(this.theClass(), n).getSource() }
|
||||
|
||||
/** Gets a base class of this class */
|
||||
Object getABaseType() { result = this.getBaseType(_) }
|
||||
|
||||
/** Whether this class has a base class */
|
||||
predicate hasABase() { exists(Types::getBase(theClass(), _)) }
|
||||
predicate hasABase() { exists(Types::getBase(this.theClass(), _)) }
|
||||
|
||||
/** Gets a super class of this class (includes transitive super classes) */
|
||||
ClassObject getASuperType() {
|
||||
result = Types::getMro(theClass()).getTail().getAnItem().getSource()
|
||||
result = Types::getMro(this.theClass()).getTail().getAnItem().getSource()
|
||||
}
|
||||
|
||||
/** Gets a super class of this class (includes transitive super classes) or this class */
|
||||
@@ -66,13 +66,13 @@ class ClassObject extends Object {
|
||||
* Whether this class is a new style class.
|
||||
* A new style class is one that implicitly or explicitly inherits from `object`.
|
||||
*/
|
||||
predicate isNewStyle() { Types::isNewStyle(theClass()) }
|
||||
predicate isNewStyle() { Types::isNewStyle(this.theClass()) }
|
||||
|
||||
/**
|
||||
* Whether this class is an old style class.
|
||||
* An old style class is one that does not inherit from `object`.
|
||||
*/
|
||||
predicate isOldStyle() { Types::isOldStyle(theClass()) }
|
||||
predicate isOldStyle() { Types::isOldStyle(this.theClass()) }
|
||||
|
||||
/**
|
||||
* Whether this class is a legal exception class.
|
||||
@@ -92,14 +92,14 @@ class ClassObject extends Object {
|
||||
/** Returns an attribute declared on this class (not on a super-class) */
|
||||
Object declaredAttribute(string name) {
|
||||
exists(ObjectInternal val |
|
||||
Types::declaredAttribute(theClass(), name, val, _) and
|
||||
Types::declaredAttribute(this.theClass(), name, val, _) and
|
||||
result = val.getSource()
|
||||
)
|
||||
}
|
||||
|
||||
/** Returns an attribute declared on this class (not on a super-class) */
|
||||
predicate declaresAttribute(string name) {
|
||||
theClass().getClassDeclaration().declaresAttribute(name)
|
||||
this.theClass().getClassDeclaration().declaresAttribute(name)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,18 +108,18 @@ class ClassObject extends Object {
|
||||
*/
|
||||
Object lookupAttribute(string name) {
|
||||
exists(ObjectInternal val |
|
||||
theClass().lookup(name, val, _) and
|
||||
this.theClass().lookup(name, val, _) and
|
||||
result = val.getSource()
|
||||
)
|
||||
}
|
||||
|
||||
ClassList getMro() { result = Types::getMro(theClass()) }
|
||||
ClassList getMro() { result = Types::getMro(this.theClass()) }
|
||||
|
||||
/** Looks up an attribute by searching this class' MRO starting at `start` */
|
||||
Object lookupMro(ClassObject start, string name) {
|
||||
exists(ClassObjectInternal other, ClassObjectInternal decl, ObjectInternal val |
|
||||
other.getSource() = start and
|
||||
decl = Types::getMro(theClass()).startingAt(other).findDeclaringClass(name) and
|
||||
decl = Types::getMro(this.theClass()).startingAt(other).findDeclaringClass(name) and
|
||||
Types::declaredAttribute(decl, name, val, _) and
|
||||
result = val.getSource()
|
||||
)
|
||||
@@ -133,7 +133,7 @@ class ClassObject extends Object {
|
||||
/** Whether the named attribute refers to the object, class and origin */
|
||||
predicate attributeRefersTo(string name, Object obj, ClassObject cls, ControlFlowNode origin) {
|
||||
exists(ObjectInternal val, CfgOrigin valorig |
|
||||
theClass().lookup(name, val, valorig) and
|
||||
this.theClass().lookup(name, val, valorig) and
|
||||
obj = val.getSource() and
|
||||
cls = val.getClass().getSource() and
|
||||
origin = valorig.toCfgNode()
|
||||
@@ -141,7 +141,7 @@ class ClassObject extends Object {
|
||||
}
|
||||
|
||||
/** Whether this class has a attribute named `name`, either declared or inherited. */
|
||||
predicate hasAttribute(string name) { theClass().hasAttribute(name) }
|
||||
predicate hasAttribute(string name) { this.theClass().hasAttribute(name) }
|
||||
|
||||
/**
|
||||
* Whether it is impossible to know all the attributes of this class. Usually because it is
|
||||
@@ -162,7 +162,7 @@ class ClassObject extends Object {
|
||||
|
||||
/** Gets the metaclass for this class */
|
||||
ClassObject getMetaClass() {
|
||||
result = theClass().getClass().getSource() and
|
||||
result = this.theClass().getClass().getSource() and
|
||||
not this.failedInference()
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ class ClassObject extends Object {
|
||||
ControlFlowNode declaredMetaClass() { result = this.getPyClass().getMetaClass().getAFlowNode() }
|
||||
|
||||
/** Has type inference failed to compute the full class hierarchy for this class for the reason given. */
|
||||
predicate failedInference(string reason) { Types::failedInference(theClass(), reason) }
|
||||
predicate failedInference(string reason) { Types::failedInference(this.theClass(), reason) }
|
||||
|
||||
/** Has type inference failed to compute the full class hierarchy for this class */
|
||||
predicate failedInference() { this.failedInference(_) }
|
||||
@@ -205,7 +205,7 @@ class ClassObject extends Object {
|
||||
|
||||
/** This class is only instantiated at one place in the code */
|
||||
private predicate hasStaticallyUniqueInstance() {
|
||||
strictcount(SpecificInstanceInternal inst | inst.getClass() = theClass()) = 1
|
||||
strictcount(SpecificInstanceInternal inst | inst.getClass() = this.theClass()) = 1
|
||||
}
|
||||
|
||||
ImportTimeScope getImportTimeScope() { result = this.getPyClass() }
|
||||
@@ -221,7 +221,7 @@ class ClassObject extends Object {
|
||||
ClassObject nextInMro(ClassObject sup) {
|
||||
exists(ClassObjectInternal other |
|
||||
other.getSource() = sup and
|
||||
result = Types::getMro(theClass()).startingAt(other).getTail().getHead().getSource()
|
||||
result = Types::getMro(this.theClass()).startingAt(other).getTail().getHead().getSource()
|
||||
) and
|
||||
not this.failedInference()
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ class RaisingNode extends ControlFlowNode {
|
||||
or
|
||||
exists(FunctionObject func | this = func.getACall() | result = func.getARaisedType())
|
||||
or
|
||||
result = systemExitRaise_objectapi()
|
||||
result = this.systemExitRaise_objectapi()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,7 +53,7 @@ class RaisingNode extends ControlFlowNode {
|
||||
or
|
||||
exists(FunctionValue func | this = func.getACall() | result = func.getARaisedType())
|
||||
or
|
||||
result = systemExitRaise()
|
||||
result = this.systemExitRaise()
|
||||
}
|
||||
|
||||
pragma[noinline]
|
||||
|
||||
@@ -137,7 +137,7 @@ class ReModulePointToExtension extends PointsToExtension {
|
||||
sre_constants.attribute("SRE_FLAG_" + flag, value, orig) and
|
||||
origin = orig.asCfgNodeOrHere(this)
|
||||
) and
|
||||
pointsTo_helper(context)
|
||||
this.pointsTo_helper(context)
|
||||
}
|
||||
|
||||
pragma[noinline]
|
||||
|
||||
@@ -36,22 +36,22 @@ abstract class FunctionObject extends Object {
|
||||
abstract string descriptiveString();
|
||||
|
||||
/** Gets a call-site from where this function is called as a function */
|
||||
CallNode getAFunctionCall() { result.getFunction().inferredValue() = theCallable() }
|
||||
CallNode getAFunctionCall() { result.getFunction().inferredValue() = this.theCallable() }
|
||||
|
||||
/** Gets a call-site from where this function is called as a method */
|
||||
CallNode getAMethodCall() {
|
||||
exists(BoundMethodObjectInternal bm |
|
||||
result.getFunction().inferredValue() = bm and
|
||||
bm.getFunction() = theCallable()
|
||||
bm.getFunction() = this.theCallable()
|
||||
)
|
||||
}
|
||||
|
||||
/** Gets a call-site from where this function is called */
|
||||
ControlFlowNode getACall() { result = theCallable().getACall() }
|
||||
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 = theCallable().getACall(caller_context)
|
||||
result = this.theCallable().getACall(caller_context)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +59,7 @@ abstract class FunctionObject extends Object {
|
||||
* This predicate will correctly handle `x.y()`, treating `x` as the zeroth argument.
|
||||
*/
|
||||
ControlFlowNode getArgumentForCall(CallNode call, int n) {
|
||||
result = theCallable().getArgumentForCall(call, n)
|
||||
result = this.theCallable().getArgumentForCall(call, n)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,11 +67,11 @@ abstract class FunctionObject extends Object {
|
||||
* This predicate will correctly handle `x.y()`, treating `x` as the self argument.
|
||||
*/
|
||||
ControlFlowNode getNamedArgumentForCall(CallNode call, string name) {
|
||||
result = theCallable().getNamedArgumentForCall(call, name)
|
||||
result = this.theCallable().getNamedArgumentForCall(call, name)
|
||||
}
|
||||
|
||||
/** Whether this function never returns. This is an approximation. */
|
||||
predicate neverReturns() { theCallable().neverReturns() }
|
||||
predicate neverReturns() { this.theCallable().neverReturns() }
|
||||
|
||||
/**
|
||||
* Whether this is a "normal" method, that is, it is exists as a class attribute
|
||||
|
||||
@@ -43,11 +43,11 @@ abstract class ModuleObject extends Object {
|
||||
pragma[inline]
|
||||
final Object attr(string name) { result = this.getAttribute(name) }
|
||||
|
||||
predicate hasAttribute(string name) { theModule().hasAttribute(name) }
|
||||
predicate hasAttribute(string name) { this.theModule().hasAttribute(name) }
|
||||
|
||||
predicate attributeRefersTo(string name, Object obj, ControlFlowNode origin) {
|
||||
exists(ObjectInternal val, CfgOrigin valorig |
|
||||
theModule().(ModuleObjectInternal).attribute(name, val, valorig) and
|
||||
this.theModule().(ModuleObjectInternal).attribute(name, val, valorig) and
|
||||
obj = val.getSource() and
|
||||
origin = valorig.toCfgNode()
|
||||
)
|
||||
@@ -55,7 +55,7 @@ abstract class ModuleObject extends Object {
|
||||
|
||||
predicate attributeRefersTo(string name, Object obj, ClassObject cls, ControlFlowNode origin) {
|
||||
exists(ObjectInternal val, CfgOrigin valorig |
|
||||
theModule().(ModuleObjectInternal).attribute(name, val, valorig) and
|
||||
this.theModule().(ModuleObjectInternal).attribute(name, val, valorig) and
|
||||
obj = val.getSource() and
|
||||
cls = val.getClass().getSource() and
|
||||
origin = valorig.toCfgNode()
|
||||
@@ -72,7 +72,7 @@ abstract class ModuleObject extends Object {
|
||||
* Whether this module "exports" `name`. That is, whether using `import *` on this module
|
||||
* will result in `name` being added to the namespace.
|
||||
*/
|
||||
predicate exports(string name) { theModule().exports(name) }
|
||||
predicate exports(string name) { this.theModule().exports(name) }
|
||||
|
||||
/**
|
||||
* Whether the complete set of names "exported" by this module can be accurately determined
|
||||
@@ -92,7 +92,7 @@ abstract class ModuleObject extends Object {
|
||||
* Whether this module is imported by 'import name'. For example on a linux system,
|
||||
* the module 'posixpath' is imported as 'os.path' or as 'posixpath'
|
||||
*/
|
||||
predicate importedAs(string name) { PointsToInternal::module_imported_as(theModule(), name) }
|
||||
predicate importedAs(string name) { PointsToInternal::module_imported_as(this.theModule(), name) }
|
||||
|
||||
ModuleObject getAnImportedModule() {
|
||||
result.importedAs(this.getModule().getAnImportedModuleName())
|
||||
@@ -181,7 +181,7 @@ class PackageObject extends ModuleObject {
|
||||
|
||||
override Object getAttribute(string name) {
|
||||
exists(ObjectInternal val |
|
||||
theModule().(PackageObjectInternal).attribute(name, val, _) and
|
||||
this.theModule().(PackageObjectInternal).attribute(name, val, _) and
|
||||
result = val.getSource()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ class Object extends @py_object {
|
||||
* class S, both attributes having the same name, and S is a super class of C.
|
||||
*/
|
||||
predicate overrides(Object o) {
|
||||
exists(string name | declaringClass(name).getASuperType() = o.declaringClass(name))
|
||||
exists(string name | this.declaringClass(name).getASuperType() = o.declaringClass(name))
|
||||
}
|
||||
|
||||
private boolean booleanFromValue() {
|
||||
@@ -148,8 +148,8 @@ class Object extends @py_object {
|
||||
}
|
||||
|
||||
final predicate maybe() {
|
||||
booleanFromValue() = true and
|
||||
booleanFromValue() = false
|
||||
this.booleanFromValue() = true and
|
||||
this.booleanFromValue() = false
|
||||
}
|
||||
|
||||
predicate notClass() { any() }
|
||||
|
||||
@@ -21,7 +21,7 @@ class TurboGearsControllerMethod extends Function {
|
||||
|
||||
private ControlFlowNode templateName() { result = decorator.(CallNode).getArg(0) }
|
||||
|
||||
predicate isTemplated() { exists(templateName()) }
|
||||
predicate isTemplated() { exists(this.templateName()) }
|
||||
|
||||
Dict getValidationDict() {
|
||||
exists(Call call, Value dict |
|
||||
|
||||
@@ -85,7 +85,7 @@ class CheckClass extends ClassObject {
|
||||
|
||||
predicate interestingUndefined(SelfAttributeRead a) {
|
||||
exists(string name | name = a.getName() |
|
||||
interestingContext(a, name) and
|
||||
this.interestingContext(a, name) and
|
||||
not this.definedInBlock(a.getAFlowNode().getBasicBlock(), name)
|
||||
)
|
||||
}
|
||||
@@ -98,7 +98,7 @@ class CheckClass extends ClassObject {
|
||||
not a.guardedByHasattr() and
|
||||
a.getScope().isPublic() and
|
||||
not this.monkeyPatched(name) and
|
||||
not attribute_assigned_in_method(lookupAttribute("setUp"), name)
|
||||
not attribute_assigned_in_method(this.lookupAttribute("setUp"), name)
|
||||
}
|
||||
|
||||
private predicate probablyAbstract() {
|
||||
@@ -127,7 +127,7 @@ class CheckClass extends ClassObject {
|
||||
// so we can push the context in from there, which must apply to a
|
||||
// SelfAttributeRead in the same scope
|
||||
exists(SelfAttributeRead a | a.getScope() = b.getScope() and name = a.getName() |
|
||||
interestingContext(a, name)
|
||||
this.interestingContext(a, name)
|
||||
) and
|
||||
this.definitionInBlock(b, name)
|
||||
or
|
||||
|
||||
@@ -96,12 +96,12 @@ abstract class TlsLibrary extends string {
|
||||
|
||||
/** Gets an API node representing a specific protocol version. */
|
||||
API::Node specific_version(ProtocolVersion version) {
|
||||
result = version_constants().getMember(specific_version_name(version))
|
||||
result = this.version_constants().getMember(this.specific_version_name(version))
|
||||
}
|
||||
|
||||
/** Gets an API node representing the protocol family `family`. */
|
||||
API::Node unspecific_version(ProtocolFamily family) {
|
||||
result = version_constants().getMember(unspecific_version_name(family))
|
||||
result = this.version_constants().getMember(this.unspecific_version_name(family))
|
||||
}
|
||||
|
||||
/** Gets a creation of a context with a default protocol. */
|
||||
@@ -112,14 +112,14 @@ abstract class TlsLibrary extends string {
|
||||
|
||||
/** Gets a creation of a context with a specific protocol version, known to be insecure. */
|
||||
ContextCreation insecure_context_creation(ProtocolVersion version) {
|
||||
result in [specific_context_creation(), default_context_creation()] and
|
||||
result in [this.specific_context_creation(), this.default_context_creation()] and
|
||||
result.getProtocol() = version and
|
||||
version.isInsecure()
|
||||
}
|
||||
|
||||
/** Gets a context that was created using `family`, known to have insecure instances. */
|
||||
ContextCreation unspecific_context_creation(ProtocolFamily family) {
|
||||
result in [specific_context_creation(), default_context_creation()] and
|
||||
result in [this.specific_context_creation(), this.default_context_creation()] and
|
||||
result.getProtocol() = family
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ private module Authlib {
|
||||
|
||||
override string getAlgorithmString() {
|
||||
exists(StrConst str |
|
||||
DataFlow::exprNode(str).(DataFlow::LocalSourceNode).flowsTo(getAlgorithm()) and
|
||||
DataFlow::exprNode(str).(DataFlow::LocalSourceNode).flowsTo(this.getAlgorithm()) and
|
||||
result = str.getText()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ private module PyJWT {
|
||||
|
||||
override string getAlgorithmString() {
|
||||
exists(StrConst str |
|
||||
DataFlow::exprNode(str).(DataFlow::LocalSourceNode).flowsTo(getAlgorithm()) and
|
||||
DataFlow::exprNode(str).(DataFlow::LocalSourceNode).flowsTo(this.getAlgorithm()) and
|
||||
result = str.getText()
|
||||
)
|
||||
}
|
||||
@@ -76,7 +76,7 @@ private module PyJWT {
|
||||
|
||||
override string getAlgorithmString() {
|
||||
exists(StrConst str |
|
||||
DataFlow::exprNode(str).(DataFlow::LocalSourceNode).flowsTo(getAlgorithm()) and
|
||||
DataFlow::exprNode(str).(DataFlow::LocalSourceNode).flowsTo(this.getAlgorithm()) and
|
||||
result = str.getText()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ private module PythonJose {
|
||||
|
||||
override string getAlgorithmString() {
|
||||
exists(StrConst str |
|
||||
DataFlow::exprNode(str).(DataFlow::LocalSourceNode).flowsTo(getAlgorithm()) and
|
||||
DataFlow::exprNode(str).(DataFlow::LocalSourceNode).flowsTo(this.getAlgorithm()) and
|
||||
result = str.getText()
|
||||
)
|
||||
}
|
||||
@@ -77,7 +77,7 @@ private module PythonJose {
|
||||
|
||||
override string getAlgorithmString() {
|
||||
exists(StrConst str |
|
||||
DataFlow::exprNode(str).(DataFlow::LocalSourceNode).flowsTo(getAlgorithm()) and
|
||||
DataFlow::exprNode(str).(DataFlow::LocalSourceNode).flowsTo(this.getAlgorithm()) and
|
||||
result = str.getText()
|
||||
)
|
||||
}
|
||||
|
||||
27
python/ql/src/external/ExternalArtifact.qll
vendored
27
python/ql/src/external/ExternalArtifact.qll
vendored
@@ -19,7 +19,9 @@ class ExternalDefect extends @externalDefect {
|
||||
Location getLocation() { externalDefects(this, _, result, _, _) }
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = getQueryPath() + ": " + getLocation() + " - " + getMessage() }
|
||||
string toString() {
|
||||
result = this.getQueryPath() + ": " + this.getLocation() + " - " + this.getMessage()
|
||||
}
|
||||
}
|
||||
|
||||
class ExternalMetric extends @externalMetric {
|
||||
@@ -30,7 +32,9 @@ class ExternalMetric extends @externalMetric {
|
||||
Location getLocation() { externalMetrics(this, _, result, _) }
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = getQueryPath() + ": " + getLocation() + " - " + getValue() }
|
||||
string toString() {
|
||||
result = this.getQueryPath() + ": " + this.getLocation() + " - " + this.getValue()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,7 +48,7 @@ class ExternalData extends @externalDataElement {
|
||||
* Gets the path of the file this data was loaded from, with its
|
||||
* extension replaced by `.ql`.
|
||||
*/
|
||||
string getQueryPath() { result = getDataPath().regexpReplaceAll("\\.[^.]*$", ".ql") }
|
||||
string getQueryPath() { result = this.getDataPath().regexpReplaceAll("\\.[^.]*$", ".ql") }
|
||||
|
||||
/** Gets the number of fields in this data item. */
|
||||
int getNumFields() { result = 1 + max(int i | externalData(this, _, i, _) | i) }
|
||||
@@ -53,22 +57,23 @@ class ExternalData extends @externalDataElement {
|
||||
string getField(int index) { externalData(this, _, index, result) }
|
||||
|
||||
/** Gets the integer value of the field at position `index` of this data item. */
|
||||
int getFieldAsInt(int index) { result = getField(index).toInt() }
|
||||
int getFieldAsInt(int index) { result = this.getField(index).toInt() }
|
||||
|
||||
/** Gets the floating-point value of the field at position `index` of this data item. */
|
||||
float getFieldAsFloat(int index) { result = getField(index).toFloat() }
|
||||
float getFieldAsFloat(int index) { result = this.getField(index).toFloat() }
|
||||
|
||||
/** Gets the value of the field at position `index` of this data item, interpreted as a date. */
|
||||
date getFieldAsDate(int index) { result = getField(index).toDate() }
|
||||
date getFieldAsDate(int index) { result = this.getField(index).toDate() }
|
||||
|
||||
/** Gets a textual representation of this data item. */
|
||||
string toString() { result = getQueryPath() + ": " + buildTupleString(0) }
|
||||
string toString() { result = this.getQueryPath() + ": " + this.buildTupleString(0) }
|
||||
|
||||
/** Gets a textual representation of this data item, starting with the field at position `start`. */
|
||||
private string buildTupleString(int start) {
|
||||
start = getNumFields() - 1 and result = getField(start)
|
||||
start = this.getNumFields() - 1 and result = this.getField(start)
|
||||
or
|
||||
start < getNumFields() - 1 and result = getField(start) + "," + buildTupleString(start + 1)
|
||||
start < this.getNumFields() - 1 and
|
||||
result = this.getField(start) + "," + this.buildTupleString(start + 1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +86,7 @@ class DefectExternalData extends ExternalData {
|
||||
this.getNumFields() = 2
|
||||
}
|
||||
|
||||
string getURL() { result = getField(0) }
|
||||
string getURL() { result = this.getField(0) }
|
||||
|
||||
string getMessage() { result = getField(1) }
|
||||
string getMessage() { result = this.getField(1) }
|
||||
}
|
||||
|
||||
4
python/ql/src/external/Thrift.qll
vendored
4
python/ql/src/external/Thrift.qll
vendored
@@ -13,9 +13,9 @@ class ThriftElement extends ExternalData {
|
||||
|
||||
string getKind() { result = kind }
|
||||
|
||||
string getId() { result = getField(0) }
|
||||
string getId() { result = this.getField(0) }
|
||||
|
||||
int getIndex() { result = getFieldAsInt(1) }
|
||||
int getIndex() { result = this.getFieldAsInt(1) }
|
||||
|
||||
ThriftElement getParent() { result.getId() = this.getField(2) }
|
||||
|
||||
|
||||
6
python/ql/src/external/VCS.qll
vendored
6
python/ql/src/external/VCS.qll
vendored
@@ -29,7 +29,7 @@ class Commit extends @svnentry {
|
||||
)
|
||||
}
|
||||
|
||||
string getAnAffectedFilePath() { result = getAnAffectedFilePath(_) }
|
||||
string getAnAffectedFilePath() { result = this.getAnAffectedFilePath(_) }
|
||||
|
||||
File getAnAffectedFile(string action) { svnaffectedfiles(this, result, action) }
|
||||
|
||||
@@ -38,7 +38,7 @@ class Commit extends @svnentry {
|
||||
predicate isRecent() { recentCommit(this) }
|
||||
|
||||
int daysToNow() {
|
||||
exists(date now | snapshotDate(now) | result = getDate().daysTo(now) and result >= 0)
|
||||
exists(date now | snapshotDate(now) | result = this.getDate().daysTo(now) and result >= 0)
|
||||
}
|
||||
|
||||
int getRecentAdditionsForFile(File f) { svnchurn(this, f, result, _) }
|
||||
@@ -46,7 +46,7 @@ class Commit extends @svnentry {
|
||||
int getRecentDeletionsForFile(File f) { svnchurn(this, f, _, result) }
|
||||
|
||||
int getRecentChurnForFile(File f) {
|
||||
result = getRecentAdditionsForFile(f) + getRecentDeletionsForFile(f)
|
||||
result = this.getRecentAdditionsForFile(f) + this.getRecentDeletionsForFile(f)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ abstract class FlowTest extends InlineExpectationsTest {
|
||||
location = toNode.getLocation() and
|
||||
tag = this.flowTag() and
|
||||
value =
|
||||
"\"" + prettyNode(fromNode).replaceAll("\"", "'") + lineStr(fromNode, toNode) + " -> " +
|
||||
"\"" + prettyNode(fromNode).replaceAll("\"", "'") + this.lineStr(fromNode, toNode) + " -> " +
|
||||
prettyNode(toNode).replaceAll("\"", "'") + "\"" and
|
||||
element = toNode.toString()
|
||||
)
|
||||
|
||||
@@ -25,11 +25,13 @@ abstract class RoutingTest extends InlineExpectationsTest {
|
||||
element = fromNode.toString() and
|
||||
(
|
||||
tag = this.flowTag() and
|
||||
if "\"" + tag + "\"" = fromValue(fromNode) then value = "" else value = fromValue(fromNode)
|
||||
if "\"" + tag + "\"" = this.fromValue(fromNode)
|
||||
then value = ""
|
||||
else value = this.fromValue(fromNode)
|
||||
or
|
||||
tag = "func" and
|
||||
value = toFunc(toNode) and
|
||||
not value = fromFunc(fromNode)
|
||||
value = this.toFunc(toNode) and
|
||||
not value = this.fromFunc(fromNode)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user