mirror of
https://github.com/github/codeql.git
synced 2025-12-20 10:46:30 +01:00
Python: Add a bunch more toString docs.
This commit is contained in:
@@ -175,6 +175,7 @@ class CommentedOutCodeLine extends Comment {
|
||||
class CommentedOutCodeBlock extends @py_comment {
|
||||
CommentedOutCodeBlock() { commented_out_code_block(this, _) }
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = "Commented out code" }
|
||||
|
||||
/** Whether this commented-out code block contains the comment c */
|
||||
|
||||
@@ -10,6 +10,7 @@ private newtype TDefinition =
|
||||
|
||||
/** A definition for the purposes of jump-to-definition. */
|
||||
class Definition extends TLocalDefinition {
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = "Definition " + this.getAstNode().getLocation().toString() }
|
||||
|
||||
AstNode getAstNode() { this = TLocalDefinition(result) }
|
||||
@@ -467,6 +468,7 @@ Definition getUniqueDefinition(Expr use) {
|
||||
|
||||
/** Helper class to get suitable locations for attributes */
|
||||
class NiceLocationExpr extends @py_expr {
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = this.(Expr).toString() }
|
||||
/**
|
||||
* Holds if this element is at the specified location.
|
||||
|
||||
2
python/ql/src/external/ExternalArtifact.qll
vendored
2
python/ql/src/external/ExternalArtifact.qll
vendored
@@ -18,6 +18,7 @@ class ExternalDefect extends @externalDefect {
|
||||
|
||||
Location getLocation() { externalDefects(this, _, result, _, _) }
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = getQueryPath() + ": " + getLocation() + " - " + getMessage() }
|
||||
}
|
||||
|
||||
@@ -28,6 +29,7 @@ class ExternalMetric extends @externalMetric {
|
||||
|
||||
Location getLocation() { externalMetrics(this, _, result, _) }
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = getQueryPath() + ": " + getLocation() + " - " + getValue() }
|
||||
}
|
||||
|
||||
|
||||
1
python/ql/src/external/VCS.qll
vendored
1
python/ql/src/external/VCS.qll
vendored
@@ -10,6 +10,7 @@ class Commit extends @svnentry {
|
||||
)
|
||||
}
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = this.getRevisionName() }
|
||||
|
||||
string getRevisionName() { svnentries(this, result, _, _, _) }
|
||||
|
||||
@@ -14,6 +14,7 @@ class Comment extends @py_comment {
|
||||
|
||||
Location getLocation() { py_comments(this, _, result) }
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = "Comment " + this.getText() }
|
||||
|
||||
/**
|
||||
@@ -55,6 +56,7 @@ class CommentBlock extends @py_comment {
|
||||
|
||||
private Comment last() { comment_block_part(this, result, this.length()) }
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = "Comment block" }
|
||||
|
||||
/** The length of this comment block (in comments) */
|
||||
|
||||
@@ -7,6 +7,7 @@ class Expr extends Expr_, AstNode {
|
||||
/** Gets the scope of this expression */
|
||||
override Scope getScope() { py_scopes(this, result) }
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
override string toString() { result = "Expression" }
|
||||
|
||||
/** Gets the module in which this expression occurs */
|
||||
|
||||
@@ -393,6 +393,7 @@ class Location extends @location {
|
||||
locations_ast(this, _, _, _, _, result)
|
||||
}
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() {
|
||||
result = this.getPath().getAbsolutePath() + ":" + this.getStartLine().toString()
|
||||
}
|
||||
@@ -433,6 +434,7 @@ class Line extends @py_line {
|
||||
)
|
||||
}
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() {
|
||||
exists(Module m | py_line_lengths(this, m, _, _) |
|
||||
result = m.getFile().getShortName() + ":" + this.getLineNumber().toString()
|
||||
|
||||
@@ -139,6 +139,7 @@ class ControlFlowNode extends @py_flow_node {
|
||||
/** Gets the syntactic element corresponding to this flow node */
|
||||
AstNode getNode() { py_flow_bb_node(this, result, _, _) }
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() {
|
||||
exists(Scope s | s.getEntryNode() = this | result = "Entry node for " + s.toString())
|
||||
or
|
||||
@@ -1014,6 +1015,7 @@ class BasicBlock extends @py_flow_node {
|
||||
/** Gets the nth node in this basic block */
|
||||
ControlFlowNode getNode(int n) { py_flow_bb_node(result, _, this, n) }
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = "BasicBlock" }
|
||||
|
||||
/** Whether this basic block strictly dominates the other */
|
||||
|
||||
@@ -76,6 +76,7 @@ class SsaVariable extends @py_ssa_var {
|
||||
result = this.getAPhiInput().getAnUltimateDefinition()
|
||||
}
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = "SSA Variable " + this.getId() }
|
||||
|
||||
Location getLocation() { result = this.getDefinition().getLocation() }
|
||||
|
||||
@@ -13,6 +13,7 @@ class Variable extends @py_variable {
|
||||
/** Gets the identifier (name) of this variable */
|
||||
string getId() { variable(this, _, result) }
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = "Variable " + this.getId() }
|
||||
|
||||
/** Gets an access (load or store) of this variable */
|
||||
|
||||
@@ -24,6 +24,7 @@ newtype TTaintTrackingContext =
|
||||
* Used to track taint through calls accurately and reasonably efficiently.
|
||||
*/
|
||||
class TaintTrackingContext extends TTaintTrackingContext {
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() {
|
||||
this = TNoParam() and result = ""
|
||||
or
|
||||
@@ -66,6 +67,7 @@ private newtype TAttributePath =
|
||||
* Used for tracking tainted attributes of objects.
|
||||
*/
|
||||
abstract class AttributePath extends TAttributePath {
|
||||
/** Gets a textual representation of this element. */
|
||||
abstract string toString();
|
||||
|
||||
abstract string extension();
|
||||
@@ -126,6 +128,7 @@ newtype TTaintTrackingNode =
|
||||
* Used for context-sensitive path-aware taint-tracking.
|
||||
*/
|
||||
class TaintTrackingNode extends TTaintTrackingNode {
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() {
|
||||
if this.getPath() instanceof NoAttribute
|
||||
then result = this.getTaintKind().repr()
|
||||
|
||||
@@ -355,6 +355,7 @@ abstract class Sanitizer extends string {
|
||||
* class to provide their own sources.
|
||||
*/
|
||||
abstract class TaintSource extends @py_flow_node {
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = "Taint source" }
|
||||
|
||||
/**
|
||||
@@ -478,6 +479,7 @@ private class SequenceExtends extends DataFlowExtension::DataFlowNode {
|
||||
* class to provide their own sink nodes.
|
||||
*/
|
||||
abstract class TaintSink extends @py_flow_node {
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = "Taint sink" }
|
||||
|
||||
/**
|
||||
@@ -511,6 +513,7 @@ abstract class TaintSink extends @py_flow_node {
|
||||
module DataFlowExtension {
|
||||
/** A control flow node that modifies the basic data-flow. */
|
||||
abstract class DataFlowNode extends @py_flow_node {
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = "Dataflow extension node" }
|
||||
|
||||
/**
|
||||
@@ -657,6 +660,7 @@ module DataFlow {
|
||||
|
||||
abstract EssaVariable asVariable();
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
abstract string toString();
|
||||
|
||||
abstract Scope getScope();
|
||||
@@ -676,6 +680,7 @@ module DataFlow {
|
||||
|
||||
override EssaVariable asVariable() { none() }
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
override string toString() { result = this.asAstNode().toString() }
|
||||
|
||||
override Scope getScope() { result = this.asCfgNode().getScope() }
|
||||
@@ -690,6 +695,7 @@ module DataFlow {
|
||||
|
||||
override EssaVariable asVariable() { this = TEssaNode(result) }
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
override string toString() { result = this.asVariable().toString() }
|
||||
|
||||
override Scope getScope() { result = this.asVariable().getScope() }
|
||||
|
||||
@@ -29,6 +29,7 @@ abstract class SsaSourceVariable extends @py_variable {
|
||||
|
||||
abstract ControlFlowNode getScopeEntryDefinition();
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = "SsaSourceVariable " + this.getName() }
|
||||
|
||||
/** Gets a use of this variable, either explicit or implicit. */
|
||||
|
||||
@@ -24,6 +24,7 @@ class EssaVariable extends TEssaDefinition {
|
||||
/** Gets the name of this variable. */
|
||||
string getName() { result = this.getSourceVariable().getName() }
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = "SSA variable " + this.getName() }
|
||||
|
||||
/**
|
||||
@@ -131,6 +132,7 @@ private newtype TEssaDefinition =
|
||||
* and exactly one variable for each definition.
|
||||
*/
|
||||
abstract class EssaDefinition extends TEssaDefinition {
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = "EssaDefinition" }
|
||||
|
||||
/** Gets the source variable for which this a definition, either explicit or implicit. */
|
||||
|
||||
@@ -36,6 +36,7 @@ class Value extends TObject {
|
||||
this != ObjectInternal::undefined()
|
||||
}
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = this.(ObjectInternal).toString() }
|
||||
|
||||
/** Gets a `ControlFlowNode` that refers to this object. */
|
||||
@@ -895,6 +896,7 @@ class PropertyValue extends Value {
|
||||
|
||||
/** A method-resolution-order sequence of classes */
|
||||
class MRO extends TClassList {
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = this.(ClassList).toString() }
|
||||
|
||||
/** Gets the `n`th class in this MRO */
|
||||
|
||||
@@ -17,6 +17,7 @@ import semmle.python.objects.Sequences
|
||||
import semmle.python.objects.Descriptors
|
||||
|
||||
class ObjectInternal extends TObject {
|
||||
/** Gets a textual representation of this element. */
|
||||
abstract string toString();
|
||||
|
||||
/**
|
||||
|
||||
@@ -447,6 +447,7 @@ library class ClassDecl extends @py_object {
|
||||
this.(ControlFlowNode).getNode() instanceof ClassExpr
|
||||
}
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = "ClassDecl" }
|
||||
|
||||
/** Gets the class scope for Python class declarations */
|
||||
|
||||
@@ -195,6 +195,7 @@ private newtype TIterationDefinition =
|
||||
* A definition of a variable in a for loop `for v in ...:`
|
||||
*/
|
||||
deprecated class IterationDefinition extends TIterationDefinition {
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = "IterationDefinition" }
|
||||
|
||||
ControlFlowNode getSequence() { this = TIterationDefinition_(_, _, result) }
|
||||
|
||||
@@ -28,6 +28,7 @@ private newtype TTInvocation =
|
||||
* all calls made to a function for a given context.
|
||||
*/
|
||||
class FunctionInvocation extends TTInvocation {
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = "Invocation" }
|
||||
|
||||
FunctionObject getFunction() { this = TInvocation(result, _) }
|
||||
|
||||
@@ -68,6 +68,7 @@ private ClassObjectInternal sole_base(ClassObjectInternal cls) {
|
||||
|
||||
/** A list of classes, used to represent the MRO of a class */
|
||||
class ClassList extends TClassList {
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = "[" + this.contents() + "]" }
|
||||
|
||||
string contents() {
|
||||
@@ -243,6 +244,7 @@ private predicate required_list(ClassList head, ClassListList tail) {
|
||||
}
|
||||
|
||||
private class ClassListList extends TClassListList {
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = "[" + this.contents() + "]" }
|
||||
|
||||
string contents() {
|
||||
|
||||
@@ -9,6 +9,7 @@ private import semmle.python.types.Extensions
|
||||
|
||||
/* Use this version for speed */
|
||||
library class CfgOrigin extends @py_object {
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() {
|
||||
/* Not to be displayed */
|
||||
result = "CfgOrigin"
|
||||
|
||||
@@ -129,6 +129,7 @@ module Context {
|
||||
* * All other contexts are call contexts and consist of a pair of call-site and caller context.
|
||||
*/
|
||||
class PointsToContext extends TPointsToContext {
|
||||
/** Gets a textual representation of this element. */
|
||||
cached
|
||||
string toString() {
|
||||
this = TMainContext() and result = "main"
|
||||
|
||||
@@ -17,6 +17,7 @@ class Builtin extends @py_cobject {
|
||||
)
|
||||
}
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() {
|
||||
not this = undefinedVariable().asBuiltin() and
|
||||
not this = Builtin::unknown() and
|
||||
|
||||
@@ -86,6 +86,7 @@ class Object extends @py_object {
|
||||
/** INTERNAL -- Do not use */
|
||||
Builtin asBuiltin() { result = this }
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() {
|
||||
not this = undefinedVariable() and
|
||||
not this = unknownValue() and
|
||||
|
||||
@@ -63,6 +63,7 @@ class UntrustedCookie extends TaintKind {
|
||||
}
|
||||
|
||||
abstract class CookieOperation extends @py_flow_node {
|
||||
/** Gets a textual representation of this element. */
|
||||
abstract string toString();
|
||||
|
||||
abstract ControlFlowNode getKey();
|
||||
|
||||
Reference in New Issue
Block a user