mirror of
https://github.com/github/codeql.git
synced 2026-05-01 03:35:13 +02:00
Merge pull request #6934 from erik-krogh/more-instanceof
Approved by MathiasVP, esbena, yoff
This commit is contained in:
@@ -1365,10 +1365,8 @@ module IterableUnpacking {
|
||||
}
|
||||
|
||||
/** A (possibly recursive) target of an unpacking assignment which is also a sequence. */
|
||||
class UnpackingAssignmentSequenceTarget extends UnpackingAssignmentTarget {
|
||||
UnpackingAssignmentSequenceTarget() { this instanceof SequenceNode }
|
||||
|
||||
ControlFlowNode getElement(int i) { result = this.(SequenceNode).getElement(i) }
|
||||
class UnpackingAssignmentSequenceTarget extends UnpackingAssignmentTarget instanceof SequenceNode {
|
||||
ControlFlowNode getElement(int i) { result = super.getElement(i) }
|
||||
|
||||
ControlFlowNode getAnElement() { result = this.getElement(_) }
|
||||
}
|
||||
|
||||
@@ -639,16 +639,14 @@ module DataFlow {
|
||||
}
|
||||
}
|
||||
|
||||
deprecated private class ConfigurationAdapter extends TaintTracking::Configuration {
|
||||
ConfigurationAdapter() { this instanceof Configuration }
|
||||
|
||||
deprecated private class ConfigurationAdapter extends TaintTracking::Configuration instanceof Configuration {
|
||||
override predicate isSource(DataFlow::Node node, TaintKind kind) {
|
||||
this.(Configuration).isSource(node.asCfgNode()) and
|
||||
Configuration.super.isSource(node.asCfgNode()) and
|
||||
kind instanceof DataFlowType
|
||||
}
|
||||
|
||||
override predicate isSink(DataFlow::Node node, TaintKind kind) {
|
||||
this.(Configuration).isSink(node.asCfgNode()) and
|
||||
Configuration.super.isSink(node.asCfgNode()) and
|
||||
kind instanceof DataFlowType
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,16 +14,14 @@ string munge(File sourceFile, ExternalPackage package) {
|
||||
result = "/" + sourceFile.getRelativePath() + "<|>" + package.getName() + "<|>unknown"
|
||||
}
|
||||
|
||||
abstract class ExternalPackage extends Object {
|
||||
ExternalPackage() { this instanceof ModuleObject }
|
||||
|
||||
abstract class ExternalPackage extends Object instanceof ModuleObject {
|
||||
abstract string getName();
|
||||
|
||||
abstract string getVersion();
|
||||
|
||||
Object getAttribute(string name) { result = this.(ModuleObject).attr(name) }
|
||||
Object getAttribute(string name) { result = super.attr(name) }
|
||||
|
||||
PackageObject getPackage() { result = this.(ModuleObject).getPackage() }
|
||||
PackageObject getPackage() { result = super.getPackage() }
|
||||
}
|
||||
|
||||
bindingset[text]
|
||||
|
||||
@@ -147,9 +147,7 @@ class Value extends TObject {
|
||||
* Class representing modules in the Python program
|
||||
* Each `ModuleValue` represents a module object in the Python program.
|
||||
*/
|
||||
class ModuleValue extends Value {
|
||||
ModuleValue() { this instanceof ModuleObjectInternal }
|
||||
|
||||
class ModuleValue extends Value instanceof ModuleObjectInternal {
|
||||
/**
|
||||
* Holds if this module "exports" name.
|
||||
* That is, does it define `name` in `__all__` or is
|
||||
@@ -159,7 +157,7 @@ class ModuleValue extends Value {
|
||||
predicate exports(string name) { PointsTo::moduleExports(this, name) }
|
||||
|
||||
/** Gets the scope for this module, provided that it is a Python module. */
|
||||
ModuleScope getScope() { result = this.(ModuleObjectInternal).getSourceModule() }
|
||||
ModuleScope getScope() { result = super.getSourceModule() }
|
||||
|
||||
/**
|
||||
* Gets the container path for this module. Will be the file for a Python module,
|
||||
@@ -181,7 +179,7 @@ class ModuleValue extends Value {
|
||||
predicate isPackage() { this instanceof PackageObjectInternal }
|
||||
|
||||
/** Whether the complete set of names "exported" by this module can be accurately determined */
|
||||
predicate hasCompleteExportInfo() { this.(ModuleObjectInternal).hasCompleteExportInfo() }
|
||||
predicate hasCompleteExportInfo() { super.hasCompleteExportInfo() }
|
||||
|
||||
/** Get a module that this module imports */
|
||||
ModuleValue getAnImportedModule() { result.importedAs(this.getScope().getAnImportedModuleName()) }
|
||||
@@ -452,23 +450,21 @@ class CallableValue extends Value {
|
||||
* Class representing bound-methods, such as `o.func`, where `o` is an instance
|
||||
* of a class that has a callable attribute `func`.
|
||||
*/
|
||||
class BoundMethodValue extends CallableValue {
|
||||
BoundMethodValue() { this instanceof BoundMethodObjectInternal }
|
||||
|
||||
class BoundMethodValue extends CallableValue instanceof BoundMethodObjectInternal {
|
||||
/**
|
||||
* Gets the callable that will be used when `this` is called.
|
||||
* The actual callable for `func` in `o.func`.
|
||||
*/
|
||||
CallableValue getFunction() { result = this.(BoundMethodObjectInternal).getFunction() }
|
||||
CallableValue getFunction() { result = super.getFunction() }
|
||||
|
||||
/**
|
||||
* Gets the value that will be used for the `self` parameter when `this` is called.
|
||||
* The value for `o` in `o.func`.
|
||||
*/
|
||||
Value getSelf() { result = this.(BoundMethodObjectInternal).getSelf() }
|
||||
Value getSelf() { result = super.getSelf() }
|
||||
|
||||
/** Gets the parameter node that will be used for `self`. */
|
||||
NameNode getSelfParameter() { result = this.(BoundMethodObjectInternal).getSelfParameter() }
|
||||
NameNode getSelfParameter() { result = super.getSelfParameter() }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -831,12 +827,10 @@ class BuiltinMethodValue extends FunctionValue {
|
||||
/**
|
||||
* A class representing sequence objects with a length and tracked items.
|
||||
*/
|
||||
class SequenceValue extends Value {
|
||||
SequenceValue() { this instanceof SequenceObjectInternal }
|
||||
class SequenceValue extends Value instanceof SequenceObjectInternal {
|
||||
Value getItem(int n) { result = super.getItem(n) }
|
||||
|
||||
Value getItem(int n) { result = this.(SequenceObjectInternal).getItem(n) }
|
||||
|
||||
int length() { result = this.(SequenceObjectInternal).length() }
|
||||
int length() { result = super.length() }
|
||||
}
|
||||
|
||||
/** A class representing tuple objects */
|
||||
@@ -887,14 +881,12 @@ class NumericValue extends Value {
|
||||
* https://docs.python.org/3/howto/descriptor.html#properties
|
||||
* https://docs.python.org/3/library/functions.html#property
|
||||
*/
|
||||
class PropertyValue extends Value {
|
||||
PropertyValue() { this instanceof PropertyInternal }
|
||||
class PropertyValue extends Value instanceof PropertyInternal {
|
||||
CallableValue getGetter() { result = super.getGetter() }
|
||||
|
||||
CallableValue getGetter() { result = this.(PropertyInternal).getGetter() }
|
||||
CallableValue getSetter() { result = super.getSetter() }
|
||||
|
||||
CallableValue getSetter() { result = this.(PropertyInternal).getSetter() }
|
||||
|
||||
CallableValue getDeleter() { result = this.(PropertyInternal).getDeleter() }
|
||||
CallableValue getDeleter() { result = super.getDeleter() }
|
||||
}
|
||||
|
||||
/** A method-resolution-order sequence of classes */
|
||||
|
||||
@@ -144,12 +144,10 @@ class ReModulePointToExtension extends PointsToExtension {
|
||||
private predicate pointsTo_helper(Context context) { context.appliesTo(this) }
|
||||
}
|
||||
|
||||
deprecated private class BackwardCompatiblePointToExtension extends PointsToExtension {
|
||||
BackwardCompatiblePointToExtension() { this instanceof CustomPointsToFact }
|
||||
|
||||
deprecated private class BackwardCompatiblePointToExtension extends PointsToExtension instanceof CustomPointsToFact {
|
||||
override predicate pointsTo(Context context, ObjectInternal value, ControlFlowNode origin) {
|
||||
exists(Object obj, ClassObject cls |
|
||||
this.(CustomPointsToFact).pointsTo(context, obj, cls, origin)
|
||||
CustomPointsToFact.super.pointsTo(context, obj, cls, origin)
|
||||
|
|
||||
value.getBuiltin() = obj
|
||||
or
|
||||
|
||||
Reference in New Issue
Block a user