diff --git a/cpp/ql/lib/semmle/code/cpp/Print.qll b/cpp/ql/lib/semmle/code/cpp/Print.qll index 64ae5b960d1..5df8f087689 100644 --- a/cpp/ql/lib/semmle/code/cpp/Print.qll +++ b/cpp/ql/lib/semmle/code/cpp/Print.qll @@ -8,9 +8,9 @@ private import PrintAST private predicate shouldPrintDeclaration(Declaration decl) { not decl instanceof Function or - not exists(PrintASTConfiguration c) + not exists(PrintAstConfiguration c) or - exists(PrintASTConfiguration config | config.shouldPrintFunction(decl)) + exists(PrintAstConfiguration config | config.shouldPrintFunction(decl)) } /** diff --git a/cpp/ql/lib/semmle/code/cpp/PrintAST.ql b/cpp/ql/lib/semmle/code/cpp/PrintAST.ql index e4c53030da5..bf7e345132c 100644 --- a/cpp/ql/lib/semmle/code/cpp/PrintAST.ql +++ b/cpp/ql/lib/semmle/code/cpp/PrintAST.ql @@ -12,7 +12,7 @@ import PrintAST * Temporarily tweak this class or make a copy to control which functions are * printed. */ -class Cfg extends PrintASTConfiguration { +class Cfg extends PrintAstConfiguration { /** * TWEAK THIS PREDICATE AS NEEDED. * Holds if the AST for `func` should be printed. diff --git a/cpp/ql/lib/semmle/code/cpp/PrintAST.qll b/cpp/ql/lib/semmle/code/cpp/PrintAST.qll index 86b39a285b0..7658d5cf17a 100644 --- a/cpp/ql/lib/semmle/code/cpp/PrintAST.qll +++ b/cpp/ql/lib/semmle/code/cpp/PrintAST.qll @@ -9,12 +9,12 @@ import cpp private import semmle.code.cpp.Print -private newtype TPrintASTConfiguration = MkPrintASTConfiguration() +private newtype TPrintAstConfiguration = MkPrintAstConfiguration() /** * The query can extend this class to control which functions are printed. */ -class PrintASTConfiguration extends TPrintASTConfiguration { +class PrintAstConfiguration extends TPrintAstConfiguration { /** * Gets a textual representation of this `PrintASTConfiguration`. */ @@ -27,8 +27,11 @@ class PrintASTConfiguration extends TPrintASTConfiguration { predicate shouldPrintFunction(Function func) { any() } } +/** DEPRECATED: Alias for PrintAstConfiguration */ +deprecated class PrintASTConfiguration = PrintAstConfiguration; + private predicate shouldPrintFunction(Function func) { - exists(PrintASTConfiguration config | config.shouldPrintFunction(func)) + exists(PrintAstConfiguration config | config.shouldPrintFunction(func)) } bindingset[s] @@ -85,8 +88,8 @@ private Function getEnclosingFunction(Locatable ast) { * Most nodes are just a wrapper around `Locatable`, but we do synthesize new * nodes for things like parameter lists and constructor init lists. */ -private newtype TPrintASTNode = - TASTNode(Locatable ast) { shouldPrintFunction(getEnclosingFunction(ast)) } or +private newtype TPrintAstNode = + TAstNode(Locatable ast) { shouldPrintFunction(getEnclosingFunction(ast)) } or TDeclarationEntryNode(DeclStmt stmt, DeclarationEntry entry) { // We create a unique node for each pair of (stmt, entry), to avoid having one node with // multiple parents due to extractor bug CPP-413. @@ -106,7 +109,7 @@ private newtype TPrintASTNode = /** * A node in the output tree. */ -class PrintASTNode extends TPrintASTNode { +class PrintAstNode extends TPrintAstNode { /** * Gets a textual representation of this node in the PrintAST output tree. */ @@ -116,17 +119,17 @@ class PrintASTNode extends TPrintASTNode { * Gets the child node at index `childIndex`. Child indices must be unique, * but need not be contiguous. */ - abstract PrintASTNode getChildInternal(int childIndex); + abstract PrintAstNode getChildInternal(int childIndex); /** * Gets the child node at index `childIndex`. * Adds edges to fully converted expressions, that are not part of the * regular parent/child relation traversal. */ - final PrintASTNode getChild(int childIndex) { + final PrintAstNode getChild(int childIndex) { // The exact value of `childIndex` doesn't matter, as long as we preserve the correct order. result = - rank[childIndex](PrintASTNode child, int nonConvertedIndex, boolean isConverted | + rank[childIndex](PrintAstNode child, int nonConvertedIndex, boolean isConverted | childAndAccessorPredicate(child, _, nonConvertedIndex, isConverted) | // Unconverted children come first, then sort by original child index within each group. @@ -138,11 +141,11 @@ class PrintASTNode extends TPrintASTNode { * Gets the node for the `.getFullyConverted()` version of the child originally at index * `childIndex`, if that node has any conversions. */ - private PrintASTNode getConvertedChild(int childIndex) { + private PrintAstNode getConvertedChild(int childIndex) { exists(Expr expr | - expr = getChildInternal(childIndex).(ASTNode).getAST() and + expr = getChildInternal(childIndex).(AstNode).getAst() and expr.getFullyConverted() instanceof Conversion and - result.(ASTNode).getAST() = expr.getFullyConverted() and + result.(AstNode).getAst() = expr.getFullyConverted() and not expr instanceof Conversion ) } @@ -166,12 +169,12 @@ class PrintASTNode extends TPrintASTNode { /** * Gets the children of this node. */ - final PrintASTNode getAChild() { result = getChild(_) } + final PrintAstNode getAChild() { result = getChild(_) } /** * Gets the parent of this node, if any. */ - final PrintASTNode getParent() { result.getAChild() = this } + final PrintAstNode getParent() { result.getAChild() = this } /** * Gets the location of this node in the source code. @@ -196,7 +199,7 @@ class PrintASTNode extends TPrintASTNode { * one result tuple, with `isConverted = false`. */ private predicate childAndAccessorPredicate( - PrintASTNode child, string childPredicate, int nonConvertedIndex, boolean isConverted + PrintAstNode child, string childPredicate, int nonConvertedIndex, boolean isConverted ) { child = getChildInternal(nonConvertedIndex) and childPredicate = getChildAccessorPredicateInternal(nonConvertedIndex) and @@ -234,12 +237,15 @@ class PrintASTNode extends TPrintASTNode { private Function getEnclosingFunction() { result = getParent*().(FunctionNode).getFunction() } } +/** DEPRECATED: Alias for PrintAstNode */ +deprecated class PrintASTNode = PrintAstNode; + /** * Class that restricts the elements that we compute `qlClass` for. */ private class PrintableElement extends Element { PrintableElement() { - exists(TASTNode(this)) + exists(TAstNode(this)) or exists(TDeclarationEntryNode(_, this)) or @@ -262,7 +268,7 @@ private string qlClass(PrintableElement el) { /** * A node representing an AST node. */ -abstract class BaseASTNode extends PrintASTNode { +abstract class BaseAstNode extends PrintAstNode { Locatable ast; override string toString() { result = qlClass(ast) + ast.toString() } @@ -272,25 +278,34 @@ abstract class BaseASTNode extends PrintASTNode { /** * Gets the AST represented by this node. */ - final Locatable getAST() { result = ast } + final Locatable getAst() { result = ast } + + /** DEPRECATED: Alias for getAst */ + deprecated Locatable getAST() { result = getAst() } } +/** DEPRECATED: Alias for BaseAstNode */ +deprecated class BaseASTNode = BaseAstNode; + /** * A node representing an AST node other than a `DeclarationEntry`. */ -abstract class ASTNode extends BaseASTNode, TASTNode { - ASTNode() { this = TASTNode(ast) } +abstract class AstNode extends BaseAstNode, TAstNode { + AstNode() { this = TAstNode(ast) } } +/** DEPRECATED: Alias for AstNode */ +deprecated class ASTNode = AstNode; + /** * A node representing an `Expr`. */ -class ExprNode extends ASTNode { +class ExprNode extends AstNode { Expr expr; ExprNode() { expr = ast } - override ASTNode getChildInternal(int childIndex) { result.getAST() = expr.getChild(childIndex) } + override AstNode getChildInternal(int childIndex) { result.getAst() = expr.getChild(childIndex) } override string getProperty(string key) { result = super.getProperty(key) @@ -306,7 +321,7 @@ class ExprNode extends ASTNode { } override string getChildAccessorPredicateInternal(int childIndex) { - result = getChildAccessorWithoutConversions(ast, getChildInternal(childIndex).getAST()) + result = getChildAccessorWithoutConversions(ast, getChildInternal(childIndex).getAst()) } /** @@ -334,9 +349,9 @@ class ConversionNode extends ExprNode { ConversionNode() { conv = expr } - override ASTNode getChildInternal(int childIndex) { + override AstNode getChildInternal(int childIndex) { childIndex = 0 and - result.getAST() = conv.getExpr() and + result.getAst() = conv.getExpr() and conv.getExpr() instanceof Conversion } } @@ -363,27 +378,27 @@ class CastNode extends ConversionNode { class StmtExprNode extends ExprNode { override StmtExpr expr; - override ASTNode getChildInternal(int childIndex) { + override AstNode getChildInternal(int childIndex) { childIndex = 0 and - result.getAST() = expr.getStmt() + result.getAst() = expr.getStmt() } } /** * A node representing a `DeclarationEntry`. */ -class DeclarationEntryNode extends BaseASTNode, TDeclarationEntryNode { +class DeclarationEntryNode extends BaseAstNode, TDeclarationEntryNode { override DeclarationEntry ast; DeclStmt declStmt; DeclarationEntryNode() { this = TDeclarationEntryNode(declStmt, ast) } - override PrintASTNode getChildInternal(int childIndex) { none() } + override PrintAstNode getChildInternal(int childIndex) { none() } override string getChildAccessorPredicateInternal(int childIndex) { none() } override string getProperty(string key) { - result = BaseASTNode.super.getProperty(key) + result = BaseAstNode.super.getProperty(key) or key = "Type" and result = qlClass(ast.getType()) + ast.getType().toString() @@ -396,9 +411,9 @@ class DeclarationEntryNode extends BaseASTNode, TDeclarationEntryNode { class VariableDeclarationEntryNode extends DeclarationEntryNode { override VariableDeclarationEntry ast; - override ASTNode getChildInternal(int childIndex) { + override AstNode getChildInternal(int childIndex) { childIndex = 0 and - result.getAST() = ast.getVariable().getInitializer() + result.getAst() = ast.getVariable().getInitializer() } override string getChildAccessorPredicateInternal(int childIndex) { @@ -410,23 +425,23 @@ class VariableDeclarationEntryNode extends DeclarationEntryNode { /** * A node representing a `Stmt`. */ -class StmtNode extends ASTNode { +class StmtNode extends AstNode { Stmt stmt; StmtNode() { stmt = ast } - override BaseASTNode getChildInternal(int childIndex) { + override BaseAstNode getChildInternal(int childIndex) { exists(Locatable child | child = stmt.getChild(childIndex) and ( - result.getAST() = child.(Expr) or - result.getAST() = child.(Stmt) + result.getAst() = child.(Expr) or + result.getAst() = child.(Stmt) ) ) } override string getChildAccessorPredicateInternal(int childIndex) { - result = getChildAccessorWithoutConversions(ast, getChildInternal(childIndex).getAST()) + result = getChildAccessorWithoutConversions(ast, getChildInternal(childIndex).getAst()) } } @@ -449,12 +464,12 @@ class DeclStmtNode extends StmtNode { /** * A node representing a `Parameter`. */ -class ParameterNode extends ASTNode { +class ParameterNode extends AstNode { Parameter param; ParameterNode() { param = ast } - final override PrintASTNode getChildInternal(int childIndex) { none() } + final override PrintAstNode getChildInternal(int childIndex) { none() } final override string getChildAccessorPredicateInternal(int childIndex) { none() } @@ -469,14 +484,14 @@ class ParameterNode extends ASTNode { /** * A node representing an `Initializer`. */ -class InitializerNode extends ASTNode { +class InitializerNode extends AstNode { Initializer init; InitializerNode() { init = ast } - override ASTNode getChildInternal(int childIndex) { + override AstNode getChildInternal(int childIndex) { childIndex = 0 and - result.getAST() = init.getExpr() + result.getAst() = init.getExpr() } override string getChildAccessorPredicateInternal(int childIndex) { @@ -488,7 +503,7 @@ class InitializerNode extends ASTNode { /** * A node representing the parameters of a `Function`. */ -class ParametersNode extends PrintASTNode, TParametersNode { +class ParametersNode extends PrintAstNode, TParametersNode { Function func; ParametersNode() { this = TParametersNode(func) } @@ -497,8 +512,8 @@ class ParametersNode extends PrintASTNode, TParametersNode { final override Location getLocation() { result = getRepresentativeLocation(func) } - override ASTNode getChildInternal(int childIndex) { - result.getAST() = func.getParameter(childIndex) + override AstNode getChildInternal(int childIndex) { + result.getAst() = func.getParameter(childIndex) } override string getChildAccessorPredicateInternal(int childIndex) { @@ -515,7 +530,7 @@ class ParametersNode extends PrintASTNode, TParametersNode { /** * A node representing the initializer list of a `Constructor`. */ -class ConstructorInitializersNode extends PrintASTNode, TConstructorInitializersNode { +class ConstructorInitializersNode extends PrintAstNode, TConstructorInitializersNode { Constructor ctor; ConstructorInitializersNode() { this = TConstructorInitializersNode(ctor) } @@ -524,8 +539,8 @@ class ConstructorInitializersNode extends PrintASTNode, TConstructorInitializers final override Location getLocation() { result = getRepresentativeLocation(ctor) } - final override ASTNode getChildInternal(int childIndex) { - result.getAST() = ctor.getInitializer(childIndex) + final override AstNode getChildInternal(int childIndex) { + result.getAst() = ctor.getInitializer(childIndex) } final override string getChildAccessorPredicateInternal(int childIndex) { @@ -542,7 +557,7 @@ class ConstructorInitializersNode extends PrintASTNode, TConstructorInitializers /** * A node representing the destruction list of a `Destructor`. */ -class DestructorDestructionsNode extends PrintASTNode, TDestructorDestructionsNode { +class DestructorDestructionsNode extends PrintAstNode, TDestructorDestructionsNode { Destructor dtor; DestructorDestructionsNode() { this = TDestructorDestructionsNode(dtor) } @@ -551,8 +566,8 @@ class DestructorDestructionsNode extends PrintASTNode, TDestructorDestructionsNo final override Location getLocation() { result = getRepresentativeLocation(dtor) } - final override ASTNode getChildInternal(int childIndex) { - result.getAST() = dtor.getDestruction(childIndex) + final override AstNode getChildInternal(int childIndex) { + result.getAst() = dtor.getDestruction(childIndex) } final override string getChildAccessorPredicateInternal(int childIndex) { @@ -569,14 +584,14 @@ class DestructorDestructionsNode extends PrintASTNode, TDestructorDestructionsNo /** * A node representing a `Function`. */ -class FunctionNode extends ASTNode { +class FunctionNode extends AstNode { Function func; FunctionNode() { func = ast } override string toString() { result = qlClass(func) + getIdentityString(func) } - override PrintASTNode getChildInternal(int childIndex) { + override PrintAstNode getChildInternal(int childIndex) { childIndex = 0 and result.(ParametersNode).getFunction() = func or @@ -584,7 +599,7 @@ class FunctionNode extends ASTNode { result.(ConstructorInitializersNode).getConstructor() = func or childIndex = 2 and - result.(ASTNode).getAST() = func.getEntryPoint() + result.(AstNode).getAst() = func.getEntryPoint() or childIndex = 3 and result.(DestructorDestructionsNode).getDestructor() = func @@ -603,7 +618,7 @@ class FunctionNode extends ASTNode { private int getOrder() { this = rank[result](FunctionNode node, Function function, string file, int line, int column | - node.getAST() = function and + node.getAst() = function and locationSortKeys(function, file, line, column) | node order by file, line, column, getIdentityString(function) @@ -856,7 +871,7 @@ private predicate namedExprChildPredicates(Expr expr, Element ele, string pred) } /** Holds if `node` belongs to the output tree, and its property `key` has the given `value`. */ -query predicate nodes(PrintASTNode node, string key, string value) { +query predicate nodes(PrintAstNode node, string key, string value) { node.shouldPrint() and value = node.getProperty(key) } @@ -865,7 +880,7 @@ query predicate nodes(PrintASTNode node, string key, string value) { * Holds if `target` is a child of `source` in the AST, and property `key` of the edge has the * given `value`. */ -query predicate edges(PrintASTNode source, PrintASTNode target, string key, string value) { +query predicate edges(PrintAstNode source, PrintAstNode target, string key, string value) { exists(int childIndex | source.shouldPrint() and target.shouldPrint() and diff --git a/cpp/ql/lib/semmle/code/cpp/XML.qll b/cpp/ql/lib/semmle/code/cpp/XML.qll index d2e6c44951f..fb781a4683f 100755 --- a/cpp/ql/lib/semmle/code/cpp/XML.qll +++ b/cpp/ql/lib/semmle/code/cpp/XML.qll @@ -4,11 +4,11 @@ import semmle.files.FileSystem -private class TXMLLocatable = +private class TXmlLocatable = @xmldtd or @xmlelement or @xmlattribute or @xmlnamespace or @xmlcomment or @xmlcharacters; /** An XML element that has a location. */ -class XMLLocatable extends @xmllocatable, TXMLLocatable { +class XMLLocatable extends @xmllocatable, TXmlLocatable { /** Gets the source location for this element. */ Location getLocation() { xmllocations(this, result) } diff --git a/cpp/ql/lib/semmle/code/cpp/controlflow/ControlFlowGraph.qll b/cpp/ql/lib/semmle/code/cpp/controlflow/ControlFlowGraph.qll index f0903db7082..846d8047982 100644 --- a/cpp/ql/lib/semmle/code/cpp/controlflow/ControlFlowGraph.qll +++ b/cpp/ql/lib/semmle/code/cpp/controlflow/ControlFlowGraph.qll @@ -65,7 +65,7 @@ class ControlFlowNode extends Locatable, ControlFlowNodeBase { * taken when this expression is true. */ ControlFlowNode getATrueSuccessor() { - qlCFGTrueSuccessor(this, result) and + qlCfgTrueSuccessor(this, result) and result = this.getASuccessor() } @@ -74,7 +74,7 @@ class ControlFlowNode extends Locatable, ControlFlowNodeBase { * taken when this expression is false. */ ControlFlowNode getAFalseSuccessor() { - qlCFGFalseSuccessor(this, result) and + qlCfgFalseSuccessor(this, result) and result = this.getASuccessor() } @@ -121,7 +121,7 @@ abstract class AdditionalControlFlowEdge extends ControlFlowNodeBase { * `AdditionalControlFlowEdge`. Use this relation instead of `qlCFGSuccessor`. */ predicate successors_extended(ControlFlowNodeBase source, ControlFlowNodeBase target) { - qlCFGSuccessor(source, target) + qlCfgSuccessor(source, target) or source.(AdditionalControlFlowEdge).getAnEdgeTarget() = target } diff --git a/cpp/ql/lib/semmle/code/cpp/controlflow/IRGuards.qll b/cpp/ql/lib/semmle/code/cpp/controlflow/IRGuards.qll index 2b222376a0b..d12eaa4e238 100644 --- a/cpp/ql/lib/semmle/code/cpp/controlflow/IRGuards.qll +++ b/cpp/ql/lib/semmle/code/cpp/controlflow/IRGuards.qll @@ -33,8 +33,8 @@ class GuardCondition extends Expr { or // the IR short-circuits if(!x) // don't produce a guard condition for `y = !x` and other non-short-circuited cases - not exists(Instruction inst | this.getFullyConverted() = inst.getAST()) and - exists(IRGuardCondition ir | this.(NotExpr).getOperand() = ir.getAST()) + not exists(Instruction inst | this.getFullyConverted() = inst.getAst()) and + exists(IRGuardCondition ir | this.(NotExpr).getOperand() = ir.getAst()) } /** @@ -146,8 +146,8 @@ private class GuardConditionFromBinaryLogicalOperator extends GuardCondition { */ private class GuardConditionFromShortCircuitNot extends GuardCondition, NotExpr { GuardConditionFromShortCircuitNot() { - not exists(Instruction inst | this.getFullyConverted() = inst.getAST()) and - exists(IRGuardCondition ir | this.getOperand() = ir.getAST()) + not exists(Instruction inst | this.getFullyConverted() = inst.getAst()) and + exists(IRGuardCondition ir | this.getOperand() = ir.getAst()) } override predicate controls(BasicBlock controlled, boolean testIsTrue) { @@ -241,7 +241,7 @@ private class GuardConditionFromIR extends GuardCondition { private predicate controlsBlock(BasicBlock controlled, boolean testIsTrue) { exists(IRBlock irb | forex(IRGuardCondition inst | inst = ir | inst.controls(irb, testIsTrue)) and - irb.getAnInstruction().getAST().(ControlFlowNode).getBasicBlock() = controlled and + irb.getAnInstruction().getAst().(ControlFlowNode).getBasicBlock() = controlled and not isUnreachedBlock(irb) ) } diff --git a/cpp/ql/lib/semmle/code/cpp/controlflow/SSA.qll b/cpp/ql/lib/semmle/code/cpp/controlflow/SSA.qll index 097087a8778..4732cd06184 100644 --- a/cpp/ql/lib/semmle/code/cpp/controlflow/SSA.qll +++ b/cpp/ql/lib/semmle/code/cpp/controlflow/SSA.qll @@ -10,10 +10,13 @@ import SSAUtils * The SSA logic comes in two versions: the standard SSA and range-analysis RangeSSA. * This class provides the standard SSA logic. */ -library class StandardSSA extends SSAHelper { - StandardSSA() { this = 0 } +library class StandardSsa extends SsaHelper { + StandardSsa() { this = 0 } } +/** DEPRECATED: Alias for StandardSsa */ +deprecated class StandardSSA = StandardSsa; + /** * A definition of one or more SSA variables, including phi node definitions. * An _SSA variable_, as defined in the literature, is effectively the pair of @@ -27,22 +30,22 @@ library class StandardSSA extends SSAHelper { * statically seen to be unreachable. */ class SsaDefinition extends ControlFlowNodeBase { - SsaDefinition() { exists(StandardSSA x | x.ssa_defn(_, this, _, _)) } + SsaDefinition() { exists(StandardSsa x | x.ssa_defn(_, this, _, _)) } /** * Gets a variable corresponding to an SSA StackVariable defined by * this definition. */ - StackVariable getAVariable() { exists(StandardSSA x | x.ssa_defn(result, this, _, _)) } + StackVariable getAVariable() { exists(StandardSsa x | x.ssa_defn(result, this, _, _)) } /** * Gets a string representation of the SSA variable represented by the pair * `(this, v)`. */ - string toString(StackVariable v) { exists(StandardSSA x | result = x.toString(this, v)) } + string toString(StackVariable v) { exists(StandardSsa x | result = x.toString(this, v)) } /** Gets a use of the SSA variable represented by the pair `(this, v)`. */ - VariableAccess getAUse(StackVariable v) { exists(StandardSSA x | result = x.getAUse(this, v)) } + VariableAccess getAUse(StackVariable v) { exists(StandardSsa x | result = x.getAUse(this, v)) } /** * Gets the control-flow node for this definition. This will usually be the @@ -62,7 +65,7 @@ class SsaDefinition extends ControlFlowNodeBase { BasicBlock getBasicBlock() { result.contains(this.getDefinition()) } /** Holds if this definition is a phi node for variable `v`. */ - predicate isPhiNode(StackVariable v) { exists(StandardSSA x | x.phi_node(v, this)) } + predicate isPhiNode(StackVariable v) { exists(StandardSsa x | x.phi_node(v, this)) } /** Gets the location of this definition. */ Location getLocation() { result = this.(ControlFlowNode).getLocation() } @@ -124,7 +127,7 @@ class SsaDefinition extends ControlFlowNodeBase { /** Holds if `(this, v)` reaches the end of basic block `b`. */ predicate reachesEndOfBB(StackVariable v, BasicBlock b) { - exists(StandardSSA x | x.ssaDefinitionReachesEndOfBB(v, this, b)) + exists(StandardSsa x | x.ssaDefinitionReachesEndOfBB(v, this, b)) } /** diff --git a/cpp/ql/lib/semmle/code/cpp/controlflow/SSAUtils.qll b/cpp/ql/lib/semmle/code/cpp/controlflow/SSAUtils.qll index b7d0742fac6..2252864c249 100644 --- a/cpp/ql/lib/semmle/code/cpp/controlflow/SSAUtils.qll +++ b/cpp/ql/lib/semmle/code/cpp/controlflow/SSAUtils.qll @@ -114,10 +114,10 @@ private predicate live_at_exit_of_bb(StackVariable v, BasicBlock b) { /** Common SSA logic for standard SSA and range-analysis SSA. */ cached -library class SSAHelper extends int { +library class SsaHelper extends int { /* 0 = StandardSSA, 1 = RangeSSA */ cached - SSAHelper() { this in [0 .. 1] } + SsaHelper() { this in [0 .. 1] } /** * Override to insert a custom phi node for variable `v` at the start of @@ -311,3 +311,6 @@ library class SSAHelper extends int { ssa_use(v, result, _, _) } } + +/** DEPRECATED: Alias for SsaHelper */ +deprecated class SSAHelper = SsaHelper; diff --git a/cpp/ql/lib/semmle/code/cpp/controlflow/internal/CFG.qll b/cpp/ql/lib/semmle/code/cpp/controlflow/internal/CFG.qll index ca1964a43c3..6ec802cf281 100644 --- a/cpp/ql/lib/semmle/code/cpp/controlflow/internal/CFG.qll +++ b/cpp/ql/lib/semmle/code/cpp/controlflow/internal/CFG.qll @@ -1379,7 +1379,7 @@ private module Cached { * true-successors and false-successors. */ cached - predicate qlCFGSuccessor(Node n1, Node n2) { + predicate qlCfgSuccessor(Node n1, Node n2) { exists(Node memberNode, Pos memberPos | subEdgeIncludingDestructors(any(Pos at | at.isAt()), n1, memberNode, memberPos) and normalGroupMember(memberNode, memberPos, n2) @@ -1388,23 +1388,32 @@ private module Cached { conditionalSuccessor(n1, _, n2) } + /** DEPRECATED: Alias for qlCfgSuccessor */ + deprecated predicate qlCFGSuccessor = qlCfgSuccessor/2; + /** * Holds if `n2` is a control-flow node such that the control-flow * edge `(n1, n2)` may be taken when `n1` is an expression that is true. */ cached - predicate qlCFGTrueSuccessor(Node n1, Node n2) { + predicate qlCfgTrueSuccessor(Node n1, Node n2) { conditionalSuccessor(n1, true, n2) and not conditionalSuccessor(n1, false, n2) } + /** DEPRECATED: Alias for qlCfgTrueSuccessor */ + deprecated predicate qlCFGTrueSuccessor = qlCfgTrueSuccessor/2; + /** * Holds if `n2` is a control-flow node such that the control-flow * edge `(n1, n2)` may be taken when `n1` is an expression that is false. */ cached - predicate qlCFGFalseSuccessor(Node n1, Node n2) { + predicate qlCfgFalseSuccessor(Node n1, Node n2) { conditionalSuccessor(n1, false, n2) and not conditionalSuccessor(n1, true, n2) } + + /** DEPRECATED: Alias for qlCfgFalseSuccessor */ + deprecated predicate qlCFGFalseSuccessor = qlCfgFalseSuccessor/2; } diff --git a/cpp/ql/lib/semmle/code/cpp/controlflow/internal/ConstantExprs.qll b/cpp/ql/lib/semmle/code/cpp/controlflow/internal/ConstantExprs.qll index a561771fe01..923533ee2fd 100644 --- a/cpp/ql/lib/semmle/code/cpp/controlflow/internal/ConstantExprs.qll +++ b/cpp/ql/lib/semmle/code/cpp/controlflow/internal/ConstantExprs.qll @@ -188,8 +188,8 @@ private predicate nonAnalyzableFunction(Function f) { */ private predicate impossibleFalseEdge(Expr condition, Node succ) { conditionAlwaysTrue(condition) and - qlCFGFalseSuccessor(condition, succ) and - not qlCFGTrueSuccessor(condition, succ) + qlCfgFalseSuccessor(condition, succ) and + not qlCfgTrueSuccessor(condition, succ) } /** @@ -197,8 +197,8 @@ private predicate impossibleFalseEdge(Expr condition, Node succ) { */ private predicate impossibleTrueEdge(Expr condition, Node succ) { conditionAlwaysFalse(condition) and - qlCFGTrueSuccessor(condition, succ) and - not qlCFGFalseSuccessor(condition, succ) + qlCfgTrueSuccessor(condition, succ) and + not qlCfgFalseSuccessor(condition, succ) } /** @@ -960,9 +960,9 @@ library class ConditionEvaluator extends ExprEvaluator { ConditionEvaluator() { this = 0 } override predicate interesting(Expr e) { - qlCFGFalseSuccessor(e, _) + qlCfgFalseSuccessor(e, _) or - qlCFGTrueSuccessor(e, _) + qlCfgTrueSuccessor(e, _) } } diff --git a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/DefaultTaintTracking.qll b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/DefaultTaintTracking.qll index c6942b7adfe..be5403734ce 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/DefaultTaintTracking.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/DefaultTaintTracking.qll @@ -129,11 +129,11 @@ private class FromGlobalVarTaintTrackingCfg extends TaintTracking2::Configuratio } private predicate readsVariable(LoadInstruction load, Variable var) { - load.getSourceAddress().(VariableAddressInstruction).getASTVariable() = var + load.getSourceAddress().(VariableAddressInstruction).getAstVariable() = var } private predicate writesVariable(StoreInstruction store, Variable var) { - store.getDestinationAddress().(VariableAddressInstruction).getASTVariable() = var + store.getDestinationAddress().(VariableAddressInstruction).getAstVariable() = var } /** @@ -489,9 +489,9 @@ module TaintedWithPath { /** Gets the element that `pathNode` wraps, if any. */ Element getElementFromPathNode(PathNode pathNode) { exists(DataFlow::Node node | node = pathNode.(WrapPathNode).inner().getNode() | - result = node.asInstruction().getAST() + result = node.asInstruction().getAst() or - result = node.asOperand().getDef().getAST() + result = node.asOperand().getDef().getAst() ) or result = pathNode.(EndpointPathNode).inner() diff --git a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/ResolveCall.qll b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/ResolveCall.qll index f25386d3ba8..bcf2fa8c7db 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/ResolveCall.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/ResolveCall.qll @@ -17,7 +17,7 @@ private import semmle.code.cpp.ir.IR */ Function resolveCall(Call call) { exists(CallInstruction callInstruction | - callInstruction.getAST() = call and + callInstruction.getAst() = call and result = viableCallable(callInstruction) ) } diff --git a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowDispatch.qll b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowDispatch.qll index 509ee01ec07..c0bdb656e0e 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowDispatch.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowDispatch.qll @@ -116,12 +116,12 @@ private module VirtualDispatch { /** Holds if `addressInstr` is an instruction that produces the address of `var`. */ private predicate addressOfGlobal(Instruction addressInstr, GlobalOrNamespaceVariable var) { // Access directly to the global variable - addressInstr.(VariableAddressInstruction).getASTVariable() = var + addressInstr.(VariableAddressInstruction).getAstVariable() = var or // Access to a field on a global union exists(FieldAddressInstruction fa | fa = addressInstr and - fa.getObjectAddress().(VariableAddressInstruction).getASTVariable() = var and + fa.getObjectAddress().(VariableAddressInstruction).getAstVariable() = var and fa.getField().getDeclaringType() instanceof Union ) } diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/IRVariable.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/IRVariable.qll index 146fc270738..ca4708857a7 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/IRVariable.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/IRVariable.qll @@ -55,7 +55,10 @@ class IRVariable extends TIRVariable { * Gets the AST node that declared this variable, or that introduced this * variable as part of the AST-to-IR translation. */ - Language::AST getAST() { none() } + Language::AST getAst() { none() } + + /** DEPRECATED: Alias for getAst */ + deprecated Language::AST getAST() { result = getAst() } /** * Gets an identifier string for the variable. This identifier is unique @@ -66,7 +69,7 @@ class IRVariable extends TIRVariable { /** * Gets the source location of this variable. */ - final Language::Location getLocation() { result = getAST().getLocation() } + final Language::Location getLocation() { result = getAst().getLocation() } /** * Gets the IR for the function that references this variable. @@ -90,7 +93,10 @@ class IRUserVariable extends IRVariable, TIRUserVariable { final override string toString() { result = getVariable().toString() } - final override Language::AST getAST() { result = var } + final override Language::AST getAst() { result = var } + + /** DEPRECATED: Alias for getAst */ + deprecated override Language::AST getAST() { result = getAst() } final override string getUniqueId() { result = getVariable().toString() + " " + getVariable().getLocation().toString() @@ -157,7 +163,10 @@ class IRGeneratedVariable extends IRVariable { final override Language::LanguageType getLanguageType() { result = type } - final override Language::AST getAST() { result = ast } + final override Language::AST getAst() { result = ast } + + /** DEPRECATED: Alias for getAst */ + deprecated override Language::AST getAST() { result = getAst() } override string toString() { result = getBaseString() + getLocationString() } diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll index 1c2cc493338..4dac3087f83 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll @@ -41,7 +41,7 @@ class Instruction extends Construction::TStageInstruction { } /** Gets a textual representation of this element. */ - final string toString() { result = this.getOpcode().toString() + ": " + this.getAST().toString() } + final string toString() { result = this.getOpcode().toString() + ": " + this.getAst().toString() } /** * Gets a string showing the result, opcode, and operands of the instruction, equivalent to what @@ -136,7 +136,7 @@ class Instruction extends Construction::TStageInstruction { string getResultId() { this.shouldGenerateDumpStrings() and result = - this.getResultPrefix() + this.getAST().getLocation().getStartLine() + "_" + this.getLineRank() + this.getResultPrefix() + this.getAst().getLocation().getStartLine() + "_" + this.getLineRank() } /** @@ -208,12 +208,15 @@ class Instruction extends Construction::TStageInstruction { /** * Gets the AST that caused this instruction to be generated. */ - final Language::AST getAST() { result = Construction::getInstructionAST(this) } + final Language::AST getAst() { result = Construction::getInstructionAst(this) } + + /** DEPRECATED: Alias for getAst */ + deprecated Language::AST getAST() { result = getAst() } /** * Gets the location of the source code for this instruction. */ - final Language::Location getLocation() { result = this.getAST().getLocation() } + final Language::Location getLocation() { result = this.getAst().getLocation() } /** * Gets the `Expr` whose result is computed by this instruction, if any. The `Expr` may be a @@ -459,7 +462,10 @@ class VariableInstruction extends Instruction { /** * Gets the AST variable that this instruction's IR variable refers to, if one exists. */ - final Language::Variable getASTVariable() { result = var.(IRUserVariable).getVariable() } + final Language::Variable getAstVariable() { result = var.(IRUserVariable).getVariable() } + + /** DEPRECATED: Alias for getAstVariable */ + deprecated Language::Variable getASTVariable() { result = getAstVariable() } } /** diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/Operand.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/Operand.qll index 89b82657c3b..c1e997d5844 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/Operand.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/Operand.qll @@ -18,7 +18,7 @@ private import internal.OperandInternal * of `TOperand` that are used in this stage. */ private class TStageOperand = - TRegisterOperand or TNonSSAMemoryOperand or TPhiOperand or TChiOperand; + TRegisterOperand or TNonSsaMemoryOperand or TPhiOperand or TChiOperand; /** * A known location. Testing `loc instanceof KnownLocation` will account for non existing locations, as @@ -38,7 +38,7 @@ class Operand extends TStageOperand { // Ensure that the operand does not refer to instructions from earlier stages that are unreachable here exists(Instruction use, Instruction def | this = registerOperand(use, _, def)) or - exists(Instruction use | this = nonSSAMemoryOperand(use, _)) + exists(Instruction use | this = nonSsaMemoryOperand(use, _)) or exists(Instruction use, Instruction def, IRBlock predecessorBlock | this = phiOperand(use, def, predecessorBlock, _) or @@ -209,7 +209,7 @@ class Operand extends TStageOperand { class MemoryOperand extends Operand { cached MemoryOperand() { - this instanceof TNonSSAMemoryOperand or + this instanceof TNonSsaMemoryOperand or this instanceof TPhiOperand or this instanceof TChiOperand } @@ -249,7 +249,7 @@ class NonPhiOperand extends Operand { NonPhiOperand() { this = registerOperand(useInstr, tag, _) or - this = nonSSAMemoryOperand(useInstr, tag) or + this = nonSsaMemoryOperand(useInstr, tag) or this = chiOperand(useInstr, tag) } @@ -299,7 +299,7 @@ class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand, TNonPhiMemoryOpe cached NonPhiMemoryOperand() { - this = nonSSAMemoryOperand(useInstr, tag) + this = nonSsaMemoryOperand(useInstr, tag) or this = chiOperand(useInstr, tag) } diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/gvn/internal/ValueNumberingInternal.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/gvn/internal/ValueNumberingInternal.qll index fdb645e03f0..2dc735f49df 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/gvn/internal/ValueNumberingInternal.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/gvn/internal/ValueNumberingInternal.qll @@ -99,7 +99,7 @@ private predicate filteredNumberableInstruction(Instruction instr) { // count rather than strictcount to handle missing AST elements // separate instanceof and inline casts to avoid failed casts with a count of 0 instr instanceof VariableAddressInstruction and - count(instr.(VariableAddressInstruction).getIRVariable().getAST()) != 1 + count(instr.(VariableAddressInstruction).getIRVariable().getAst()) != 1 or instr instanceof ConstantInstruction and count(instr.getResultIRType()) != 1 @@ -121,7 +121,7 @@ private predicate variableAddressValueNumber( // The underlying AST element is used as value-numbering key instead of the // `IRVariable` to work around a problem where a variable or expression with // multiple types gives rise to multiple `IRVariable`s. - unique( | | instr.getIRVariable().getAST()) = ast + unique( | | instr.getIRVariable().getAst()) = ast } private predicate initializeParameterValueNumber( @@ -131,7 +131,7 @@ private predicate initializeParameterValueNumber( // The underlying AST element is used as value-numbering key instead of the // `IRVariable` to work around a problem where a variable or expression with // multiple types gives rise to multiple `IRVariable`s. - instr.getIRVariable().getAST() = var + instr.getIRVariable().getAst() = var } private predicate constantValueNumber( diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/AliasConfiguration.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/AliasConfiguration.qll index 8ba91d70087..7e12ebc1c90 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/AliasConfiguration.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/AliasConfiguration.qll @@ -2,12 +2,12 @@ private import AliasConfigurationInternal private import semmle.code.cpp.ir.implementation.unaliased_ssa.IR private import cpp private import AliasAnalysis -private import semmle.code.cpp.ir.implementation.unaliased_ssa.internal.SimpleSSA as UnaliasedSSA +private import semmle.code.cpp.ir.implementation.unaliased_ssa.internal.SimpleSSA as UnaliasedSsa private newtype TAllocation = TVariableAllocation(IRVariable var) { // Only model variables that were not already handled in unaliased SSA. - not UnaliasedSSA::canReuseSSAForVariable(var) + not UnaliasedSsa::canReuseSsaForVariable(var) } or TIndirectParameterAllocation(IRAutomaticVariable var) { exists(InitializeIndirectionInstruction instr | instr.getIRVariable() = var) diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/AliasedSSA.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/AliasedSSA.qll index acdae2b758a..76a99026d59 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/AliasedSSA.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/AliasedSSA.qll @@ -133,7 +133,10 @@ abstract class MemoryLocation extends TMemoryLocation { */ predicate isAlwaysAllocatedOnStack() { none() } - final predicate canReuseSSA() { none() } + final predicate canReuseSsa() { none() } + + /** DEPRECATED: Alias for canReuseSsa */ + deprecated predicate canReuseSSA() { canReuseSsa() } } /** @@ -569,13 +572,16 @@ private Overlap getVariableMemoryLocationOverlap( * Holds if the def/use information for the result of `instr` can be reused from the previous * iteration of the IR. */ -predicate canReuseSSAForOldResult(Instruction instr) { OldSSA::canReuseSSAForMemoryResult(instr) } +predicate canReuseSsaForOldResult(Instruction instr) { OldSSA::canReuseSsaForMemoryResult(instr) } + +/** DEPRECATED: Alias for canReuseSsaForOldResult */ +deprecated predicate canReuseSSAForOldResult = canReuseSsaForOldResult/1; bindingset[result, b] private boolean unbindBool(boolean b) { result != b.booleanNot() } MemoryLocation getResultMemoryLocation(Instruction instr) { - not canReuseSSAForOldResult(instr) and + not canReuseSsaForOldResult(instr) and exists(MemoryAccessKind kind, boolean isMayAccess | kind = instr.getResultMemoryAccess() and (if instr.hasResultMayMemoryAccess() then isMayAccess = true else isMayAccess = false) and @@ -608,7 +614,7 @@ MemoryLocation getResultMemoryLocation(Instruction instr) { } MemoryLocation getOperandMemoryLocation(MemoryOperand operand) { - not canReuseSSAForOldResult(operand.getAnyDef()) and + not canReuseSsaForOldResult(operand.getAnyDef()) and exists(MemoryAccessKind kind, boolean isMayAccess | kind = operand.getMemoryAccess() and (if operand.hasMayReadMemoryAccess() then isMayAccess = true else isMayAccess = false) and diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/OperandInternal.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/OperandInternal.qll index b47c20e97ef..c7a5389901b 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/OperandInternal.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/OperandInternal.qll @@ -1,2 +1,2 @@ private import semmle.code.cpp.ir.implementation.internal.TOperand -import AliasedSSAOperands +import AliasedSsaOperands diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/PrintSSA.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/PrintSSA.qll index 72bb239c153..c7487872512 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/PrintSSA.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/PrintSSA.qll @@ -2,7 +2,7 @@ private import SSAConstructionInternal private import OldIR private import Alias private import SSAConstruction -private import DebugSSA +private import DebugSsa bindingset[offset] private string getKeySuffixForOffset(int offset) { diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConsistency.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConsistency.qll index 5686bb439eb..1c75529be00 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConsistency.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConsistency.qll @@ -1,2 +1,2 @@ private import SSAConstruction as SSA -import SSA::SSAConsistency +import SSA::SsaConsistency diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConstruction.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConstruction.qll index 5092e921cb3..13ec2ca4ca4 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConstruction.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConstruction.qll @@ -112,7 +112,7 @@ private module Cached { exists(Alias::getResultMemoryLocation(oldInstruction)) or // This result was already modeled by a previous iteration of SSA. - Alias::canReuseSSAForOldResult(oldInstruction) + Alias::canReuseSsaForOldResult(oldInstruction) } cached @@ -182,7 +182,7 @@ private module Cached { * unreachable, this predicate will recurse through any degenerate `Phi` instructions to find the * true definition. */ - private Instruction getNewDefinitionFromOldSSA(OldIR::MemoryOperand oldOperand, Overlap overlap) { + private Instruction getNewDefinitionFromOldSsa(OldIR::MemoryOperand oldOperand, Overlap overlap) { exists(Overlap originalOverlap | originalOverlap = oldOperand.getDefinitionOverlap() and ( @@ -191,7 +191,7 @@ private module Cached { or exists(OldIR::PhiInputOperand phiOperand, Overlap phiOperandOverlap | phiOperand = getDegeneratePhiOperand(oldOperand.getAnyDef()) and - result = getNewDefinitionFromOldSSA(phiOperand, phiOperandOverlap) and + result = getNewDefinitionFromOldSsa(phiOperand, phiOperandOverlap) and overlap = combineOverlap(pragma[only_bind_out](phiOperandOverlap), pragma[only_bind_out](originalOverlap)) @@ -233,7 +233,7 @@ private module Cached { ) or exists(OldIR::NonPhiMemoryOperand oldOperand | - result = getNewDefinitionFromOldSSA(oldOperand, overlap) and + result = getNewDefinitionFromOldSsa(oldOperand, overlap) and oldOperand.getUse() = instruction and tag = oldOperand.getOperandTag() ) @@ -307,13 +307,13 @@ private module Cached { * Gets the new definition instruction for the operand of `instr` that flows from the block * `newPredecessorBlock`, based on that operand's definition in the old IR. */ - private Instruction getNewPhiOperandDefinitionFromOldSSA( + private Instruction getNewPhiOperandDefinitionFromOldSsa( Instruction instr, IRBlock newPredecessorBlock, Overlap overlap ) { exists(OldIR::PhiInstruction oldPhi, OldIR::PhiInputOperand oldOperand | oldPhi = getOldInstruction(instr) and oldOperand = oldPhi.getInputOperand(getOldBlock(newPredecessorBlock)) and - result = getNewDefinitionFromOldSSA(oldOperand, overlap) + result = getNewDefinitionFromOldSsa(oldOperand, overlap) ) } @@ -333,7 +333,7 @@ private module Cached { overlap = Alias::getOverlap(actualDefLocation, useLocation) ) or - result = getNewPhiOperandDefinitionFromOldSSA(instr, newPredecessorBlock, overlap) + result = getNewPhiOperandDefinitionFromOldSsa(instr, newPredecessorBlock, overlap) } cached @@ -412,17 +412,17 @@ private module Cached { } cached - Language::AST getInstructionAST(Instruction instr) { - result = getOldInstruction(instr).getAST() + Language::AST getInstructionAst(Instruction instr) { + result = getOldInstruction(instr).getAst() or exists(RawIR::Instruction blockStartInstr | instr = phiInstruction(blockStartInstr, _) and - result = blockStartInstr.getAST() + result = blockStartInstr.getAst() ) or exists(RawIR::Instruction primaryInstr | instr = chiInstruction(primaryInstr) and - result = primaryInstr.getAST() + result = primaryInstr.getAst() ) or exists(IRFunctionBase irFunc | @@ -430,6 +430,12 @@ private module Cached { ) } + /** DEPRECATED: Alias for getInstructionAst */ + cached + deprecated Language::AST getInstructionAST(Instruction instr) { + result = getInstructionAst(instr) + } + cached Language::LanguageType getInstructionResultType(Instruction instr) { result = instr.(RawIR::Instruction).getResultLanguageType() @@ -975,35 +981,41 @@ module DefUse { } } -predicate canReuseSSAForMemoryResult(Instruction instruction) { +predicate canReuseSsaForMemoryResult(Instruction instruction) { exists(OldInstruction oldInstruction | oldInstruction = getOldInstruction(instruction) and ( // The previous iteration said it was reusable, so we should mark it as reusable as well. - Alias::canReuseSSAForOldResult(oldInstruction) + Alias::canReuseSsaForOldResult(oldInstruction) or // The current alias analysis says it is reusable. - Alias::getResultMemoryLocation(oldInstruction).canReuseSSA() + Alias::getResultMemoryLocation(oldInstruction).canReuseSsa() ) ) or exists(Alias::MemoryLocation defLocation | // This is a `Phi` for a reusable location, so the result of the `Phi` is reusable as well. instruction = phiInstruction(_, defLocation) and - defLocation.canReuseSSA() + defLocation.canReuseSsa() ) // We don't support reusing SSA for any location that could create a `Chi` instruction. } +/** DEPRECATED: Alias for canReuseSsaForMemoryResult */ +deprecated predicate canReuseSSAForMemoryResult = canReuseSsaForMemoryResult/1; + /** * Expose some of the internal predicates to PrintSSA.qll. We do this by publically importing those modules in the * `DebugSSA` module, which is then imported by PrintSSA. */ -module DebugSSA { +module DebugSsa { import PhiInsertion import DefUse } +/** DEPRECATED: Alias for DebugSsa */ +deprecated module DebugSSA = DebugSsa; + import CachedForDebugging cached @@ -1038,7 +1050,7 @@ private module CachedForDebugging { private OldIR::IRTempVariable getOldTempVariable(IRTempVariable var) { result.getEnclosingFunction() = var.getEnclosingFunction() and - result.getAST() = var.getAST() and + result.getAst() = var.getAst() and result.getTag() = var.getTag() } @@ -1061,7 +1073,7 @@ private module CachedForDebugging { int maxValue() { result = 2147483647 } } -module SSAConsistency { +module SsaConsistency { /** * Holds if a `MemoryOperand` has more than one `MemoryLocation` assigned by alias analysis. */ @@ -1114,6 +1126,9 @@ module SSAConsistency { } } +/** DEPRECATED: Alias for SsaConsistency */ +deprecated module SSAConsistency = SsaConsistency; + /** * Provides the portion of the parameterized IR interface that is used to construct the SSA stages * of the IR. The raw stage of the IR does not expose these predicates. diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConstructionInternal.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConstructionInternal.qll index a1ce2629cc2..74919a57870 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConstructionInternal.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConstructionInternal.qll @@ -2,7 +2,7 @@ import semmle.code.cpp.ir.implementation.unaliased_ssa.IR as OldIR import semmle.code.cpp.ir.implementation.unaliased_ssa.internal.reachability.ReachableBlock as Reachability import semmle.code.cpp.ir.implementation.unaliased_ssa.internal.reachability.Dominance as Dominance import semmle.code.cpp.ir.implementation.aliased_ssa.IR as NewIR -import semmle.code.cpp.ir.implementation.internal.TInstruction::AliasedSSAInstructions as SSAInstructions +import semmle.code.cpp.ir.implementation.internal.TInstruction::AliasedSsaInstructions as SSAInstructions import semmle.code.cpp.ir.internal.IRCppLanguage as Language import AliasedSSA as Alias -import semmle.code.cpp.ir.implementation.internal.TOperand::AliasedSSAOperands as SSAOperands +import semmle.code.cpp.ir.implementation.internal.TOperand::AliasedSsaOperands as SSAOperands diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/internal/TInstruction.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/internal/TInstruction.qll index 4b3f19cbdde..5a7099d9fa2 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/internal/TInstruction.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/internal/TInstruction.qll @@ -19,24 +19,24 @@ newtype TInstruction = ) { IRConstruction::Raw::hasInstruction(tag1, tag2) } or - TUnaliasedSSAPhiInstruction( - TRawInstruction blockStartInstr, UnaliasedSSA::SSA::MemoryLocation memoryLocation + TUnaliasedSsaPhiInstruction( + TRawInstruction blockStartInstr, UnaliasedSsa::SSA::MemoryLocation memoryLocation ) { - UnaliasedSSA::SSA::hasPhiInstruction(blockStartInstr, memoryLocation) + UnaliasedSsa::SSA::hasPhiInstruction(blockStartInstr, memoryLocation) } or - TUnaliasedSSAChiInstruction(TRawInstruction primaryInstruction) { none() } or - TUnaliasedSSAUnreachedInstruction(IRFunctionBase irFunc) { - UnaliasedSSA::SSA::hasUnreachedInstruction(irFunc) + TUnaliasedSsaChiInstruction(TRawInstruction primaryInstruction) { none() } or + TUnaliasedSsaUnreachedInstruction(IRFunctionBase irFunc) { + UnaliasedSsa::SSA::hasUnreachedInstruction(irFunc) } or - TAliasedSSAPhiInstruction( + TAliasedSsaPhiInstruction( TRawInstruction blockStartInstr, AliasedSSA::SSA::MemoryLocation memoryLocation ) { AliasedSSA::SSA::hasPhiInstruction(blockStartInstr, memoryLocation) } or - TAliasedSSAChiInstruction(TRawInstruction primaryInstruction) { + TAliasedSsaChiInstruction(TRawInstruction primaryInstruction) { AliasedSSA::SSA::hasChiInstruction(primaryInstruction) } or - TAliasedSSAUnreachedInstruction(IRFunctionBase irFunc) { + TAliasedSsaUnreachedInstruction(IRFunctionBase irFunc) { AliasedSSA::SSA::hasUnreachedInstruction(irFunc) } @@ -46,58 +46,64 @@ newtype TInstruction = * These wrappers are not parameterized because it is not possible to invoke an IPA constructor via * a class alias. */ -module UnaliasedSSAInstructions { - class TPhiInstruction = TUnaliasedSSAPhiInstruction; +module UnaliasedSsaInstructions { + class TPhiInstruction = TUnaliasedSsaPhiInstruction; TPhiInstruction phiInstruction( - TRawInstruction blockStartInstr, UnaliasedSSA::SSA::MemoryLocation memoryLocation + TRawInstruction blockStartInstr, UnaliasedSsa::SSA::MemoryLocation memoryLocation ) { - result = TUnaliasedSSAPhiInstruction(blockStartInstr, memoryLocation) + result = TUnaliasedSsaPhiInstruction(blockStartInstr, memoryLocation) } TRawInstruction reusedPhiInstruction(TRawInstruction blockStartInstr) { none() } - class TChiInstruction = TUnaliasedSSAChiInstruction; + class TChiInstruction = TUnaliasedSsaChiInstruction; TChiInstruction chiInstruction(TRawInstruction primaryInstruction) { - result = TUnaliasedSSAChiInstruction(primaryInstruction) + result = TUnaliasedSsaChiInstruction(primaryInstruction) } - class TUnreachedInstruction = TUnaliasedSSAUnreachedInstruction; + class TUnreachedInstruction = TUnaliasedSsaUnreachedInstruction; TUnreachedInstruction unreachedInstruction(IRFunctionBase irFunc) { - result = TUnaliasedSSAUnreachedInstruction(irFunc) + result = TUnaliasedSsaUnreachedInstruction(irFunc) } } +/** DEPRECATED: Alias for UnaliasedSsaInstructions */ +deprecated module UnaliasedSSAInstructions = UnaliasedSsaInstructions; + /** * Provides wrappers for the constructors of each branch of `TInstruction` that is used by the * aliased SSA stage. * These wrappers are not parameterized because it is not possible to invoke an IPA constructor via * a class alias. */ -module AliasedSSAInstructions { - class TPhiInstruction = TAliasedSSAPhiInstruction or TUnaliasedSSAPhiInstruction; +module AliasedSsaInstructions { + class TPhiInstruction = TAliasedSsaPhiInstruction or TUnaliasedSsaPhiInstruction; TPhiInstruction phiInstruction( TRawInstruction blockStartInstr, AliasedSSA::SSA::MemoryLocation memoryLocation ) { - result = TAliasedSSAPhiInstruction(blockStartInstr, memoryLocation) + result = TAliasedSsaPhiInstruction(blockStartInstr, memoryLocation) } TPhiInstruction reusedPhiInstruction(TRawInstruction blockStartInstr) { - result = TUnaliasedSSAPhiInstruction(blockStartInstr, _) + result = TUnaliasedSsaPhiInstruction(blockStartInstr, _) } - class TChiInstruction = TAliasedSSAChiInstruction; + class TChiInstruction = TAliasedSsaChiInstruction; TChiInstruction chiInstruction(TRawInstruction primaryInstruction) { - result = TAliasedSSAChiInstruction(primaryInstruction) + result = TAliasedSsaChiInstruction(primaryInstruction) } - class TUnreachedInstruction = TAliasedSSAUnreachedInstruction; + class TUnreachedInstruction = TAliasedSsaUnreachedInstruction; TUnreachedInstruction unreachedInstruction(IRFunctionBase irFunc) { - result = TAliasedSSAUnreachedInstruction(irFunc) + result = TAliasedSsaUnreachedInstruction(irFunc) } } + +/** DEPRECATED: Alias for AliasedSsaInstructions */ +deprecated module AliasedSSAInstructions = AliasedSsaInstructions; diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/internal/TInstructionInternal.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/internal/TInstructionInternal.qll index adaaaca9cd8..2c9ac1c4b80 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/internal/TInstructionInternal.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/internal/TInstructionInternal.qll @@ -1,4 +1,4 @@ import semmle.code.cpp.ir.internal.IRCppLanguage as Language import semmle.code.cpp.ir.implementation.raw.internal.IRConstruction as IRConstruction -import semmle.code.cpp.ir.implementation.unaliased_ssa.internal.SSAConstruction as UnaliasedSSA +import semmle.code.cpp.ir.implementation.unaliased_ssa.internal.SSAConstruction as UnaliasedSsa import semmle.code.cpp.ir.implementation.aliased_ssa.internal.SSAConstruction as AliasedSSA diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/internal/TOperand.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/internal/TOperand.qll index e86494af03a..bc69754fe32 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/internal/TOperand.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/internal/TOperand.qll @@ -31,7 +31,7 @@ private module Internal { TNoOperand() { none() } or // Can be "removed" later when there's unreachable code // These operands can be reused across all three stages. They just get different defs. - TNonSSAMemoryOperand(Raw::Instruction useInstr, MemoryOperandTag tag) { + TNonSsaMemoryOperand(Raw::Instruction useInstr, MemoryOperandTag tag) { // Has no definition in raw but will get definitions later useInstr.getOpcode().hasOperand(tag) } or @@ -49,11 +49,11 @@ private module Internal { // important that we use the same definition of "is variable aliased" across // the phases. TAliasedPhiOperand( - TAliasedSSAPhiInstruction useInstr, Aliased::IRBlock predecessorBlock, Overlap overlap + TAliasedSsaPhiInstruction useInstr, Aliased::IRBlock predecessorBlock, Overlap overlap ) { exists(AliasedConstruction::getPhiOperandDefinition(useInstr, predecessorBlock, overlap)) } or - TAliasedChiOperand(TAliasedSSAChiInstruction useInstr, ChiOperandTag tag) { any() } + TAliasedChiOperand(TAliasedSsaChiInstruction useInstr, ChiOperandTag tag) { any() } } /** @@ -72,13 +72,21 @@ private module Shared { result = Internal::TRegisterOperand(useInstr, tag, defInstr) } - class TNonSSAMemoryOperand = Internal::TNonSSAMemoryOperand; + class TNonSsaMemoryOperand = Internal::TNonSsaMemoryOperand; + + /** DEPRECATED: Alias for TNonSsaMemoryOperand */ + deprecated class TNonSSAMemoryOperand = TNonSsaMemoryOperand; /** * Returns the non-Phi memory operand with the specified parameters. */ - TNonSSAMemoryOperand nonSSAMemoryOperand(TRawInstruction useInstr, MemoryOperandTag tag) { - result = Internal::TNonSSAMemoryOperand(useInstr, tag) + TNonSsaMemoryOperand nonSsaMemoryOperand(TRawInstruction useInstr, MemoryOperandTag tag) { + result = Internal::TNonSsaMemoryOperand(useInstr, tag) + } + + /** DEPRECATED: Alias for nonSsaMemoryOperand */ + deprecated TNonSSAMemoryOperand nonSSAMemoryOperand(TRawInstruction useInstr, MemoryOperandTag tag) { + result = nonSsaMemoryOperand(useInstr, tag) } } @@ -95,7 +103,7 @@ module RawOperands { class TChiOperand = Internal::TNoOperand; - class TNonPhiMemoryOperand = TNonSSAMemoryOperand or TChiOperand; + class TNonPhiMemoryOperand = TNonSsaMemoryOperand or TChiOperand; /** * Returns the Phi operand with the specified parameters. @@ -126,14 +134,14 @@ module RawOperands { * These wrappers are not parameterized because it is not possible to invoke an IPA constructor via * a class alias. */ -module UnaliasedSSAOperands { +module UnaliasedSsaOperands { import Shared class TPhiOperand = Internal::TUnaliasedPhiOperand; class TChiOperand = Internal::TNoOperand; - class TNonPhiMemoryOperand = TNonSSAMemoryOperand or TChiOperand; + class TNonPhiMemoryOperand = TNonSsaMemoryOperand or TChiOperand; /** * Returns the Phi operand with the specified parameters. @@ -159,20 +167,23 @@ module UnaliasedSSAOperands { TChiOperand chiOperand(Unaliased::Instruction useInstr, ChiOperandTag tag) { none() } } +/** DEPRECATED: Alias for UnaliasedSsaOperands */ +deprecated module UnaliasedSSAOperands = UnaliasedSsaOperands; + /** * Provides wrappers for the constructors of each branch of `TOperand` that is used by the * asliased SSA stage. * These wrappers are not parameterized because it is not possible to invoke an IPA constructor via * a class alias. */ -module AliasedSSAOperands { +module AliasedSsaOperands { import Shared class TPhiOperand = Internal::TAliasedPhiOperand or Internal::TUnaliasedPhiOperand; class TChiOperand = Internal::TAliasedChiOperand; - class TNonPhiMemoryOperand = TNonSSAMemoryOperand or TChiOperand; + class TNonPhiMemoryOperand = TNonSsaMemoryOperand or TChiOperand; /** * Returns the Phi operand with the specified parameters. @@ -202,7 +213,10 @@ module AliasedSSAOperands { /** * Returns the Chi operand with the specified parameters. */ - TChiOperand chiOperand(TAliasedSSAChiInstruction useInstr, ChiOperandTag tag) { + TChiOperand chiOperand(TAliasedSsaChiInstruction useInstr, ChiOperandTag tag) { result = Internal::TAliasedChiOperand(useInstr, tag) } } + +/** DEPRECATED: Alias for AliasedSsaOperands */ +deprecated module AliasedSSAOperands = AliasedSsaOperands; diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/IRVariable.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/IRVariable.qll index 146fc270738..ca4708857a7 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/IRVariable.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/IRVariable.qll @@ -55,7 +55,10 @@ class IRVariable extends TIRVariable { * Gets the AST node that declared this variable, or that introduced this * variable as part of the AST-to-IR translation. */ - Language::AST getAST() { none() } + Language::AST getAst() { none() } + + /** DEPRECATED: Alias for getAst */ + deprecated Language::AST getAST() { result = getAst() } /** * Gets an identifier string for the variable. This identifier is unique @@ -66,7 +69,7 @@ class IRVariable extends TIRVariable { /** * Gets the source location of this variable. */ - final Language::Location getLocation() { result = getAST().getLocation() } + final Language::Location getLocation() { result = getAst().getLocation() } /** * Gets the IR for the function that references this variable. @@ -90,7 +93,10 @@ class IRUserVariable extends IRVariable, TIRUserVariable { final override string toString() { result = getVariable().toString() } - final override Language::AST getAST() { result = var } + final override Language::AST getAst() { result = var } + + /** DEPRECATED: Alias for getAst */ + deprecated override Language::AST getAST() { result = getAst() } final override string getUniqueId() { result = getVariable().toString() + " " + getVariable().getLocation().toString() @@ -157,7 +163,10 @@ class IRGeneratedVariable extends IRVariable { final override Language::LanguageType getLanguageType() { result = type } - final override Language::AST getAST() { result = ast } + final override Language::AST getAst() { result = ast } + + /** DEPRECATED: Alias for getAst */ + deprecated override Language::AST getAST() { result = getAst() } override string toString() { result = getBaseString() + getLocationString() } diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/Instruction.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/Instruction.qll index 1c2cc493338..4dac3087f83 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/Instruction.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/Instruction.qll @@ -41,7 +41,7 @@ class Instruction extends Construction::TStageInstruction { } /** Gets a textual representation of this element. */ - final string toString() { result = this.getOpcode().toString() + ": " + this.getAST().toString() } + final string toString() { result = this.getOpcode().toString() + ": " + this.getAst().toString() } /** * Gets a string showing the result, opcode, and operands of the instruction, equivalent to what @@ -136,7 +136,7 @@ class Instruction extends Construction::TStageInstruction { string getResultId() { this.shouldGenerateDumpStrings() and result = - this.getResultPrefix() + this.getAST().getLocation().getStartLine() + "_" + this.getLineRank() + this.getResultPrefix() + this.getAst().getLocation().getStartLine() + "_" + this.getLineRank() } /** @@ -208,12 +208,15 @@ class Instruction extends Construction::TStageInstruction { /** * Gets the AST that caused this instruction to be generated. */ - final Language::AST getAST() { result = Construction::getInstructionAST(this) } + final Language::AST getAst() { result = Construction::getInstructionAst(this) } + + /** DEPRECATED: Alias for getAst */ + deprecated Language::AST getAST() { result = getAst() } /** * Gets the location of the source code for this instruction. */ - final Language::Location getLocation() { result = this.getAST().getLocation() } + final Language::Location getLocation() { result = this.getAst().getLocation() } /** * Gets the `Expr` whose result is computed by this instruction, if any. The `Expr` may be a @@ -459,7 +462,10 @@ class VariableInstruction extends Instruction { /** * Gets the AST variable that this instruction's IR variable refers to, if one exists. */ - final Language::Variable getASTVariable() { result = var.(IRUserVariable).getVariable() } + final Language::Variable getAstVariable() { result = var.(IRUserVariable).getVariable() } + + /** DEPRECATED: Alias for getAstVariable */ + deprecated Language::Variable getASTVariable() { result = getAstVariable() } } /** diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/Operand.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/Operand.qll index 89b82657c3b..c1e997d5844 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/Operand.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/Operand.qll @@ -18,7 +18,7 @@ private import internal.OperandInternal * of `TOperand` that are used in this stage. */ private class TStageOperand = - TRegisterOperand or TNonSSAMemoryOperand or TPhiOperand or TChiOperand; + TRegisterOperand or TNonSsaMemoryOperand or TPhiOperand or TChiOperand; /** * A known location. Testing `loc instanceof KnownLocation` will account for non existing locations, as @@ -38,7 +38,7 @@ class Operand extends TStageOperand { // Ensure that the operand does not refer to instructions from earlier stages that are unreachable here exists(Instruction use, Instruction def | this = registerOperand(use, _, def)) or - exists(Instruction use | this = nonSSAMemoryOperand(use, _)) + exists(Instruction use | this = nonSsaMemoryOperand(use, _)) or exists(Instruction use, Instruction def, IRBlock predecessorBlock | this = phiOperand(use, def, predecessorBlock, _) or @@ -209,7 +209,7 @@ class Operand extends TStageOperand { class MemoryOperand extends Operand { cached MemoryOperand() { - this instanceof TNonSSAMemoryOperand or + this instanceof TNonSsaMemoryOperand or this instanceof TPhiOperand or this instanceof TChiOperand } @@ -249,7 +249,7 @@ class NonPhiOperand extends Operand { NonPhiOperand() { this = registerOperand(useInstr, tag, _) or - this = nonSSAMemoryOperand(useInstr, tag) or + this = nonSsaMemoryOperand(useInstr, tag) or this = chiOperand(useInstr, tag) } @@ -299,7 +299,7 @@ class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand, TNonPhiMemoryOpe cached NonPhiMemoryOperand() { - this = nonSSAMemoryOperand(useInstr, tag) + this = nonSsaMemoryOperand(useInstr, tag) or this = chiOperand(useInstr, tag) } diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/gvn/internal/ValueNumberingInternal.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/gvn/internal/ValueNumberingInternal.qll index fdb645e03f0..2dc735f49df 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/gvn/internal/ValueNumberingInternal.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/gvn/internal/ValueNumberingInternal.qll @@ -99,7 +99,7 @@ private predicate filteredNumberableInstruction(Instruction instr) { // count rather than strictcount to handle missing AST elements // separate instanceof and inline casts to avoid failed casts with a count of 0 instr instanceof VariableAddressInstruction and - count(instr.(VariableAddressInstruction).getIRVariable().getAST()) != 1 + count(instr.(VariableAddressInstruction).getIRVariable().getAst()) != 1 or instr instanceof ConstantInstruction and count(instr.getResultIRType()) != 1 @@ -121,7 +121,7 @@ private predicate variableAddressValueNumber( // The underlying AST element is used as value-numbering key instead of the // `IRVariable` to work around a problem where a variable or expression with // multiple types gives rise to multiple `IRVariable`s. - unique( | | instr.getIRVariable().getAST()) = ast + unique( | | instr.getIRVariable().getAst()) = ast } private predicate initializeParameterValueNumber( @@ -131,7 +131,7 @@ private predicate initializeParameterValueNumber( // The underlying AST element is used as value-numbering key instead of the // `IRVariable` to work around a problem where a variable or expression with // multiple types gives rise to multiple `IRVariable`s. - instr.getIRVariable().getAST() = var + instr.getIRVariable().getAst() = var } private predicate constantValueNumber( diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/IRConstruction.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/IRConstruction.qll index e8fcf3fcdf3..16158a4c73a 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/IRConstruction.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/IRConstruction.qll @@ -48,7 +48,7 @@ module Raw { cached predicate hasTempVariable(Function func, Locatable ast, TempVariableTag tag, CppType type) { exists(TranslatedElement element | - element.getAST() = ast and + element.getAst() = ast and func = element.getFunction() and element.hasTempVariable(tag, type) ) @@ -75,7 +75,7 @@ module Raw { tag = getInstructionTag(instruction) and ( result = element.getInstructionVariable(tag) or - result.(IRStringLiteral).getAST() = element.getInstructionStringLiteral(tag) + result.(IRStringLiteral).getAst() = element.getInstructionStringLiteral(tag) ) ) } @@ -339,7 +339,7 @@ Instruction getInstructionBackEdgeSuccessor(Instruction instruction, EdgeKind ki // such a `goto` creates a back edge. exists(TranslatedElement s, GotoStmt goto | not isStrictlyForwardGoto(goto) and - goto = s.getAST() and + goto = s.getAst() and exists(InstructionTag tag | result = s.getInstructionSuccessor(tag, kind) and instruction = s.getInstruction(tag) @@ -352,8 +352,13 @@ private predicate isStrictlyForwardGoto(GotoStmt goto) { goto.getLocation().isBefore(goto.getTarget().getLocation()) } -Locatable getInstructionAST(TStageInstruction instr) { - result = getInstructionTranslatedElement(instr).getAST() +Locatable getInstructionAst(TStageInstruction instr) { + result = getInstructionTranslatedElement(instr).getAst() +} + +/** DEPRECATED: Alias for getInstructionAst */ +deprecated Locatable getInstructionAST(TStageInstruction instr) { + result = getInstructionAst(instr) } CppType getInstructionResultType(TStageInstruction instr) { diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedCall.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedCall.qll index 8ef5334b598..66c601736af 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedCall.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedCall.qll @@ -175,7 +175,10 @@ abstract class TranslatedSideEffects extends TranslatedElement { /** Gets the expression whose side effects are being modeled. */ abstract Expr getExpr(); - final override Locatable getAST() { result = getExpr() } + final override Locatable getAst() { result = getExpr() } + + /** DEPRECATED: Alias for getAst */ + deprecated override Locatable getAST() { result = getAst() } final override Function getFunction() { result = getExpr().getEnclosingFunction() } @@ -522,7 +525,10 @@ class TranslatedArgumentExprSideEffect extends TranslatedArgumentSideEffect, this = TTranslatedArgumentExprSideEffect(call, arg, index, sideEffectOpcode) } - final override Locatable getAST() { result = arg } + final override Locatable getAst() { result = arg } + + /** DEPRECATED: Alias for getAst */ + deprecated override Locatable getAST() { result = getAst() } final override Type getIndirectionType() { result = arg.getUnspecifiedType().(DerivedType).getBaseType() @@ -553,7 +559,10 @@ class TranslatedStructorQualifierSideEffect extends TranslatedArgumentSideEffect index = -1 } - final override Locatable getAST() { result = call } + final override Locatable getAst() { result = call } + + /** DEPRECATED: Alias for getAst */ + deprecated override Locatable getAST() { result = getAst() } final override Type getIndirectionType() { result = call.getTarget().getDeclaringType() } @@ -574,7 +583,10 @@ class TranslatedCallSideEffect extends TranslatedSideEffect, TTranslatedCallSide TranslatedCallSideEffect() { this = TTranslatedCallSideEffect(expr, sideEffectOpcode) } - override Locatable getAST() { result = expr } + override Locatable getAst() { result = expr } + + /** DEPRECATED: Alias for getAst */ + deprecated override Locatable getAST() { result = getAst() } override Expr getPrimaryExpr() { result = expr } @@ -612,7 +624,10 @@ class TranslatedAllocationSideEffect extends TranslatedSideEffect, TTranslatedAl TranslatedAllocationSideEffect() { this = TTranslatedAllocationSideEffect(expr) } - override Locatable getAST() { result = expr } + override Locatable getAst() { result = expr } + + /** DEPRECATED: Alias for getAst */ + deprecated override Locatable getAST() { result = getAst() } override Expr getPrimaryExpr() { result = expr } diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedCondition.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedCondition.qll index 0779d6fbda5..528acf4498b 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedCondition.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedCondition.qll @@ -19,7 +19,10 @@ abstract class TranslatedCondition extends TranslatedElement { final override string toString() { result = expr.toString() } - final override Locatable getAST() { result = expr } + final override Locatable getAst() { result = expr } + + /** DEPRECATED: Alias for getAst */ + deprecated override Locatable getAST() { result = getAst() } final ConditionContext getConditionContext() { result = getParent() } diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedDeclarationEntry.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedDeclarationEntry.qll index de63b81c876..36f1ce9443d 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedDeclarationEntry.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedDeclarationEntry.qll @@ -14,7 +14,7 @@ private import TranslatedInitialization * `entry`. */ TranslatedDeclarationEntry getTranslatedDeclarationEntry(DeclarationEntry entry) { - result.getAST() = entry + result.getAst() = entry } /** @@ -37,7 +37,10 @@ abstract class TranslatedDeclarationEntry extends TranslatedElement, TTranslated final override string toString() { result = entry.toString() } - final override Locatable getAST() { result = entry } + final override Locatable getAst() { result = entry } + + /** DEPRECATED: Alias for getAst */ + deprecated override Locatable getAST() { result = getAst() } } /** @@ -223,7 +226,10 @@ class TranslatedStaticLocalVariableInitialization extends TranslatedElement, final override string toString() { result = "init: " + entry.toString() } - final override Locatable getAST() { result = entry } + final override Locatable getAst() { result = entry } + + /** DEPRECATED: Alias for getAst */ + deprecated override Locatable getAST() { result = getAst() } final override LocalVariable getVariable() { result = var } @@ -254,7 +260,10 @@ class TranslatedRangeBasedForVariableDeclaration extends TranslatedLocalVariable override string toString() { result = var.toString() } - override Locatable getAST() { result = var } + override Locatable getAst() { result = var } + + /** DEPRECATED: Alias for getAst */ + deprecated override Locatable getAST() { result = getAst() } override Function getFunction() { result = forStmt.getEnclosingFunction() } @@ -262,7 +271,7 @@ class TranslatedRangeBasedForVariableDeclaration extends TranslatedLocalVariable } TranslatedConditionDecl getTranslatedConditionDecl(ConditionDeclExpr expr) { - result.getAST() = expr + result.getAst() = expr } /** @@ -280,7 +289,10 @@ class TranslatedConditionDecl extends TranslatedLocalVariableDeclaration, TTrans override string toString() { result = "decl: " + conditionDeclExpr.toString() } - override Locatable getAST() { result = conditionDeclExpr } + override Locatable getAst() { result = conditionDeclExpr } + + /** DEPRECATED: Alias for getAst */ + deprecated override Locatable getAST() { result = getAst() } override Function getFunction() { result = conditionDeclExpr.getEnclosingFunction() } diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll index 8034e9e2bd1..c9ac4d0e6d9 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll @@ -31,7 +31,7 @@ IRUserVariable getIRUserVariable(Function func, Variable var) { } IRTempVariable getIRTempVariable(Locatable ast, TempVariableTag tag) { - result.getAST() = ast and + result.getAst() = ast and result.getTag() = tag } @@ -730,7 +730,10 @@ abstract class TranslatedElement extends TTranslatedElement { /** * Gets the AST node being translated. */ - abstract Locatable getAST(); + abstract Locatable getAst(); + + /** DEPRECATED: Alias for getAst */ + deprecated Locatable getAST() { result = getAst() } /** * Get the first instruction to be executed in the evaluation of this element. @@ -929,16 +932,16 @@ abstract class TranslatedElement extends TTranslatedElement { */ final IRTempVariable getTempVariable(TempVariableTag tag) { exists(Locatable ast | - result.getAST() = ast and + result.getAst() = ast and result.getTag() = tag and - hasTempVariableAndAST(tag, ast) + hasTempVariableAndAst(tag, ast) ) } pragma[noinline] - private predicate hasTempVariableAndAST(TempVariableTag tag, Locatable ast) { + private predicate hasTempVariableAndAst(TempVariableTag tag, Locatable ast) { hasTempVariable(tag, _) and - ast = getAST() + ast = getAst() } /** diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedExpr.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedExpr.qll index 1b761a85640..a4a21f039fb 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedExpr.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedExpr.qll @@ -74,7 +74,10 @@ abstract class TranslatedExpr extends TranslatedElement { expr.isGLValueCategory() } - final override Locatable getAST() { result = expr } + final override Locatable getAst() { result = expr } + + /** DEPRECATED: Alias for getAst */ + deprecated override Locatable getAST() { result = getAst() } final override Function getFunction() { result = expr.getEnclosingFunction() } @@ -1709,7 +1712,7 @@ abstract class TranslatedAllocationSize extends TranslatedExpr, TTranslatedAlloc } TranslatedAllocationSize getTranslatedAllocationSize(NewOrNewArrayExpr newExpr) { - result.getAST() = newExpr + result.getAst() = newExpr } /** @@ -1875,7 +1878,7 @@ class TranslatedAllocatorCall extends TTranslatedAllocatorCall, TranslatedDirect } TranslatedAllocatorCall getTranslatedAllocatorCall(NewOrNewArrayExpr newExpr) { - result.getAST() = newExpr + result.getAst() = newExpr } /** diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedFunction.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedFunction.qll index 2fa4548fc3c..0f781cb2244 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedFunction.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedFunction.qll @@ -15,7 +15,7 @@ private import VarArgs /** * Gets the `TranslatedFunction` that represents function `func`. */ -TranslatedFunction getTranslatedFunction(Function func) { result.getAST() = func } +TranslatedFunction getTranslatedFunction(Function func) { result.getAst() = func } /** * Gets the size, in bytes, of the variable used to represent the `...` parameter in a varargs @@ -65,7 +65,10 @@ class TranslatedFunction extends TranslatedElement, TTranslatedFunction { final override string toString() { result = func.toString() } - final override Locatable getAST() { result = func } + final override Locatable getAst() { result = func } + + /** DEPRECATED: Alias for getAst */ + deprecated override Locatable getAST() { result = getAst() } /** * Gets the function being translated. @@ -344,7 +347,7 @@ TranslatedThisParameter getTranslatedThisParameter(Function func) { result.getFu /** * Gets the `TranslatedPositionalParameter` that represents parameter `param`. */ -TranslatedPositionalParameter getTranslatedParameter(Parameter param) { result.getAST() = param } +TranslatedPositionalParameter getTranslatedParameter(Parameter param) { result.getAst() = param } /** * Gets the `TranslatedEllipsisParameter` for function `func`, if one exists. @@ -457,7 +460,10 @@ class TranslatedThisParameter extends TranslatedParameter, TTranslatedThisParame final override string toString() { result = "this" } - final override Locatable getAST() { result = func } + final override Locatable getAst() { result = func } + + /** DEPRECATED: Alias for getAst */ + deprecated override Locatable getAST() { result = getAst() } final override Function getFunction() { result = func } @@ -489,7 +495,10 @@ class TranslatedPositionalParameter extends TranslatedParameter, TTranslatedPara final override string toString() { result = param.toString() } - final override Locatable getAST() { result = param } + final override Locatable getAst() { result = param } + + /** DEPRECATED: Alias for getAst */ + deprecated override Locatable getAST() { result = getAst() } final override Function getFunction() { result = param.getFunction() or @@ -526,7 +535,10 @@ class TranslatedEllipsisParameter extends TranslatedParameter, TTranslatedEllips final override string toString() { result = "..." } - final override Locatable getAST() { result = func } + final override Locatable getAst() { result = func } + + /** DEPRECATED: Alias for getAst */ + deprecated override Locatable getAST() { result = getAst() } final override Function getFunction() { result = func } @@ -544,7 +556,7 @@ class TranslatedEllipsisParameter extends TranslatedParameter, TTranslatedEllips } private TranslatedConstructorInitList getTranslatedConstructorInitList(Function func) { - result.getAST() = func + result.getAst() = func } /** @@ -561,7 +573,10 @@ class TranslatedConstructorInitList extends TranslatedElement, InitializationCon override string toString() { result = "ctor init: " + func.toString() } - override Locatable getAST() { result = func } + override Locatable getAst() { result = func } + + /** DEPRECATED: Alias for getAst */ + deprecated override Locatable getAST() { result = getAst() } override TranslatedElement getChild(int id) { exists(ConstructorFieldInit fieldInit | @@ -611,7 +626,7 @@ class TranslatedConstructorInitList extends TranslatedElement, InitializationCon } private TranslatedDestructorDestructionList getTranslatedDestructorDestructionList(Function func) { - result.getAST() = func + result.getAst() = func } /** @@ -629,7 +644,10 @@ class TranslatedDestructorDestructionList extends TranslatedElement, override string toString() { result = "dtor destruction: " + func.toString() } - override Locatable getAST() { result = func } + override Locatable getAst() { result = func } + + /** DEPRECATED: Alias for getAst */ + deprecated override Locatable getAST() { result = getAst() } override TranslatedElement getChild(int id) { exists(DestructorFieldDestruction fieldDestruction | @@ -667,14 +685,17 @@ class TranslatedDestructorDestructionList extends TranslatedElement, } } -TranslatedReadEffects getTranslatedReadEffects(Function func) { result.getAST() = func } +TranslatedReadEffects getTranslatedReadEffects(Function func) { result.getAst() = func } class TranslatedReadEffects extends TranslatedElement, TTranslatedReadEffects { Function func; TranslatedReadEffects() { this = TTranslatedReadEffects(func) } - override Locatable getAST() { result = func } + override Locatable getAst() { result = func } + + /** DEPRECATED: Alias for getAst */ + deprecated override Locatable getAST() { result = getAst() } override Function getFunction() { result = func } @@ -718,11 +739,11 @@ class TranslatedReadEffects extends TranslatedElement, TTranslatedReadEffects { } private TranslatedThisReadEffect getTranslatedThisReadEffect(Function func) { - result.getAST() = func + result.getAst() = func } private TranslatedParameterReadEffect getTranslatedParameterReadEffect(Parameter param) { - result.getAST() = param + result.getAst() = param } abstract class TranslatedReadEffect extends TranslatedElement { @@ -758,7 +779,10 @@ class TranslatedThisReadEffect extends TranslatedReadEffect, TTranslatedThisRead TranslatedThisReadEffect() { this = TTranslatedThisReadEffect(func) } - override Locatable getAST() { result = func } + override Locatable getAst() { result = func } + + /** DEPRECATED: Alias for getAst */ + deprecated override Locatable getAST() { result = getAst() } override Function getFunction() { result = func } @@ -781,7 +805,10 @@ class TranslatedParameterReadEffect extends TranslatedReadEffect, TTranslatedPar TranslatedParameterReadEffect() { this = TTranslatedParameterReadEffect(param) } - override Locatable getAST() { result = param } + override Locatable getAst() { result = param } + + /** DEPRECATED: Alias for getAst */ + deprecated override Locatable getAST() { result = getAst() } override string toString() { result = "read effect: " + param.toString() } diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedInitialization.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedInitialization.qll index 23d6ad133cf..1a9d7ad9d70 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedInitialization.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedInitialization.qll @@ -139,7 +139,10 @@ abstract class TranslatedInitialization extends TranslatedElement, TTranslatedIn final override Function getFunction() { result = expr.getEnclosingFunction() } - final override Locatable getAST() { result = expr } + final override Locatable getAst() { result = expr } + + /** DEPRECATED: Alias for getAst */ + deprecated override Locatable getAST() { result = getAst() } /** * Gets the expression that is doing the initialization. @@ -461,11 +464,11 @@ class TranslatedConstructorInitialization extends TranslatedDirectInitialization TranslatedFieldInitialization getTranslatedFieldInitialization( ClassAggregateLiteral initList, Field field ) { - result.getAST() = initList and result.getField() = field + result.getAst() = initList and result.getField() = field } TranslatedFieldInitialization getTranslatedConstructorFieldInitialization(ConstructorFieldInit init) { - result.getAST() = init + result.getAst() = init } /** @@ -478,7 +481,10 @@ abstract class TranslatedFieldInitialization extends TranslatedElement { final override string toString() { result = ast.toString() + "." + field.toString() } - final override Locatable getAST() { result = ast } + final override Locatable getAst() { result = ast } + + /** DEPRECATED: Alias for getAst */ + deprecated override Locatable getAST() { result = getAst() } final override Function getFunction() { result = ast.getEnclosingFunction() } @@ -622,7 +628,10 @@ abstract class TranslatedElementInitialization extends TranslatedElement { result = initList.toString() + "[" + getElementIndex().toString() + "]" } - final override Locatable getAST() { result = initList } + final override Locatable getAst() { result = initList } + + /** DEPRECATED: Alias for getAst */ + deprecated override Locatable getAST() { result = getAst() } final override Function getFunction() { result = initList.getEnclosingFunction() } @@ -802,7 +811,10 @@ class TranslatedElementValueInitialization extends TranslatedElementInitializati abstract class TranslatedStructorCallFromStructor extends TranslatedElement, StructorCallContext { FunctionCall call; - final override Locatable getAST() { result = call } + final override Locatable getAst() { result = call } + + /** DEPRECATED: Alias for getAst */ + deprecated override Locatable getAST() { result = getAst() } final override TranslatedElement getChild(int id) { id = 0 and @@ -864,7 +876,7 @@ abstract class TranslatedConstructorCallFromConstructor extends TranslatedStruct } TranslatedConstructorCallFromConstructor getTranslatedConstructorBaseInit(ConstructorBaseInit init) { - result.getAST() = init + result.getAst() = init } /** @@ -904,7 +916,7 @@ class TranslatedConstructorBaseInit extends TranslatedConstructorCallFromConstru TranslatedDestructorBaseDestruction getTranslatedDestructorBaseDestruction( DestructorBaseDestruction destruction ) { - result.getAST() = destruction + result.getAst() = destruction } /** @@ -928,7 +940,10 @@ class TranslatedConstructorBareInit extends TranslatedElement, TTranslatedConstr TranslatedConstructorBareInit() { this = TTranslatedConstructorBareInit(init) } - override Locatable getAST() { result = init } + override Locatable getAst() { result = init } + + /** DEPRECATED: Alias for getAst */ + deprecated override Locatable getAST() { result = getAst() } final override string toString() { result = "construct base (no constructor)" } @@ -948,5 +963,5 @@ class TranslatedConstructorBareInit extends TranslatedElement, TTranslatedConstr } TranslatedConstructorBareInit getTranslatedConstructorBareInit(ConstructorInit init) { - result.getAST() = init + result.getAst() = init } diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedStmt.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedStmt.qll index 2bc3b5bc3ef..eb195286339 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedStmt.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedStmt.qll @@ -11,7 +11,7 @@ private import TranslatedExpr private import TranslatedFunction private import TranslatedInitialization -TranslatedStmt getTranslatedStmt(Stmt stmt) { result.getAST() = stmt } +TranslatedStmt getTranslatedStmt(Stmt stmt) { result.getAst() = stmt } abstract class TranslatedStmt extends TranslatedElement, TTranslatedStmt { Stmt stmt; @@ -20,7 +20,10 @@ abstract class TranslatedStmt extends TranslatedElement, TTranslatedStmt { final override string toString() { result = stmt.toString() } - final override Locatable getAST() { result = stmt } + final override Locatable getAst() { result = stmt } + + /** DEPRECATED: Alias for getAst */ + deprecated override Locatable getAST() { result = getAst() } final override Function getFunction() { result = stmt.getEnclosingFunction() } } diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/IRVariable.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/IRVariable.qll index 146fc270738..ca4708857a7 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/IRVariable.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/IRVariable.qll @@ -55,7 +55,10 @@ class IRVariable extends TIRVariable { * Gets the AST node that declared this variable, or that introduced this * variable as part of the AST-to-IR translation. */ - Language::AST getAST() { none() } + Language::AST getAst() { none() } + + /** DEPRECATED: Alias for getAst */ + deprecated Language::AST getAST() { result = getAst() } /** * Gets an identifier string for the variable. This identifier is unique @@ -66,7 +69,7 @@ class IRVariable extends TIRVariable { /** * Gets the source location of this variable. */ - final Language::Location getLocation() { result = getAST().getLocation() } + final Language::Location getLocation() { result = getAst().getLocation() } /** * Gets the IR for the function that references this variable. @@ -90,7 +93,10 @@ class IRUserVariable extends IRVariable, TIRUserVariable { final override string toString() { result = getVariable().toString() } - final override Language::AST getAST() { result = var } + final override Language::AST getAst() { result = var } + + /** DEPRECATED: Alias for getAst */ + deprecated override Language::AST getAST() { result = getAst() } final override string getUniqueId() { result = getVariable().toString() + " " + getVariable().getLocation().toString() @@ -157,7 +163,10 @@ class IRGeneratedVariable extends IRVariable { final override Language::LanguageType getLanguageType() { result = type } - final override Language::AST getAST() { result = ast } + final override Language::AST getAst() { result = ast } + + /** DEPRECATED: Alias for getAst */ + deprecated override Language::AST getAST() { result = getAst() } override string toString() { result = getBaseString() + getLocationString() } diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll index 1c2cc493338..4dac3087f83 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll @@ -41,7 +41,7 @@ class Instruction extends Construction::TStageInstruction { } /** Gets a textual representation of this element. */ - final string toString() { result = this.getOpcode().toString() + ": " + this.getAST().toString() } + final string toString() { result = this.getOpcode().toString() + ": " + this.getAst().toString() } /** * Gets a string showing the result, opcode, and operands of the instruction, equivalent to what @@ -136,7 +136,7 @@ class Instruction extends Construction::TStageInstruction { string getResultId() { this.shouldGenerateDumpStrings() and result = - this.getResultPrefix() + this.getAST().getLocation().getStartLine() + "_" + this.getLineRank() + this.getResultPrefix() + this.getAst().getLocation().getStartLine() + "_" + this.getLineRank() } /** @@ -208,12 +208,15 @@ class Instruction extends Construction::TStageInstruction { /** * Gets the AST that caused this instruction to be generated. */ - final Language::AST getAST() { result = Construction::getInstructionAST(this) } + final Language::AST getAst() { result = Construction::getInstructionAst(this) } + + /** DEPRECATED: Alias for getAst */ + deprecated Language::AST getAST() { result = getAst() } /** * Gets the location of the source code for this instruction. */ - final Language::Location getLocation() { result = this.getAST().getLocation() } + final Language::Location getLocation() { result = this.getAst().getLocation() } /** * Gets the `Expr` whose result is computed by this instruction, if any. The `Expr` may be a @@ -459,7 +462,10 @@ class VariableInstruction extends Instruction { /** * Gets the AST variable that this instruction's IR variable refers to, if one exists. */ - final Language::Variable getASTVariable() { result = var.(IRUserVariable).getVariable() } + final Language::Variable getAstVariable() { result = var.(IRUserVariable).getVariable() } + + /** DEPRECATED: Alias for getAstVariable */ + deprecated Language::Variable getASTVariable() { result = getAstVariable() } } /** diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/Operand.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/Operand.qll index 89b82657c3b..c1e997d5844 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/Operand.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/Operand.qll @@ -18,7 +18,7 @@ private import internal.OperandInternal * of `TOperand` that are used in this stage. */ private class TStageOperand = - TRegisterOperand or TNonSSAMemoryOperand or TPhiOperand or TChiOperand; + TRegisterOperand or TNonSsaMemoryOperand or TPhiOperand or TChiOperand; /** * A known location. Testing `loc instanceof KnownLocation` will account for non existing locations, as @@ -38,7 +38,7 @@ class Operand extends TStageOperand { // Ensure that the operand does not refer to instructions from earlier stages that are unreachable here exists(Instruction use, Instruction def | this = registerOperand(use, _, def)) or - exists(Instruction use | this = nonSSAMemoryOperand(use, _)) + exists(Instruction use | this = nonSsaMemoryOperand(use, _)) or exists(Instruction use, Instruction def, IRBlock predecessorBlock | this = phiOperand(use, def, predecessorBlock, _) or @@ -209,7 +209,7 @@ class Operand extends TStageOperand { class MemoryOperand extends Operand { cached MemoryOperand() { - this instanceof TNonSSAMemoryOperand or + this instanceof TNonSsaMemoryOperand or this instanceof TPhiOperand or this instanceof TChiOperand } @@ -249,7 +249,7 @@ class NonPhiOperand extends Operand { NonPhiOperand() { this = registerOperand(useInstr, tag, _) or - this = nonSSAMemoryOperand(useInstr, tag) or + this = nonSsaMemoryOperand(useInstr, tag) or this = chiOperand(useInstr, tag) } @@ -299,7 +299,7 @@ class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand, TNonPhiMemoryOpe cached NonPhiMemoryOperand() { - this = nonSSAMemoryOperand(useInstr, tag) + this = nonSsaMemoryOperand(useInstr, tag) or this = chiOperand(useInstr, tag) } diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/gvn/internal/ValueNumberingInternal.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/gvn/internal/ValueNumberingInternal.qll index fdb645e03f0..2dc735f49df 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/gvn/internal/ValueNumberingInternal.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/gvn/internal/ValueNumberingInternal.qll @@ -99,7 +99,7 @@ private predicate filteredNumberableInstruction(Instruction instr) { // count rather than strictcount to handle missing AST elements // separate instanceof and inline casts to avoid failed casts with a count of 0 instr instanceof VariableAddressInstruction and - count(instr.(VariableAddressInstruction).getIRVariable().getAST()) != 1 + count(instr.(VariableAddressInstruction).getIRVariable().getAst()) != 1 or instr instanceof ConstantInstruction and count(instr.getResultIRType()) != 1 @@ -121,7 +121,7 @@ private predicate variableAddressValueNumber( // The underlying AST element is used as value-numbering key instead of the // `IRVariable` to work around a problem where a variable or expression with // multiple types gives rise to multiple `IRVariable`s. - unique( | | instr.getIRVariable().getAST()) = ast + unique( | | instr.getIRVariable().getAst()) = ast } private predicate initializeParameterValueNumber( @@ -131,7 +131,7 @@ private predicate initializeParameterValueNumber( // The underlying AST element is used as value-numbering key instead of the // `IRVariable` to work around a problem where a variable or expression with // multiple types gives rise to multiple `IRVariable`s. - instr.getIRVariable().getAST() = var + instr.getIRVariable().getAst() = var } private predicate constantValueNumber( diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/OperandInternal.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/OperandInternal.qll index 80e06a381a1..369f7c317f9 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/OperandInternal.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/OperandInternal.qll @@ -1,2 +1,2 @@ private import semmle.code.cpp.ir.implementation.internal.TOperand -import UnaliasedSSAOperands +import UnaliasedSsaOperands diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/PrintSSA.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/PrintSSA.qll index 72bb239c153..c7487872512 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/PrintSSA.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/PrintSSA.qll @@ -2,7 +2,7 @@ private import SSAConstructionInternal private import OldIR private import Alias private import SSAConstruction -private import DebugSSA +private import DebugSsa bindingset[offset] private string getKeySuffixForOffset(int offset) { diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConsistency.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConsistency.qll index 5686bb439eb..1c75529be00 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConsistency.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConsistency.qll @@ -1,2 +1,2 @@ private import SSAConstruction as SSA -import SSA::SSAConsistency +import SSA::SsaConsistency diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll index 5092e921cb3..13ec2ca4ca4 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll @@ -112,7 +112,7 @@ private module Cached { exists(Alias::getResultMemoryLocation(oldInstruction)) or // This result was already modeled by a previous iteration of SSA. - Alias::canReuseSSAForOldResult(oldInstruction) + Alias::canReuseSsaForOldResult(oldInstruction) } cached @@ -182,7 +182,7 @@ private module Cached { * unreachable, this predicate will recurse through any degenerate `Phi` instructions to find the * true definition. */ - private Instruction getNewDefinitionFromOldSSA(OldIR::MemoryOperand oldOperand, Overlap overlap) { + private Instruction getNewDefinitionFromOldSsa(OldIR::MemoryOperand oldOperand, Overlap overlap) { exists(Overlap originalOverlap | originalOverlap = oldOperand.getDefinitionOverlap() and ( @@ -191,7 +191,7 @@ private module Cached { or exists(OldIR::PhiInputOperand phiOperand, Overlap phiOperandOverlap | phiOperand = getDegeneratePhiOperand(oldOperand.getAnyDef()) and - result = getNewDefinitionFromOldSSA(phiOperand, phiOperandOverlap) and + result = getNewDefinitionFromOldSsa(phiOperand, phiOperandOverlap) and overlap = combineOverlap(pragma[only_bind_out](phiOperandOverlap), pragma[only_bind_out](originalOverlap)) @@ -233,7 +233,7 @@ private module Cached { ) or exists(OldIR::NonPhiMemoryOperand oldOperand | - result = getNewDefinitionFromOldSSA(oldOperand, overlap) and + result = getNewDefinitionFromOldSsa(oldOperand, overlap) and oldOperand.getUse() = instruction and tag = oldOperand.getOperandTag() ) @@ -307,13 +307,13 @@ private module Cached { * Gets the new definition instruction for the operand of `instr` that flows from the block * `newPredecessorBlock`, based on that operand's definition in the old IR. */ - private Instruction getNewPhiOperandDefinitionFromOldSSA( + private Instruction getNewPhiOperandDefinitionFromOldSsa( Instruction instr, IRBlock newPredecessorBlock, Overlap overlap ) { exists(OldIR::PhiInstruction oldPhi, OldIR::PhiInputOperand oldOperand | oldPhi = getOldInstruction(instr) and oldOperand = oldPhi.getInputOperand(getOldBlock(newPredecessorBlock)) and - result = getNewDefinitionFromOldSSA(oldOperand, overlap) + result = getNewDefinitionFromOldSsa(oldOperand, overlap) ) } @@ -333,7 +333,7 @@ private module Cached { overlap = Alias::getOverlap(actualDefLocation, useLocation) ) or - result = getNewPhiOperandDefinitionFromOldSSA(instr, newPredecessorBlock, overlap) + result = getNewPhiOperandDefinitionFromOldSsa(instr, newPredecessorBlock, overlap) } cached @@ -412,17 +412,17 @@ private module Cached { } cached - Language::AST getInstructionAST(Instruction instr) { - result = getOldInstruction(instr).getAST() + Language::AST getInstructionAst(Instruction instr) { + result = getOldInstruction(instr).getAst() or exists(RawIR::Instruction blockStartInstr | instr = phiInstruction(blockStartInstr, _) and - result = blockStartInstr.getAST() + result = blockStartInstr.getAst() ) or exists(RawIR::Instruction primaryInstr | instr = chiInstruction(primaryInstr) and - result = primaryInstr.getAST() + result = primaryInstr.getAst() ) or exists(IRFunctionBase irFunc | @@ -430,6 +430,12 @@ private module Cached { ) } + /** DEPRECATED: Alias for getInstructionAst */ + cached + deprecated Language::AST getInstructionAST(Instruction instr) { + result = getInstructionAst(instr) + } + cached Language::LanguageType getInstructionResultType(Instruction instr) { result = instr.(RawIR::Instruction).getResultLanguageType() @@ -975,35 +981,41 @@ module DefUse { } } -predicate canReuseSSAForMemoryResult(Instruction instruction) { +predicate canReuseSsaForMemoryResult(Instruction instruction) { exists(OldInstruction oldInstruction | oldInstruction = getOldInstruction(instruction) and ( // The previous iteration said it was reusable, so we should mark it as reusable as well. - Alias::canReuseSSAForOldResult(oldInstruction) + Alias::canReuseSsaForOldResult(oldInstruction) or // The current alias analysis says it is reusable. - Alias::getResultMemoryLocation(oldInstruction).canReuseSSA() + Alias::getResultMemoryLocation(oldInstruction).canReuseSsa() ) ) or exists(Alias::MemoryLocation defLocation | // This is a `Phi` for a reusable location, so the result of the `Phi` is reusable as well. instruction = phiInstruction(_, defLocation) and - defLocation.canReuseSSA() + defLocation.canReuseSsa() ) // We don't support reusing SSA for any location that could create a `Chi` instruction. } +/** DEPRECATED: Alias for canReuseSsaForMemoryResult */ +deprecated predicate canReuseSSAForMemoryResult = canReuseSsaForMemoryResult/1; + /** * Expose some of the internal predicates to PrintSSA.qll. We do this by publically importing those modules in the * `DebugSSA` module, which is then imported by PrintSSA. */ -module DebugSSA { +module DebugSsa { import PhiInsertion import DefUse } +/** DEPRECATED: Alias for DebugSsa */ +deprecated module DebugSSA = DebugSsa; + import CachedForDebugging cached @@ -1038,7 +1050,7 @@ private module CachedForDebugging { private OldIR::IRTempVariable getOldTempVariable(IRTempVariable var) { result.getEnclosingFunction() = var.getEnclosingFunction() and - result.getAST() = var.getAST() and + result.getAst() = var.getAst() and result.getTag() = var.getTag() } @@ -1061,7 +1073,7 @@ private module CachedForDebugging { int maxValue() { result = 2147483647 } } -module SSAConsistency { +module SsaConsistency { /** * Holds if a `MemoryOperand` has more than one `MemoryLocation` assigned by alias analysis. */ @@ -1114,6 +1126,9 @@ module SSAConsistency { } } +/** DEPRECATED: Alias for SsaConsistency */ +deprecated module SSAConsistency = SsaConsistency; + /** * Provides the portion of the parameterized IR interface that is used to construct the SSA stages * of the IR. The raw stage of the IR does not expose these predicates. diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConstructionInternal.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConstructionInternal.qll index 70d44e03267..8f64bff29f2 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConstructionInternal.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConstructionInternal.qll @@ -3,7 +3,7 @@ import semmle.code.cpp.ir.implementation.raw.internal.reachability.ReachableBloc import semmle.code.cpp.ir.implementation.raw.internal.reachability.Dominance as Dominance import semmle.code.cpp.ir.implementation.unaliased_ssa.IR as NewIR import semmle.code.cpp.ir.implementation.raw.internal.IRConstruction as RawStage -import semmle.code.cpp.ir.implementation.internal.TInstruction::UnaliasedSSAInstructions as SSAInstructions +import semmle.code.cpp.ir.implementation.internal.TInstruction::UnaliasedSsaInstructions as SSAInstructions import semmle.code.cpp.ir.internal.IRCppLanguage as Language import SimpleSSA as Alias -import semmle.code.cpp.ir.implementation.internal.TOperand::UnaliasedSSAOperands as SSAOperands +import semmle.code.cpp.ir.implementation.internal.TOperand::UnaliasedSsaOperands as SSAOperands diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SimpleSSA.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SimpleSSA.qll index f3e02c9f6a8..ec2e6f5ef34 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SimpleSSA.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SimpleSSA.qll @@ -41,11 +41,14 @@ predicate isVariableModeled(Allocation var) { * subsequent iterations will recompute SSA for any variable that we assumed did not escape, but * actually would have escaped if we had used a sound escape analysis. */ -predicate canReuseSSAForVariable(IRAutomaticVariable var) { +predicate canReuseSsaForVariable(IRAutomaticVariable var) { isVariableModeled(var) and not allocationEscapes(var) } +/** DEPRECATED: Alias for canReuseSsaForVariable */ +deprecated predicate canReuseSSAForVariable = canReuseSsaForVariable/1; + private newtype TMemoryLocation = MkMemoryLocation(Allocation var) { isVariableModeled(var) } private MemoryLocation getMemoryLocation(Allocation var) { result.getAllocation() = var } @@ -69,10 +72,16 @@ class MemoryLocation extends TMemoryLocation { final string getUniqueId() { result = var.getUniqueId() } - final predicate canReuseSSA() { canReuseSSAForVariable(var) } + final predicate canReuseSsa() { canReuseSsaForVariable(var) } + + /** DEPRECATED: Alias for canReuseSsa */ + deprecated predicate canReuseSSA() { canReuseSsa() } } -predicate canReuseSSAForOldResult(Instruction instr) { none() } +predicate canReuseSsaForOldResult(Instruction instr) { none() } + +/** DEPRECATED: Alias for canReuseSsaForOldResult */ +deprecated predicate canReuseSSAForOldResult = canReuseSsaForOldResult/1; /** * Represents a set of `MemoryLocation`s that cannot overlap with diff --git a/cpp/ql/lib/semmle/code/cpp/rangeanalysis/RangeSSA.qll b/cpp/ql/lib/semmle/code/cpp/rangeanalysis/RangeSSA.qll index d2d2fbd5b3c..02cd5cb7876 100644 --- a/cpp/ql/lib/semmle/code/cpp/rangeanalysis/RangeSSA.qll +++ b/cpp/ql/lib/semmle/code/cpp/rangeanalysis/RangeSSA.qll @@ -29,8 +29,8 @@ private import RangeAnalysisUtils * The SSA logic comes in two versions: the standard SSA and range-analysis RangeSSA. * This class provides the range-analysis SSA logic. */ -library class RangeSSA extends SSAHelper { - RangeSSA() { this = 1 } +library class RangeSsa extends SsaHelper { + RangeSsa() { this = 1 } /** * Add a phi node on the out-edge of a guard. @@ -40,6 +40,9 @@ library class RangeSSA extends SSAHelper { } } +/** DEPRECATED: Alias for RangeSsa */ +deprecated class RangeSSA = RangeSsa; + private predicate guard_defn(VariableAccess v, Expr guard, BasicBlock b, boolean branch) { guardCondition(guard, v, branch) and guardSuccessor(guard, branch, b) @@ -67,22 +70,22 @@ private predicate guardSuccessor(Expr guard, boolean branch, BasicBlock succ) { * nodes. */ class RangeSsaDefinition extends ControlFlowNodeBase { - RangeSsaDefinition() { exists(RangeSSA x | x.ssa_defn(_, this, _, _)) } + RangeSsaDefinition() { exists(RangeSsa x | x.ssa_defn(_, this, _, _)) } /** * Gets a variable corresponding to a SSA StackVariable defined by * this definition. */ - StackVariable getAVariable() { exists(RangeSSA x | x.ssa_defn(result, this, _, _)) } + StackVariable getAVariable() { exists(RangeSsa x | x.ssa_defn(result, this, _, _)) } /** * A string representation of the SSA variable represented by the pair * `(this, v)`. */ - string toString(StackVariable v) { exists(RangeSSA x | result = x.toString(this, v)) } + string toString(StackVariable v) { exists(RangeSsa x | result = x.toString(this, v)) } /** Gets a use of the SSA variable represented by the pair `(this, v)`. */ - VariableAccess getAUse(StackVariable v) { exists(RangeSSA x | result = x.getAUse(this, v)) } + VariableAccess getAUse(StackVariable v) { exists(RangeSsa x | result = x.getAUse(this, v)) } /** Gets the control flow node for this definition. */ ControlFlowNode getDefinition() { result = this } @@ -91,7 +94,7 @@ class RangeSsaDefinition extends ControlFlowNodeBase { BasicBlock getBasicBlock() { result.contains(this.getDefinition()) } /** Whether this definition is a phi node for variable `v`. */ - predicate isPhiNode(StackVariable v) { exists(RangeSSA x | x.phi_node(v, this)) } + predicate isPhiNode(StackVariable v) { exists(RangeSsa x | x.phi_node(v, this)) } /** * DEPRECATED: Use isGuardPhi/4 instead @@ -172,6 +175,6 @@ class RangeSsaDefinition extends ControlFlowNodeBase { * Holds if this definition of the variable `v` reached the end of the basic block `b`. */ predicate reachesEndOfBB(StackVariable v, BasicBlock b) { - exists(RangeSSA x | x.ssaDefinitionReachesEndOfBB(v, this, b)) + exists(RangeSsa x | x.ssaDefinitionReachesEndOfBB(v, this, b)) } } diff --git a/cpp/ql/lib/semmle/code/cpp/valuenumbering/GlobalValueNumberingImpl.qll b/cpp/ql/lib/semmle/code/cpp/valuenumbering/GlobalValueNumberingImpl.qll index f9231e24725..d5e69d31254 100644 --- a/cpp/ql/lib/semmle/code/cpp/valuenumbering/GlobalValueNumberingImpl.qll +++ b/cpp/ql/lib/semmle/code/cpp/valuenumbering/GlobalValueNumberingImpl.qll @@ -89,7 +89,7 @@ private ControlFlowNode getControlFlowEntry(ControlFlowNode node) { * graph so that we can use the dominator tree to find the most recent * side-effect. */ -private predicate sideEffectCFG(ControlFlowNode src, ControlFlowNode dst) { +private predicate sideEffectCfg(ControlFlowNode src, ControlFlowNode dst) { src.getASuccessor() = dst or // Add an edge from the entry point to any node that might have a side @@ -103,7 +103,7 @@ private predicate sideEffectCFG(ControlFlowNode src, ControlFlowNode dst) { * the side-effect CFG. */ private predicate iDomEffect(ControlFlowNode dominator, ControlFlowNode node) = - idominance(functionEntry/1, sideEffectCFG/2)(_, dominator, node) + idominance(functionEntry/1, sideEffectCfg/2)(_, dominator, node) /** * Gets the most recent side effect. To be more precise, `result` is a diff --git a/cpp/ql/src/Likely Bugs/Memory Management/ReturnStackAllocatedMemory.ql b/cpp/ql/src/Likely Bugs/Memory Management/ReturnStackAllocatedMemory.ql index 50da750e9a8..c9f9d981f0f 100644 --- a/cpp/ql/src/Likely Bugs/Memory Management/ReturnStackAllocatedMemory.ql +++ b/cpp/ql/src/Likely Bugs/Memory Management/ReturnStackAllocatedMemory.ql @@ -34,7 +34,7 @@ class ReturnStackAllocatedMemoryConfig extends MustFlowConfiguration { exists(VariableAddressInstruction var, Function func | var = source.asInstruction() and func = var.getEnclosingFunction() and - var.getASTVariable() instanceof StackVariable and + var.getAstVariable() instanceof StackVariable and // Pointer-to-member types aren't properly handled in the dbscheme. not var.getResultType() instanceof PointerToMemberType and // Rule out FPs caused by extraction errors. @@ -84,5 +84,5 @@ where // Only raise an alert if we're returning from the _same_ callable as the on that // declared the stack variable. var.getEnclosingFunction() = sink.getNode().getEnclosingCallable() -select sink.getNode(), source, sink, "May return stack-allocated memory from $@.", var.getAST(), - var.getAST().toString() +select sink.getNode(), source, sink, "May return stack-allocated memory from $@.", var.getAst(), + var.getAst().toString() diff --git a/cpp/ql/src/Likely Bugs/Memory Management/UsingExpiredStackAddress.ql b/cpp/ql/src/Likely Bugs/Memory Management/UsingExpiredStackAddress.ql index af847701f85..27aeabbaf49 100644 --- a/cpp/ql/src/Likely Bugs/Memory Management/UsingExpiredStackAddress.ql +++ b/cpp/ql/src/Likely Bugs/Memory Management/UsingExpiredStackAddress.ql @@ -19,7 +19,7 @@ import semmle.code.cpp.valuenumbering.GlobalValueNumbering import semmle.code.cpp.ir.IR predicate instructionHasVariable(VariableAddressInstruction vai, StackVariable var, Function f) { - var = vai.getASTVariable() and + var = vai.getAstVariable() and f = vai.getEnclosingFunction() and // Pointer-to-member types aren't properly handled in the dbscheme. not vai.getResultType() instanceof PointerToMemberType and @@ -108,7 +108,7 @@ predicate inheritanceConversionTypes( /** Gets the HashCons value of an address computed by `instr`, if any. */ TGlobalAddress globalAddress(Instruction instr) { - result = TGlobalVariable(instr.(VariableAddressInstruction).getASTVariable()) + result = TGlobalVariable(instr.(VariableAddressInstruction).getAstVariable()) or not instr instanceof LoadInstruction and result = globalAddress(instr.(CopyInstruction).getSourceValue()) diff --git a/cpp/ql/src/Likely Bugs/RedundantNullCheckSimple.ql b/cpp/ql/src/Likely Bugs/RedundantNullCheckSimple.ql index 65ba665dff2..8d7a07f4335 100644 --- a/cpp/ql/src/Likely Bugs/RedundantNullCheckSimple.ql +++ b/cpp/ql/src/Likely Bugs/RedundantNullCheckSimple.ql @@ -52,7 +52,7 @@ predicate explicitNullTestOfInstruction(Instruction checked, Instruction bool) { pragma[noinline] predicate candidateResult(LoadInstruction checked, ValueNumber value, IRBlock dominator) { explicitNullTestOfInstruction(checked, _) and - not checked.getAST().isInMacroExpansion() and + not checked.getAst().isInMacroExpansion() and value.getAnInstruction() = checked and dominator.dominates(checked.getBlock()) } diff --git a/cpp/ql/src/Security/CWE/CWE-020/CountUntrustedDataToExternalAPI.ql b/cpp/ql/src/Security/CWE/CWE-020/CountUntrustedDataToExternalAPI.ql index 8c75e8da6e2..bebff32a5c1 100644 --- a/cpp/ql/src/Security/CWE/CWE-020/CountUntrustedDataToExternalAPI.ql +++ b/cpp/ql/src/Security/CWE/CWE-020/CountUntrustedDataToExternalAPI.ql @@ -11,7 +11,7 @@ import cpp import ExternalAPIs -from ExternalAPIUsedWithUntrustedData externalAPI -select externalAPI, count(externalAPI.getUntrustedDataNode()) as numberOfUses, - externalAPI.getNumberOfUntrustedSources() as numberOfUntrustedSources order by +from ExternalApiUsedWithUntrustedData externalApi +select externalApi, count(externalApi.getUntrustedDataNode()) as numberOfUses, + externalApi.getNumberOfUntrustedSources() as numberOfUntrustedSources order by numberOfUntrustedSources desc diff --git a/cpp/ql/src/Security/CWE/CWE-020/ExternalAPIs.qll b/cpp/ql/src/Security/CWE/CWE-020/ExternalAPIs.qll index 29d5b20cfc4..0636dcbe11b 100644 --- a/cpp/ql/src/Security/CWE/CWE-020/ExternalAPIs.qll +++ b/cpp/ql/src/Security/CWE/CWE-020/ExternalAPIs.qll @@ -9,28 +9,31 @@ private import semmle.code.cpp.models.interfaces.Taint import ExternalAPIsSpecific /** A node representing untrusted data being passed to an external API. */ -class UntrustedExternalAPIDataNode extends ExternalAPIDataNode { - UntrustedExternalAPIDataNode() { any(UntrustedDataToExternalAPIConfig c).hasFlow(_, this) } +class UntrustedExternalApiDataNode extends ExternalApiDataNode { + UntrustedExternalApiDataNode() { any(UntrustedDataToExternalApiConfig c).hasFlow(_, this) } /** Gets a source of untrusted data which is passed to this external API data node. */ DataFlow::Node getAnUntrustedSource() { - any(UntrustedDataToExternalAPIConfig c).hasFlow(result, this) + any(UntrustedDataToExternalApiConfig c).hasFlow(result, this) } } -private newtype TExternalAPI = - TExternalAPIParameter(Function f, int index) { - exists(UntrustedExternalAPIDataNode n | +/** DEPRECATED: Alias for UntrustedExternalApiDataNode */ +deprecated class UntrustedExternalAPIDataNode = UntrustedExternalApiDataNode; + +private newtype TExternalApi = + TExternalApiParameter(Function f, int index) { + exists(UntrustedExternalApiDataNode n | f = n.getExternalFunction() and index = n.getIndex() ) } /** An external API which is used with untrusted data. */ -class ExternalAPIUsedWithUntrustedData extends TExternalAPI { +class ExternalApiUsedWithUntrustedData extends TExternalApi { /** Gets a possibly untrusted use of this external API. */ - UntrustedExternalAPIDataNode getUntrustedDataNode() { - this = TExternalAPIParameter(result.getExternalFunction(), result.getIndex()) + UntrustedExternalApiDataNode getUntrustedDataNode() { + this = TExternalApiParameter(result.getExternalFunction(), result.getIndex()) } /** Gets the number of untrusted sources used with this external API. */ @@ -43,8 +46,11 @@ class ExternalAPIUsedWithUntrustedData extends TExternalAPI { exists(Function f, int index, string indexString | if index = -1 then indexString = "qualifier" else indexString = "param " + index | - this = TExternalAPIParameter(f, index) and + this = TExternalApiParameter(f, index) and result = f.toString() + " [" + indexString + "]" ) } } + +/** DEPRECATED: Alias for ExternalApiUsedWithUntrustedData */ +deprecated class ExternalAPIUsedWithUntrustedData = ExternalApiUsedWithUntrustedData; diff --git a/cpp/ql/src/Security/CWE/CWE-020/ExternalAPIsSpecific.qll b/cpp/ql/src/Security/CWE/CWE-020/ExternalAPIsSpecific.qll index 5e710c9548d..db236b510b9 100644 --- a/cpp/ql/src/Security/CWE/CWE-020/ExternalAPIsSpecific.qll +++ b/cpp/ql/src/Security/CWE/CWE-020/ExternalAPIsSpecific.qll @@ -8,11 +8,11 @@ import semmle.code.cpp.models.interfaces.DataFlow import SafeExternalAPIFunction /** A node representing untrusted data being passed to an external API. */ -class ExternalAPIDataNode extends DataFlow::Node { +class ExternalApiDataNode extends DataFlow::Node { Call call; int i; - ExternalAPIDataNode() { + ExternalApiDataNode() { // Argument to call to a function ( this.asExpr() = call.getArgument(i) @@ -27,7 +27,7 @@ class ExternalAPIDataNode extends DataFlow::Node { not f instanceof DataFlowFunction and not f instanceof TaintFunction and // Not a call to a known safe external API - not f instanceof SafeExternalAPIFunction + not f instanceof SafeExternalApiFunction ) } @@ -41,9 +41,12 @@ class ExternalAPIDataNode extends DataFlow::Node { string getFunctionDescription() { result = this.getExternalFunction().toString() } } -/** A configuration for tracking flow from `RemoteFlowSource`s to `ExternalAPIDataNode`s. */ -class UntrustedDataToExternalAPIConfig extends TaintTracking::Configuration { - UntrustedDataToExternalAPIConfig() { this = "UntrustedDataToExternalAPIConfig" } +/** DEPRECATED: Alias for ExternalApiDataNode */ +deprecated class ExternalAPIDataNode = ExternalApiDataNode; + +/** A configuration for tracking flow from `RemoteFlowSource`s to `ExternalApiDataNode`s. */ +class UntrustedDataToExternalApiConfig extends TaintTracking::Configuration { + UntrustedDataToExternalApiConfig() { this = "UntrustedDataToExternalAPIConfig" } override predicate isSource(DataFlow::Node source) { exists(RemoteFlowSourceFunction remoteFlow | @@ -52,5 +55,8 @@ class UntrustedDataToExternalAPIConfig extends TaintTracking::Configuration { ) } - override predicate isSink(DataFlow::Node sink) { sink instanceof ExternalAPIDataNode } + override predicate isSink(DataFlow::Node sink) { sink instanceof ExternalApiDataNode } } + +/** DEPRECATED: Alias for UntrustedDataToExternalApiConfig */ +deprecated class UntrustedDataToExternalAPIConfig = UntrustedDataToExternalApiConfig; diff --git a/cpp/ql/src/Security/CWE/CWE-020/IRCountUntrustedDataToExternalAPI.ql b/cpp/ql/src/Security/CWE/CWE-020/IRCountUntrustedDataToExternalAPI.ql index 4d0c2174809..69911c22c6a 100644 --- a/cpp/ql/src/Security/CWE/CWE-020/IRCountUntrustedDataToExternalAPI.ql +++ b/cpp/ql/src/Security/CWE/CWE-020/IRCountUntrustedDataToExternalAPI.ql @@ -11,7 +11,7 @@ import cpp import ir.ExternalAPIs -from ExternalAPIUsedWithUntrustedData externalAPI -select externalAPI, count(externalAPI.getUntrustedDataNode()) as numberOfUses, - externalAPI.getNumberOfUntrustedSources() as numberOfUntrustedSources order by +from ExternalApiUsedWithUntrustedData externalApi +select externalApi, count(externalApi.getUntrustedDataNode()) as numberOfUses, + externalApi.getNumberOfUntrustedSources() as numberOfUntrustedSources order by numberOfUntrustedSources desc diff --git a/cpp/ql/src/Security/CWE/CWE-020/IRUntrustedDataToExternalAPI.ql b/cpp/ql/src/Security/CWE/CWE-020/IRUntrustedDataToExternalAPI.ql index 47a0bf14b7f..4860fc5356f 100644 --- a/cpp/ql/src/Security/CWE/CWE-020/IRUntrustedDataToExternalAPI.ql +++ b/cpp/ql/src/Security/CWE/CWE-020/IRUntrustedDataToExternalAPI.ql @@ -15,8 +15,8 @@ import ir.ExternalAPIs import semmle.code.cpp.security.FlowSources import DataFlow::PathGraph -from UntrustedDataToExternalAPIConfig config, DataFlow::PathNode source, DataFlow::PathNode sink +from UntrustedDataToExternalApiConfig config, DataFlow::PathNode source, DataFlow::PathNode sink where config.hasFlowPath(source, sink) select sink, source, sink, - "Call to " + sink.getNode().(ExternalAPIDataNode).getExternalFunction().toString() + + "Call to " + sink.getNode().(ExternalApiDataNode).getExternalFunction().toString() + " with untrusted data from $@.", source, source.getNode().(RemoteFlowSource).getSourceType() diff --git a/cpp/ql/src/Security/CWE/CWE-020/SafeExternalAPIFunction.qll b/cpp/ql/src/Security/CWE/CWE-020/SafeExternalAPIFunction.qll index 5eb0b23d914..de59e82e552 100644 --- a/cpp/ql/src/Security/CWE/CWE-020/SafeExternalAPIFunction.qll +++ b/cpp/ql/src/Security/CWE/CWE-020/SafeExternalAPIFunction.qll @@ -8,11 +8,14 @@ private import semmle.code.cpp.models.interfaces.SideEffect /** * A `Function` that is considered a "safe" external API from a security perspective. */ -abstract class SafeExternalAPIFunction extends Function { } +abstract class SafeExternalApiFunction extends Function { } + +/** DEPRECATED: Alias for SafeExternalApiFunction */ +deprecated class SafeExternalAPIFunction = SafeExternalApiFunction; /** The default set of "safe" external APIs. */ -private class DefaultSafeExternalAPIFunction extends SafeExternalAPIFunction { - DefaultSafeExternalAPIFunction() { +private class DefaultSafeExternalApiFunction extends SafeExternalApiFunction { + DefaultSafeExternalApiFunction() { // If a function does not write to any of its arguments, we consider it safe to // pass untrusted data to it. This means that string functions such as `strcmp` // and `strlen`, as well as memory functions such as `memcmp`, are considered safe. diff --git a/cpp/ql/src/Security/CWE/CWE-020/UntrustedDataToExternalAPI.ql b/cpp/ql/src/Security/CWE/CWE-020/UntrustedDataToExternalAPI.ql index b85a5b26a7f..01067425190 100644 --- a/cpp/ql/src/Security/CWE/CWE-020/UntrustedDataToExternalAPI.ql +++ b/cpp/ql/src/Security/CWE/CWE-020/UntrustedDataToExternalAPI.ql @@ -14,8 +14,8 @@ import semmle.code.cpp.dataflow.TaintTracking import ExternalAPIs import DataFlow::PathGraph -from UntrustedDataToExternalAPIConfig config, DataFlow::PathNode source, DataFlow::PathNode sink +from UntrustedDataToExternalApiConfig config, DataFlow::PathNode source, DataFlow::PathNode sink where config.hasFlowPath(source, sink) select sink, source, sink, - "Call to " + sink.getNode().(ExternalAPIDataNode).getExternalFunction().toString() + + "Call to " + sink.getNode().(ExternalApiDataNode).getExternalFunction().toString() + " with untrusted data from $@.", source, source.toString() diff --git a/cpp/ql/src/Security/CWE/CWE-020/ir/ExternalAPIs.qll b/cpp/ql/src/Security/CWE/CWE-020/ir/ExternalAPIs.qll index 29d5b20cfc4..0636dcbe11b 100644 --- a/cpp/ql/src/Security/CWE/CWE-020/ir/ExternalAPIs.qll +++ b/cpp/ql/src/Security/CWE/CWE-020/ir/ExternalAPIs.qll @@ -9,28 +9,31 @@ private import semmle.code.cpp.models.interfaces.Taint import ExternalAPIsSpecific /** A node representing untrusted data being passed to an external API. */ -class UntrustedExternalAPIDataNode extends ExternalAPIDataNode { - UntrustedExternalAPIDataNode() { any(UntrustedDataToExternalAPIConfig c).hasFlow(_, this) } +class UntrustedExternalApiDataNode extends ExternalApiDataNode { + UntrustedExternalApiDataNode() { any(UntrustedDataToExternalApiConfig c).hasFlow(_, this) } /** Gets a source of untrusted data which is passed to this external API data node. */ DataFlow::Node getAnUntrustedSource() { - any(UntrustedDataToExternalAPIConfig c).hasFlow(result, this) + any(UntrustedDataToExternalApiConfig c).hasFlow(result, this) } } -private newtype TExternalAPI = - TExternalAPIParameter(Function f, int index) { - exists(UntrustedExternalAPIDataNode n | +/** DEPRECATED: Alias for UntrustedExternalApiDataNode */ +deprecated class UntrustedExternalAPIDataNode = UntrustedExternalApiDataNode; + +private newtype TExternalApi = + TExternalApiParameter(Function f, int index) { + exists(UntrustedExternalApiDataNode n | f = n.getExternalFunction() and index = n.getIndex() ) } /** An external API which is used with untrusted data. */ -class ExternalAPIUsedWithUntrustedData extends TExternalAPI { +class ExternalApiUsedWithUntrustedData extends TExternalApi { /** Gets a possibly untrusted use of this external API. */ - UntrustedExternalAPIDataNode getUntrustedDataNode() { - this = TExternalAPIParameter(result.getExternalFunction(), result.getIndex()) + UntrustedExternalApiDataNode getUntrustedDataNode() { + this = TExternalApiParameter(result.getExternalFunction(), result.getIndex()) } /** Gets the number of untrusted sources used with this external API. */ @@ -43,8 +46,11 @@ class ExternalAPIUsedWithUntrustedData extends TExternalAPI { exists(Function f, int index, string indexString | if index = -1 then indexString = "qualifier" else indexString = "param " + index | - this = TExternalAPIParameter(f, index) and + this = TExternalApiParameter(f, index) and result = f.toString() + " [" + indexString + "]" ) } } + +/** DEPRECATED: Alias for ExternalApiUsedWithUntrustedData */ +deprecated class ExternalAPIUsedWithUntrustedData = ExternalApiUsedWithUntrustedData; diff --git a/cpp/ql/src/Security/CWE/CWE-020/ir/ExternalAPIsSpecific.qll b/cpp/ql/src/Security/CWE/CWE-020/ir/ExternalAPIsSpecific.qll index 994e76d6ced..b0fa685d1a4 100644 --- a/cpp/ql/src/Security/CWE/CWE-020/ir/ExternalAPIsSpecific.qll +++ b/cpp/ql/src/Security/CWE/CWE-020/ir/ExternalAPIsSpecific.qll @@ -8,11 +8,11 @@ private import semmle.code.cpp.models.interfaces.DataFlow import SafeExternalAPIFunction /** A node representing untrusted data being passed to an external API. */ -class ExternalAPIDataNode extends DataFlow::Node { +class ExternalApiDataNode extends DataFlow::Node { Call call; int i; - ExternalAPIDataNode() { + ExternalApiDataNode() { // Argument to call to a function ( this.asExpr() = call.getArgument(i) @@ -27,7 +27,7 @@ class ExternalAPIDataNode extends DataFlow::Node { not f instanceof DataFlowFunction and not f instanceof TaintFunction and // Not a call to a known safe external API - not f instanceof SafeExternalAPIFunction + not f instanceof SafeExternalApiFunction ) } @@ -41,11 +41,17 @@ class ExternalAPIDataNode extends DataFlow::Node { string getFunctionDescription() { result = this.getExternalFunction().toString() } } -/** A configuration for tracking flow from `RemoteFlowSource`s to `ExternalAPIDataNode`s. */ -class UntrustedDataToExternalAPIConfig extends TaintTracking::Configuration { - UntrustedDataToExternalAPIConfig() { this = "UntrustedDataToExternalAPIConfigIR" } +/** DEPRECATED: Alias for ExternalApiDataNode */ +deprecated class ExternalAPIDataNode = ExternalApiDataNode; + +/** A configuration for tracking flow from `RemoteFlowSource`s to `ExternalApiDataNode`s. */ +class UntrustedDataToExternalApiConfig extends TaintTracking::Configuration { + UntrustedDataToExternalApiConfig() { this = "UntrustedDataToExternalAPIConfigIR" } override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource } - override predicate isSink(DataFlow::Node sink) { sink instanceof ExternalAPIDataNode } + override predicate isSink(DataFlow::Node sink) { sink instanceof ExternalApiDataNode } } + +/** DEPRECATED: Alias for UntrustedDataToExternalApiConfig */ +deprecated class UntrustedDataToExternalAPIConfig = UntrustedDataToExternalApiConfig; diff --git a/cpp/ql/src/Security/CWE/CWE-020/ir/SafeExternalAPIFunction.qll b/cpp/ql/src/Security/CWE/CWE-020/ir/SafeExternalAPIFunction.qll index 5eb0b23d914..de59e82e552 100644 --- a/cpp/ql/src/Security/CWE/CWE-020/ir/SafeExternalAPIFunction.qll +++ b/cpp/ql/src/Security/CWE/CWE-020/ir/SafeExternalAPIFunction.qll @@ -8,11 +8,14 @@ private import semmle.code.cpp.models.interfaces.SideEffect /** * A `Function` that is considered a "safe" external API from a security perspective. */ -abstract class SafeExternalAPIFunction extends Function { } +abstract class SafeExternalApiFunction extends Function { } + +/** DEPRECATED: Alias for SafeExternalApiFunction */ +deprecated class SafeExternalAPIFunction = SafeExternalApiFunction; /** The default set of "safe" external APIs. */ -private class DefaultSafeExternalAPIFunction extends SafeExternalAPIFunction { - DefaultSafeExternalAPIFunction() { +private class DefaultSafeExternalApiFunction extends SafeExternalApiFunction { + DefaultSafeExternalApiFunction() { // If a function does not write to any of its arguments, we consider it safe to // pass untrusted data to it. This means that string functions such as `strcmp` // and `strlen`, as well as memory functions such as `memcmp`, are considered safe. diff --git a/cpp/ql/src/Security/CWE/CWE-089/SqlTainted.ql b/cpp/ql/src/Security/CWE/CWE-089/SqlTainted.ql index 92c8b9a2bd5..1f8a5023864 100644 --- a/cpp/ql/src/Security/CWE/CWE-089/SqlTainted.ql +++ b/cpp/ql/src/Security/CWE/CWE-089/SqlTainted.ql @@ -18,15 +18,15 @@ import semmle.code.cpp.security.FunctionWithWrappers import semmle.code.cpp.security.TaintTracking import TaintedWithPath -class SQLLikeFunction extends FunctionWithWrappers { - SQLLikeFunction() { sqlArgument(this.getName(), _) } +class SqlLikeFunction extends FunctionWithWrappers { + SqlLikeFunction() { sqlArgument(this.getName(), _) } override predicate interestingArg(int arg) { sqlArgument(this.getName(), arg) } } class Configuration extends TaintTrackingConfiguration { override predicate isSink(Element tainted) { - exists(SQLLikeFunction runSql | runSql.outermostWrapperFunctionCall(tainted, _)) + exists(SqlLikeFunction runSql | runSql.outermostWrapperFunctionCall(tainted, _)) } override predicate isBarrier(Expr e) { @@ -43,7 +43,7 @@ class Configuration extends TaintTrackingConfiguration { } from - SQLLikeFunction runSql, Expr taintedArg, Expr taintSource, PathNode sourceNode, PathNode sinkNode, + SqlLikeFunction runSql, Expr taintedArg, Expr taintSource, PathNode sourceNode, PathNode sinkNode, string taintCause, string callChain where runSql.outermostWrapperFunctionCall(taintedArg, callChain) and diff --git a/cpp/ql/src/Security/CWE/CWE-497/ExposedSystemData.ql b/cpp/ql/src/Security/CWE/CWE-497/ExposedSystemData.ql index 7a50d4f15f3..31a152a167a 100644 --- a/cpp/ql/src/Security/CWE/CWE-497/ExposedSystemData.ql +++ b/cpp/ql/src/Security/CWE/CWE-497/ExposedSystemData.ql @@ -46,8 +46,8 @@ class EnvData extends SystemData { /** * Data originating from a call to `mysql_get_client_info()`. */ -class SQLClientInfo extends SystemData { - SQLClientInfo() { this.(FunctionCall).getTarget().hasName("mysql_get_client_info") } +class SqlClientInfo extends SystemData { + SqlClientInfo() { this.(FunctionCall).getTarget().hasName("mysql_get_client_info") } override Expr getAnExpr() { result = this } } @@ -63,8 +63,8 @@ private predicate sqlConnectInfo(FunctionCall source, VariableAccess use) { /** * Data passed into an SQL connect function. */ -class SQLConnectInfo extends SystemData { - SQLConnectInfo() { sqlConnectInfo(this, _) } +class SqlConnectInfo extends SystemData { + SqlConnectInfo() { sqlConnectInfo(this, _) } override Expr getAnExpr() { sqlConnectInfo(this, result) } } diff --git a/cpp/ql/src/jsf/4.10 Classes/AV Rule 97.ql b/cpp/ql/src/jsf/4.10 Classes/AV Rule 97.ql index 872a7443e6e..58b83e4bd13 100644 --- a/cpp/ql/src/jsf/4.10 Classes/AV Rule 97.ql +++ b/cpp/ql/src/jsf/4.10 Classes/AV Rule 97.ql @@ -27,13 +27,13 @@ predicate containsArray(Type t) { ) } -predicate functionAPIViolation(MemberFunction f) { +predicate functionApiViolation(MemberFunction f) { f.isPublic() and containsArray(f.getAParameter().getType()) } from MemberFunction m where - functionAPIViolation(m) and + functionApiViolation(m) and not m.getDeclaringType() instanceof Struct select m, "Raw arrays should not be used in interfaces. A container class should be used instead." diff --git a/cpp/ql/src/jsf/4.24 Control Flow Structures/AV Rule 186.ql b/cpp/ql/src/jsf/4.24 Control Flow Structures/AV Rule 186.ql index ed713c4b109..4c1f8cfdd7f 100644 --- a/cpp/ql/src/jsf/4.24 Control Flow Structures/AV Rule 186.ql +++ b/cpp/ql/src/jsf/4.24 Control Flow Structures/AV Rule 186.ql @@ -12,13 +12,13 @@ import cpp // whether f is to be considered an API entry point, and hence reachable by default -predicate isAPI(Function f) { +predicate isApi(Function f) { f.hasName("main") or f.(MemberFunction).hasSpecifier("public") } predicate unusedFunction(Function f) { - not isAPI(f) and + not isApi(f) and not exists(FunctionCall c | c.getTarget() = f) and not exists(Access acc | acc.getTarget() = f) and f.hasDefinition() diff --git a/cpp/ql/src/printAst.ql b/cpp/ql/src/printAst.ql index f800fa3be3e..ae6b3052ec7 100644 --- a/cpp/ql/src/printAst.ql +++ b/cpp/ql/src/printAst.ql @@ -16,7 +16,7 @@ import definitions */ external string selectedSourceFile(); -class Cfg extends PrintASTConfiguration { +class Cfg extends PrintAstConfiguration { /** * Holds if the AST for `func` should be printed. * Print All functions from the selected file. diff --git a/cpp/ql/test/TestUtilities/dataflow/FlowTestCommon.qll b/cpp/ql/test/TestUtilities/dataflow/FlowTestCommon.qll index 87602ef0e4c..5841412331d 100644 --- a/cpp/ql/test/TestUtilities/dataflow/FlowTestCommon.qll +++ b/cpp/ql/test/TestUtilities/dataflow/FlowTestCommon.qll @@ -42,8 +42,8 @@ class IRFlowTest extends InlineExpectationsTest { } } -class ASTFlowTest extends InlineExpectationsTest { - ASTFlowTest() { this = "ASTFlowTest" } +class AstFlowTest extends InlineExpectationsTest { + AstFlowTest() { this = "ASTFlowTest" } override string getARelevantTag() { result = "ast" } @@ -69,3 +69,6 @@ class ASTFlowTest extends InlineExpectationsTest { ) } } + +/** DEPRECATED: Alias for AstFlowTest */ +deprecated class ASTFlowTest = AstFlowTest; diff --git a/cpp/ql/test/library-tests/dataflow/DefaultTaintTracking/annotate_path_to_sink/tainted.ql b/cpp/ql/test/library-tests/dataflow/DefaultTaintTracking/annotate_path_to_sink/tainted.ql index c1477d788ca..1737bb0bb33 100644 --- a/cpp/ql/test/library-tests/dataflow/DefaultTaintTracking/annotate_path_to_sink/tainted.ql +++ b/cpp/ql/test/library-tests/dataflow/DefaultTaintTracking/annotate_path_to_sink/tainted.ql @@ -67,8 +67,8 @@ class IRDefaultTaintTrackingTest extends InlineExpectationsTest { } } -class ASTTaintTrackingTest extends InlineExpectationsTest { - ASTTaintTrackingTest() { this = "ASTTaintTrackingTest" } +class AstTaintTrackingTest extends InlineExpectationsTest { + AstTaintTrackingTest() { this = "ASTTaintTrackingTest" } override string getARelevantTag() { result = "ast" } diff --git a/cpp/ql/test/library-tests/dataflow/DefaultTaintTracking/annotate_sinks_only/tainted.ql b/cpp/ql/test/library-tests/dataflow/DefaultTaintTracking/annotate_sinks_only/tainted.ql index 5784906862b..61014bbd48f 100644 --- a/cpp/ql/test/library-tests/dataflow/DefaultTaintTracking/annotate_sinks_only/tainted.ql +++ b/cpp/ql/test/library-tests/dataflow/DefaultTaintTracking/annotate_sinks_only/tainted.ql @@ -55,8 +55,8 @@ class IRDefaultTaintTrackingTest extends InlineExpectationsTest { } } -class ASTTaintTrackingTest extends InlineExpectationsTest { - ASTTaintTrackingTest() { this = "ASTTaintTrackingTest" } +class AstTaintTrackingTest extends InlineExpectationsTest { + AstTaintTrackingTest() { this = "ASTTaintTrackingTest" } override string getARelevantTag() { result = "ast" } diff --git a/cpp/ql/test/library-tests/dataflow/DefaultTaintTracking/globals/global.ql b/cpp/ql/test/library-tests/dataflow/DefaultTaintTracking/globals/global.ql index 953b15a9f9c..a9a4a1af231 100644 --- a/cpp/ql/test/library-tests/dataflow/DefaultTaintTracking/globals/global.ql +++ b/cpp/ql/test/library-tests/dataflow/DefaultTaintTracking/globals/global.ql @@ -27,8 +27,8 @@ class IRGlobalDefaultTaintTrackingTest extends InlineExpectationsTest { } } -class ASTGlobalDefaultTaintTrackingTest extends InlineExpectationsTest { - ASTGlobalDefaultTaintTrackingTest() { this = "ASTGlobalDefaultTaintTrackingTest" } +class AstGlobalDefaultTaintTrackingTest extends InlineExpectationsTest { + AstGlobalDefaultTaintTrackingTest() { this = "ASTGlobalDefaultTaintTrackingTest" } override string getARelevantTag() { result = "ast" } diff --git a/cpp/ql/test/library-tests/dataflow/dataflow-tests/test.ql b/cpp/ql/test/library-tests/dataflow/dataflow-tests/test.ql index 331956083ad..63c20affad1 100644 --- a/cpp/ql/test/library-tests/dataflow/dataflow-tests/test.ql +++ b/cpp/ql/test/library-tests/dataflow/dataflow-tests/test.ql @@ -1,6 +1,6 @@ import TestUtilities.dataflow.FlowTestCommon -module ASTTest { +module AstTest { private import semmle.code.cpp.dataflow.DataFlow /** @@ -18,8 +18,8 @@ module ASTTest { } /** Common data flow configuration to be used by tests. */ - class ASTTestAllocationConfig extends DataFlow::Configuration { - ASTTestAllocationConfig() { this = "ASTTestAllocationConfig" } + class AstTestAllocationConfig extends DataFlow::Configuration { + AstTestAllocationConfig() { this = "ASTTestAllocationConfig" } override predicate isSource(DataFlow::Node source) { source.asExpr().(FunctionCall).getTarget().getName() = "source" @@ -100,10 +100,10 @@ module IRTest { } private predicate readsVariable(LoadInstruction load, Variable var) { - load.getSourceAddress().(VariableAddressInstruction).getASTVariable() = var + load.getSourceAddress().(VariableAddressInstruction).getAstVariable() = var } private predicate writesVariable(StoreInstruction store, Variable var) { - store.getDestinationAddress().(VariableAddressInstruction).getASTVariable() = var + store.getDestinationAddress().(VariableAddressInstruction).getAstVariable() = var } } diff --git a/cpp/ql/test/library-tests/dataflow/fields/ASTConfiguration.qll b/cpp/ql/test/library-tests/dataflow/fields/ASTConfiguration.qll index 67017f63abd..39d6cff3492 100644 --- a/cpp/ql/test/library-tests/dataflow/fields/ASTConfiguration.qll +++ b/cpp/ql/test/library-tests/dataflow/fields/ASTConfiguration.qll @@ -1,8 +1,8 @@ private import semmle.code.cpp.dataflow.DataFlow private import DataFlow -class ASTConf extends Configuration { - ASTConf() { this = "ASTFieldFlowConf" } +class AstConf extends Configuration { + AstConf() { this = "ASTFieldFlowConf" } override predicate isSource(Node src) { src.asExpr() instanceof NewExpr @@ -30,3 +30,6 @@ class ASTConf extends Configuration { b.asExpr().(AddressOfExpr).getOperand() = a.asExpr() } } + +/** DEPRECATED: Alias for AstConf */ +deprecated class ASTConf = AstConf; diff --git a/cpp/ql/test/library-tests/dataflow/fields/Nodes.qll b/cpp/ql/test/library-tests/dataflow/fields/Nodes.qll index eb6f3247b82..2c3186b3dfa 100644 --- a/cpp/ql/test/library-tests/dataflow/fields/Nodes.qll +++ b/cpp/ql/test/library-tests/dataflow/fields/Nodes.qll @@ -3,7 +3,7 @@ private import semmle.code.cpp.dataflow.DataFlow as AST private import cpp private newtype TNode = - TASTNode(AST::DataFlow::Node n) or + TAstNode(AST::DataFlow::Node n) or TIRNode(IR::DataFlow::Node n) class Node extends TNode { @@ -11,23 +11,32 @@ class Node extends TNode { IR::DataFlow::Node asIR() { none() } - AST::DataFlow::Node asAST() { none() } + AST::DataFlow::Node asAst() { none() } + + /** DEPRECATED: Alias for asAst */ + deprecated AST::DataFlow::Node asAST() { result = asAst() } Location getLocation() { none() } } -class ASTNode extends Node, TASTNode { +class AstNode extends Node, TAstNode { AST::DataFlow::Node n; - ASTNode() { this = TASTNode(n) } + AstNode() { this = TAstNode(n) } override string toString() { result = n.toString() } - override AST::DataFlow::Node asAST() { result = n } + override AST::DataFlow::Node asAst() { result = n } + + /** DEPRECATED: Alias for asAst */ + deprecated override AST::DataFlow::Node asAST() { result = asAst() } override Location getLocation() { result = n.getLocation() } } +/** DEPRECATED: Alias for AstNode */ +deprecated class ASTNode = AstNode; + class IRNode extends Node, TIRNode { IR::DataFlow::Node n; diff --git a/cpp/ql/test/library-tests/dataflow/fields/flow.ql b/cpp/ql/test/library-tests/dataflow/fields/flow.ql index 23a7281c718..f902afd33db 100644 --- a/cpp/ql/test/library-tests/dataflow/fields/flow.ql +++ b/cpp/ql/test/library-tests/dataflow/fields/flow.ql @@ -1,6 +1,6 @@ import TestUtilities.dataflow.FlowTestCommon -module ASTTest { +module AstTest { private import ASTConfiguration } diff --git a/cpp/ql/test/library-tests/dataflow/fields/partial-definition-diff.ql b/cpp/ql/test/library-tests/dataflow/fields/partial-definition-diff.ql index fae4b06da5a..3baba1a02ff 100644 --- a/cpp/ql/test/library-tests/dataflow/fields/partial-definition-diff.ql +++ b/cpp/ql/test/library-tests/dataflow/fields/partial-definition-diff.ql @@ -7,8 +7,8 @@ import semmle.code.cpp.ir.dataflow.DataFlow::DataFlow as IR import semmle.code.cpp.dataflow.DataFlow::DataFlow as AST import Nodes -class ASTPartialDefNode extends ASTNode { - ASTPartialDefNode() { exists(n.asPartialDefinition()) } +class AstPartialDefNode extends AstNode { + AstPartialDefNode() { exists(n.asPartialDefinition()) } override string toString() { result = n.asPartialDefinition().toString() } } @@ -29,7 +29,7 @@ where msg = "IR only" or exists(AST::Node astNode, Expr partial | - node.asAST() = astNode and + node.asAst() = astNode and partial = astNode.asPartialDefinition() and not exists(IR::Node otherNode | otherNode.asPartialDefinition() = partial) ) and diff --git a/cpp/ql/test/library-tests/dataflow/fields/path-flow.ql b/cpp/ql/test/library-tests/dataflow/fields/path-flow.ql index 1772a3d6ad2..b1aeadfbb60 100644 --- a/cpp/ql/test/library-tests/dataflow/fields/path-flow.ql +++ b/cpp/ql/test/library-tests/dataflow/fields/path-flow.ql @@ -7,6 +7,6 @@ import ASTConfiguration import cpp import DataFlow::PathGraph -from DataFlow::PathNode src, DataFlow::PathNode sink, ASTConf conf +from DataFlow::PathNode src, DataFlow::PathNode sink, AstConf conf where conf.hasFlowPath(src, sink) select sink, src, sink, sink + " flows from $@", src, src.toString() diff --git a/cpp/ql/test/library-tests/dataflow/smart-pointers-taint/taint.ql b/cpp/ql/test/library-tests/dataflow/smart-pointers-taint/taint.ql index 4f18139b2af..d16552d983d 100644 --- a/cpp/ql/test/library-tests/dataflow/smart-pointers-taint/taint.ql +++ b/cpp/ql/test/library-tests/dataflow/smart-pointers-taint/taint.ql @@ -1,10 +1,10 @@ import TestUtilities.dataflow.FlowTestCommon -module ASTTest { +module AstTest { private import semmle.code.cpp.dataflow.TaintTracking - class ASTSmartPointerTaintConfig extends TaintTracking::Configuration { - ASTSmartPointerTaintConfig() { this = "ASTSmartPointerTaintConfig" } + class AstSmartPointerTaintConfig extends TaintTracking::Configuration { + AstSmartPointerTaintConfig() { this = "ASTSmartPointerTaintConfig" } override predicate isSource(DataFlow::Node source) { source.asExpr().(FunctionCall).getTarget().getName() = "source" diff --git a/cpp/ql/test/library-tests/dataflow/taint-tests/taint.ql b/cpp/ql/test/library-tests/dataflow/taint-tests/taint.ql index 4bf7420a9fd..bd513adcef2 100644 --- a/cpp/ql/test/library-tests/dataflow/taint-tests/taint.ql +++ b/cpp/ql/test/library-tests/dataflow/taint-tests/taint.ql @@ -38,13 +38,13 @@ module TaintModels { } } -module ASTTest { +module AstTest { private import semmle.code.cpp.dataflow.TaintTracking private import semmle.code.cpp.models.interfaces.Taint /** Common data flow configuration to be used by tests. */ - class ASTTestAllocationConfig extends TaintTracking::Configuration { - ASTTestAllocationConfig() { this = "ASTTestAllocationConfig" } + class AstTestAllocationConfig extends TaintTracking::Configuration { + AstTestAllocationConfig() { this = "ASTTestAllocationConfig" } override predicate isSource(DataFlow::Node source) { source.asExpr().(FunctionCall).getTarget().getName() = "source" diff --git a/cpp/ql/test/library-tests/depends_initializers/InitializerCFG.ql b/cpp/ql/test/library-tests/depends_initializers/InitializerCFG.ql index fdb42979dc5..a9c52dd8223 100644 --- a/cpp/ql/test/library-tests/depends_initializers/InitializerCFG.ql +++ b/cpp/ql/test/library-tests/depends_initializers/InitializerCFG.ql @@ -1,7 +1,7 @@ import cpp -Function getCFGFunction(Initializer i) { result = i.getASuccessor*() } +Function getCfgFunction(Initializer i) { result = i.getASuccessor*() } from Initializer i, string f -where if exists(getCFGFunction(i)) then f = getCFGFunction(i).toString() else f = "" +where if exists(getCfgFunction(i)) then f = getCfgFunction(i).toString() else f = "" select i, f diff --git a/cpp/ql/test/library-tests/ir/ir/PrintAST.ql b/cpp/ql/test/library-tests/ir/ir/PrintAST.ql index e107c80de02..471b12ed3e5 100644 --- a/cpp/ql/test/library-tests/ir/ir/PrintAST.ql +++ b/cpp/ql/test/library-tests/ir/ir/PrintAST.ql @@ -6,6 +6,6 @@ private import cpp private import semmle.code.cpp.PrintAST private import PrintConfig -private class PrintConfig extends PrintASTConfiguration { +private class PrintConfig extends PrintAstConfiguration { override predicate shouldPrintFunction(Function func) { shouldDumpFunction(func) } } diff --git a/cpp/ql/test/library-tests/ir/points_to/points_to.ql b/cpp/ql/test/library-tests/ir/points_to/points_to.ql index b639a235ee8..6cc7b7efb34 100644 --- a/cpp/ql/test/library-tests/ir/points_to/points_to.ql +++ b/cpp/ql/test/library-tests/ir/points_to/points_to.ql @@ -40,7 +40,7 @@ module Raw { } } -module UnaliasedSSA { +module UnaliasedSsa { private import semmle.code.cpp.ir.implementation.unaliased_ssa.IR private import semmle.code.cpp.ir.implementation.aliased_ssa.internal.AliasedSSA @@ -49,8 +49,8 @@ module UnaliasedSSA { result = getOperandMemoryLocation(instr.getAnOperand()) } - class UnaliasedSSAPointsToTest extends InlineExpectationsTest { - UnaliasedSSAPointsToTest() { this = "UnaliasedSSAPointsToTest" } + class UnaliasedSsaPointsToTest extends InlineExpectationsTest { + UnaliasedSsaPointsToTest() { this = "UnaliasedSSAPointsToTest" } override string getARelevantTag() { result = "ussa" } diff --git a/csharp/ql/lib/semmle/code/asp/WebConfig.qll b/csharp/ql/lib/semmle/code/asp/WebConfig.qll index 16d5393afc2..024d60ca450 100644 --- a/csharp/ql/lib/semmle/code/asp/WebConfig.qll +++ b/csharp/ql/lib/semmle/code/asp/WebConfig.qll @@ -7,67 +7,88 @@ import csharp /** * A `Web.config` file. */ -class WebConfigXML extends XMLFile { - WebConfigXML() { this.getName().matches("%Web.config") } +class WebConfigXml extends XMLFile { + WebConfigXml() { this.getName().matches("%Web.config") } } +/** DEPRECATED: Alias for WebConfigXml */ +deprecated class WebConfigXML = WebConfigXml; + /** A `` tag in an ASP.NET configuration file. */ -class ConfigurationXMLElement extends XMLElement { - ConfigurationXMLElement() { this.getName().toLowerCase() = "configuration" } +class ConfigurationXmlElement extends XMLElement { + ConfigurationXmlElement() { this.getName().toLowerCase() = "configuration" } } +/** DEPRECATED: Alias for ConfigurationXmlElement */ +deprecated class ConfigurationXMLElement = ConfigurationXmlElement; + /** A `` tag in an ASP.NET configuration file. */ -class LocationXMLElement extends XMLElement { - LocationXMLElement() { - this.getParent() instanceof ConfigurationXMLElement and +class LocationXmlElement extends XMLElement { + LocationXmlElement() { + this.getParent() instanceof ConfigurationXmlElement and this.getName().toLowerCase() = "location" } } +/** DEPRECATED: Alias for LocationXmlElement */ +deprecated class LocationXMLElement = LocationXmlElement; + /** A `` tag in an ASP.NET configuration file. */ -class SystemWebXMLElement extends XMLElement { - SystemWebXMLElement() { +class SystemWebXmlElement extends XMLElement { + SystemWebXmlElement() { ( - this.getParent() instanceof ConfigurationXMLElement + this.getParent() instanceof ConfigurationXmlElement or - this.getParent() instanceof LocationXMLElement + this.getParent() instanceof LocationXmlElement ) and this.getName().toLowerCase() = "system.web" } } +/** DEPRECATED: Alias for SystemWebXmlElement */ +deprecated class SystemWebXMLElement = SystemWebXmlElement; + /** A `` tag in an ASP.NET configuration file. */ -class SystemWebServerXMLElement extends XMLElement { - SystemWebServerXMLElement() { +class SystemWebServerXmlElement extends XMLElement { + SystemWebServerXmlElement() { ( - this.getParent() instanceof ConfigurationXMLElement + this.getParent() instanceof ConfigurationXmlElement or - this.getParent() instanceof LocationXMLElement + this.getParent() instanceof LocationXmlElement ) and this.getName().toLowerCase() = "system.webserver" } } +/** DEPRECATED: Alias for SystemWebServerXmlElement */ +deprecated class SystemWebServerXMLElement = SystemWebServerXmlElement; + /** A `` tag in an ASP.NET configuration file. */ -class CustomErrorsXMLElement extends XMLElement { - CustomErrorsXMLElement() { - this.getParent() instanceof SystemWebXMLElement and +class CustomErrorsXmlElement extends XMLElement { + CustomErrorsXmlElement() { + this.getParent() instanceof SystemWebXmlElement and this.getName().toLowerCase() = "customerrors" } } +/** DEPRECATED: Alias for CustomErrorsXmlElement */ +deprecated class CustomErrorsXMLElement = CustomErrorsXmlElement; + /** A `` tag in an ASP.NET configuration file. */ -class HttpRuntimeXMLElement extends XMLElement { - HttpRuntimeXMLElement() { - this.getParent() instanceof SystemWebXMLElement and +class HttpRuntimeXmlElement extends XMLElement { + HttpRuntimeXmlElement() { + this.getParent() instanceof SystemWebXmlElement and this.getName().toLowerCase() = "httpruntime" } } +/** DEPRECATED: Alias for HttpRuntimeXmlElement */ +deprecated class HttpRuntimeXMLElement = HttpRuntimeXmlElement; + /** A `` tag under `` in an ASP.NET configuration file. */ class FormsElement extends XMLElement { FormsElement() { - this = any(SystemWebXMLElement sw).getAChild("authentication").getAChild("forms") + this = any(SystemWebXmlElement sw).getAChild("authentication").getAChild("forms") } /** @@ -85,7 +106,7 @@ class FormsElement extends XMLElement { /** A `` tag in an ASP.NET configuration file. */ class HttpCookiesElement extends XMLElement { - HttpCookiesElement() { this = any(SystemWebXMLElement sw).getAChild("httpCookies") } + HttpCookiesElement() { this = any(SystemWebXmlElement sw).getAChild("httpCookies") } /** * Gets attribute's `httpOnlyCookies` value. diff --git a/csharp/ql/lib/semmle/code/csharp/XML.qll b/csharp/ql/lib/semmle/code/csharp/XML.qll index d2e6c44951f..fb781a4683f 100755 --- a/csharp/ql/lib/semmle/code/csharp/XML.qll +++ b/csharp/ql/lib/semmle/code/csharp/XML.qll @@ -4,11 +4,11 @@ import semmle.files.FileSystem -private class TXMLLocatable = +private class TXmlLocatable = @xmldtd or @xmlelement or @xmlattribute or @xmlnamespace or @xmlcomment or @xmlcharacters; /** An XML element that has a location. */ -class XMLLocatable extends @xmllocatable, TXMLLocatable { +class XMLLocatable extends @xmllocatable, TXmlLocatable { /** Gets the source location for this element. */ Location getLocation() { xmllocations(this, result) } diff --git a/csharp/ql/lib/semmle/code/csharp/controlflow/Guards.qll b/csharp/ql/lib/semmle/code/csharp/controlflow/Guards.qll index 7e9b8f7818a..062be133c58 100644 --- a/csharp/ql/lib/semmle/code/csharp/controlflow/Guards.qll +++ b/csharp/ql/lib/semmle/code/csharp/controlflow/Guards.qll @@ -1000,7 +1000,7 @@ module Internal { // The predicates in this module should be evaluated in the same stage as the CFG // construction stage. This is to avoid recomputation of pre-basic-blocks and // pre-SSA predicates - private module PreCFG { + private module PreCfg { private import semmle.code.csharp.controlflow.internal.PreBasicBlocks as PreBasicBlocks private import semmle.code.csharp.controlflow.internal.PreSsa @@ -1414,7 +1414,7 @@ module Internal { } cached - private module CachedWithCFG { + private module CachedWithCfg { private import semmle.code.csharp.Caching cached @@ -1719,10 +1719,10 @@ module Internal { } } - import CachedWithCFG + import CachedWithCfg } - import PreCFG + import PreCfg private predicate interestingDescendantCandidate(Expr e) { guardControls(e, _, _) diff --git a/csharp/ql/lib/semmle/code/csharp/security/dataflow/ExternalAPIsQuery.qll b/csharp/ql/lib/semmle/code/csharp/security/dataflow/ExternalAPIsQuery.qll index 34cff98208d..6b6b49e3a60 100644 --- a/csharp/ql/lib/semmle/code/csharp/security/dataflow/ExternalAPIsQuery.qll +++ b/csharp/ql/lib/semmle/code/csharp/security/dataflow/ExternalAPIsQuery.qll @@ -12,15 +12,18 @@ private import semmle.code.csharp.dataflow.FlowSummary /** * A callable that is considered a "safe" external API from a security perspective. */ -abstract class SafeExternalAPICallable extends Callable { } +abstract class SafeExternalApiCallable extends Callable { } -private class SummarizedCallableSafe extends SafeExternalAPICallable { +/** DEPRECATED: Alias for SafeExternalApiCallable */ +deprecated class SafeExternalAPICallable = SafeExternalApiCallable; + +private class SummarizedCallableSafe extends SafeExternalApiCallable { SummarizedCallableSafe() { this instanceof SummarizedCallable } } /** The default set of "safe" external APIs. */ -private class DefaultSafeExternalAPICallable extends SafeExternalAPICallable { - DefaultSafeExternalAPICallable() { +private class DefaultSafeExternalApiCallable extends SafeExternalApiCallable { + DefaultSafeExternalApiCallable() { this instanceof EqualsMethod or this instanceof IEquatableEqualsMethod or this = any(SystemObjectClass s).getEqualsMethod() or @@ -36,11 +39,11 @@ private class DefaultSafeExternalAPICallable extends SafeExternalAPICallable { } /** A node representing data being passed to an external API. */ -class ExternalAPIDataNode extends DataFlow::Node { +class ExternalApiDataNode extends DataFlow::Node { Call call; int i; - ExternalAPIDataNode() { + ExternalApiDataNode() { ( // Argument to call this.asExpr() = call.getArgument(i) @@ -59,7 +62,7 @@ class ExternalAPIDataNode extends DataFlow::Node { m.fromSource() ) and // Not a call to a known safe external API - not call.getTarget().getUnboundDeclaration() instanceof SafeExternalAPICallable + not call.getTarget().getUnboundDeclaration() instanceof SafeExternalApiCallable } /** Gets the called API callable. */ @@ -72,38 +75,47 @@ class ExternalAPIDataNode extends DataFlow::Node { string getCallableDescription() { result = this.getCallable().getQualifiedName() } } -/** A configuration for tracking flow from `RemoteFlowSource`s to `ExternalAPIDataNode`s. */ -class UntrustedDataToExternalAPIConfig extends TaintTracking::Configuration { - UntrustedDataToExternalAPIConfig() { this = "UntrustedDataToExternalAPIConfig" } +/** DEPRECATED: Alias for ExternalApiDataNode */ +deprecated class ExternalAPIDataNode = ExternalApiDataNode; + +/** A configuration for tracking flow from `RemoteFlowSource`s to `ExternalApiDataNode`s. */ +class UntrustedDataToExternalApiConfig extends TaintTracking::Configuration { + UntrustedDataToExternalApiConfig() { this = "UntrustedDataToExternalAPIConfig" } override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource } - override predicate isSink(DataFlow::Node sink) { sink instanceof ExternalAPIDataNode } + override predicate isSink(DataFlow::Node sink) { sink instanceof ExternalApiDataNode } } -/** A node representing untrusted data being passed to an external API. */ -class UntrustedExternalAPIDataNode extends ExternalAPIDataNode { - private UntrustedDataToExternalAPIConfig c; +/** DEPRECATED: Alias for UntrustedDataToExternalApiConfig */ +deprecated class UntrustedDataToExternalAPIConfig = UntrustedDataToExternalApiConfig; - UntrustedExternalAPIDataNode() { c.hasFlow(_, this) } +/** A node representing untrusted data being passed to an external API. */ +class UntrustedExternalApiDataNode extends ExternalApiDataNode { + private UntrustedDataToExternalApiConfig c; + + UntrustedExternalApiDataNode() { c.hasFlow(_, this) } /** Gets a source of untrusted data which is passed to this external API data node. */ DataFlow::Node getAnUntrustedSource() { c.hasFlow(result, this) } } -private newtype TExternalAPI = - TExternalAPIParameter(Callable m, int index) { - exists(UntrustedExternalAPIDataNode n | +/** DEPRECATED: Alias for UntrustedExternalApiDataNode */ +deprecated class UntrustedExternalAPIDataNode = UntrustedExternalApiDataNode; + +private newtype TExternalApi = + TExternalApiParameter(Callable m, int index) { + exists(UntrustedExternalApiDataNode n | m = n.getCallable().getUnboundDeclaration() and index = n.getIndex() ) } /** An external API which is used with untrusted data. */ -class ExternalAPIUsedWithUntrustedData extends TExternalAPI { +class ExternalApiUsedWithUntrustedData extends TExternalApi { /** Gets a possibly untrusted use of this external API. */ - UntrustedExternalAPIDataNode getUntrustedDataNode() { - this = TExternalAPIParameter(result.getCallable().getUnboundDeclaration(), result.getIndex()) + UntrustedExternalApiDataNode getUntrustedDataNode() { + this = TExternalApiParameter(result.getCallable().getUnboundDeclaration(), result.getIndex()) } /** Gets the number of untrusted sources used with this external API. */ @@ -116,10 +128,13 @@ class ExternalAPIUsedWithUntrustedData extends TExternalAPI { exists(Callable m, int index, string indexString | if index = -1 then indexString = "qualifier" else indexString = "param " + index | - this = TExternalAPIParameter(m, index) and + this = TExternalApiParameter(m, index) and result = m.getDeclaringType().getQualifiedName() + "." + m.toStringWithTypes() + " [" + indexString + "]" ) } } + +/** DEPRECATED: Alias for ExternalApiUsedWithUntrustedData */ +deprecated class ExternalAPIUsedWithUntrustedData = ExternalApiUsedWithUntrustedData; diff --git a/csharp/ql/lib/semmle/code/csharp/security/dataflow/LDAPInjectionQuery.qll b/csharp/ql/lib/semmle/code/csharp/security/dataflow/LDAPInjectionQuery.qll index 5aa27202f4f..6f985463763 100644 --- a/csharp/ql/lib/semmle/code/csharp/security/dataflow/LDAPInjectionQuery.qll +++ b/csharp/ql/lib/semmle/code/csharp/security/dataflow/LDAPInjectionQuery.qll @@ -117,12 +117,15 @@ class SearchRequestFilterSink extends Sink { * * This will match the encoding methods provided by the AntiXSS library. */ -class LDAPEncodeSanitizer extends Sanitizer { - LDAPEncodeSanitizer() { +class LdapEncodeSanitizer extends Sanitizer { + LdapEncodeSanitizer() { this.getExpr().(MethodCall).getTarget().getName().regexpMatch("(?i)LDAP.*Encode.*") } } +/** DEPRECATED: Alias for LdapEncodeSanitizer */ +deprecated class LDAPEncodeSanitizer = LdapEncodeSanitizer; + private class SimpleTypeSanitizer extends Sanitizer, SimpleTypeSanitizedExpr { } private class GuidSanitizer extends Sanitizer, GuidSanitizedExpr { } diff --git a/csharp/ql/lib/semmle/code/csharp/security/dataflow/XMLEntityInjectionQuery.qll b/csharp/ql/lib/semmle/code/csharp/security/dataflow/XMLEntityInjectionQuery.qll index cf27d2db49b..d49ecd7c900 100644 --- a/csharp/ql/lib/semmle/code/csharp/security/dataflow/XMLEntityInjectionQuery.qll +++ b/csharp/ql/lib/semmle/code/csharp/security/dataflow/XMLEntityInjectionQuery.qll @@ -28,10 +28,10 @@ abstract class Sink extends DataFlow::ExprNode { abstract string getReason(); } -private class InsecureXMLSink extends Sink { +private class InsecureXmlSink extends Sink { private string reason; - InsecureXMLSink() { + InsecureXmlSink() { exists(InsecureXML::InsecureXmlProcessing r | r.isUnsafe(reason) | this.getExpr() = r.getAnArgument() ) diff --git a/csharp/ql/src/Security Features/CWE-011/ASPNetDebug.ql b/csharp/ql/src/Security Features/CWE-011/ASPNetDebug.ql index 3bccd9b0331..8477401fe17 100644 --- a/csharp/ql/src/Security Features/CWE-011/ASPNetDebug.ql +++ b/csharp/ql/src/Security Features/CWE-011/ASPNetDebug.ql @@ -17,7 +17,7 @@ import csharp import semmle.code.asp.WebConfig -from SystemWebXMLElement web, XMLAttribute debugAttribute +from SystemWebXmlElement web, XMLAttribute debugAttribute where debugAttribute = web.getAChild("compilation").getAttribute("debug") and not debugAttribute.getValue().toLowerCase() = "false" diff --git a/csharp/ql/src/Security Features/CWE-016/ASPNetMaxRequestLength.ql b/csharp/ql/src/Security Features/CWE-016/ASPNetMaxRequestLength.ql index 5a527c96084..d6b4da2c258 100644 --- a/csharp/ql/src/Security Features/CWE-016/ASPNetMaxRequestLength.ql +++ b/csharp/ql/src/Security Features/CWE-016/ASPNetMaxRequestLength.ql @@ -14,7 +14,7 @@ import csharp import semmle.code.asp.WebConfig -from SystemWebXMLElement web, XMLAttribute maxReqLength +from SystemWebXmlElement web, XMLAttribute maxReqLength where maxReqLength = web.getAChild(any(string s | s.toLowerCase() = "httpruntime")) diff --git a/csharp/ql/src/Security Features/CWE-016/ASPNetPagesValidateRequest.ql b/csharp/ql/src/Security Features/CWE-016/ASPNetPagesValidateRequest.ql index f093a888446..3a8208c270f 100644 --- a/csharp/ql/src/Security Features/CWE-016/ASPNetPagesValidateRequest.ql +++ b/csharp/ql/src/Security Features/CWE-016/ASPNetPagesValidateRequest.ql @@ -13,7 +13,7 @@ import csharp import semmle.code.asp.WebConfig -from SystemWebXMLElement web, XMLAttribute requestvalidateAttribute +from SystemWebXmlElement web, XMLAttribute requestvalidateAttribute where requestvalidateAttribute = web.getAChild("pages").getAttribute("validateRequest") and requestvalidateAttribute.getValue().toLowerCase() = "false" diff --git a/csharp/ql/src/Security Features/CWE-020/ExternalAPIsUsedWithUntrustedData.ql b/csharp/ql/src/Security Features/CWE-020/ExternalAPIsUsedWithUntrustedData.ql index 8b6a657ecd4..b07b1093ec8 100644 --- a/csharp/ql/src/Security Features/CWE-020/ExternalAPIsUsedWithUntrustedData.ql +++ b/csharp/ql/src/Security Features/CWE-020/ExternalAPIsUsedWithUntrustedData.ql @@ -11,7 +11,7 @@ import csharp import semmle.code.csharp.security.dataflow.ExternalAPIsQuery -from ExternalAPIUsedWithUntrustedData externalAPI -select externalAPI, count(externalAPI.getUntrustedDataNode()) as numberOfUses, - externalAPI.getNumberOfUntrustedSources() as numberOfUntrustedSources order by +from ExternalApiUsedWithUntrustedData externalApi +select externalApi, count(externalApi.getUntrustedDataNode()) as numberOfUses, + externalApi.getNumberOfUntrustedSources() as numberOfUntrustedSources order by numberOfUntrustedSources desc diff --git a/csharp/ql/src/Security Features/CWE-020/UntrustedDataToExternalAPI.ql b/csharp/ql/src/Security Features/CWE-020/UntrustedDataToExternalAPI.ql index 3db73db09d4..aaf18f7f312 100644 --- a/csharp/ql/src/Security Features/CWE-020/UntrustedDataToExternalAPI.ql +++ b/csharp/ql/src/Security Features/CWE-020/UntrustedDataToExternalAPI.ql @@ -14,8 +14,8 @@ import semmle.code.csharp.dataflow.TaintTracking import semmle.code.csharp.security.dataflow.ExternalAPIsQuery import DataFlow::PathGraph -from UntrustedDataToExternalAPIConfig config, DataFlow::PathNode source, DataFlow::PathNode sink +from UntrustedDataToExternalApiConfig config, DataFlow::PathNode source, DataFlow::PathNode sink where config.hasFlowPath(source, sink) select sink, source, sink, - "Call to " + sink.getNode().(ExternalAPIDataNode).getCallableDescription() + + "Call to " + sink.getNode().(ExternalApiDataNode).getCallableDescription() + " with untrusted data from $@.", source, source.toString() diff --git a/csharp/ql/src/Security Features/CWE-248/MissingASPNETGlobalErrorHandler.ql b/csharp/ql/src/Security Features/CWE-248/MissingASPNETGlobalErrorHandler.ql index 416608b9115..1e7a9a4ddb1 100644 --- a/csharp/ql/src/Security Features/CWE-248/MissingASPNETGlobalErrorHandler.ql +++ b/csharp/ql/src/Security Features/CWE-248/MissingASPNETGlobalErrorHandler.ql @@ -24,7 +24,7 @@ class Application_Error extends Method { } } -from CustomErrorsXMLElement customError +from CustomErrorsXmlElement customError where // `` must be set to "off" to be dangerous customError.getAttributeValue("mode").toLowerCase() = "off" and diff --git a/csharp/ql/src/Security Features/CWE-451/MissingXFrameOptions.ql b/csharp/ql/src/Security Features/CWE-451/MissingXFrameOptions.ql index 67f3ae1d7b8..9e51b663038 100644 --- a/csharp/ql/src/Security Features/CWE-451/MissingXFrameOptions.ql +++ b/csharp/ql/src/Security Features/CWE-451/MissingXFrameOptions.ql @@ -19,7 +19,7 @@ import semmle.code.csharp.frameworks.system.Web /** * Holds if the `Web.config` file `webConfig` adds an `X-Frame-Options` header. */ -predicate hasWebConfigXFrameOptions(WebConfigXML webConfig) { +predicate hasWebConfigXFrameOptions(WebConfigXml webConfig) { // Looking for an entry in `webConfig` that looks like this: // ```xml // @@ -52,7 +52,7 @@ predicate hasCodeXFrameOptions() { ) } -from WebConfigXML webConfig +from WebConfigXml webConfig where not hasWebConfigXFrameOptions(webConfig) and not hasCodeXFrameOptions() diff --git a/csharp/ql/src/Security Features/CWE-548/ASPNetDirectoryListing.ql b/csharp/ql/src/Security Features/CWE-548/ASPNetDirectoryListing.ql index 9416fa32f0a..2337ecfc4cf 100644 --- a/csharp/ql/src/Security Features/CWE-548/ASPNetDirectoryListing.ql +++ b/csharp/ql/src/Security Features/CWE-548/ASPNetDirectoryListing.ql @@ -13,7 +13,7 @@ import csharp import semmle.code.asp.WebConfig -from SystemWebServerXMLElement ws, XMLAttribute a +from SystemWebServerXmlElement ws, XMLAttribute a where ws.getAChild("directoryBrowse").getAttribute("enabled") = a and a.getValue() = "true" diff --git a/csharp/ql/src/Security Features/HeaderCheckingDisabled.ql b/csharp/ql/src/Security Features/HeaderCheckingDisabled.ql index 631b408a5a3..5d0958d06f9 100644 --- a/csharp/ql/src/Security Features/HeaderCheckingDisabled.ql +++ b/csharp/ql/src/Security Features/HeaderCheckingDisabled.ql @@ -27,7 +27,7 @@ where ) or // header checking is disabled in a configuration file - exists(HttpRuntimeXMLElement e, XMLAttribute a | + exists(HttpRuntimeXmlElement e, XMLAttribute a | a = e.getAttribute("enableHeaderChecking") and a.getValue().toLowerCase() = "false" and a = l diff --git a/csharp/ql/src/experimental/ir/implementation/internal/TInstruction.qll b/csharp/ql/src/experimental/ir/implementation/internal/TInstruction.qll index 4b3f19cbdde..5a7099d9fa2 100644 --- a/csharp/ql/src/experimental/ir/implementation/internal/TInstruction.qll +++ b/csharp/ql/src/experimental/ir/implementation/internal/TInstruction.qll @@ -19,24 +19,24 @@ newtype TInstruction = ) { IRConstruction::Raw::hasInstruction(tag1, tag2) } or - TUnaliasedSSAPhiInstruction( - TRawInstruction blockStartInstr, UnaliasedSSA::SSA::MemoryLocation memoryLocation + TUnaliasedSsaPhiInstruction( + TRawInstruction blockStartInstr, UnaliasedSsa::SSA::MemoryLocation memoryLocation ) { - UnaliasedSSA::SSA::hasPhiInstruction(blockStartInstr, memoryLocation) + UnaliasedSsa::SSA::hasPhiInstruction(blockStartInstr, memoryLocation) } or - TUnaliasedSSAChiInstruction(TRawInstruction primaryInstruction) { none() } or - TUnaliasedSSAUnreachedInstruction(IRFunctionBase irFunc) { - UnaliasedSSA::SSA::hasUnreachedInstruction(irFunc) + TUnaliasedSsaChiInstruction(TRawInstruction primaryInstruction) { none() } or + TUnaliasedSsaUnreachedInstruction(IRFunctionBase irFunc) { + UnaliasedSsa::SSA::hasUnreachedInstruction(irFunc) } or - TAliasedSSAPhiInstruction( + TAliasedSsaPhiInstruction( TRawInstruction blockStartInstr, AliasedSSA::SSA::MemoryLocation memoryLocation ) { AliasedSSA::SSA::hasPhiInstruction(blockStartInstr, memoryLocation) } or - TAliasedSSAChiInstruction(TRawInstruction primaryInstruction) { + TAliasedSsaChiInstruction(TRawInstruction primaryInstruction) { AliasedSSA::SSA::hasChiInstruction(primaryInstruction) } or - TAliasedSSAUnreachedInstruction(IRFunctionBase irFunc) { + TAliasedSsaUnreachedInstruction(IRFunctionBase irFunc) { AliasedSSA::SSA::hasUnreachedInstruction(irFunc) } @@ -46,58 +46,64 @@ newtype TInstruction = * These wrappers are not parameterized because it is not possible to invoke an IPA constructor via * a class alias. */ -module UnaliasedSSAInstructions { - class TPhiInstruction = TUnaliasedSSAPhiInstruction; +module UnaliasedSsaInstructions { + class TPhiInstruction = TUnaliasedSsaPhiInstruction; TPhiInstruction phiInstruction( - TRawInstruction blockStartInstr, UnaliasedSSA::SSA::MemoryLocation memoryLocation + TRawInstruction blockStartInstr, UnaliasedSsa::SSA::MemoryLocation memoryLocation ) { - result = TUnaliasedSSAPhiInstruction(blockStartInstr, memoryLocation) + result = TUnaliasedSsaPhiInstruction(blockStartInstr, memoryLocation) } TRawInstruction reusedPhiInstruction(TRawInstruction blockStartInstr) { none() } - class TChiInstruction = TUnaliasedSSAChiInstruction; + class TChiInstruction = TUnaliasedSsaChiInstruction; TChiInstruction chiInstruction(TRawInstruction primaryInstruction) { - result = TUnaliasedSSAChiInstruction(primaryInstruction) + result = TUnaliasedSsaChiInstruction(primaryInstruction) } - class TUnreachedInstruction = TUnaliasedSSAUnreachedInstruction; + class TUnreachedInstruction = TUnaliasedSsaUnreachedInstruction; TUnreachedInstruction unreachedInstruction(IRFunctionBase irFunc) { - result = TUnaliasedSSAUnreachedInstruction(irFunc) + result = TUnaliasedSsaUnreachedInstruction(irFunc) } } +/** DEPRECATED: Alias for UnaliasedSsaInstructions */ +deprecated module UnaliasedSSAInstructions = UnaliasedSsaInstructions; + /** * Provides wrappers for the constructors of each branch of `TInstruction` that is used by the * aliased SSA stage. * These wrappers are not parameterized because it is not possible to invoke an IPA constructor via * a class alias. */ -module AliasedSSAInstructions { - class TPhiInstruction = TAliasedSSAPhiInstruction or TUnaliasedSSAPhiInstruction; +module AliasedSsaInstructions { + class TPhiInstruction = TAliasedSsaPhiInstruction or TUnaliasedSsaPhiInstruction; TPhiInstruction phiInstruction( TRawInstruction blockStartInstr, AliasedSSA::SSA::MemoryLocation memoryLocation ) { - result = TAliasedSSAPhiInstruction(blockStartInstr, memoryLocation) + result = TAliasedSsaPhiInstruction(blockStartInstr, memoryLocation) } TPhiInstruction reusedPhiInstruction(TRawInstruction blockStartInstr) { - result = TUnaliasedSSAPhiInstruction(blockStartInstr, _) + result = TUnaliasedSsaPhiInstruction(blockStartInstr, _) } - class TChiInstruction = TAliasedSSAChiInstruction; + class TChiInstruction = TAliasedSsaChiInstruction; TChiInstruction chiInstruction(TRawInstruction primaryInstruction) { - result = TAliasedSSAChiInstruction(primaryInstruction) + result = TAliasedSsaChiInstruction(primaryInstruction) } - class TUnreachedInstruction = TAliasedSSAUnreachedInstruction; + class TUnreachedInstruction = TAliasedSsaUnreachedInstruction; TUnreachedInstruction unreachedInstruction(IRFunctionBase irFunc) { - result = TAliasedSSAUnreachedInstruction(irFunc) + result = TAliasedSsaUnreachedInstruction(irFunc) } } + +/** DEPRECATED: Alias for AliasedSsaInstructions */ +deprecated module AliasedSSAInstructions = AliasedSsaInstructions; diff --git a/csharp/ql/src/experimental/ir/implementation/internal/TInstructionInternal.qll b/csharp/ql/src/experimental/ir/implementation/internal/TInstructionInternal.qll index 978d2c41aa7..252f390bf55 100644 --- a/csharp/ql/src/experimental/ir/implementation/internal/TInstructionInternal.qll +++ b/csharp/ql/src/experimental/ir/implementation/internal/TInstructionInternal.qll @@ -1,4 +1,4 @@ import experimental.ir.internal.IRCSharpLanguage as Language import experimental.ir.implementation.raw.internal.IRConstruction as IRConstruction -import experimental.ir.implementation.unaliased_ssa.internal.SSAConstruction as UnaliasedSSA +import experimental.ir.implementation.unaliased_ssa.internal.SSAConstruction as UnaliasedSsa import AliasedSSAStub as AliasedSSA diff --git a/csharp/ql/src/experimental/ir/implementation/internal/TOperand.qll b/csharp/ql/src/experimental/ir/implementation/internal/TOperand.qll index 20fe77f8223..6327c603901 100644 --- a/csharp/ql/src/experimental/ir/implementation/internal/TOperand.qll +++ b/csharp/ql/src/experimental/ir/implementation/internal/TOperand.qll @@ -29,7 +29,7 @@ private module Internal { TNoOperand() { none() } or // Can be "removed" later when there's unreachable code // These operands can be reused across all three stages. They just get different defs. - TNonSSAMemoryOperand(Raw::Instruction useInstr, MemoryOperandTag tag) { + TNonSsaMemoryOperand(Raw::Instruction useInstr, MemoryOperandTag tag) { // Has no definition in raw but will get definitions later useInstr.getOpcode().hasOperand(tag) } or @@ -57,13 +57,21 @@ private module Shared { result = Internal::TRegisterOperand(useInstr, tag, defInstr) } - class TNonSSAMemoryOperand = Internal::TNonSSAMemoryOperand; + class TNonSsaMemoryOperand = Internal::TNonSsaMemoryOperand; + + /** DEPRECATED: Alias for TNonSsaMemoryOperand */ + deprecated class TNonSSAMemoryOperand = TNonSsaMemoryOperand; /** * Returns the non-Phi memory operand with the specified parameters. */ - TNonSSAMemoryOperand nonSSAMemoryOperand(TRawInstruction useInstr, MemoryOperandTag tag) { - result = Internal::TNonSSAMemoryOperand(useInstr, tag) + TNonSsaMemoryOperand nonSsaMemoryOperand(TRawInstruction useInstr, MemoryOperandTag tag) { + result = Internal::TNonSsaMemoryOperand(useInstr, tag) + } + + /** DEPRECATED: Alias for nonSsaMemoryOperand */ + deprecated TNonSSAMemoryOperand nonSSAMemoryOperand(TRawInstruction useInstr, MemoryOperandTag tag) { + result = nonSsaMemoryOperand(useInstr, tag) } } @@ -80,7 +88,7 @@ module RawOperands { class TChiOperand = Internal::TNoOperand; - class TNonPhiMemoryOperand = TNonSSAMemoryOperand or TChiOperand; + class TNonPhiMemoryOperand = TNonSsaMemoryOperand or TChiOperand; /** * Returns the Phi operand with the specified parameters. @@ -114,14 +122,14 @@ module RawOperands { * These wrappers are not parameterized because it is not possible to invoke an IPA constructor via * a class alias. */ -module UnaliasedSSAOperands { +module UnaliasedSsaOperands { import Shared class TPhiOperand = Internal::TUnaliasedPhiOperand; class TChiOperand = Internal::TNoOperand; - class TNonPhiMemoryOperand = TNonSSAMemoryOperand or TChiOperand; + class TNonPhiMemoryOperand = TNonSsaMemoryOperand or TChiOperand; /** * Returns the Phi operand with the specified parameters. @@ -148,3 +156,6 @@ module UnaliasedSSAOperands { */ TChiOperand chiOperand(Unaliased::Instruction useInstr, ChiOperandTag tag) { none() } } + +/** DEPRECATED: Alias for UnaliasedSsaOperands */ +deprecated module UnaliasedSSAOperands = UnaliasedSsaOperands; diff --git a/csharp/ql/src/experimental/ir/implementation/raw/IRVariable.qll b/csharp/ql/src/experimental/ir/implementation/raw/IRVariable.qll index 146fc270738..ca4708857a7 100644 --- a/csharp/ql/src/experimental/ir/implementation/raw/IRVariable.qll +++ b/csharp/ql/src/experimental/ir/implementation/raw/IRVariable.qll @@ -55,7 +55,10 @@ class IRVariable extends TIRVariable { * Gets the AST node that declared this variable, or that introduced this * variable as part of the AST-to-IR translation. */ - Language::AST getAST() { none() } + Language::AST getAst() { none() } + + /** DEPRECATED: Alias for getAst */ + deprecated Language::AST getAST() { result = getAst() } /** * Gets an identifier string for the variable. This identifier is unique @@ -66,7 +69,7 @@ class IRVariable extends TIRVariable { /** * Gets the source location of this variable. */ - final Language::Location getLocation() { result = getAST().getLocation() } + final Language::Location getLocation() { result = getAst().getLocation() } /** * Gets the IR for the function that references this variable. @@ -90,7 +93,10 @@ class IRUserVariable extends IRVariable, TIRUserVariable { final override string toString() { result = getVariable().toString() } - final override Language::AST getAST() { result = var } + final override Language::AST getAst() { result = var } + + /** DEPRECATED: Alias for getAst */ + deprecated override Language::AST getAST() { result = getAst() } final override string getUniqueId() { result = getVariable().toString() + " " + getVariable().getLocation().toString() @@ -157,7 +163,10 @@ class IRGeneratedVariable extends IRVariable { final override Language::LanguageType getLanguageType() { result = type } - final override Language::AST getAST() { result = ast } + final override Language::AST getAst() { result = ast } + + /** DEPRECATED: Alias for getAst */ + deprecated override Language::AST getAST() { result = getAst() } override string toString() { result = getBaseString() + getLocationString() } diff --git a/csharp/ql/src/experimental/ir/implementation/raw/Instruction.qll b/csharp/ql/src/experimental/ir/implementation/raw/Instruction.qll index 1c2cc493338..4dac3087f83 100644 --- a/csharp/ql/src/experimental/ir/implementation/raw/Instruction.qll +++ b/csharp/ql/src/experimental/ir/implementation/raw/Instruction.qll @@ -41,7 +41,7 @@ class Instruction extends Construction::TStageInstruction { } /** Gets a textual representation of this element. */ - final string toString() { result = this.getOpcode().toString() + ": " + this.getAST().toString() } + final string toString() { result = this.getOpcode().toString() + ": " + this.getAst().toString() } /** * Gets a string showing the result, opcode, and operands of the instruction, equivalent to what @@ -136,7 +136,7 @@ class Instruction extends Construction::TStageInstruction { string getResultId() { this.shouldGenerateDumpStrings() and result = - this.getResultPrefix() + this.getAST().getLocation().getStartLine() + "_" + this.getLineRank() + this.getResultPrefix() + this.getAst().getLocation().getStartLine() + "_" + this.getLineRank() } /** @@ -208,12 +208,15 @@ class Instruction extends Construction::TStageInstruction { /** * Gets the AST that caused this instruction to be generated. */ - final Language::AST getAST() { result = Construction::getInstructionAST(this) } + final Language::AST getAst() { result = Construction::getInstructionAst(this) } + + /** DEPRECATED: Alias for getAst */ + deprecated Language::AST getAST() { result = getAst() } /** * Gets the location of the source code for this instruction. */ - final Language::Location getLocation() { result = this.getAST().getLocation() } + final Language::Location getLocation() { result = this.getAst().getLocation() } /** * Gets the `Expr` whose result is computed by this instruction, if any. The `Expr` may be a @@ -459,7 +462,10 @@ class VariableInstruction extends Instruction { /** * Gets the AST variable that this instruction's IR variable refers to, if one exists. */ - final Language::Variable getASTVariable() { result = var.(IRUserVariable).getVariable() } + final Language::Variable getAstVariable() { result = var.(IRUserVariable).getVariable() } + + /** DEPRECATED: Alias for getAstVariable */ + deprecated Language::Variable getASTVariable() { result = getAstVariable() } } /** diff --git a/csharp/ql/src/experimental/ir/implementation/raw/Operand.qll b/csharp/ql/src/experimental/ir/implementation/raw/Operand.qll index 89b82657c3b..c1e997d5844 100644 --- a/csharp/ql/src/experimental/ir/implementation/raw/Operand.qll +++ b/csharp/ql/src/experimental/ir/implementation/raw/Operand.qll @@ -18,7 +18,7 @@ private import internal.OperandInternal * of `TOperand` that are used in this stage. */ private class TStageOperand = - TRegisterOperand or TNonSSAMemoryOperand or TPhiOperand or TChiOperand; + TRegisterOperand or TNonSsaMemoryOperand or TPhiOperand or TChiOperand; /** * A known location. Testing `loc instanceof KnownLocation` will account for non existing locations, as @@ -38,7 +38,7 @@ class Operand extends TStageOperand { // Ensure that the operand does not refer to instructions from earlier stages that are unreachable here exists(Instruction use, Instruction def | this = registerOperand(use, _, def)) or - exists(Instruction use | this = nonSSAMemoryOperand(use, _)) + exists(Instruction use | this = nonSsaMemoryOperand(use, _)) or exists(Instruction use, Instruction def, IRBlock predecessorBlock | this = phiOperand(use, def, predecessorBlock, _) or @@ -209,7 +209,7 @@ class Operand extends TStageOperand { class MemoryOperand extends Operand { cached MemoryOperand() { - this instanceof TNonSSAMemoryOperand or + this instanceof TNonSsaMemoryOperand or this instanceof TPhiOperand or this instanceof TChiOperand } @@ -249,7 +249,7 @@ class NonPhiOperand extends Operand { NonPhiOperand() { this = registerOperand(useInstr, tag, _) or - this = nonSSAMemoryOperand(useInstr, tag) or + this = nonSsaMemoryOperand(useInstr, tag) or this = chiOperand(useInstr, tag) } @@ -299,7 +299,7 @@ class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand, TNonPhiMemoryOpe cached NonPhiMemoryOperand() { - this = nonSSAMemoryOperand(useInstr, tag) + this = nonSsaMemoryOperand(useInstr, tag) or this = chiOperand(useInstr, tag) } diff --git a/csharp/ql/src/experimental/ir/implementation/raw/gvn/internal/ValueNumberingInternal.qll b/csharp/ql/src/experimental/ir/implementation/raw/gvn/internal/ValueNumberingInternal.qll index fdb645e03f0..2dc735f49df 100644 --- a/csharp/ql/src/experimental/ir/implementation/raw/gvn/internal/ValueNumberingInternal.qll +++ b/csharp/ql/src/experimental/ir/implementation/raw/gvn/internal/ValueNumberingInternal.qll @@ -99,7 +99,7 @@ private predicate filteredNumberableInstruction(Instruction instr) { // count rather than strictcount to handle missing AST elements // separate instanceof and inline casts to avoid failed casts with a count of 0 instr instanceof VariableAddressInstruction and - count(instr.(VariableAddressInstruction).getIRVariable().getAST()) != 1 + count(instr.(VariableAddressInstruction).getIRVariable().getAst()) != 1 or instr instanceof ConstantInstruction and count(instr.getResultIRType()) != 1 @@ -121,7 +121,7 @@ private predicate variableAddressValueNumber( // The underlying AST element is used as value-numbering key instead of the // `IRVariable` to work around a problem where a variable or expression with // multiple types gives rise to multiple `IRVariable`s. - unique( | | instr.getIRVariable().getAST()) = ast + unique( | | instr.getIRVariable().getAst()) = ast } private predicate initializeParameterValueNumber( @@ -131,7 +131,7 @@ private predicate initializeParameterValueNumber( // The underlying AST element is used as value-numbering key instead of the // `IRVariable` to work around a problem where a variable or expression with // multiple types gives rise to multiple `IRVariable`s. - instr.getIRVariable().getAST() = var + instr.getIRVariable().getAst() = var } private predicate constantValueNumber( diff --git a/csharp/ql/src/experimental/ir/implementation/raw/internal/IRConstruction.qll b/csharp/ql/src/experimental/ir/implementation/raw/internal/IRConstruction.qll index 956a95e0667..032026e7969 100644 --- a/csharp/ql/src/experimental/ir/implementation/raw/internal/IRConstruction.qll +++ b/csharp/ql/src/experimental/ir/implementation/raw/internal/IRConstruction.qll @@ -62,7 +62,7 @@ module Raw { Callable callable, Language::AST ast, TempVariableTag tag, CSharpType type ) { exists(TranslatedElement element | - element.getAST() = ast and + element.getAst() = ast and callable = element.getFunction() and element.hasTempVariable(tag, type) ) @@ -105,7 +105,7 @@ module Raw { tag = getInstructionTag(instruction) and ( result = element.getInstructionVariable(tag) or - result.(IRStringLiteral).getAST() = element.getInstructionStringLiteral(tag) + result.(IRStringLiteral).getAst() = element.getInstructionStringLiteral(tag) ) ) } @@ -357,7 +357,7 @@ private module Cached { exists(TranslatedElement s, GotoStmt goto | goto instanceof GotoStmt and not isStrictlyForwardGoto(goto) and - goto = s.getAST() and + goto = s.getAst() and exists(InstructionTag tag | result = s.getInstructionSuccessor(tag, kind) and instruction = s.getInstruction(tag) @@ -372,8 +372,14 @@ private module Cached { } cached - Language::AST getInstructionAST(Instruction instruction) { - result = getInstructionTranslatedElement(instruction).getAST() + Language::AST getInstructionAst(Instruction instruction) { + result = getInstructionTranslatedElement(instruction).getAst() + } + + /** DEPRECATED: Alias for getInstructionAst */ + cached + deprecated Language::AST getInstructionAST(Instruction instruction) { + result = getInstructionAst(instruction) } cached diff --git a/csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedCondition.qll b/csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedCondition.qll index 99833c70d0b..97ecc25fb43 100644 --- a/csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedCondition.qll +++ b/csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedCondition.qll @@ -15,7 +15,10 @@ abstract class TranslatedCondition extends ConditionBase { final override string toString() { result = expr.toString() } - final override Language::AST getAST() { result = expr } + final override Language::AST getAst() { result = expr } + + /** DEPRECATED: Alias for getAst */ + deprecated override Language::AST getAST() { result = getAst() } final Expr getExpr() { result = expr } diff --git a/csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedDeclaration.qll b/csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedDeclaration.qll index 9b4fbbba723..bc4a2da5b91 100644 --- a/csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedDeclaration.qll +++ b/csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedDeclaration.qll @@ -14,7 +14,7 @@ private import common.TranslatedDeclarationBase * `entry`. */ TranslatedLocalDeclaration getTranslatedLocalDeclaration(LocalVariableDeclExpr declExpr) { - result.getAST() = declExpr + result.getAst() = declExpr } /** @@ -29,7 +29,10 @@ abstract class TranslatedLocalDeclaration extends TranslatedElement, TTranslated final override string toString() { result = expr.toString() } - final override Language::AST getAST() { result = expr } + final override Language::AST getAst() { result = expr } + + /** DEPRECATED: Alias for getAst */ + deprecated override Language::AST getAST() { result = getAst() } } /** diff --git a/csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedElement.qll b/csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedElement.qll index ea1ad7931cb..0f269010702 100644 --- a/csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedElement.qll +++ b/csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedElement.qll @@ -27,7 +27,7 @@ IRUserVariable getIRUserVariable(Language::Function func, Language::Variable var } IRTempVariable getIRTempVariable(Language::AST ast, TempVariableTag tag) { - result.getAST() = ast and + result.getAst() = ast and result.getTag() = tag } @@ -365,7 +365,10 @@ abstract class TranslatedElement extends TTranslatedElement { /** * Gets the AST node being translated. */ - abstract Language::AST getAST(); + abstract Language::AST getAst(); + + /** DEPRECATED: Alias for getAst */ + deprecated Language::AST getAST() { result = getAst() } /** * Get the first instruction to be executed in the evaluation of this element. @@ -558,7 +561,7 @@ abstract class TranslatedElement extends TTranslatedElement { * Gets the temporary variable generated by this element with tag `tag`. */ final IRTempVariable getTempVariable(TempVariableTag tag) { - result.getAST() = this.getAST() and + result.getAst() = this.getAst() and result.getTag() = tag and this.hasTempVariable(tag, _) } diff --git a/csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedExpr.qll b/csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedExpr.qll index 4f4c1a5f073..e8696aa88f2 100644 --- a/csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedExpr.qll +++ b/csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedExpr.qll @@ -62,7 +62,10 @@ abstract class TranslatedExpr extends TranslatedExprBase { */ final Type getResultType() { result = expr.getType() } - final override Language::AST getAST() { result = expr } + final override Language::AST getAst() { result = expr } + + /** DEPRECATED: Alias for getAst */ + deprecated override Language::AST getAST() { result = getAst() } final override Callable getFunction() { result = expr.getEnclosingCallable() } @@ -577,9 +580,9 @@ class TranslatedArrayAccess extends TranslatedNonConstantExpr { result = this.getInstruction(ElementsAddressTag(0)) or // The successor of an offset expression is a `PointerAdd` expression. - child = this.getOffsetOperand(child.getAST().getIndex()) and - child.getAST().getIndex() >= 0 and - result = this.getInstruction(PointerAddTag(child.getAST().getIndex())) + child = this.getOffsetOperand(child.getAst().getIndex()) and + child.getAst().getIndex() >= 0 and + result = this.getInstruction(PointerAddTag(child.getAst().getIndex())) } override Instruction getResult() { @@ -2039,7 +2042,7 @@ class TranslatedObjectCreation extends TranslatedCreation { // Since calls are also expressions, we can't // use the predicate getTranslatedExpr (since that would // also return `this`). - result.getAST() = this.getAST() + result.getAst() = this.getAst() } override predicate needsLoad() { expr.getObjectType().isValueType() } diff --git a/csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedFunction.qll b/csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedFunction.qll index 94b48b0985d..0ec4146ad1b 100644 --- a/csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedFunction.qll +++ b/csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedFunction.qll @@ -15,7 +15,7 @@ private import experimental.ir.internal.IRCSharpLanguage as Language /** * Gets the `TranslatedFunction` that represents function `callable`. */ -TranslatedFunction getTranslatedFunction(Callable callable) { result.getAST() = callable } +TranslatedFunction getTranslatedFunction(Callable callable) { result.getAst() = callable } /** * Represents the IR translation of a function. This is the root element for @@ -28,7 +28,10 @@ class TranslatedFunction extends TranslatedElement, TTranslatedFunction { final override string toString() { result = callable.toString() } - final override Language::AST getAST() { result = callable } + final override Language::AST getAst() { result = callable } + + /** DEPRECATED: Alias for getAst */ + deprecated override Language::AST getAST() { result = getAst() } /** * Gets the function being translated. @@ -269,7 +272,7 @@ class TranslatedFunction extends TranslatedElement, TTranslatedFunction { /** * Gets the `TranslatedParameter` that represents parameter `param`. */ -TranslatedParameter getTranslatedParameter(Parameter param) { result.getAST() = param } +TranslatedParameter getTranslatedParameter(Parameter param) { result.getAst() = param } /** * Represents the IR translation of a function parameter, including the @@ -282,7 +285,10 @@ class TranslatedParameter extends TranslatedElement, TTranslatedParameter { final override string toString() { result = param.toString() } - final override Language::AST getAST() { result = param } + final override Language::AST getAst() { result = param } + + /** DEPRECATED: Alias for getAst */ + deprecated override Language::AST getAST() { result = getAst() } final override Callable getFunction() { result = param.getCallable() } diff --git a/csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedInitialization.qll b/csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedInitialization.qll index 77e41c15e72..13a583d23d9 100644 --- a/csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedInitialization.qll +++ b/csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedInitialization.qll @@ -51,7 +51,10 @@ abstract class TranslatedInitialization extends TranslatedElement, TTranslatedIn final override Callable getFunction() { result = expr.getEnclosingCallable() } - final override Language::AST getAST() { result = expr } + final override Language::AST getAst() { result = expr } + + /** DEPRECATED: Alias for getAst */ + deprecated override Language::AST getAST() { result = getAst() } /** * Gets the expression that is doing the initialization. @@ -206,7 +209,10 @@ abstract class TranslatedElementInitialization extends TranslatedElement { result = initList.toString() + "[" + this.getElementIndex().toString() + "]" } - final override Language::AST getAST() { result = initList } + final override Language::AST getAst() { result = initList } + + /** DEPRECATED: Alias for getAst */ + deprecated override Language::AST getAST() { result = getAst() } final override Callable getFunction() { result = initList.getEnclosingCallable() } @@ -310,7 +316,10 @@ abstract class TranslatedConstructorCallFromConstructor extends TranslatedElemen ConstructorCallContext { Call call; - final override Language::AST getAST() { result = call } + final override Language::AST getAst() { result = call } + + /** DEPRECATED: Alias for getAst */ + deprecated override Language::AST getAST() { result = getAst() } final override TranslatedElement getChild(int id) { id = 0 and result = this.getConstructorCall() @@ -327,7 +336,7 @@ abstract class TranslatedConstructorCallFromConstructor extends TranslatedElemen } TranslatedConstructorInitializer getTranslatedConstructorInitializer(ConstructorInitializer ci) { - result.getAST() = ci + result.getAst() = ci } /** diff --git a/csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedStmt.qll b/csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedStmt.qll index ac69a9c0f28..edd65b5a1a2 100644 --- a/csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedStmt.qll +++ b/csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedStmt.qll @@ -15,7 +15,7 @@ private import experimental.ir.internal.IRUtilities private import desugar.Foreach private import desugar.Lock -TranslatedStmt getTranslatedStmt(Stmt stmt) { result.getAST() = stmt } +TranslatedStmt getTranslatedStmt(Stmt stmt) { result.getAst() = stmt } abstract class TranslatedStmt extends TranslatedElement, TTranslatedStmt { Stmt stmt; @@ -24,7 +24,10 @@ abstract class TranslatedStmt extends TranslatedElement, TTranslatedStmt { final override string toString() { result = stmt.toString() } - final override Language::AST getAST() { result = stmt } + final override Language::AST getAst() { result = stmt } + + /** DEPRECATED: Alias for getAst */ + deprecated override Language::AST getAST() { result = getAst() } final override Callable getFunction() { result = stmt.getEnclosingCallable() } } diff --git a/csharp/ql/src/experimental/ir/implementation/raw/internal/desugar/Delegate.qll b/csharp/ql/src/experimental/ir/implementation/raw/internal/desugar/Delegate.qll index f7c80e497fa..5e51073900e 100644 --- a/csharp/ql/src/experimental/ir/implementation/raw/internal/desugar/Delegate.qll +++ b/csharp/ql/src/experimental/ir/implementation/raw/internal/desugar/Delegate.qll @@ -27,10 +27,10 @@ private import experimental.ir.implementation.raw.internal.common.TranslatedExpr */ module DelegateElements { TranslatedDelegateConstructorCall getConstructor(DelegateCreation generatedBy) { - result.getAST() = generatedBy + result.getAst() = generatedBy } - TranslatedDelegateInvokeCall getInvoke(DelegateCall generatedBy) { result.getAST() = generatedBy } + TranslatedDelegateInvokeCall getInvoke(DelegateCall generatedBy) { result.getAst() = generatedBy } int noGeneratedElements(Element generatedBy) { ( diff --git a/csharp/ql/src/experimental/ir/implementation/raw/internal/desugar/Foreach.qll b/csharp/ql/src/experimental/ir/implementation/raw/internal/desugar/Foreach.qll index 195072ed124..bc8ec748648 100644 --- a/csharp/ql/src/experimental/ir/implementation/raw/internal/desugar/Foreach.qll +++ b/csharp/ql/src/experimental/ir/implementation/raw/internal/desugar/Foreach.qll @@ -56,9 +56,9 @@ private import internal.TranslatedCompilerGeneratedElement * Module that exposes the functions needed for the translation of the `foreach` stmt. */ module ForeachElements { - TranslatedForeachTry getTry(ForeachStmt generatedBy) { result.getAST() = generatedBy } + TranslatedForeachTry getTry(ForeachStmt generatedBy) { result.getAst() = generatedBy } - TranslatedForeachEnumerator getEnumDecl(ForeachStmt generatedBy) { result.getAST() = generatedBy } + TranslatedForeachEnumerator getEnumDecl(ForeachStmt generatedBy) { result.getAst() = generatedBy } int noGeneratedElements() { result = 13 } } @@ -71,14 +71,14 @@ private class TranslatedForeachTry extends TranslatedCompilerGeneratedTry, override TranslatedElement getFinally() { exists(TranslatedForeachFinally ff | - ff.getAST() = generatedBy and + ff.getAst() = generatedBy and result = ff ) } override TranslatedElement getBody() { exists(TranslatedForeachWhile fw | - fw.getAST() = generatedBy and + fw.getAst() = generatedBy and result = fw ) } @@ -96,7 +96,7 @@ private class TranslatedForeachFinally extends TranslatedCompilerGeneratedBlock, override TranslatedElement getStmt(int index) { index = 0 and exists(TranslatedForeachDispose fd | - fd.getAST() = generatedBy and + fd.getAst() = generatedBy and result = fd ) } @@ -147,14 +147,14 @@ class TranslatedForeachWhile extends TranslatedCompilerGeneratedStmt, ConditionC TranslatedElement getInit() { exists(TranslatedForeachIterVar iv | - iv.getAST() = generatedBy and + iv.getAst() = generatedBy and result = iv ) } ValueConditionBase getCondition() { exists(TranslatedForeachWhileCondition cond | - cond.getAST() = generatedBy and + cond.getAst() = generatedBy and result = cond ) } @@ -180,7 +180,7 @@ private class TranslatedForeachMoveNext extends TranslatedCompilerGeneratedCall, override TranslatedExprBase getQualifier() { exists(TranslatedMoveNextEnumAcc acc | - acc.getAST() = generatedBy and + acc.getAst() = generatedBy and result = acc ) } @@ -230,7 +230,7 @@ private class TranslatedForeachCurrent extends TranslatedCompilerGeneratedCall, override TranslatedExprBase getQualifier() { exists(TranslatedForeachCurrentEnumAcc acc | - acc.getAST() = generatedBy and + acc.getAst() = generatedBy and result = acc ) } @@ -263,7 +263,7 @@ private class TranslatedForeachDispose extends TranslatedCompilerGeneratedCall, override TranslatedExprBase getQualifier() { exists(TranslatedForeachDisposeEnumAcc acc | - acc.getAST() = generatedBy and + acc.getAst() = generatedBy and result = acc ) } @@ -282,7 +282,7 @@ private class TranslatedForeachWhileCondition extends TranslatedCompilerGenerate override TranslatedCompilerGeneratedCall getValueExpr() { exists(TranslatedForeachMoveNext mn | - mn.getAST() = generatedBy and + mn.getAst() = generatedBy and result = mn ) } @@ -311,7 +311,7 @@ private class TranslatedForeachEnumerator extends TranslatedCompilerGeneratedDec override TranslatedCompilerGeneratedCall getInitialization() { exists(TranslatedForeachGetEnumerator ge | - ge.getAST() = generatedBy and + ge.getAst() = generatedBy and result = ge ) } @@ -339,7 +339,7 @@ private class TranslatedForeachIterVar extends TranslatedCompilerGeneratedDeclar override TranslatedCompilerGeneratedCall getInitialization() { exists(TranslatedForeachCurrent crtProp | - crtProp.getAST() = generatedBy and + crtProp.getAst() = generatedBy and result = crtProp ) } @@ -361,7 +361,7 @@ private class TranslatedMoveNextEnumAcc extends TTranslatedCompilerGeneratedElem override Type getVariableType() { exists(TranslatedForeachGetEnumerator ge | - ge.getAST() = generatedBy and + ge.getAst() = generatedBy and result = ge.getCallResultType() ) } @@ -393,7 +393,7 @@ private class TranslatedForeachCurrentEnumAcc extends TTranslatedCompilerGenerat override Type getVariableType() { exists(TranslatedForeachGetEnumerator ge | - ge.getAST() = generatedBy and + ge.getAst() = generatedBy and result = ge.getCallResultType() ) } @@ -425,7 +425,7 @@ private class TranslatedForeachDisposeEnumAcc extends TTranslatedCompilerGenerat override Type getVariableType() { exists(TranslatedForeachGetEnumerator ge | - ge.getAST() = generatedBy and + ge.getAst() = generatedBy and result = ge.getCallResultType() ) } diff --git a/csharp/ql/src/experimental/ir/implementation/raw/internal/desugar/Lock.qll b/csharp/ql/src/experimental/ir/implementation/raw/internal/desugar/Lock.qll index c83957d9b94..e061a1371b2 100644 --- a/csharp/ql/src/experimental/ir/implementation/raw/internal/desugar/Lock.qll +++ b/csharp/ql/src/experimental/ir/implementation/raw/internal/desugar/Lock.qll @@ -42,12 +42,12 @@ private import internal.TranslatedCompilerGeneratedExpr * Module that exposes the functions needed for the translation of the `lock` stmt. */ module LockElements { - TranslatedLockedVarDecl getLockedVarDecl(LockStmt generatedBy) { result.getAST() = generatedBy } + TranslatedLockedVarDecl getLockedVarDecl(LockStmt generatedBy) { result.getAst() = generatedBy } - TranslatedLockTry getTry(LockStmt generatedBy) { result.getAST() = generatedBy } + TranslatedLockTry getTry(LockStmt generatedBy) { result.getAst() = generatedBy } TranslatedLockWasTakenDecl getLockWasTakenDecl(LockStmt generatedBy) { - result.getAST() = generatedBy + result.getAst() = generatedBy } int noGeneratedElements() { result = 14 } @@ -64,14 +64,14 @@ private class TranslatedLockTry extends TranslatedCompilerGeneratedTry, override TranslatedElement getFinally() { exists(TranslatedLockFinally fin | - fin.getAST() = generatedBy and + fin.getAst() = generatedBy and result = fin ) } override TranslatedElement getBody() { exists(TranslatedLockTryBody ltb | - ltb.getAST() = generatedBy and + ltb.getAst() = generatedBy and result = ltb ) } @@ -89,7 +89,7 @@ private class TranslatedLockTryBody extends TranslatedCompilerGeneratedBlock, override TranslatedElement getStmt(int index) { index = 0 and exists(TranslatedMonitorEnter me | - me.getAST() = generatedBy and + me.getAst() = generatedBy and result = me ) or @@ -110,7 +110,7 @@ private class TranslatedLockFinally extends TranslatedCompilerGeneratedBlock, override TranslatedElement getStmt(int index) { index = 0 and exists(TranslatedFinallyIf fif | - fif.getAST() = generatedBy and + fif.getAst() = generatedBy and result = fif ) } @@ -138,7 +138,7 @@ private class TranslatedMonitorExit extends TranslatedCompilerGeneratedCall, override TranslatedExprBase getArgument(int id) { id = 0 and exists(TranslatedMonitorExitVarAcc var | - var.getAST() = generatedBy and + var.getAst() = generatedBy and result = var ) } @@ -170,13 +170,13 @@ private class TranslatedMonitorEnter extends TranslatedCompilerGeneratedCall, override TranslatedExprBase getArgument(int id) { id = 0 and exists(TranslatedMonitorEnterVarAcc var | - var.getAST() = generatedBy and + var.getAst() = generatedBy and result = var ) or id = 1 and exists(TranslatedLockWasTakenRefArg refArg | - refArg.getAST() = generatedBy and + refArg.getAst() = generatedBy and result = refArg ) } @@ -197,7 +197,7 @@ private class TranslatedIfCondition extends TranslatedCompilerGeneratedValueCond override TranslatedCompilerGeneratedExpr getValueExpr() { exists(TranslatedLockWasTakenCondVarAcc condVar | - condVar.getAST() = generatedBy and + condVar.getAst() = generatedBy and result = condVar ) } @@ -216,14 +216,14 @@ private class TranslatedFinallyIf extends TranslatedCompilerGeneratedIfStmt, override TranslatedCompilerGeneratedValueCondition getCondition() { exists(TranslatedIfCondition cond | - cond.getAST() = generatedBy and + cond.getAst() = generatedBy and result = cond ) } override TranslatedCompilerGeneratedCall getThen() { exists(TranslatedMonitorExit me | - me.getAST() = generatedBy and + me.getAst() = generatedBy and result = me ) } @@ -271,7 +271,7 @@ private class TranslatedLockWasTakenDecl extends TranslatedCompilerGeneratedDecl override TranslatedCompilerGeneratedExpr getInitialization() { exists(TranslatedWasTakenConst const | - const.getAST() = generatedBy and + const.getAst() = generatedBy and result = const ) } diff --git a/csharp/ql/src/experimental/ir/implementation/raw/internal/desugar/internal/TranslatedCompilerGeneratedElement.qll b/csharp/ql/src/experimental/ir/implementation/raw/internal/desugar/internal/TranslatedCompilerGeneratedElement.qll index 1eb7520eda4..ffcc400a9bc 100644 --- a/csharp/ql/src/experimental/ir/implementation/raw/internal/desugar/internal/TranslatedCompilerGeneratedElement.qll +++ b/csharp/ql/src/experimental/ir/implementation/raw/internal/desugar/internal/TranslatedCompilerGeneratedElement.qll @@ -18,5 +18,8 @@ abstract class TranslatedCompilerGeneratedElement extends TranslatedElement, final override Callable getFunction() { result = generatedBy.getEnclosingCallable() } - final override Language::AST getAST() { result = generatedBy } + final override Language::AST getAst() { result = generatedBy } + + /** DEPRECATED: Alias for getAst */ + deprecated override Language::AST getAST() { result = getAst() } } diff --git a/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/IRVariable.qll b/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/IRVariable.qll index 146fc270738..ca4708857a7 100644 --- a/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/IRVariable.qll +++ b/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/IRVariable.qll @@ -55,7 +55,10 @@ class IRVariable extends TIRVariable { * Gets the AST node that declared this variable, or that introduced this * variable as part of the AST-to-IR translation. */ - Language::AST getAST() { none() } + Language::AST getAst() { none() } + + /** DEPRECATED: Alias for getAst */ + deprecated Language::AST getAST() { result = getAst() } /** * Gets an identifier string for the variable. This identifier is unique @@ -66,7 +69,7 @@ class IRVariable extends TIRVariable { /** * Gets the source location of this variable. */ - final Language::Location getLocation() { result = getAST().getLocation() } + final Language::Location getLocation() { result = getAst().getLocation() } /** * Gets the IR for the function that references this variable. @@ -90,7 +93,10 @@ class IRUserVariable extends IRVariable, TIRUserVariable { final override string toString() { result = getVariable().toString() } - final override Language::AST getAST() { result = var } + final override Language::AST getAst() { result = var } + + /** DEPRECATED: Alias for getAst */ + deprecated override Language::AST getAST() { result = getAst() } final override string getUniqueId() { result = getVariable().toString() + " " + getVariable().getLocation().toString() @@ -157,7 +163,10 @@ class IRGeneratedVariable extends IRVariable { final override Language::LanguageType getLanguageType() { result = type } - final override Language::AST getAST() { result = ast } + final override Language::AST getAst() { result = ast } + + /** DEPRECATED: Alias for getAst */ + deprecated override Language::AST getAST() { result = getAst() } override string toString() { result = getBaseString() + getLocationString() } diff --git a/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/Instruction.qll b/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/Instruction.qll index 1c2cc493338..4dac3087f83 100644 --- a/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/Instruction.qll +++ b/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/Instruction.qll @@ -41,7 +41,7 @@ class Instruction extends Construction::TStageInstruction { } /** Gets a textual representation of this element. */ - final string toString() { result = this.getOpcode().toString() + ": " + this.getAST().toString() } + final string toString() { result = this.getOpcode().toString() + ": " + this.getAst().toString() } /** * Gets a string showing the result, opcode, and operands of the instruction, equivalent to what @@ -136,7 +136,7 @@ class Instruction extends Construction::TStageInstruction { string getResultId() { this.shouldGenerateDumpStrings() and result = - this.getResultPrefix() + this.getAST().getLocation().getStartLine() + "_" + this.getLineRank() + this.getResultPrefix() + this.getAst().getLocation().getStartLine() + "_" + this.getLineRank() } /** @@ -208,12 +208,15 @@ class Instruction extends Construction::TStageInstruction { /** * Gets the AST that caused this instruction to be generated. */ - final Language::AST getAST() { result = Construction::getInstructionAST(this) } + final Language::AST getAst() { result = Construction::getInstructionAst(this) } + + /** DEPRECATED: Alias for getAst */ + deprecated Language::AST getAST() { result = getAst() } /** * Gets the location of the source code for this instruction. */ - final Language::Location getLocation() { result = this.getAST().getLocation() } + final Language::Location getLocation() { result = this.getAst().getLocation() } /** * Gets the `Expr` whose result is computed by this instruction, if any. The `Expr` may be a @@ -459,7 +462,10 @@ class VariableInstruction extends Instruction { /** * Gets the AST variable that this instruction's IR variable refers to, if one exists. */ - final Language::Variable getASTVariable() { result = var.(IRUserVariable).getVariable() } + final Language::Variable getAstVariable() { result = var.(IRUserVariable).getVariable() } + + /** DEPRECATED: Alias for getAstVariable */ + deprecated Language::Variable getASTVariable() { result = getAstVariable() } } /** diff --git a/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/Operand.qll b/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/Operand.qll index 89b82657c3b..c1e997d5844 100644 --- a/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/Operand.qll +++ b/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/Operand.qll @@ -18,7 +18,7 @@ private import internal.OperandInternal * of `TOperand` that are used in this stage. */ private class TStageOperand = - TRegisterOperand or TNonSSAMemoryOperand or TPhiOperand or TChiOperand; + TRegisterOperand or TNonSsaMemoryOperand or TPhiOperand or TChiOperand; /** * A known location. Testing `loc instanceof KnownLocation` will account for non existing locations, as @@ -38,7 +38,7 @@ class Operand extends TStageOperand { // Ensure that the operand does not refer to instructions from earlier stages that are unreachable here exists(Instruction use, Instruction def | this = registerOperand(use, _, def)) or - exists(Instruction use | this = nonSSAMemoryOperand(use, _)) + exists(Instruction use | this = nonSsaMemoryOperand(use, _)) or exists(Instruction use, Instruction def, IRBlock predecessorBlock | this = phiOperand(use, def, predecessorBlock, _) or @@ -209,7 +209,7 @@ class Operand extends TStageOperand { class MemoryOperand extends Operand { cached MemoryOperand() { - this instanceof TNonSSAMemoryOperand or + this instanceof TNonSsaMemoryOperand or this instanceof TPhiOperand or this instanceof TChiOperand } @@ -249,7 +249,7 @@ class NonPhiOperand extends Operand { NonPhiOperand() { this = registerOperand(useInstr, tag, _) or - this = nonSSAMemoryOperand(useInstr, tag) or + this = nonSsaMemoryOperand(useInstr, tag) or this = chiOperand(useInstr, tag) } @@ -299,7 +299,7 @@ class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand, TNonPhiMemoryOpe cached NonPhiMemoryOperand() { - this = nonSSAMemoryOperand(useInstr, tag) + this = nonSsaMemoryOperand(useInstr, tag) or this = chiOperand(useInstr, tag) } diff --git a/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/gvn/internal/ValueNumberingInternal.qll b/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/gvn/internal/ValueNumberingInternal.qll index fdb645e03f0..2dc735f49df 100644 --- a/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/gvn/internal/ValueNumberingInternal.qll +++ b/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/gvn/internal/ValueNumberingInternal.qll @@ -99,7 +99,7 @@ private predicate filteredNumberableInstruction(Instruction instr) { // count rather than strictcount to handle missing AST elements // separate instanceof and inline casts to avoid failed casts with a count of 0 instr instanceof VariableAddressInstruction and - count(instr.(VariableAddressInstruction).getIRVariable().getAST()) != 1 + count(instr.(VariableAddressInstruction).getIRVariable().getAst()) != 1 or instr instanceof ConstantInstruction and count(instr.getResultIRType()) != 1 @@ -121,7 +121,7 @@ private predicate variableAddressValueNumber( // The underlying AST element is used as value-numbering key instead of the // `IRVariable` to work around a problem where a variable or expression with // multiple types gives rise to multiple `IRVariable`s. - unique( | | instr.getIRVariable().getAST()) = ast + unique( | | instr.getIRVariable().getAst()) = ast } private predicate initializeParameterValueNumber( @@ -131,7 +131,7 @@ private predicate initializeParameterValueNumber( // The underlying AST element is used as value-numbering key instead of the // `IRVariable` to work around a problem where a variable or expression with // multiple types gives rise to multiple `IRVariable`s. - instr.getIRVariable().getAST() = var + instr.getIRVariable().getAst() = var } private predicate constantValueNumber( diff --git a/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/OperandInternal.qll b/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/OperandInternal.qll index 88a4e6f8551..e522599abe9 100644 --- a/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/OperandInternal.qll +++ b/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/OperandInternal.qll @@ -1,2 +1,2 @@ private import experimental.ir.implementation.internal.TOperand -import UnaliasedSSAOperands +import UnaliasedSsaOperands diff --git a/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/PrintSSA.qll b/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/PrintSSA.qll index 72bb239c153..c7487872512 100644 --- a/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/PrintSSA.qll +++ b/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/PrintSSA.qll @@ -2,7 +2,7 @@ private import SSAConstructionInternal private import OldIR private import Alias private import SSAConstruction -private import DebugSSA +private import DebugSsa bindingset[offset] private string getKeySuffixForOffset(int offset) { diff --git a/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/SSAConsistency.qll b/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/SSAConsistency.qll index 5686bb439eb..1c75529be00 100644 --- a/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/SSAConsistency.qll +++ b/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/SSAConsistency.qll @@ -1,2 +1,2 @@ private import SSAConstruction as SSA -import SSA::SSAConsistency +import SSA::SsaConsistency diff --git a/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll b/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll index 5092e921cb3..13ec2ca4ca4 100644 --- a/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll +++ b/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll @@ -112,7 +112,7 @@ private module Cached { exists(Alias::getResultMemoryLocation(oldInstruction)) or // This result was already modeled by a previous iteration of SSA. - Alias::canReuseSSAForOldResult(oldInstruction) + Alias::canReuseSsaForOldResult(oldInstruction) } cached @@ -182,7 +182,7 @@ private module Cached { * unreachable, this predicate will recurse through any degenerate `Phi` instructions to find the * true definition. */ - private Instruction getNewDefinitionFromOldSSA(OldIR::MemoryOperand oldOperand, Overlap overlap) { + private Instruction getNewDefinitionFromOldSsa(OldIR::MemoryOperand oldOperand, Overlap overlap) { exists(Overlap originalOverlap | originalOverlap = oldOperand.getDefinitionOverlap() and ( @@ -191,7 +191,7 @@ private module Cached { or exists(OldIR::PhiInputOperand phiOperand, Overlap phiOperandOverlap | phiOperand = getDegeneratePhiOperand(oldOperand.getAnyDef()) and - result = getNewDefinitionFromOldSSA(phiOperand, phiOperandOverlap) and + result = getNewDefinitionFromOldSsa(phiOperand, phiOperandOverlap) and overlap = combineOverlap(pragma[only_bind_out](phiOperandOverlap), pragma[only_bind_out](originalOverlap)) @@ -233,7 +233,7 @@ private module Cached { ) or exists(OldIR::NonPhiMemoryOperand oldOperand | - result = getNewDefinitionFromOldSSA(oldOperand, overlap) and + result = getNewDefinitionFromOldSsa(oldOperand, overlap) and oldOperand.getUse() = instruction and tag = oldOperand.getOperandTag() ) @@ -307,13 +307,13 @@ private module Cached { * Gets the new definition instruction for the operand of `instr` that flows from the block * `newPredecessorBlock`, based on that operand's definition in the old IR. */ - private Instruction getNewPhiOperandDefinitionFromOldSSA( + private Instruction getNewPhiOperandDefinitionFromOldSsa( Instruction instr, IRBlock newPredecessorBlock, Overlap overlap ) { exists(OldIR::PhiInstruction oldPhi, OldIR::PhiInputOperand oldOperand | oldPhi = getOldInstruction(instr) and oldOperand = oldPhi.getInputOperand(getOldBlock(newPredecessorBlock)) and - result = getNewDefinitionFromOldSSA(oldOperand, overlap) + result = getNewDefinitionFromOldSsa(oldOperand, overlap) ) } @@ -333,7 +333,7 @@ private module Cached { overlap = Alias::getOverlap(actualDefLocation, useLocation) ) or - result = getNewPhiOperandDefinitionFromOldSSA(instr, newPredecessorBlock, overlap) + result = getNewPhiOperandDefinitionFromOldSsa(instr, newPredecessorBlock, overlap) } cached @@ -412,17 +412,17 @@ private module Cached { } cached - Language::AST getInstructionAST(Instruction instr) { - result = getOldInstruction(instr).getAST() + Language::AST getInstructionAst(Instruction instr) { + result = getOldInstruction(instr).getAst() or exists(RawIR::Instruction blockStartInstr | instr = phiInstruction(blockStartInstr, _) and - result = blockStartInstr.getAST() + result = blockStartInstr.getAst() ) or exists(RawIR::Instruction primaryInstr | instr = chiInstruction(primaryInstr) and - result = primaryInstr.getAST() + result = primaryInstr.getAst() ) or exists(IRFunctionBase irFunc | @@ -430,6 +430,12 @@ private module Cached { ) } + /** DEPRECATED: Alias for getInstructionAst */ + cached + deprecated Language::AST getInstructionAST(Instruction instr) { + result = getInstructionAst(instr) + } + cached Language::LanguageType getInstructionResultType(Instruction instr) { result = instr.(RawIR::Instruction).getResultLanguageType() @@ -975,35 +981,41 @@ module DefUse { } } -predicate canReuseSSAForMemoryResult(Instruction instruction) { +predicate canReuseSsaForMemoryResult(Instruction instruction) { exists(OldInstruction oldInstruction | oldInstruction = getOldInstruction(instruction) and ( // The previous iteration said it was reusable, so we should mark it as reusable as well. - Alias::canReuseSSAForOldResult(oldInstruction) + Alias::canReuseSsaForOldResult(oldInstruction) or // The current alias analysis says it is reusable. - Alias::getResultMemoryLocation(oldInstruction).canReuseSSA() + Alias::getResultMemoryLocation(oldInstruction).canReuseSsa() ) ) or exists(Alias::MemoryLocation defLocation | // This is a `Phi` for a reusable location, so the result of the `Phi` is reusable as well. instruction = phiInstruction(_, defLocation) and - defLocation.canReuseSSA() + defLocation.canReuseSsa() ) // We don't support reusing SSA for any location that could create a `Chi` instruction. } +/** DEPRECATED: Alias for canReuseSsaForMemoryResult */ +deprecated predicate canReuseSSAForMemoryResult = canReuseSsaForMemoryResult/1; + /** * Expose some of the internal predicates to PrintSSA.qll. We do this by publically importing those modules in the * `DebugSSA` module, which is then imported by PrintSSA. */ -module DebugSSA { +module DebugSsa { import PhiInsertion import DefUse } +/** DEPRECATED: Alias for DebugSsa */ +deprecated module DebugSSA = DebugSsa; + import CachedForDebugging cached @@ -1038,7 +1050,7 @@ private module CachedForDebugging { private OldIR::IRTempVariable getOldTempVariable(IRTempVariable var) { result.getEnclosingFunction() = var.getEnclosingFunction() and - result.getAST() = var.getAST() and + result.getAst() = var.getAst() and result.getTag() = var.getTag() } @@ -1061,7 +1073,7 @@ private module CachedForDebugging { int maxValue() { result = 2147483647 } } -module SSAConsistency { +module SsaConsistency { /** * Holds if a `MemoryOperand` has more than one `MemoryLocation` assigned by alias analysis. */ @@ -1114,6 +1126,9 @@ module SSAConsistency { } } +/** DEPRECATED: Alias for SsaConsistency */ +deprecated module SSAConsistency = SsaConsistency; + /** * Provides the portion of the parameterized IR interface that is used to construct the SSA stages * of the IR. The raw stage of the IR does not expose these predicates. diff --git a/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/SSAConstructionInternal.qll b/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/SSAConstructionInternal.qll index 8f726b81345..005ea53b018 100644 --- a/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/SSAConstructionInternal.qll +++ b/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/SSAConstructionInternal.qll @@ -3,7 +3,7 @@ import experimental.ir.implementation.raw.internal.reachability.ReachableBlock a import experimental.ir.implementation.raw.internal.reachability.Dominance as Dominance import experimental.ir.implementation.unaliased_ssa.IR as NewIR import experimental.ir.implementation.raw.internal.IRConstruction as RawStage -import experimental.ir.implementation.internal.TInstruction::UnaliasedSSAInstructions as SSAInstructions +import experimental.ir.implementation.internal.TInstruction::UnaliasedSsaInstructions as SSAInstructions import experimental.ir.internal.IRCSharpLanguage as Language import SimpleSSA as Alias -import experimental.ir.implementation.internal.TOperand::UnaliasedSSAOperands as SSAOperands +import experimental.ir.implementation.internal.TOperand::UnaliasedSsaOperands as SSAOperands diff --git a/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/SimpleSSA.qll b/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/SimpleSSA.qll index f3e02c9f6a8..ec2e6f5ef34 100644 --- a/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/SimpleSSA.qll +++ b/csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/SimpleSSA.qll @@ -41,11 +41,14 @@ predicate isVariableModeled(Allocation var) { * subsequent iterations will recompute SSA for any variable that we assumed did not escape, but * actually would have escaped if we had used a sound escape analysis. */ -predicate canReuseSSAForVariable(IRAutomaticVariable var) { +predicate canReuseSsaForVariable(IRAutomaticVariable var) { isVariableModeled(var) and not allocationEscapes(var) } +/** DEPRECATED: Alias for canReuseSsaForVariable */ +deprecated predicate canReuseSSAForVariable = canReuseSsaForVariable/1; + private newtype TMemoryLocation = MkMemoryLocation(Allocation var) { isVariableModeled(var) } private MemoryLocation getMemoryLocation(Allocation var) { result.getAllocation() = var } @@ -69,10 +72,16 @@ class MemoryLocation extends TMemoryLocation { final string getUniqueId() { result = var.getUniqueId() } - final predicate canReuseSSA() { canReuseSSAForVariable(var) } + final predicate canReuseSsa() { canReuseSsaForVariable(var) } + + /** DEPRECATED: Alias for canReuseSsa */ + deprecated predicate canReuseSSA() { canReuseSsa() } } -predicate canReuseSSAForOldResult(Instruction instr) { none() } +predicate canReuseSsaForOldResult(Instruction instr) { none() } + +/** DEPRECATED: Alias for canReuseSsaForOldResult */ +deprecated predicate canReuseSSAForOldResult = canReuseSsaForOldResult/1; /** * Represents a set of `MemoryLocation`s that cannot overlap with diff --git a/csharp/ql/src/experimental/ir/internal/IRGuards.qll b/csharp/ql/src/experimental/ir/internal/IRGuards.qll index a87788eb9a0..91e2208c6f7 100644 --- a/csharp/ql/src/experimental/ir/internal/IRGuards.qll +++ b/csharp/ql/src/experimental/ir/internal/IRGuards.qll @@ -28,8 +28,8 @@ class GuardCondition extends Expr { or // the IR short-circuits if(!x) // don't produce a guard condition for `y = !x` and other non-short-circuited cases - not exists(Instruction inst | this = inst.getAST()) and - exists(IRGuardCondition ir | this.(LogicalNotExpr).getOperand() = ir.getAST()) + not exists(Instruction inst | this = inst.getAst()) and + exists(IRGuardCondition ir | this.(LogicalNotExpr).getOperand() = ir.getAst()) } /** @@ -172,8 +172,8 @@ private class GuardConditionFromBinaryLogicalOperator extends GuardCondition { */ private class GuardConditionFromShortCircuitNot extends GuardCondition, LogicalNotExpr { GuardConditionFromShortCircuitNot() { - not exists(Instruction inst | this = inst.getAST()) and - exists(IRGuardCondition ir | this.getOperand() = ir.getAST()) + not exists(Instruction inst | this = inst.getAst()) and + exists(IRGuardCondition ir | this.getOperand() = ir.getAst()) } override predicate controls(BasicBlock controlled, boolean testIsTrue) { @@ -267,7 +267,7 @@ private class GuardConditionFromIR extends GuardCondition { private predicate controlsBlock1(BasicBlock controlled, boolean testIsTrue) { exists(IRBlock irb | forex(IRGuardCondition inst | inst = ir | inst.controls(irb, testIsTrue)) and - irb.getAnInstruction().getAST().(ControlFlowElement).getAControlFlowNode().getBasicBlock() = + irb.getAnInstruction().getAst().(ControlFlowElement).getAControlFlowNode().getBasicBlock() = controlled and not isUnreachedBlock(irb) ) diff --git a/csharp/ql/src/experimental/ir/rangeanalysis/RangeAnalysis.qll b/csharp/ql/src/experimental/ir/rangeanalysis/RangeAnalysis.qll index ccc6b9ea30e..ebdca09414f 100644 --- a/csharp/ql/src/experimental/ir/rangeanalysis/RangeAnalysis.qll +++ b/csharp/ql/src/experimental/ir/rangeanalysis/RangeAnalysis.qll @@ -623,7 +623,7 @@ private predicate boundedInstruction( ) or exists(PropertyAccess pa | - i.(CallInstruction).getAST() = pa and + i.(CallInstruction).getAst() = pa and pa.getProperty().getName() = "Length" and b instanceof ZeroBound and delta = origdelta and diff --git a/csharp/ql/test/experimental/ir/offbyone/OffByOneRA.ql b/csharp/ql/test/experimental/ir/offbyone/OffByOneRA.ql index 7518386e6d2..38386d47568 100644 --- a/csharp/ql/test/experimental/ir/offbyone/OffByOneRA.ql +++ b/csharp/ql/test/experimental/ir/offbyone/OffByOneRA.ql @@ -10,17 +10,17 @@ predicate boundedArrayAccess(ElementAccess aa, int k) { exists(Instruction index, Instruction usage, Bound b, int delta | ( // indexer access - usage.(CallInstruction).getAST() = aa + usage.(CallInstruction).getAst() = aa or // array access - usage.(PointerAddInstruction).getAST() = aa + usage.(PointerAddInstruction).getAst() = aa ) and usage.getAnOperand().getDef() = index and boundedInstruction(index, b, delta, true, _) | exists(PropertyAccess pa | k = delta and - b.getInstruction().getAST() = pa and + b.getInstruction().getAst() = pa and pa.getProperty().getName() = "Length" and pa.(QualifiableExpr).getQualifier().(VariableAccess).getTarget() = aa.getQualifier().(VariableAccess).getTarget() diff --git a/java/ql/lib/semmle/code/java/Expr.qll b/java/ql/lib/semmle/code/java/Expr.qll index d98cdbb6b0e..ad14984cffa 100755 --- a/java/ql/lib/semmle/code/java/Expr.qll +++ b/java/ql/lib/semmle/code/java/Expr.qll @@ -1668,7 +1668,10 @@ class LValue extends VarAccess { * (such as (`+=`), both the RHS and the LHS of the compound assignment * are source expressions of the assignment. */ - Expr getRHS() { exists(Assignment e | e.getDest() = this and e.getSource() = result) } + Expr getRhs() { exists(Assignment e | e.getDest() = this and e.getSource() = result) } + + /** DEPRECATED: Alias for getRhs */ + deprecated Expr getRHS() { result = getRhs() } } /** diff --git a/java/ql/lib/semmle/code/java/dataflow/SSA.qll b/java/ql/lib/semmle/code/java/dataflow/SSA.qll index f67a211198b..abcaf737d80 100644 --- a/java/ql/lib/semmle/code/java/dataflow/SSA.qll +++ b/java/ql/lib/semmle/code/java/dataflow/SSA.qll @@ -920,7 +920,7 @@ class SsaVariable extends TSsaVariable { } /** Gets the `ControlFlowNode` at which this SSA variable is defined. */ - ControlFlowNode getCFGNode() { + ControlFlowNode getCfgNode() { this = TSsaPhiNode(_, result) or this = TSsaCertainUpdate(_, result, _, _) or this = TSsaUncertainUpdate(_, result, _, _) or @@ -928,14 +928,17 @@ class SsaVariable extends TSsaVariable { this = TSsaUntracked(_, result) } + /** DEPRECATED: Alias for getCfgNode */ + deprecated ControlFlowNode getCFGNode() { result = getCfgNode() } + /** Gets a textual representation of this SSA variable. */ string toString() { none() } /** Gets the source location for this element. */ - Location getLocation() { result = this.getCFGNode().getLocation() } + Location getLocation() { result = this.getCfgNode().getLocation() } /** Gets the `BasicBlock` in which this SSA variable is defined. */ - BasicBlock getBasicBlock() { result = this.getCFGNode().getBasicBlock() } + BasicBlock getBasicBlock() { result = this.getCfgNode().getBasicBlock() } /** Gets an access of this SSA variable. */ RValue getAUse() { @@ -990,7 +993,7 @@ class SsaUpdate extends SsaVariable { class SsaExplicitUpdate extends SsaUpdate, TSsaCertainUpdate { SsaExplicitUpdate() { exists(VariableUpdate upd | - upd = this.getCFGNode() and getDestVar(upd) = this.getSourceVariable() + upd = this.getCfgNode() and getDestVar(upd) = this.getSourceVariable() ) } @@ -998,7 +1001,7 @@ class SsaExplicitUpdate extends SsaUpdate, TSsaCertainUpdate { /** Gets the `VariableUpdate` defining the SSA variable. */ VariableUpdate getDefiningExpr() { - result = this.getCFGNode() and getDestVar(result) = this.getSourceVariable() + result = this.getCfgNode() and getDestVar(result) = this.getSourceVariable() } } @@ -1018,10 +1021,10 @@ class SsaImplicitUpdate extends SsaUpdate { private string getKind() { this = TSsaUntracked(_, _) and result = "untracked" or - certainVariableUpdate(this.getSourceVariable().getQualifier(), this.getCFGNode(), _, _) and + certainVariableUpdate(this.getSourceVariable().getQualifier(), this.getCfgNode(), _, _) and result = "explicit qualifier" or - if uncertainVariableUpdate(this.getSourceVariable().getQualifier(), this.getCFGNode(), _, _) + if uncertainVariableUpdate(this.getSourceVariable().getQualifier(), this.getCfgNode(), _, _) then if exists(this.getANonLocalUpdate()) then result = "nonlocal + nonlocal qualifier" @@ -1038,7 +1041,7 @@ class SsaImplicitUpdate extends SsaUpdate { exists(SsaSourceField f, Callable setter | f = this.getSourceVariable() and relevantFieldUpdate(setter, f.getField(), result) and - updatesNamedField(this.getCFGNode(), f, setter) + updatesNamedField(this.getCfgNode(), f, setter) ) } @@ -1051,8 +1054,8 @@ class SsaImplicitUpdate extends SsaUpdate { */ predicate assignsUnknownValue() { this = TSsaUntracked(_, _) or - certainVariableUpdate(this.getSourceVariable().getQualifier(), this.getCFGNode(), _, _) or - uncertainVariableUpdate(this.getSourceVariable().getQualifier(), this.getCFGNode(), _, _) + certainVariableUpdate(this.getSourceVariable().getQualifier(), this.getCfgNode(), _, _) or + uncertainVariableUpdate(this.getSourceVariable().getQualifier(), this.getCfgNode(), _, _) } } @@ -1086,7 +1089,7 @@ class SsaImplicitInit extends SsaVariable, TSsaEntryDef { */ predicate isParameterDefinition(Parameter p) { this.getSourceVariable() = TLocalVar(p.getCallable(), p) and - p.getCallable().getBody() = this.getCFGNode() + p.getCallable().getBody() = this.getCfgNode() } } @@ -1098,7 +1101,7 @@ class SsaPhiNode extends SsaVariable, TSsaPhiNode { SsaVariable getAPhiInput() { exists(BasicBlock phiPred, TrackedVar v | v = this.getSourceVariable() and - this.getCFGNode().(BasicBlock).getABBPredecessor() = phiPred and + this.getCfgNode().(BasicBlock).getABBPredecessor() = phiPred and ssaDefReachesEndOfBlock(v, result, phiPred) ) } diff --git a/java/ql/lib/semmle/code/java/dataflow/internal/BaseSSA.qll b/java/ql/lib/semmle/code/java/dataflow/internal/BaseSSA.qll index 218fe6ef287..e41928fd9e5 100644 --- a/java/ql/lib/semmle/code/java/dataflow/internal/BaseSSA.qll +++ b/java/ql/lib/semmle/code/java/dataflow/internal/BaseSSA.qll @@ -476,18 +476,21 @@ class BaseSsaVariable extends TBaseSsaVariable { } /** Gets the `ControlFlowNode` at which this SSA variable is defined. */ - ControlFlowNode getCFGNode() { + ControlFlowNode getCfgNode() { this = TSsaPhiNode(_, result) or this = TSsaUpdate(_, result, _, _) or this = TSsaEntryDef(_, result) } + /** DEPRECATED: Alias for getCfgNode */ + deprecated ControlFlowNode getCFGNode() { result = getCfgNode() } + string toString() { none() } - Location getLocation() { result = this.getCFGNode().getLocation() } + Location getLocation() { result = this.getCfgNode().getLocation() } /** Gets the `BasicBlock` in which this SSA variable is defined. */ - BasicBlock getBasicBlock() { result = this.getCFGNode().getBasicBlock() } + BasicBlock getBasicBlock() { result = this.getCfgNode().getBasicBlock() } /** Gets an access of this SSA variable. */ RValue getAUse() { ssaDefReachesUse(_, this, result) } @@ -533,7 +536,7 @@ class BaseSsaVariable extends TBaseSsaVariable { class BaseSsaUpdate extends BaseSsaVariable, TSsaUpdate { BaseSsaUpdate() { exists(VariableUpdate upd | - upd = this.getCFGNode() and getDestVar(upd) = this.getSourceVariable() + upd = this.getCfgNode() and getDestVar(upd) = this.getSourceVariable() ) } @@ -541,7 +544,7 @@ class BaseSsaUpdate extends BaseSsaVariable, TSsaUpdate { /** Gets the `VariableUpdate` defining the SSA variable. */ VariableUpdate getDefiningExpr() { - result = this.getCFGNode() and getDestVar(result) = this.getSourceVariable() + result = this.getCfgNode() and getDestVar(result) = this.getSourceVariable() } } @@ -562,7 +565,7 @@ class BaseSsaImplicitInit extends BaseSsaVariable, TSsaEntryDef { */ predicate isParameterDefinition(Parameter p) { this.getSourceVariable() = TLocalVar(p.getCallable(), p) and - p.getCallable().getBody() = this.getCFGNode() + p.getCallable().getBody() = this.getCfgNode() } } @@ -574,7 +577,7 @@ class BaseSsaPhiNode extends BaseSsaVariable, TSsaPhiNode { BaseSsaVariable getAPhiInput() { exists(BasicBlock phiPred, BaseSsaSourceVariable v | v = this.getSourceVariable() and - this.getCFGNode().(BasicBlock).getABBPredecessor() = phiPred and + this.getCfgNode().(BasicBlock).getABBPredecessor() = phiPred and ssaDefReachesEndOfBlock(v, result, phiPred) ) } diff --git a/java/ql/lib/semmle/code/java/dataflow/internal/FlowSummaryImplSpecific.qll b/java/ql/lib/semmle/code/java/dataflow/internal/FlowSummaryImplSpecific.qll index eb59ee5f06a..f4fbcf0045f 100644 --- a/java/ql/lib/semmle/code/java/dataflow/internal/FlowSummaryImplSpecific.qll +++ b/java/ql/lib/semmle/code/java/dataflow/internal/FlowSummaryImplSpecific.qll @@ -196,7 +196,7 @@ predicate interpretInputSpecific(string c, InterpretNode mid, InterpretNode n) { exists(FieldWrite fw | c = "" and fw.getField() = mid.asElement() and - n.asNode().asExpr() = fw.getRHS() + n.asNode().asExpr() = fw.getRhs() ) } diff --git a/java/ql/lib/semmle/code/java/deadcode/EntryPoints.qll b/java/ql/lib/semmle/code/java/deadcode/EntryPoints.qll index cbb29066102..027e2392252 100644 --- a/java/ql/lib/semmle/code/java/deadcode/EntryPoints.qll +++ b/java/ql/lib/semmle/code/java/deadcode/EntryPoints.qll @@ -427,8 +427,8 @@ class PersistenceCallbackMethod extends CallableEntryPoint { * A source class which is referred to by fully qualified name in the value of an arbitrary XML * attribute which has a name containing "className" or "ClassName". */ -class ArbitraryXMLEntryPoint extends ReflectivelyConstructedClass { - ArbitraryXMLEntryPoint() { +class ArbitraryXmlEntryPoint extends ReflectivelyConstructedClass { + ArbitraryXmlEntryPoint() { this.fromSource() and exists(XMLAttribute attribute | attribute.getName() = "className" or @@ -446,6 +446,9 @@ class ArbitraryXMLEntryPoint extends ReflectivelyConstructedClass { } } +/** DEPRECATED: Alias for ArbitraryXmlEntryPoint */ +deprecated class ArbitraryXMLEntryPoint = ArbitraryXmlEntryPoint; + /** A Selenium PageObject, created by a call to PageFactory.initElements(..). */ class SeleniumPageObjectEntryPoint extends ReflectivelyConstructedClass { SeleniumPageObjectEntryPoint() { this instanceof SeleniumPageObject } diff --git a/java/ql/lib/semmle/code/java/deadcode/SpringEntryPoints.qll b/java/ql/lib/semmle/code/java/deadcode/SpringEntryPoints.qll index 4929ba2b7f2..562c7ef7c1c 100644 --- a/java/ql/lib/semmle/code/java/deadcode/SpringEntryPoints.qll +++ b/java/ql/lib/semmle/code/java/deadcode/SpringEntryPoints.qll @@ -13,7 +13,7 @@ class SpringInjectionCallableEntryPoint extends CallableEntryPoint { this instanceof SpringBeanReflectivelyConstructed or // A setter method specified in the context. this instanceof SpringBeanPropertySetterMethod or - exists(this.(SpringBeanXMLAutowiredSetterMethod).getInjectedBean()) or + exists(this.(SpringBeanXmlAutowiredSetterMethod).getInjectedBean()) or this instanceof SpringBeanAutowiredCallable } } diff --git a/java/ql/lib/semmle/code/java/deadcode/WebEntryPoints.qll b/java/ql/lib/semmle/code/java/deadcode/WebEntryPoints.qll index b061502fffe..836ad5a1f55 100644 --- a/java/ql/lib/semmle/code/java/deadcode/WebEntryPoints.qll +++ b/java/ql/lib/semmle/code/java/deadcode/WebEntryPoints.qll @@ -14,7 +14,7 @@ class ServletConstructedClass extends ReflectivelyConstructedClass { // referred to as a servlet-class in at least one. If no `web.xml` files are found, we assume // that XML extraction was not enabled, and therefore consider all `Servlet` classes as live. ( - isWebXMLIncluded() + isWebXmlIncluded() implies exists(WebServletClass servletClass | this = servletClass.getClass()) ) @@ -29,12 +29,12 @@ class ServletConstructedClass extends ReflectivelyConstructedClass { */ class ServletListenerClass extends ReflectivelyConstructedClass { ServletListenerClass() { - this.getAnAncestor() instanceof ServletWebXMLListenerType and + this.getAnAncestor() instanceof ServletWebXmlListenerType and // If we have seen any `web.xml` files, this listener will be considered to be live only if it is // referred to as a listener-class in at least one. If no `web.xml` files are found, we assume // that XML extraction was not enabled, and therefore consider all listener classes as live. ( - isWebXMLIncluded() + isWebXmlIncluded() implies exists(WebListenerClass listenerClass | this = listenerClass.getClass()) ) @@ -51,7 +51,7 @@ class ServletFilterClass extends ReflectivelyConstructedClass { // If we have seen any `web.xml` files, this filter will be considered to be live only if it is // referred to as a filter-class in at least one. If no `web.xml` files are found, we assume // that XML extraction was not enabled, and therefore consider all filter classes as live. - (isWebXMLIncluded() implies exists(WebFilterClass filterClass | this = filterClass.getClass())) + (isWebXmlIncluded() implies exists(WebFilterClass filterClass | this = filterClass.getClass())) } } diff --git a/java/ql/lib/semmle/code/java/frameworks/Camel.qll b/java/ql/lib/semmle/code/java/frameworks/Camel.qll index 09bfa73d460..0d7161e5f8f 100644 --- a/java/ql/lib/semmle/code/java/frameworks/Camel.qll +++ b/java/ql/lib/semmle/code/java/frameworks/Camel.qll @@ -12,7 +12,7 @@ import semmle.code.java.frameworks.camel.CamelJavaAnnotations */ class CamelToURI extends string { CamelToURI() { - exists(SpringCamelXMLToElement toXMLElement | this = toXMLElement.getURI()) or + exists(SpringCamelXmlToElement toXmlElement | this = toXmlElement.getURI()) or exists(CamelJavaDSLToDecl toJavaDSL | this = toJavaDSL.getURI()) } } @@ -56,17 +56,17 @@ class CamelToBeanURI extends CamelToURI { */ class CamelTargetClass extends Class { CamelTargetClass() { - exists(SpringCamelXMLBeanRef camelXMLBeanRef | + exists(SpringCamelXmlBeanRef camelXmlBeanRef | // A target may be defined by referencing an existing Spring Bean. - this = camelXMLBeanRef.getRefBean().getClass() + this = camelXmlBeanRef.getRefBean().getClass() or // A target may be defined by referencing a class, which Apache Camel will create into a bean. - this = camelXMLBeanRef.getBeanType() + this = camelXmlBeanRef.getBeanType() ) or exists(CamelToBeanURI toBeanURI | this = toBeanURI.getRefBean().getClass()) or - exists(SpringCamelXMLMethodElement xmlMethod | + exists(SpringCamelXmlMethodElement xmlMethod | this = xmlMethod.getRefBean().getClass() or this = xmlMethod.getBeanType() ) diff --git a/java/ql/lib/semmle/code/java/frameworks/Networking.qll b/java/ql/lib/semmle/code/java/frameworks/Networking.qll index 1ab9c74e0ca..66a798f40d3 100644 --- a/java/ql/lib/semmle/code/java/frameworks/Networking.qll +++ b/java/ql/lib/semmle/code/java/frameworks/Networking.qll @@ -4,7 +4,7 @@ import semmle.code.java.Type -/** The type `java.net.URLConnection`. */ +/** The type `java.net.UrlConnection`. */ class TypeUrlConnection extends RefType { TypeUrlConnection() { this.hasQualifiedName("java.net", "URLConnection") } } @@ -29,15 +29,18 @@ class TypeUri extends RefType { TypeUri() { this.hasQualifiedName("java.net", "URI") } } -/** The method `java.net.URLConnection::getInputStream`. */ -class URLConnectionGetInputStreamMethod extends Method { - URLConnectionGetInputStreamMethod() { +/** The method `java.net.UrlConnection::getInputStream`. */ +class UrlConnectionGetInputStreamMethod extends Method { + UrlConnectionGetInputStreamMethod() { this.getDeclaringType() instanceof TypeUrlConnection and this.hasName("getInputStream") and this.hasNoParameters() } } +/** DEPRECATED: Alias for UrlConnectionGetInputStreamMethod */ +deprecated class URLConnectionGetInputStreamMethod = UrlConnectionGetInputStreamMethod; + /** The method `java.net.Socket::getInputStream`. */ class SocketGetInputStreamMethod extends Method { SocketGetInputStreamMethod() { diff --git a/java/ql/lib/semmle/code/java/frameworks/Servlets.qll b/java/ql/lib/semmle/code/java/frameworks/Servlets.qll index 81f334015bd..de82d49a7aa 100644 --- a/java/ql/lib/semmle/code/java/frameworks/Servlets.qll +++ b/java/ql/lib/semmle/code/java/frameworks/Servlets.qll @@ -120,14 +120,17 @@ library class HttpServletRequestGetHeaderNamesMethod extends Method { /** * The method `getRequestURL()` declared in `javax.servlet.http.HttpServletRequest`. */ -class HttpServletRequestGetRequestURLMethod extends Method { - HttpServletRequestGetRequestURLMethod() { +class HttpServletRequestGetRequestUrlMethod extends Method { + HttpServletRequestGetRequestUrlMethod() { this.getDeclaringType() instanceof HttpServletRequest and this.hasName("getRequestURL") and this.getNumberOfParameters() = 0 } } +/** DEPRECATED: Alias for HttpServletRequestGetRequestUrlMethod */ +deprecated class HttpServletRequestGetRequestURLMethod = HttpServletRequestGetRequestUrlMethod; + /** * The method `getRequestURI()` declared in `javax.servlet.http.HttpServletRequest`. */ @@ -318,8 +321,8 @@ class ServletClass extends Class { * Note: There are a number of other listener interfaces in the `javax.servlet` package that cannot * be configured in `web.xml` and therefore are not covered by this class. */ -class ServletWebXMLListenerType extends RefType { - ServletWebXMLListenerType() { +class ServletWebXmlListenerType extends RefType { + ServletWebXmlListenerType() { this.hasQualifiedName("javax.servlet", "ServletContextAttributeListener") or this.hasQualifiedName("javax.servlet", "ServletContextListener") or this.hasQualifiedName("javax.servlet", "ServletRequestAttributeListener") or @@ -333,6 +336,9 @@ class ServletWebXMLListenerType extends RefType { } } +/** DEPRECATED: Alias for ServletWebXmlListenerType */ +deprecated class ServletWebXMLListenerType = ServletWebXmlListenerType; + /** Holds if `m` is a request handler method (for example `doGet` or `doPost`). */ predicate isServletRequestMethod(Method m) { m.getDeclaringType() instanceof ServletClass and diff --git a/java/ql/lib/semmle/code/java/frameworks/UnboundId.qll b/java/ql/lib/semmle/code/java/frameworks/UnboundId.qll index 88156da0264..2bac6eb5ce2 100644 --- a/java/ql/lib/semmle/code/java/frameworks/UnboundId.qll +++ b/java/ql/lib/semmle/code/java/frameworks/UnboundId.qll @@ -25,12 +25,15 @@ class TypeUnboundIdLdapFilter extends Class { } /** The class `com.unboundid.ldap.sdk.LDAPConnection`. */ -class TypeUnboundIdLDAPConnection extends Class { - TypeUnboundIdLDAPConnection() { +class TypeUnboundIdLdapConnection extends Class { + TypeUnboundIdLdapConnection() { this.hasQualifiedName("com.unboundid.ldap.sdk", "LDAPConnection") } } +/** DEPRECATED: Alias for TypeUnboundIdLdapConnection */ +deprecated class TypeUnboundIdLDAPConnection = TypeUnboundIdLdapConnection; + /*--- Methods ---*/ /** A method with the name `setBaseDN` declared in `com.unboundid.ldap.sdk.SearchRequest`. */ class MethodUnboundIdSearchRequestSetBaseDN extends Method { @@ -89,25 +92,36 @@ class MethodUnboundIdFilterSimplifyFilter extends Method { } /** A method with the name `search` declared in `com.unboundid.ldap.sdk.LDAPConnection`. */ -class MethodUnboundIdLDAPConnectionSearch extends Method { - MethodUnboundIdLDAPConnectionSearch() { - this.getDeclaringType() instanceof TypeUnboundIdLDAPConnection and +class MethodUnboundIdLdapConnectionSearch extends Method { + MethodUnboundIdLdapConnectionSearch() { + this.getDeclaringType() instanceof TypeUnboundIdLdapConnection and this.hasName("search") } } +/** DEPRECATED: Alias for MethodUnboundIdLdapConnectionSearch */ +deprecated class MethodUnboundIdLDAPConnectionSearch = MethodUnboundIdLdapConnectionSearch; + /** A method with the name `asyncSearch` declared in `com.unboundid.ldap.sdk.LDAPConnection`. */ -class MethodUnboundIdLDAPConnectionAsyncSearch extends Method { - MethodUnboundIdLDAPConnectionAsyncSearch() { - this.getDeclaringType() instanceof TypeUnboundIdLDAPConnection and +class MethodUnboundIdLdapConnectionAsyncSearch extends Method { + MethodUnboundIdLdapConnectionAsyncSearch() { + this.getDeclaringType() instanceof TypeUnboundIdLdapConnection and this.hasName("asyncSearch") } } +/** DEPRECATED: Alias for MethodUnboundIdLdapConnectionAsyncSearch */ +deprecated class MethodUnboundIdLDAPConnectionAsyncSearch = + MethodUnboundIdLdapConnectionAsyncSearch; + /** A method with the name `searchForEntry` declared in `com.unboundid.ldap.sdk.LDAPConnection`. */ -class MethodUnboundIdLDAPConnectionSearchForEntry extends Method { - MethodUnboundIdLDAPConnectionSearchForEntry() { - this.getDeclaringType() instanceof TypeUnboundIdLDAPConnection and +class MethodUnboundIdLdapConnectionSearchForEntry extends Method { + MethodUnboundIdLdapConnectionSearchForEntry() { + this.getDeclaringType() instanceof TypeUnboundIdLdapConnection and this.hasName("searchForEntry") } } + +/** DEPRECATED: Alias for MethodUnboundIdLdapConnectionSearchForEntry */ +deprecated class MethodUnboundIdLDAPConnectionSearchForEntry = + MethodUnboundIdLdapConnectionSearchForEntry; diff --git a/java/ql/lib/semmle/code/java/frameworks/gwt/GwtXml.qll b/java/ql/lib/semmle/code/java/frameworks/gwt/GwtXml.qll index 3ac223be2d5..f3d5c58c0ce 100644 --- a/java/ql/lib/semmle/code/java/frameworks/gwt/GwtXml.qll +++ b/java/ql/lib/semmle/code/java/frameworks/gwt/GwtXml.qll @@ -5,7 +5,7 @@ import semmle.code.xml.XML /** * Holds if any `*.gwt.xml` files are included in this snapshot. */ -predicate isGwtXmlIncluded() { exists(GwtXmlFile webXML) } +predicate isGwtXmlIncluded() { exists(GwtXmlFile webXml) } /** A GWT module XML file with a `.gwt.xml` suffix. */ class GwtXmlFile extends XMLFile { diff --git a/java/ql/lib/semmle/code/java/frameworks/jOOQ.qll b/java/ql/lib/semmle/code/java/frameworks/jOOQ.qll index 8a6ee13ec57..0e74408bca1 100644 --- a/java/ql/lib/semmle/code/java/frameworks/jOOQ.qll +++ b/java/ql/lib/semmle/code/java/frameworks/jOOQ.qll @@ -10,8 +10,8 @@ import semmle.code.java.dataflow.ExternalFlow * and is prone to SQL injection. * https://www.jooq.org/doc/current/manual/sql-building/plain-sql/ */ -private class PlainSQLType extends Annotation { - PlainSQLType() { this.getType().hasQualifiedName("org.jooq", "PlainSQL") } +private class PlainSqlType extends Annotation { + PlainSqlType() { this.getType().hasQualifiedName("org.jooq", "PlainSQL") } } /** @@ -19,7 +19,7 @@ private class PlainSQLType extends Annotation { * first argument. */ predicate jOOQSqlMethod(Method m) { - m.getAnAnnotation() instanceof PlainSQLType and + m.getAnAnnotation() instanceof PlainSqlType and m.getParameterType(0) instanceof TypeString } diff --git a/java/ql/lib/semmle/code/java/frameworks/jackson/JacksonSerializability.qll b/java/ql/lib/semmle/code/java/frameworks/jackson/JacksonSerializability.qll index bf87e7fbc57..1fb2e377841 100644 --- a/java/ql/lib/semmle/code/java/frameworks/jackson/JacksonSerializability.qll +++ b/java/ql/lib/semmle/code/java/frameworks/jackson/JacksonSerializability.qll @@ -14,14 +14,17 @@ private import semmle.code.java.dataflow.ExternalFlow /** * A `@com.fasterxml.jackson.annotation.JsonIgnore` annoation. */ -class JacksonJSONIgnoreAnnotation extends NonReflectiveAnnotation { - JacksonJSONIgnoreAnnotation() { +class JacksonJsonIgnoreAnnotation extends NonReflectiveAnnotation { + JacksonJsonIgnoreAnnotation() { exists(AnnotationType anntp | anntp = this.getType() | anntp.hasQualifiedName("com.fasterxml.jackson.annotation", "JsonIgnore") ) } } +/** DEPRECATED: Alias for JacksonJsonIgnoreAnnotation */ +deprecated class JacksonJSONIgnoreAnnotation = JacksonJsonIgnoreAnnotation; + /** A type whose values may be serialized using the Jackson JSON framework. */ abstract class JacksonSerializableType extends Type { } @@ -143,7 +146,7 @@ class JacksonSerializableField extends SerializableField { not superType instanceof TypeObject and superType.fromSource() ) and - not this.getAnAnnotation() instanceof JacksonJSONIgnoreAnnotation + not this.getAnAnnotation() instanceof JacksonJsonIgnoreAnnotation } } @@ -155,7 +158,7 @@ class JacksonDeserializableField extends DeserializableField { not superType instanceof TypeObject and superType.fromSource() ) and - not this.getAnAnnotation() instanceof JacksonJSONIgnoreAnnotation + not this.getAnAnnotation() instanceof JacksonJsonIgnoreAnnotation } } diff --git a/java/ql/lib/semmle/code/java/frameworks/javaee/JavaServerFaces.qll b/java/ql/lib/semmle/code/java/frameworks/javaee/JavaServerFaces.qll index 1d6c08c4862..326bfe34381 100644 --- a/java/ql/lib/semmle/code/java/frameworks/javaee/JavaServerFaces.qll +++ b/java/ql/lib/semmle/code/java/frameworks/javaee/JavaServerFaces.qll @@ -67,8 +67,8 @@ class FacesComponent extends Class { ) or // Or in an XML file - exists(FacesConfigComponentClass componentClassXML | - this = componentClassXML.getFacesComponentClass() + exists(FacesConfigComponentClass componentClassXml | + this = componentClassXml.getFacesComponentClass() ) ) } diff --git a/java/ql/lib/semmle/code/java/frameworks/javaee/PersistenceXML.qll b/java/ql/lib/semmle/code/java/frameworks/javaee/PersistenceXML.qll index 82fc32baca2..077c2baf862 100644 --- a/java/ql/lib/semmle/code/java/frameworks/javaee/PersistenceXML.qll +++ b/java/ql/lib/semmle/code/java/frameworks/javaee/PersistenceXML.qll @@ -8,8 +8,8 @@ import java /** * A JavaEE persistence configuration XML file (persistence.xml). */ -class PersistenceXMLFile extends XMLFile { - PersistenceXMLFile() { this.getStem() = "persistence" } +class PersistenceXmlFile extends XMLFile { + PersistenceXmlFile() { this.getStem() = "persistence" } /** Gets the root XML element in this `persistence.xml` file. */ PersistenceXmlRoot getRoot() { result = this.getAChild() } @@ -26,10 +26,13 @@ class PersistenceXMLFile extends XMLFile { } } +/** DEPRECATED: Alias for PersistenceXmlFile */ +deprecated class PersistenceXMLFile = PersistenceXmlFile; + /** The root `persistence` XML element in a `persistence.xml` file. */ class PersistenceXmlRoot extends XMLElement { PersistenceXmlRoot() { - this.getParent() instanceof PersistenceXMLFile and + this.getParent() instanceof PersistenceXmlFile and this.getName() = "persistence" } diff --git a/java/ql/lib/semmle/code/java/frameworks/javaee/ejb/EJB.qll b/java/ql/lib/semmle/code/java/frameworks/javaee/ejb/EJB.qll index 58968c753ac..5a65891020a 100644 --- a/java/ql/lib/semmle/code/java/frameworks/javaee/ejb/EJB.qll +++ b/java/ql/lib/semmle/code/java/frameworks/javaee/ejb/EJB.qll @@ -22,7 +22,7 @@ class SessionEJB extends EJB { this.getAnAnnotation().getType().hasName("Stateless") or this.getAnAnnotation().getType().hasName("Stateful") or // XML deployment descriptor. - exists(EjbJarXMLFile f | + exists(EjbJarXmlFile f | this.getQualifiedName() = f.getASessionElement().getAnEjbClassElement().getACharactersSet().getCharacters() ) @@ -121,7 +121,7 @@ class StatefulSessionEJB extends SessionEJB { this.getAnAnnotation().getType().hasName("Stateful") or // XML deployment descriptor. - exists(EjbJarXMLFile f, EjbJarSessionElement se | + exists(EjbJarXmlFile f, EjbJarSessionElement se | se = f.getASessionElement() and this.getQualifiedName() = se.getAnEjbClassElement().getACharactersSet().getCharacters() and se.getASessionTypeElement().isStateful() @@ -138,7 +138,7 @@ class StatelessSessionEJB extends SessionEJB { this.getAnAnnotation().getType().hasName("Stateless") or // XML deployment descriptor. - exists(EjbJarXMLFile f, EjbJarSessionElement se | + exists(EjbJarXmlFile f, EjbJarSessionElement se | se = f.getASessionElement() and this.getQualifiedName() = se.getAnEjbClassElement().getACharactersSet().getCharacters() and se.getASessionTypeElement().isStateless() @@ -158,7 +158,7 @@ class MessageDrivenBean extends EJB { this.getAnAnnotation().getType().hasName("MessageDriven") or // XML deployment descriptor. - exists(EjbJarXMLFile f | + exists(EjbJarXmlFile f | this.getQualifiedName() = f.getAMessageDrivenElement().getAnEjbClassElement().getACharactersSet().getCharacters() ) @@ -174,7 +174,7 @@ class EntityEJB extends EJB { this instanceof EntityBean or // XML deployment descriptor. - exists(EjbJarXMLFile f | + exists(EjbJarXmlFile f | this.getQualifiedName() = f.getAnEntityElement().getAnEjbClassElement().getACharactersSet().getCharacters() ) @@ -245,14 +245,14 @@ abstract class BusinessInterface extends Interface { */ class XmlSpecifiedBusinessInterface extends BusinessInterface { XmlSpecifiedBusinessInterface() { - exists(EjbJarXMLFile f | + exists(EjbJarXmlFile f | this.getQualifiedName() = f.getASessionElement().getABusinessElement().getACharactersSet().getCharacters() ) } override SessionEJB getAnEJB() { - exists(EjbJarXMLFile f, EjbJarSessionElement se | + exists(EjbJarXmlFile f, EjbJarSessionElement se | se = f.getASessionElement() and this.getQualifiedName() = se.getABusinessElement().getACharactersSet().getCharacters() and result.getQualifiedName() = se.getAnEjbClassElement().getACharactersSet().getCharacters() @@ -260,14 +260,14 @@ class XmlSpecifiedBusinessInterface extends BusinessInterface { } override predicate isDeclaredLocal() { - exists(EjbJarXMLFile f | + exists(EjbJarXmlFile f | this.getQualifiedName() = f.getASessionElement().getABusinessLocalElement().getACharactersSet().getCharacters() ) } override predicate isDeclaredRemote() { - exists(EjbJarXMLFile f | + exists(EjbJarXmlFile f | this.getQualifiedName() = f.getASessionElement().getABusinessRemoteElement().getACharactersSet().getCharacters() ) @@ -411,7 +411,7 @@ class ExtendedRemoteInterface extends LegacyEjbRemoteInterface, RemoteEJBInterfa /** A legacy remote interface specified within an XML deployment descriptor. */ class XmlSpecifiedRemoteInterface extends LegacyEjbRemoteInterface { XmlSpecifiedRemoteInterface() { - exists(EjbJarXMLFile f | + exists(EjbJarXmlFile f | this.getQualifiedName() = f.getASessionElement().getARemoteElement().getACharactersSet().getCharacters() ) @@ -422,7 +422,7 @@ class XmlSpecifiedRemoteInterface extends LegacyEjbRemoteInterface { * for this legacy EJB remote interface. */ SessionEJB getAnEJB() { - exists(EjbJarXMLFile f, EjbJarSessionElement se | + exists(EjbJarXmlFile f, EjbJarSessionElement se | se = f.getASessionElement() and this.getQualifiedName() = se.getARemoteElement().getACharactersSet().getCharacters() and result.getQualifiedName() = se.getAnEjbClassElement().getACharactersSet().getCharacters() @@ -453,7 +453,7 @@ class AnnotatedRemoteHomeInterface extends LegacyEjbRemoteHomeInterface { /** A legacy remote home interface specified within an XML deployment descriptor. */ class XmlSpecifiedRemoteHomeInterface extends LegacyEjbRemoteHomeInterface { XmlSpecifiedRemoteHomeInterface() { - exists(EjbJarXMLFile f | + exists(EjbJarXmlFile f | this.getQualifiedName() = f.getASessionElement().getARemoteHomeElement().getACharactersSet().getCharacters() ) @@ -461,7 +461,7 @@ class XmlSpecifiedRemoteHomeInterface extends LegacyEjbRemoteHomeInterface { /** Gets an EJB to which this interface belongs. */ SessionEJB getAnEJB() { - exists(EjbJarXMLFile f, EjbJarSessionElement se | + exists(EjbJarXmlFile f, EjbJarSessionElement se | se = f.getASessionElement() and this.getQualifiedName() = se.getARemoteHomeElement().getACharactersSet().getCharacters() and result.getQualifiedName() = se.getAnEjbClassElement().getACharactersSet().getCharacters() @@ -478,7 +478,7 @@ class ExtendedLocalInterface extends LegacyEjbLocalInterface, LocalEJBInterface /** A legacy local interface specified within an XML deployment descriptor. */ class XmlSpecifiedLocalInterface extends LegacyEjbLocalInterface { XmlSpecifiedLocalInterface() { - exists(EjbJarXMLFile f | + exists(EjbJarXmlFile f | this.getQualifiedName() = f.getASessionElement().getALocalElement().getACharactersSet().getCharacters() ) @@ -486,7 +486,7 @@ class XmlSpecifiedLocalInterface extends LegacyEjbLocalInterface { /** Gets an EJB to which this interface belongs. */ SessionEJB getAnEJB() { - exists(EjbJarXMLFile f, EjbJarSessionElement se | + exists(EjbJarXmlFile f, EjbJarSessionElement se | se = f.getASessionElement() and this.getQualifiedName() = se.getALocalElement().getACharactersSet().getCharacters() and result.getQualifiedName() = se.getAnEjbClassElement().getACharactersSet().getCharacters() @@ -517,7 +517,7 @@ class AnnotatedLocalHomeInterface extends LegacyEjbLocalHomeInterface { /** A legacy local home interface specified within an XML deployment descriptor. */ class XmlSpecifiedLocalHomeInterface extends LegacyEjbLocalHomeInterface { XmlSpecifiedLocalHomeInterface() { - exists(EjbJarXMLFile f | + exists(EjbJarXmlFile f | this.getQualifiedName() = f.getASessionElement().getALocalHomeElement().getACharactersSet().getCharacters() ) @@ -525,7 +525,7 @@ class XmlSpecifiedLocalHomeInterface extends LegacyEjbLocalHomeInterface { /** Gets an EJB to which this interface belongs. */ SessionEJB getAnEJB() { - exists(EjbJarXMLFile f, EjbJarSessionElement se | + exists(EjbJarXmlFile f, EjbJarSessionElement se | se = f.getASessionElement() and this.getQualifiedName() = se.getALocalHomeElement().getACharactersSet().getCharacters() and result.getQualifiedName() = se.getAnEjbClassElement().getACharactersSet().getCharacters() diff --git a/java/ql/lib/semmle/code/java/frameworks/javaee/ejb/EJBJarXML.qll b/java/ql/lib/semmle/code/java/frameworks/javaee/ejb/EJBJarXML.qll index db89836ff9d..4122869ecdb 100644 --- a/java/ql/lib/semmle/code/java/frameworks/javaee/ejb/EJBJarXML.qll +++ b/java/ql/lib/semmle/code/java/frameworks/javaee/ejb/EJBJarXML.qll @@ -8,8 +8,8 @@ import java /** * An EJB deployment descriptor XML file named `ejb-jar.xml`. */ -class EjbJarXMLFile extends XMLFile { - EjbJarXMLFile() { this.getStem() = "ejb-jar" } +class EjbJarXmlFile extends XMLFile { + EjbJarXmlFile() { this.getStem() = "ejb-jar" } /** Gets the root `ejb-jar` XML element of this `ejb-jar.xml` file. */ EjbJarRootElement getRoot() { result = this.getAChild() } @@ -35,10 +35,13 @@ class EjbJarXMLFile extends XMLFile { } } +/** DEPRECATED: Alias for EjbJarXmlFile */ +deprecated class EjbJarXMLFile = EjbJarXmlFile; + /** The root `ejb-jar` XML element in an `ejb-jar.xml` file. */ class EjbJarRootElement extends XMLElement { EjbJarRootElement() { - this.getParent() instanceof EjbJarXMLFile and + this.getParent() instanceof EjbJarXmlFile and this.getName() = "ejb-jar" } diff --git a/java/ql/lib/semmle/code/java/frameworks/javaee/jsf/JSFFacesContextXML.qll b/java/ql/lib/semmle/code/java/frameworks/javaee/jsf/JSFFacesContextXML.qll index 2d6721298a9..657df736c4c 100644 --- a/java/ql/lib/semmle/code/java/frameworks/javaee/jsf/JSFFacesContextXML.qll +++ b/java/ql/lib/semmle/code/java/frameworks/javaee/jsf/JSFFacesContextXML.qll @@ -8,19 +8,22 @@ import default * A JSF "application configuration resources file", typically called `faces-config.xml`, which * contains the configuration for a JSF application */ -class FacesConfigXMLFile extends XMLFile { - FacesConfigXMLFile() { +class FacesConfigXmlFile extends XMLFile { + FacesConfigXmlFile() { // Contains a single top-level XML node named "faces-Config". count(XMLElement e | e = this.getAChild()) = 1 and this.getAChild().getName() = "faces-config" } } +/** DEPRECATED: Alias for FacesConfigXmlFile */ +deprecated class FacesConfigXMLFile = FacesConfigXmlFile; + /** * An XML element in a `FacesConfigXMLFile`. */ -class FacesConfigXMLElement extends XMLElement { - FacesConfigXMLElement() { this.getFile() instanceof FacesConfigXMLFile } +class FacesConfigXmlElement extends XMLElement { + FacesConfigXmlElement() { this.getFile() instanceof FacesConfigXmlFile } /** * Gets the value for this element, with leading and trailing whitespace trimmed. @@ -28,17 +31,20 @@ class FacesConfigXMLElement extends XMLElement { string getValue() { result = this.allCharactersString().trim() } } +/** DEPRECATED: Alias for FacesConfigXmlElement */ +deprecated class FacesConfigXMLElement = FacesConfigXmlElement; + /** * An element in a JSF config file that declares a managed bean. */ -class FacesConfigManagedBean extends FacesConfigXMLElement { +class FacesConfigManagedBean extends FacesConfigXmlElement { FacesConfigManagedBean() { this.getName() = "managed-bean" } } /** * An element in a JSF config file that declares the Class of a managed bean. */ -class FacesConfigManagedBeanClass extends FacesConfigXMLElement { +class FacesConfigManagedBeanClass extends FacesConfigXmlElement { FacesConfigManagedBeanClass() { this.getName() = "managed-bean-class" and this.getParent() instanceof FacesConfigManagedBean @@ -53,14 +59,14 @@ class FacesConfigManagedBeanClass extends FacesConfigXMLElement { /** * An element in a JSF config file that declares a custom component. */ -class FacesConfigComponent extends FacesConfigXMLElement { +class FacesConfigComponent extends FacesConfigXmlElement { FacesConfigComponent() { this.getName() = "component" } } /** * An element in a JSF config file that declares the Class of a faces component. */ -class FacesConfigComponentClass extends FacesConfigXMLElement { +class FacesConfigComponentClass extends FacesConfigXmlElement { FacesConfigComponentClass() { this.getName() = "component-class" and this.getParent() instanceof FacesConfigComponent diff --git a/java/ql/lib/semmle/code/java/frameworks/spring/SpringAbstractRef.qll b/java/ql/lib/semmle/code/java/frameworks/spring/SpringAbstractRef.qll index 685c22779f3..4dd4b0ab947 100644 --- a/java/ql/lib/semmle/code/java/frameworks/spring/SpringAbstractRef.qll +++ b/java/ql/lib/semmle/code/java/frameworks/spring/SpringAbstractRef.qll @@ -3,7 +3,7 @@ import semmle.code.java.frameworks.spring.SpringXMLElement import semmle.code.java.frameworks.spring.SpringBean /** A common supertype of `SpringRef` and `SpringIdRef`. */ -class SpringAbstractRef extends SpringXMLElement { +class SpringAbstractRef extends SpringXmlElement { SpringAbstractRef() { this.getName() = "idref" or this.getName() = "ref" @@ -29,7 +29,7 @@ class SpringAbstractRef extends SpringXMLElement { } /** Holds if `other` is also a reference and points to the same bean as this reference. */ - override predicate isSimilar(SpringXMLElement other) { + override predicate isSimilar(SpringXmlElement other) { exists(SpringAbstractRef otherRef | otherRef = other and this.getBean() = otherRef.getBean() diff --git a/java/ql/lib/semmle/code/java/frameworks/spring/SpringAlias.qll b/java/ql/lib/semmle/code/java/frameworks/spring/SpringAlias.qll index a3aa0fd38ac..cbc4f025dac 100644 --- a/java/ql/lib/semmle/code/java/frameworks/spring/SpringAlias.qll +++ b/java/ql/lib/semmle/code/java/frameworks/spring/SpringAlias.qll @@ -3,7 +3,7 @@ import semmle.code.java.frameworks.spring.SpringXMLElement import semmle.code.java.frameworks.spring.SpringBean /** An `` element in Spring XML files. */ -class SpringAlias extends SpringXMLElement { +class SpringAlias extends SpringXmlElement { SpringAlias() { this.getName() = "alias" } /** Gets the value of the `alias` attribute. */ diff --git a/java/ql/lib/semmle/code/java/frameworks/spring/SpringArgType.qll b/java/ql/lib/semmle/code/java/frameworks/spring/SpringArgType.qll index 285c34d48e4..bddf5f01f9e 100644 --- a/java/ql/lib/semmle/code/java/frameworks/spring/SpringArgType.qll +++ b/java/ql/lib/semmle/code/java/frameworks/spring/SpringArgType.qll @@ -2,7 +2,7 @@ import java import semmle.code.java.frameworks.spring.SpringXMLElement /** An `` element in Spring XML files. */ -class SpringArgType extends SpringXMLElement { +class SpringArgType extends SpringXmlElement { SpringArgType() { this.getName() = "arg-type" } /** Gets the value of the `match` attribute. */ diff --git a/java/ql/lib/semmle/code/java/frameworks/spring/SpringAttribute.qll b/java/ql/lib/semmle/code/java/frameworks/spring/SpringAttribute.qll index 1f2f2a13e68..a20eef4d0d7 100644 --- a/java/ql/lib/semmle/code/java/frameworks/spring/SpringAttribute.qll +++ b/java/ql/lib/semmle/code/java/frameworks/spring/SpringAttribute.qll @@ -2,7 +2,7 @@ import java import semmle.code.java.frameworks.spring.SpringXMLElement /** An `` element in Spring XML files. */ -class SpringAttribute extends SpringXMLElement { +class SpringAttribute extends SpringXmlElement { SpringAttribute() { this.getName() = "attribute" } /** Gets the value of the `key` attribute. */ diff --git a/java/ql/lib/semmle/code/java/frameworks/spring/SpringAutowire.qll b/java/ql/lib/semmle/code/java/frameworks/spring/SpringAutowire.qll index f387b40a547..b99dafecc65 100644 --- a/java/ql/lib/semmle/code/java/frameworks/spring/SpringAutowire.qll +++ b/java/ql/lib/semmle/code/java/frameworks/spring/SpringAutowire.qll @@ -58,8 +58,8 @@ class SpringBeanPropertySetterMethod extends Method { * * Confusingly, this is a different form of autowiring to the `@Autowired` annotation. */ -class SpringBeanXMLAutowiredSetterMethod extends Method { - SpringBeanXMLAutowiredSetterMethod() { +class SpringBeanXmlAutowiredSetterMethod extends Method { + SpringBeanXmlAutowiredSetterMethod() { // The bean as marked with some form of autowiring in the XML file. exists(string xmlAutowire | xmlAutowire = this.getDeclaringType().(SpringBeanRefType).getSpringBean().getAutowire() @@ -100,6 +100,9 @@ class SpringBeanXMLAutowiredSetterMethod extends Method { } } +/** DEPRECATED: Alias for SpringBeanXmlAutowiredSetterMethod */ +deprecated class SpringBeanXMLAutowiredSetterMethod = SpringBeanXmlAutowiredSetterMethod; + /** * A callable that is annotated with `@Autowired`. * diff --git a/java/ql/lib/semmle/code/java/frameworks/spring/SpringBean.qll b/java/ql/lib/semmle/code/java/frameworks/spring/SpringBean.qll index 17a19c9a228..6b7636203e1 100644 --- a/java/ql/lib/semmle/code/java/frameworks/spring/SpringBean.qll +++ b/java/ql/lib/semmle/code/java/frameworks/spring/SpringBean.qll @@ -12,7 +12,7 @@ import semmle.code.java.frameworks.spring.SpringReplacedMethod */ /** A `` element in a Spring XML file. */ -class SpringBean extends SpringXMLElement { +class SpringBean extends SpringXmlElement { SpringBean() { this.getName() = "bean" and // Do not capture Camel beans, which are different @@ -268,7 +268,7 @@ class SpringBean extends SpringXMLElement { /** * Holds if this bean element has the same bean identifier as `other`. */ - override predicate isSimilar(SpringXMLElement other) { + override predicate isSimilar(SpringXmlElement other) { this.getBeanIdentifier() = other.(SpringBean).getBeanIdentifier() } diff --git a/java/ql/lib/semmle/code/java/frameworks/spring/SpringCamel.qll b/java/ql/lib/semmle/code/java/frameworks/spring/SpringCamel.qll index 3cbbf6acf11..656837e6d5e 100644 --- a/java/ql/lib/semmle/code/java/frameworks/spring/SpringCamel.qll +++ b/java/ql/lib/semmle/code/java/frameworks/spring/SpringCamel.qll @@ -9,56 +9,71 @@ import semmle.code.java.frameworks.spring.SpringBean /** * An Apache Camel element in a Spring Beans file. */ -class SpringCamelXMLElement extends SpringXMLElement { - SpringCamelXMLElement() { getNamespace().getURI() = "http://camel.apache.org/schema/spring" } +class SpringCamelXmlElement extends SpringXmlElement { + SpringCamelXmlElement() { getNamespace().getURI() = "http://camel.apache.org/schema/spring" } } +/** DEPRECATED: Alias for SpringCamelXmlElement */ +deprecated class SpringCamelXMLElement = SpringCamelXmlElement; + /** * An element in a Spring beans file that defines an Apache Camel context. * * All Apache Camel Spring elements are nested within a `` or a ``. */ -class SpringCamelXMLContext extends SpringCamelXMLElement { - SpringCamelXMLContext() { getName() = "camelContext" } +class SpringCamelXmlContext extends SpringCamelXmlElement { + SpringCamelXmlContext() { getName() = "camelContext" } } +/** DEPRECATED: Alias for SpringCamelXmlContext */ +deprecated class SpringCamelXMLContext = SpringCamelXmlContext; + /** * An element in a Spring beans file that defines an Apache Camel route context. * * A `` is a fragment, containing route definitions, that can be included within a * ``. */ -class SpringCamelXMLRouteContext extends SpringCamelXMLElement { - SpringCamelXMLRouteContext() { getName() = "routeContext" } +class SpringCamelXmlRouteContext extends SpringCamelXmlElement { + SpringCamelXmlRouteContext() { getName() = "routeContext" } } +/** DEPRECATED: Alias for SpringCamelXmlRouteContext */ +deprecated class SpringCamelXMLRouteContext = SpringCamelXmlRouteContext; + /** * An element in a Spring beans files that defines an Apache Camel route. * * A Camel `` element defines how messages that match certain criteria are handled by Apache * Camel. */ -class SpringCamelXMLRoute extends SpringCamelXMLElement { - SpringCamelXMLRoute() { +class SpringCamelXmlRoute extends SpringCamelXmlElement { + SpringCamelXmlRoute() { // A route must either be in a `` or a ``. ( - getParent() instanceof SpringCamelXMLRouteContext or - getParent() instanceof SpringCamelXMLContext + getParent() instanceof SpringCamelXmlRouteContext or + getParent() instanceof SpringCamelXmlContext ) and getName() = "route" } } +/** DEPRECATED: Alias for SpringCamelXmlRoute */ +deprecated class SpringCamelXMLRoute = SpringCamelXmlRoute; + /** * An element in a Spring bean file that is logically contained in an Apache Camel route. */ -class SpringCamelXMLRouteElement extends SpringCamelXMLElement { - SpringCamelXMLRouteElement() { - getParent() instanceof SpringCamelXMLRoute or - getParent() instanceof SpringCamelXMLRouteElement +class SpringCamelXmlRouteElement extends SpringCamelXmlElement { + SpringCamelXmlRouteElement() { + getParent() instanceof SpringCamelXmlRoute or + getParent() instanceof SpringCamelXmlRouteElement } } +/** DEPRECATED: Alias for SpringCamelXmlRouteElement */ +deprecated class SpringCamelXMLRouteElement = SpringCamelXmlRouteElement; + /** * A reference to a Spring bean in an Apache Camel route defined in a Spring beans file. * @@ -66,8 +81,8 @@ class SpringCamelXMLRouteElement extends SpringCamelXMLElement { * specifies a Spring bean that should be called in response to messages that match the enclosing * route. */ -class SpringCamelXMLBeanRef extends SpringCamelXMLRouteElement { - SpringCamelXMLBeanRef() { getName() = "bean" } +class SpringCamelXmlBeanRef extends SpringCamelXmlRouteElement { + SpringCamelXmlBeanRef() { getName() = "bean" } /** * Gets the Spring bean that is referenced by this route bean definition, if any. @@ -83,6 +98,9 @@ class SpringCamelXMLBeanRef extends SpringCamelXMLRouteElement { RefType getBeanType() { result.getQualifiedName() = getAttribute("beanType").getValue() } } +/** DEPRECATED: Alias for SpringCamelXmlBeanRef */ +deprecated class SpringCamelXMLBeanRef = SpringCamelXmlBeanRef; + /** * A declaration of a target in an Apache Camel route defined in a Spring beans file. * @@ -90,8 +108,8 @@ class SpringCamelXMLBeanRef extends SpringCamelXMLRouteElement { * determines the type of the target. For example, if the scheme is "bean:" then the rest of the uri * consists of a bean name and optional method name. */ -class SpringCamelXMLToElement extends SpringCamelXMLRouteElement { - SpringCamelXMLToElement() { getName() = "to" } +class SpringCamelXmlToElement extends SpringCamelXmlRouteElement { + SpringCamelXmlToElement() { getName() = "to" } /** * Gets the URI attribute for this `` element. @@ -99,6 +117,9 @@ class SpringCamelXMLToElement extends SpringCamelXMLRouteElement { string getURI() { result = getAttribute("uri").getValue() } } +/** DEPRECATED: Alias for SpringCamelXmlToElement */ +deprecated class SpringCamelXMLToElement = SpringCamelXmlToElement; + /** * A declaration of a Apache Camel "method" expression defined in a Spring beans file. * @@ -107,8 +128,8 @@ class SpringCamelXMLToElement extends SpringCamelXMLRouteElement { * (when the "ref" or "bean" attributes are used), or a type that should be instantiated as a bean * (if "beanType" is used. */ -class SpringCamelXMLMethodElement extends SpringCamelXMLElement { - SpringCamelXMLMethodElement() { getName() = "method" } +class SpringCamelXmlMethodElement extends SpringCamelXmlElement { + SpringCamelXmlMethodElement() { getName() = "method" } /** * Gets the `SpringBean` that this method expression refers to. @@ -123,3 +144,6 @@ class SpringCamelXMLMethodElement extends SpringCamelXMLElement { */ RefType getBeanType() { result.getQualifiedName() = getAttribute("beanType").getValue() } } + +/** DEPRECATED: Alias for SpringCamelXmlMethodElement */ +deprecated class SpringCamelXMLMethodElement = SpringCamelXmlMethodElement; diff --git a/java/ql/lib/semmle/code/java/frameworks/spring/SpringComponentScan.qll b/java/ql/lib/semmle/code/java/frameworks/spring/SpringComponentScan.qll index b2b507414d1..1c037adefd6 100644 --- a/java/ql/lib/semmle/code/java/frameworks/spring/SpringComponentScan.qll +++ b/java/ql/lib/semmle/code/java/frameworks/spring/SpringComponentScan.qll @@ -8,8 +8,8 @@ import semmle.code.xml.WebXML * An element in a Spring configuration file that configures which packages are considered to be * "base" packages when performing the Spring component scan. */ -class SpringXMLComponentScan extends SpringXMLElement { - SpringXMLComponentScan() { +class SpringXmlComponentScan extends SpringXmlElement { + SpringXmlComponentScan() { this.getName() = "component-scan" and this.getNamespace().getPrefix() = "context" } @@ -23,6 +23,9 @@ class SpringXMLComponentScan extends SpringXMLElement { string getAProfileExpr() { result = this.getSpringBeanFile().getAProfileExpr() } } +/** DEPRECATED: Alias for SpringXmlComponentScan */ +deprecated class SpringXMLComponentScan = SpringXmlComponentScan; + /** * An annotation of a class that configures which packages are considered to be "base" packages * when performing the Spring component scan. @@ -59,11 +62,11 @@ class SpringBasePackage extends string { exists(string basePackages | // Interpret the contexts of the `web.xml` "contextConfigLocation" parameter as a base package, // but only if the appropriate context class is chosen. - exists(WebXMLFile webXML | - webXML.getContextParamValue("contextClass") = + exists(WebXmlFile webXml | + webXml.getContextParamValue("contextClass") = "org.springframework.web.context.support.AnnotationConfigWebApplicationContext" | - basePackages = webXML.getContextParamValue("contextConfigLocation") + basePackages = webXml.getContextParamValue("contextConfigLocation") ) or exists(SpringComponent c, Annotation componentScan | @@ -75,7 +78,7 @@ class SpringBasePackage extends string { c.isLive() ) or - exists(SpringXMLComponentScan xmlComponentScan | + exists(SpringXmlComponentScan xmlComponentScan | basePackages = xmlComponentScan.getBasePackages() and // The component scan profile must be active, if one is specified. ( @@ -110,7 +113,7 @@ class SpringComponentAnnotation extends AnnotationType { * In order for Spring XML to be "enabled", XML must have been indexed into the snapshot, and that * XML must contain the appropriate Spring configuration files. */ -private predicate isSpringXMLEnabled() { exists(SpringXMLElement springXMLElement) } +private predicate isSpringXmlEnabled() { exists(SpringXmlElement springXmlElement) } /** * A Spring component class, identified by the presence of a particular annotation. @@ -178,7 +181,7 @@ class SpringComponent extends RefType { // only validate whether this class is ever picked up if XML indexing is enabled. If it's // enabled, then the package of this class must belong in one of the packages defined as a base // package. - not isSpringXMLEnabled() + not isSpringXmlEnabled() or exists(SpringBasePackage sbp | this.getPackage().getName().prefix(sbp.length() + 1) = sbp + "." or diff --git a/java/ql/lib/semmle/code/java/frameworks/spring/SpringConstructorArg.qll b/java/ql/lib/semmle/code/java/frameworks/spring/SpringConstructorArg.qll index d9762d792f9..e434e53ca3d 100644 --- a/java/ql/lib/semmle/code/java/frameworks/spring/SpringConstructorArg.qll +++ b/java/ql/lib/semmle/code/java/frameworks/spring/SpringConstructorArg.qll @@ -5,7 +5,7 @@ import semmle.code.java.frameworks.spring.SpringAbstractRef import semmle.code.java.frameworks.spring.SpringValue /** A `` element in a Spring XML file. */ -class SpringConstructorArg extends SpringXMLElement { +class SpringConstructorArg extends SpringXmlElement { SpringConstructorArg() { this.getName() = "constructor-arg" } /** Holds if this `constructor-arg` element has an `index` attribute. */ diff --git a/java/ql/lib/semmle/code/java/frameworks/spring/SpringDescription.qll b/java/ql/lib/semmle/code/java/frameworks/spring/SpringDescription.qll index a6a803a6275..34cf13a9571 100644 --- a/java/ql/lib/semmle/code/java/frameworks/spring/SpringDescription.qll +++ b/java/ql/lib/semmle/code/java/frameworks/spring/SpringDescription.qll @@ -6,6 +6,6 @@ import semmle.code.java.frameworks.spring.SpringXMLElement * * Its contents can be accessed using `SpringXMLElement.getContentString()`. */ -class SpringDescription extends SpringXMLElement { +class SpringDescription extends SpringXmlElement { SpringDescription() { this.getName() = "description" } } diff --git a/java/ql/lib/semmle/code/java/frameworks/spring/SpringEntry.qll b/java/ql/lib/semmle/code/java/frameworks/spring/SpringEntry.qll index 128d1abd548..8ec02002af5 100644 --- a/java/ql/lib/semmle/code/java/frameworks/spring/SpringEntry.qll +++ b/java/ql/lib/semmle/code/java/frameworks/spring/SpringEntry.qll @@ -6,7 +6,7 @@ import semmle.code.java.frameworks.spring.SpringKey import semmle.code.java.frameworks.spring.SpringValue /** An `` element in Spring XML files. */ -class SpringEntry extends SpringXMLElement { +class SpringEntry extends SpringXmlElement { SpringEntry() { this.getName() = "entry" } /** Holds if this `entry` has a `key` attribute. */ diff --git a/java/ql/lib/semmle/code/java/frameworks/spring/SpringFlex.qll b/java/ql/lib/semmle/code/java/frameworks/spring/SpringFlex.qll index 7ed0f78fd37..e1c32fe7687 100644 --- a/java/ql/lib/semmle/code/java/frameworks/spring/SpringFlex.qll +++ b/java/ql/lib/semmle/code/java/frameworks/spring/SpringFlex.qll @@ -9,7 +9,7 @@ import semmle.code.java.frameworks.spring.SpringComponentScan import semmle.code.java.frameworks.spring.SpringXMLElement /** Represents a `` element in Spring XML files. */ -class SpringRemotingDestination extends SpringXMLElement { +class SpringRemotingDestination extends SpringXmlElement { SpringRemotingDestination() { this.getName() = "remoting-destination" } /** @@ -55,7 +55,12 @@ class SpringRemotingDestinationClass extends Class { /** * Gets the XML configuration of the remoting destination, if it was configured in XML. */ - SpringRemotingDestination getRemotingDestinationXML() { this = result.getSpringBean().getClass() } + SpringRemotingDestination getRemotingDestinationXml() { this = result.getSpringBean().getClass() } + + /** DEPRECATED: Alias for getRemotingDestinationXml */ + deprecated SpringRemotingDestination getRemotingDestinationXML() { + result = getRemotingDestinationXml() + } /** * Holds if the class is operating on an "include" or "exclude" basis. @@ -70,7 +75,7 @@ class SpringRemotingDestinationClass extends Class { m.hasAnnotation("org.springframework.flex.remoting", "RemotingInclude") ) or - exists(this.getRemotingDestinationXML().getAnIncludeMethod()) + exists(this.getRemotingDestinationXml().getAnIncludeMethod()) } /** @@ -81,10 +86,10 @@ class SpringRemotingDestinationClass extends Class { if this.isIncluding() then result.hasAnnotation("org.springframework.flex.remoting", "RemotingInclude") or - result.getName() = this.getRemotingDestinationXML().getAnIncludeMethod() + result.getName() = this.getRemotingDestinationXml().getAnIncludeMethod() else ( not result.hasAnnotation("org.springframework.flex.remoting", "RemotingExclude") and - not result.getName() = this.getRemotingDestinationXML().getAnExcludeMethod() + not result.getName() = this.getRemotingDestinationXml().getAnExcludeMethod() ) } } diff --git a/java/ql/lib/semmle/code/java/frameworks/spring/SpringImport.qll b/java/ql/lib/semmle/code/java/frameworks/spring/SpringImport.qll index 72290764540..688a14da32e 100644 --- a/java/ql/lib/semmle/code/java/frameworks/spring/SpringImport.qll +++ b/java/ql/lib/semmle/code/java/frameworks/spring/SpringImport.qll @@ -2,7 +2,7 @@ import java import semmle.code.java.frameworks.spring.SpringXMLElement /** An `` element in a Spring XML file. */ -class SpringImport extends SpringXMLElement { +class SpringImport extends SpringXmlElement { SpringImport() { this.getName() = "import" } /** Gets the value of the `resource` attribute. */ diff --git a/java/ql/lib/semmle/code/java/frameworks/spring/SpringKey.qll b/java/ql/lib/semmle/code/java/frameworks/spring/SpringKey.qll index 1b993b6bf9d..5f07b227706 100644 --- a/java/ql/lib/semmle/code/java/frameworks/spring/SpringKey.qll +++ b/java/ql/lib/semmle/code/java/frameworks/spring/SpringKey.qll @@ -2,6 +2,6 @@ import java import semmle.code.java.frameworks.spring.SpringXMLElement /** A `` element in Spring XML files. */ -class SpringKey extends SpringXMLElement { +class SpringKey extends SpringXmlElement { SpringKey() { this.getName() = "key" } } diff --git a/java/ql/lib/semmle/code/java/frameworks/spring/SpringLookupMethod.qll b/java/ql/lib/semmle/code/java/frameworks/spring/SpringLookupMethod.qll index 81ef06c14c5..9dba22a3cb7 100644 --- a/java/ql/lib/semmle/code/java/frameworks/spring/SpringLookupMethod.qll +++ b/java/ql/lib/semmle/code/java/frameworks/spring/SpringLookupMethod.qll @@ -3,7 +3,7 @@ import semmle.code.java.frameworks.spring.SpringXMLElement import semmle.code.java.frameworks.spring.SpringBean /** A `` element in a Spring XML file. */ -class SpringLookupMethod extends SpringXMLElement { +class SpringLookupMethod extends SpringXmlElement { SpringLookupMethod() { this.getName() = "lookup-method" } /** Gets the value of the `bean` attribute. */ diff --git a/java/ql/lib/semmle/code/java/frameworks/spring/SpringMergable.qll b/java/ql/lib/semmle/code/java/frameworks/spring/SpringMergable.qll index 2898a1d1e70..baef7d3b91a 100644 --- a/java/ql/lib/semmle/code/java/frameworks/spring/SpringMergable.qll +++ b/java/ql/lib/semmle/code/java/frameworks/spring/SpringMergable.qll @@ -4,7 +4,7 @@ import semmle.code.java.frameworks.spring.SpringXMLElement /** * A common superclass for mergeable Spring XML elements (`list`, `map`). */ -/*abstract*/ class SpringMergable extends SpringXMLElement { +/*abstract*/ class SpringMergable extends SpringXmlElement { string getMergeRaw() { result = this.getAttributeValueWithDefault("merge") } /** Holds if this element is merged, taking `default-merged` values in `` into account. */ diff --git a/java/ql/lib/semmle/code/java/frameworks/spring/SpringMeta.qll b/java/ql/lib/semmle/code/java/frameworks/spring/SpringMeta.qll index 6e42dad820e..640305b313a 100644 --- a/java/ql/lib/semmle/code/java/frameworks/spring/SpringMeta.qll +++ b/java/ql/lib/semmle/code/java/frameworks/spring/SpringMeta.qll @@ -2,7 +2,7 @@ import java import semmle.code.java.frameworks.spring.SpringXMLElement /** A `` element in Spring XML files. */ -class SpringMeta extends SpringXMLElement { +class SpringMeta extends SpringXmlElement { SpringMeta() { this.getName() = "meta" } /** Gets the value of the `key` attribute. */ diff --git a/java/ql/lib/semmle/code/java/frameworks/spring/SpringNull.qll b/java/ql/lib/semmle/code/java/frameworks/spring/SpringNull.qll index b46a888b4e0..c3f2c00a2b7 100644 --- a/java/ql/lib/semmle/code/java/frameworks/spring/SpringNull.qll +++ b/java/ql/lib/semmle/code/java/frameworks/spring/SpringNull.qll @@ -2,6 +2,6 @@ import java import semmle.code.java.frameworks.spring.SpringXMLElement /** A `` element in Spring XML files. */ -class SpringNull extends SpringXMLElement { +class SpringNull extends SpringXmlElement { SpringNull() { this.getName() = "null" } } diff --git a/java/ql/lib/semmle/code/java/frameworks/spring/SpringProp.qll b/java/ql/lib/semmle/code/java/frameworks/spring/SpringProp.qll index fb4964e4b61..771370a3e7a 100644 --- a/java/ql/lib/semmle/code/java/frameworks/spring/SpringProp.qll +++ b/java/ql/lib/semmle/code/java/frameworks/spring/SpringProp.qll @@ -2,7 +2,7 @@ import java import semmle.code.java.frameworks.spring.SpringXMLElement /** A `` element in Spring XML files. */ -class SpringProp extends SpringXMLElement { +class SpringProp extends SpringXmlElement { SpringProp() { this.getName() = "prop" } /** Gets the value of the `key` attribute. */ diff --git a/java/ql/lib/semmle/code/java/frameworks/spring/SpringProperty.qll b/java/ql/lib/semmle/code/java/frameworks/spring/SpringProperty.qll index cdf6a1f9bd0..06d5daefaa1 100644 --- a/java/ql/lib/semmle/code/java/frameworks/spring/SpringProperty.qll +++ b/java/ql/lib/semmle/code/java/frameworks/spring/SpringProperty.qll @@ -6,7 +6,7 @@ import semmle.code.java.frameworks.spring.SpringList import semmle.code.java.frameworks.spring.SpringValue /** A `` element in Spring XML files. */ -class SpringProperty extends SpringXMLElement { +class SpringProperty extends SpringXmlElement { SpringProperty() { this.getName() = "property" } override string toString() { result = this.getPropertyName() } @@ -55,7 +55,7 @@ class SpringProperty extends SpringXMLElement { * Holds if this property is similar to another property. * Currently only checks the property name and references to beans. */ - override predicate isSimilar(SpringXMLElement element) { + override predicate isSimilar(SpringXmlElement element) { exists(SpringProperty other | other = element and this.getPropertyName() = other.getPropertyName() | diff --git a/java/ql/lib/semmle/code/java/frameworks/spring/SpringQualifier.qll b/java/ql/lib/semmle/code/java/frameworks/spring/SpringQualifier.qll index 3ac11e9e5f3..eb57b37efe0 100644 --- a/java/ql/lib/semmle/code/java/frameworks/spring/SpringQualifier.qll +++ b/java/ql/lib/semmle/code/java/frameworks/spring/SpringQualifier.qll @@ -2,7 +2,7 @@ import java import semmle.code.java.frameworks.spring.SpringXMLElement /** A `` element in a Spring XML file. */ -class SpringQualifier extends SpringXMLElement { +class SpringQualifier extends SpringXmlElement { SpringQualifier() { this.getName() = "qualifier" } /** Gets the name of the Java class of this qualifier. */ diff --git a/java/ql/lib/semmle/code/java/frameworks/spring/SpringReplacedMethod.qll b/java/ql/lib/semmle/code/java/frameworks/spring/SpringReplacedMethod.qll index ae2e827e703..47e8d182898 100644 --- a/java/ql/lib/semmle/code/java/frameworks/spring/SpringReplacedMethod.qll +++ b/java/ql/lib/semmle/code/java/frameworks/spring/SpringReplacedMethod.qll @@ -3,7 +3,7 @@ import semmle.code.java.frameworks.spring.SpringXMLElement import semmle.code.java.frameworks.spring.SpringBean /** A `` element in a Spring XML file. */ -class SpringReplacedMethod extends SpringXMLElement { +class SpringReplacedMethod extends SpringXmlElement { SpringReplacedMethod() { this.getName() = "replaced-method" } /** Gets the value of the `name` attribute. */ diff --git a/java/ql/lib/semmle/code/java/frameworks/spring/SpringValue.qll b/java/ql/lib/semmle/code/java/frameworks/spring/SpringValue.qll index 73c4098a8c2..55854d60f9c 100644 --- a/java/ql/lib/semmle/code/java/frameworks/spring/SpringValue.qll +++ b/java/ql/lib/semmle/code/java/frameworks/spring/SpringValue.qll @@ -2,7 +2,7 @@ import java import semmle.code.java.frameworks.spring.SpringXMLElement /** A `` element in a Spring XML file. */ -class SpringValue extends SpringXMLElement { +class SpringValue extends SpringXmlElement { SpringValue() { this.getName() = "value" } /** Gets the value of the `type` attribute. */ diff --git a/java/ql/lib/semmle/code/java/frameworks/spring/SpringXMLElement.qll b/java/ql/lib/semmle/code/java/frameworks/spring/SpringXMLElement.qll index 943285d99a8..adaf69c5890 100644 --- a/java/ql/lib/semmle/code/java/frameworks/spring/SpringXMLElement.qll +++ b/java/ql/lib/semmle/code/java/frameworks/spring/SpringXMLElement.qll @@ -3,11 +3,11 @@ import semmle.code.java.frameworks.spring.SpringBeanFile import semmle.code.java.frameworks.spring.SpringBean /** A common superclass for all Spring XML elements. */ -class SpringXMLElement extends XMLElement { - SpringXMLElement() { this.getFile() instanceof SpringBeanFile } +class SpringXmlElement extends XMLElement { + SpringXmlElement() { this.getFile() instanceof SpringBeanFile } /** Gets a child of this Spring XML element. */ - SpringXMLElement getASpringChild() { result = this.getAChild() } + SpringXmlElement getASpringChild() { result = this.getAChild() } /** Gets the bean file of this XML element. */ SpringBeanFile getSpringBeanFile() { result = this.getFile() } @@ -27,13 +27,16 @@ class SpringXMLElement extends XMLElement { SpringBean getEnclosingBean() { if this instanceof SpringBean then result = this - else result = this.getParent().(SpringXMLElement).getEnclosingBean() + else result = this.getParent().(SpringXmlElement).getEnclosingBean() } /** * Overridden by subclasses. Used to match `value`, `property` and `ref` elements for similarity. */ - predicate isSimilar(SpringXMLElement other) { none() } + predicate isSimilar(SpringXmlElement other) { none() } string getContentString() { result = this.allCharactersString() } } + +/** DEPRECATED: Alias for SpringXmlElement */ +deprecated class SpringXMLElement = SpringXmlElement; diff --git a/java/ql/lib/semmle/code/java/frameworks/spring/metrics/MetricSpringBean.qll b/java/ql/lib/semmle/code/java/frameworks/spring/metrics/MetricSpringBean.qll index 9cac47fa281..ffbc5c9e5ec 100644 --- a/java/ql/lib/semmle/code/java/frameworks/spring/metrics/MetricSpringBean.qll +++ b/java/ql/lib/semmle/code/java/frameworks/spring/metrics/MetricSpringBean.qll @@ -2,7 +2,7 @@ import semmle.code.java.frameworks.spring.SpringBean import semmle.code.java.frameworks.spring.SpringBeanFile import semmle.code.java.frameworks.spring.SpringEntry -predicate springDepends(SpringBean b1, SpringBean b2, SpringXMLElement cause) { +predicate springDepends(SpringBean b1, SpringBean b2, SpringXmlElement cause) { b1 != b2 and b1.getBeanParent() = b2 and cause = b1 @@ -63,7 +63,7 @@ class MetricSpringBean extends SpringBean { this.getSpringBeanFile() = result.getSpringBeanFile() } - SpringXMLElement getBeanDependencyCause(SpringBean dependency) { + SpringXmlElement getBeanDependencyCause(SpringBean dependency) { springDepends(this, dependency, result) } } diff --git a/java/ql/lib/semmle/code/java/frameworks/struts/StrutsActions.qll b/java/ql/lib/semmle/code/java/frameworks/struts/StrutsActions.qll index ebe6716e4f5..4d50dbf92ab 100644 --- a/java/ql/lib/semmle/code/java/frameworks/struts/StrutsActions.qll +++ b/java/ql/lib/semmle/code/java/frameworks/struts/StrutsActions.qll @@ -6,7 +6,7 @@ import semmle.code.java.frameworks.struts.StrutsXML * Gets the custom struts mapper class used for this `refType`, if any. */ private string getStrutsMapperClass(RefType refType) { - result = getRootXMLFile(refType).getConstantValue("struts.mapper.class") + result = getRootXmlFile(refType).getConstantValue("struts.mapper.class") } /** @@ -21,7 +21,7 @@ class Struts2ActionClass extends Class { or // If there is a struts.xml file, then any class that is specified as an action is considered // to be reflectively constructed. - exists(StrutsXMLAction strutsAction | this = strutsAction.getActionClass()) + exists(StrutsXmlAction strutsAction | this = strutsAction.getActionClass()) or // We have determined that this is an action class due to the conventions plugin. this instanceof Struts2ConventionActionClass @@ -64,7 +64,7 @@ class Struts2ActionClass extends Class { any() else ( // Use the default mapping - exists(StrutsXMLAction strutsAction | + exists(StrutsXmlAction strutsAction | this = strutsAction.getActionClass() and result = strutsAction.getActionMethod() ) diff --git a/java/ql/lib/semmle/code/java/frameworks/struts/StrutsConventions.qll b/java/ql/lib/semmle/code/java/frameworks/struts/StrutsConventions.qll index 0f38147ad13..fd9f14d4c6f 100644 --- a/java/ql/lib/semmle/code/java/frameworks/struts/StrutsConventions.qll +++ b/java/ql/lib/semmle/code/java/frameworks/struts/StrutsConventions.qll @@ -53,7 +53,7 @@ private predicate isStrutsConventionPluginUsed(RefType refType) { strutsConventionAnnotationUsedInFolder(getSourceFolder(refType.getCompilationUnit())) or // The struts configuration file for this file sets a convention property - getRootXMLFile(refType).getAConstant().getName().matches("struts.convention%") + getRootXmlFile(refType).getAConstant().getName().matches("struts.convention%") or // We've found the POM for this RefType, and it includes a dependency on the convention plugin exists(Pom pom | @@ -68,7 +68,7 @@ private predicate isStrutsConventionPluginUsed(RefType refType) { * We guess by identifying the "nearest" `struts.xml` configuration file, i.e. the Struts * configuration file with the lowest common ancestor to this file. */ -StrutsXMLFile getRootXMLFile(RefType refType) { +StrutsXmlFile getRootXmlFile(RefType refType) { exists(StrutsFolder strutsFolder | strutsFolder = refType.getFile().getParentContainer*() and strutsFolder.isUnique() @@ -77,14 +77,17 @@ StrutsXMLFile getRootXMLFile(RefType refType) { ) } +/** DEPRECATED: Alias for getRootXmlFile */ +deprecated StrutsXMLFile getRootXMLFile(RefType refType) { result = getRootXmlFile(refType) } + /** * Gets the suffix used for automatically identifying actions when using the convention plugin. * * If no configuration is supplied, or identified, the default is "Action". */ private string getConventionSuffix(RefType refType) { - if exists(getRootXMLFile(refType).getConstantValue("struts.convention.action.suffix")) - then result = getRootXMLFile(refType).getConstantValue("struts.convention.action.suffix") + if exists(getRootXmlFile(refType).getConstantValue("struts.convention.action.suffix")) + then result = getRootXmlFile(refType).getConstantValue("struts.convention.action.suffix") else result = "Action" } diff --git a/java/ql/lib/semmle/code/java/frameworks/struts/StrutsXML.qll b/java/ql/lib/semmle/code/java/frameworks/struts/StrutsXML.qll index 8e69c5d9a83..77285d98175 100644 --- a/java/ql/lib/semmle/code/java/frameworks/struts/StrutsXML.qll +++ b/java/ql/lib/semmle/code/java/frameworks/struts/StrutsXML.qll @@ -4,13 +4,16 @@ import semmle.code.xml.XML /** * Holds if any struts XML files are included in this snapshot. */ -predicate isStrutsXMLIncluded() { exists(StrutsXMLFile strutsXML) } +predicate isStrutsXmlIncluded() { exists(StrutsXmlFile strutsXml) } + +/** DEPRECATED: Alias for isStrutsXmlIncluded */ +deprecated predicate isStrutsXMLIncluded = isStrutsXmlIncluded/0; /** * A struts 2 configuration file. */ -abstract class StrutsXMLFile extends XMLFile { - StrutsXMLFile() { +abstract class StrutsXmlFile extends XMLFile { + StrutsXmlFile() { // Contains a single top-level XML node named "struts". count(XMLElement e | e = this.getAChild()) = 1 and this.getAChild().getName() = "struts" @@ -19,55 +22,64 @@ abstract class StrutsXMLFile extends XMLFile { /** * Gets a "root" struts configuration file that includes this file. */ - StrutsRootXMLFile getARoot() { result.getAnIncludedFile() = this } + StrutsRootXmlFile getARoot() { result.getAnIncludedFile() = this } /** * Gets a directly included file. */ - StrutsXMLFile getADirectlyIncludedFile() { - exists(StrutsXMLInclude include | include.getFile() = this | result = include.getIncludedFile()) + StrutsXmlFile getADirectlyIncludedFile() { + exists(StrutsXmlInclude include | include.getFile() = this | result = include.getIncludedFile()) } /** * Gets a transitively included file. */ - StrutsXMLFile getAnIncludedFile() { result = this.getADirectlyIncludedFile*() } + StrutsXmlFile getAnIncludedFile() { result = this.getADirectlyIncludedFile*() } /** * Gets a `` defined in this file, or an included file. */ - StrutsXMLConstant getAConstant() { result.getFile() = this.getAnIncludedFile() } + StrutsXmlConstant getAConstant() { result.getFile() = this.getAnIncludedFile() } /** * Gets the value of the constant with the given `name`. */ string getConstantValue(string name) { - exists(StrutsXMLConstant constant | constant = this.getAConstant() | + exists(StrutsXmlConstant constant | constant = this.getAConstant() | constant.getConstantName() = name and result = constant.getConstantValue() ) } } +/** DEPRECATED: Alias for StrutsXmlFile */ +deprecated class StrutsXMLFile = StrutsXmlFile; + /** * A Struts 2 "root" configuration XML file directly read by struts. * * Root configurations either have the name `struts.xml` or `struts-plugin.xml`. */ -class StrutsRootXMLFile extends StrutsXMLFile { - StrutsRootXMLFile() { +class StrutsRootXmlFile extends StrutsXmlFile { + StrutsRootXmlFile() { this.getBaseName() = "struts.xml" or this.getBaseName() = "struts-plugin.xml" } } +/** DEPRECATED: Alias for StrutsRootXmlFile */ +deprecated class StrutsRootXMLFile = StrutsRootXmlFile; + /** * A Struts 2 configuration XML file included, directly or indirectly, by a root Struts configuration. */ -class StrutsIncludedXMLFile extends StrutsXMLFile { - StrutsIncludedXMLFile() { exists(StrutsXMLInclude include | this = include.getIncludedFile()) } +class StrutsIncludedXmlFile extends StrutsXmlFile { + StrutsIncludedXmlFile() { exists(StrutsXmlInclude include | this = include.getIncludedFile()) } } +/** DEPRECATED: Alias for StrutsIncludedXmlFile */ +deprecated class StrutsIncludedXMLFile = StrutsIncludedXmlFile; + /** * A Folder which has one or more Struts 2 root configurations. */ @@ -75,7 +87,7 @@ class StrutsFolder extends Folder { StrutsFolder() { exists(Container c | c = this.getAChildContainer() | c instanceof StrutsFolder or - c instanceof StrutsXMLFile + c instanceof StrutsXmlFile ) } @@ -87,7 +99,7 @@ class StrutsFolder extends Folder { /** * Gets a struts root configuration that applies to this folder. */ - StrutsRootXMLFile getAStrutsRootFile() { + StrutsRootXmlFile getAStrutsRootFile() { result = this.getAChildContainer() or result = this.getAChildContainer().(StrutsFolder).getAStrutsRootFile() } @@ -96,8 +108,8 @@ class StrutsFolder extends Folder { /** * An XML element in a `StrutsXMLFile`. */ -class StrutsXMLElement extends XMLElement { - StrutsXMLElement() { this.getFile() instanceof StrutsXMLFile } +class StrutsXmlElement extends XMLElement { + StrutsXmlElement() { this.getFile() instanceof StrutsXmlFile } /** * Gets the value for this element, with leading and trailing whitespace trimmed. @@ -105,14 +117,17 @@ class StrutsXMLElement extends XMLElement { string getValue() { result = this.allCharactersString().trim() } } +/** DEPRECATED: Alias for StrutsXmlElement */ +deprecated class StrutsXMLElement = StrutsXmlElement; + /** * A `` element within a `struts.xml` file. * * This indicates that the file specified in the `file` attribute should be included in the struts * configuration. The file is looked up using the classpath. */ -class StrutsXMLInclude extends StrutsXMLElement { - StrutsXMLInclude() { this.getName() = "include" } +class StrutsXmlInclude extends StrutsXmlElement { + StrutsXmlInclude() { this.getName() = "include" } /** * Gets the XMLFile that we believe is included by this include statement. @@ -127,6 +142,9 @@ class StrutsXMLInclude extends StrutsXMLElement { } } +/** DEPRECATED: Alias for StrutsXmlInclude */ +deprecated class StrutsXMLInclude = StrutsXmlInclude; + /** * Escape a string for use as the matcher in a string.match(..) call. */ @@ -150,8 +168,8 @@ private predicate strutsWildcardMatching(string matches, string wildcardstring) /** * A `` element within a `struts.xml` file. */ -class StrutsXMLAction extends StrutsXMLElement { - StrutsXMLAction() { this.getName() = "action" } +class StrutsXmlAction extends StrutsXmlElement { + StrutsXmlAction() { this.getName() = "action" } /** * Gets the `Class` that is referenced by this Struts action. @@ -175,13 +193,19 @@ class StrutsXMLAction extends StrutsXMLElement { } } +/** DEPRECATED: Alias for StrutsXmlAction */ +deprecated class StrutsXMLAction = StrutsXmlAction; + /** * A `` property, representing a configuration parameter to struts. */ -class StrutsXMLConstant extends StrutsXMLElement { - StrutsXMLConstant() { this.getName() = "constant" } +class StrutsXmlConstant extends StrutsXmlElement { + StrutsXmlConstant() { this.getName() = "constant" } string getConstantName() { result = this.getAttribute("name").getValue() } string getConstantValue() { result = this.getAttribute("value").getValue() } } + +/** DEPRECATED: Alias for StrutsXmlConstant */ +deprecated class StrutsXMLConstant = StrutsXmlConstant; diff --git a/java/ql/lib/semmle/code/java/security/Encryption.qll b/java/ql/lib/semmle/code/java/security/Encryption.qll index 281a97bc60d..d3c2cc7420e 100644 --- a/java/ql/lib/semmle/code/java/security/Encryption.qll +++ b/java/ql/lib/semmle/code/java/security/Encryption.qll @@ -17,10 +17,13 @@ class X509TrustManager extends RefType { X509TrustManager() { this.hasQualifiedName("javax.net.ssl", "X509TrustManager") } } -class HttpsURLConnection extends RefType { - HttpsURLConnection() { this.hasQualifiedName("javax.net.ssl", "HttpsURLConnection") } +class HttpsUrlConnection extends RefType { + HttpsUrlConnection() { this.hasQualifiedName("javax.net.ssl", "HttpsURLConnection") } } +/** DEPRECATED: Alias for HttpsUrlConnection */ +deprecated class HttpsURLConnection = HttpsUrlConnection; + class SSLSocketFactory extends RefType { SSLSocketFactory() { this.hasQualifiedName("javax.net.ssl", "SSLSocketFactory") } } @@ -105,22 +108,22 @@ class CreateSslEngineMethod extends Method { class SetConnectionFactoryMethod extends Method { SetConnectionFactoryMethod() { this.hasName("setSSLSocketFactory") and - this.getDeclaringType().getAnAncestor() instanceof HttpsURLConnection + this.getDeclaringType().getAnAncestor() instanceof HttpsUrlConnection } } class SetHostnameVerifierMethod extends Method { SetHostnameVerifierMethod() { this.hasName("setHostnameVerifier") and - this.getDeclaringType().getAnAncestor() instanceof HttpsURLConnection + this.getDeclaringType().getAnAncestor() instanceof HttpsUrlConnection } } -/** The `setDefaultHostnameVerifier` method of the class `javax.net.ssl.HttpsURLConnection`. */ +/** The `setDefaultHostnameVerifier` method of the class `javax.net.ssl.HttpsUrlConnection`. */ class SetDefaultHostnameVerifierMethod extends Method { SetDefaultHostnameVerifierMethod() { this.hasName("setDefaultHostnameVerifier") and - this.getDeclaringType().getAnAncestor() instanceof HttpsURLConnection + this.getDeclaringType().getAnAncestor() instanceof HttpsUrlConnection } } diff --git a/java/ql/lib/semmle/code/java/security/ExternalAPIs.qll b/java/ql/lib/semmle/code/java/security/ExternalAPIs.qll index 0aee4aaf802..b4b8ea7fdd9 100644 --- a/java/ql/lib/semmle/code/java/security/ExternalAPIs.qll +++ b/java/ql/lib/semmle/code/java/security/ExternalAPIs.qll @@ -10,11 +10,14 @@ import semmle.code.java.dataflow.TaintTracking /** * A `Method` that is considered a "safe" external API from a security perspective. */ -abstract class SafeExternalAPIMethod extends Method { } +abstract class SafeExternalApiMethod extends Method { } + +/** DEPRECATED: Alias for SafeExternalApiMethod */ +deprecated class SafeExternalAPIMethod = SafeExternalApiMethod; /** The default set of "safe" external APIs. */ -private class DefaultSafeExternalAPIMethod extends SafeExternalAPIMethod { - DefaultSafeExternalAPIMethod() { +private class DefaultSafeExternalApiMethod extends SafeExternalApiMethod { + DefaultSafeExternalApiMethod() { this instanceof EqualsMethod or this.getName().regexpMatch("size|length|compareTo|getClass|lastIndexOf") @@ -53,11 +56,11 @@ private class DefaultSafeExternalAPIMethod extends SafeExternalAPIMethod { } /** A node representing data being passed to an external API. */ -class ExternalAPIDataNode extends DataFlow::Node { +class ExternalApiDataNode extends DataFlow::Node { Call call; int i; - ExternalAPIDataNode() { + ExternalApiDataNode() { ( // Argument to call to a method this.asExpr() = call.getArgument(i) @@ -79,7 +82,7 @@ class ExternalAPIDataNode extends DataFlow::Node { not exists(DataFlow::Node next | TaintTracking::localTaintStep(this, next)) and not exists(DataFlow::Node next | TaintTracking::defaultAdditionalTaintStep(this, next)) and // Not a call to a known safe external API - not call.getCallee() instanceof SafeExternalAPIMethod + not call.getCallee() instanceof SafeExternalApiMethod } /** Gets the called API `Method`. */ @@ -95,38 +98,47 @@ class ExternalAPIDataNode extends DataFlow::Node { } } -/** A configuration for tracking flow from `RemoteFlowSource`s to `ExternalAPIDataNode`s. */ -class UntrustedDataToExternalAPIConfig extends TaintTracking::Configuration { - UntrustedDataToExternalAPIConfig() { this = "UntrustedDataToExternalAPIConfig" } +/** DEPRECATED: Alias for ExternalApiDataNode */ +deprecated class ExternalAPIDataNode = ExternalApiDataNode; + +/** A configuration for tracking flow from `RemoteFlowSource`s to `ExternalApiDataNode`s. */ +class UntrustedDataToExternalApiConfig extends TaintTracking::Configuration { + UntrustedDataToExternalApiConfig() { this = "UntrustedDataToExternalAPIConfig" } override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource } - override predicate isSink(DataFlow::Node sink) { sink instanceof ExternalAPIDataNode } + override predicate isSink(DataFlow::Node sink) { sink instanceof ExternalApiDataNode } } +/** DEPRECATED: Alias for UntrustedDataToExternalApiConfig */ +deprecated class UntrustedDataToExternalAPIConfig = UntrustedDataToExternalApiConfig; + /** A node representing untrusted data being passed to an external API. */ -class UntrustedExternalAPIDataNode extends ExternalAPIDataNode { - UntrustedExternalAPIDataNode() { any(UntrustedDataToExternalAPIConfig c).hasFlow(_, this) } +class UntrustedExternalApiDataNode extends ExternalApiDataNode { + UntrustedExternalApiDataNode() { any(UntrustedDataToExternalApiConfig c).hasFlow(_, this) } /** Gets a source of untrusted data which is passed to this external API data node. */ DataFlow::Node getAnUntrustedSource() { - any(UntrustedDataToExternalAPIConfig c).hasFlow(result, this) + any(UntrustedDataToExternalApiConfig c).hasFlow(result, this) } } -private newtype TExternalAPI = - TExternalAPIParameter(Method m, int index) { - exists(UntrustedExternalAPIDataNode n | +/** DEPRECATED: Alias for UntrustedExternalApiDataNode */ +deprecated class UntrustedExternalAPIDataNode = UntrustedExternalApiDataNode; + +private newtype TExternalApi = + TExternalApiParameter(Method m, int index) { + exists(UntrustedExternalApiDataNode n | m = n.getMethod() and index = n.getIndex() ) } /** An external API which is used with untrusted data. */ -class ExternalAPIUsedWithUntrustedData extends TExternalAPI { +class ExternalApiUsedWithUntrustedData extends TExternalApi { /** Gets a possibly untrusted use of this external API. */ - UntrustedExternalAPIDataNode getUntrustedDataNode() { - this = TExternalAPIParameter(result.getMethod(), result.getIndex()) + UntrustedExternalApiDataNode getUntrustedDataNode() { + this = TExternalApiParameter(result.getMethod(), result.getIndex()) } /** Gets the number of untrusted sources used with this external API. */ @@ -139,9 +151,12 @@ class ExternalAPIUsedWithUntrustedData extends TExternalAPI { exists(Method m, int index, string indexString | if index = -1 then indexString = "qualifier" else indexString = "param " + index | - this = TExternalAPIParameter(m, index) and + this = TExternalApiParameter(m, index) and result = m.getDeclaringType().getQualifiedName() + "." + m.getSignature() + " [" + indexString + "]" ) } } + +/** DEPRECATED: Alias for ExternalApiUsedWithUntrustedData */ +deprecated class ExternalAPIUsedWithUntrustedData = ExternalApiUsedWithUntrustedData; diff --git a/java/ql/lib/semmle/code/java/security/RequestForgeryConfig.qll b/java/ql/lib/semmle/code/java/security/RequestForgeryConfig.qll index c93d3089dc9..c8a59f65b0e 100644 --- a/java/ql/lib/semmle/code/java/security/RequestForgeryConfig.qll +++ b/java/ql/lib/semmle/code/java/security/RequestForgeryConfig.qll @@ -18,7 +18,7 @@ class RequestForgeryConfiguration extends TaintTracking::Configuration { // Exclude results of remote HTTP requests: fetching something else based on that result // is no worse than following a redirect returned by the remote server, and typically // we're requesting a resource via https which we trust to only send us to safe URLs. - not source.asExpr().(MethodAccess).getCallee() instanceof URLConnectionGetInputStreamMethod + not source.asExpr().(MethodAccess).getCallee() instanceof UrlConnectionGetInputStreamMethod } override predicate isSink(DataFlow::Node sink) { sink instanceof RequestForgerySink } diff --git a/java/ql/lib/semmle/code/java/security/UnsafeDeserializationQuery.qll b/java/ql/lib/semmle/code/java/security/UnsafeDeserializationQuery.qll index 71a2492c70c..6d0ff888d82 100644 --- a/java/ql/lib/semmle/code/java/security/UnsafeDeserializationQuery.qll +++ b/java/ql/lib/semmle/code/java/security/UnsafeDeserializationQuery.qll @@ -28,8 +28,8 @@ private class ObjectInputStreamReadObjectMethod extends Method { } } -private class XMLDecoderReadObjectMethod extends Method { - XMLDecoderReadObjectMethod() { +private class XmlDecoderReadObjectMethod extends Method { + XmlDecoderReadObjectMethod() { this.getDeclaringType().hasQualifiedName("java.beans", "XMLDecoder") and this.hasName("readObject") } @@ -140,7 +140,7 @@ predicate unsafeDeserialization(MethodAccess ma, Expr sink) { .hasQualifiedName("org.apache.commons.io.serialization", "ValidatingObjectInputStream") ) or - m instanceof XMLDecoderReadObjectMethod and + m instanceof XmlDecoderReadObjectMethod and sink = ma.getQualifier() or m instanceof XStreamReadObjectMethod and diff --git a/java/ql/lib/semmle/code/java/security/XSS.qll b/java/ql/lib/semmle/code/java/security/XSS.qll index 6053e3f4511..23bda5b9964 100644 --- a/java/ql/lib/semmle/code/java/security/XSS.qll +++ b/java/ql/lib/semmle/code/java/security/XSS.qll @@ -50,8 +50,8 @@ private class DefaultXssSink extends XssSink { } /** A default sanitizer that considers numeric and boolean typed data safe for writing to output. */ -private class DefaultXSSSanitizer extends XssSanitizer { - DefaultXSSSanitizer() { +private class DefaultXssSanitizer extends XssSanitizer { + DefaultXssSanitizer() { this.getType() instanceof NumericType or this.getType() instanceof BooleanType or // Match `org.springframework.web.util.HtmlUtils.htmlEscape` and possibly other methods like it. diff --git a/java/ql/lib/semmle/code/java/security/XmlParsers.qll b/java/ql/lib/semmle/code/java/security/XmlParsers.qll index 376e7481590..795d92538fc 100644 --- a/java/ql/lib/semmle/code/java/security/XmlParsers.qll +++ b/java/ql/lib/semmle/code/java/security/XmlParsers.qll @@ -358,21 +358,24 @@ class SafeXmlInputFactory extends VarAccess { /** * The class `org.jdom.input.SAXBuilder.` */ -class SAXBuilder extends RefType { - SAXBuilder() { +class SaxBuilder extends RefType { + SaxBuilder() { this.hasQualifiedName("org.jdom.input", "SAXBuilder") or this.hasQualifiedName("org.jdom2.input", "SAXBuilder") } } +/** DEPRECATED: Alias for SaxBuilder */ +deprecated class SAXBuilder = SaxBuilder; + /** * A call to `SAXBuilder.build.` */ -class SAXBuilderParse extends XmlParserCall { - SAXBuilderParse() { +class SaxBuilderParse extends XmlParserCall { + SaxBuilderParse() { exists(Method m | m = this.getMethod() and - m.getDeclaringType() instanceof SAXBuilder and + m.getDeclaringType() instanceof SaxBuilder and m.hasName("build") ) } @@ -380,19 +383,22 @@ class SAXBuilderParse extends XmlParserCall { override Expr getSink() { result = this.getArgument(0) } override predicate isSafe() { - exists(SafeSAXBuilderToSAXBuilderParseFlowConfig conf | conf.hasFlowToExpr(this.getQualifier())) + exists(SafeSaxBuilderToSaxBuilderParseFlowConfig conf | conf.hasFlowToExpr(this.getQualifier())) } } -private class SafeSAXBuilderToSAXBuilderParseFlowConfig extends DataFlow2::Configuration { - SafeSAXBuilderToSAXBuilderParseFlowConfig() { +/** DEPRECATED: Alias for SaxBuilderParse */ +deprecated class SAXBuilderParse = SaxBuilderParse; + +private class SafeSaxBuilderToSaxBuilderParseFlowConfig extends DataFlow2::Configuration { + SafeSaxBuilderToSaxBuilderParseFlowConfig() { this = "XmlParsers::SafeSAXBuilderToSAXBuilderParseFlowConfig" } - override predicate isSource(DataFlow::Node src) { src.asExpr() instanceof SafeSAXBuilder } + override predicate isSource(DataFlow::Node src) { src.asExpr() instanceof SafeSaxBuilder } override predicate isSink(DataFlow::Node sink) { - sink.asExpr() = any(SAXBuilderParse sax).getQualifier() + sink.asExpr() = any(SaxBuilderParse sax).getQualifier() } override int fieldFlowBranchLimit() { result = 0 } @@ -401,22 +407,25 @@ private class SafeSAXBuilderToSAXBuilderParseFlowConfig extends DataFlow2::Confi /** * A `ParserConfig` specific to `SAXBuilder`. */ -class SAXBuilderConfig extends ParserConfig { - SAXBuilderConfig() { +class SaxBuilderConfig extends ParserConfig { + SaxBuilderConfig() { exists(Method m | m = this.getMethod() and - m.getDeclaringType() instanceof SAXBuilder and + m.getDeclaringType() instanceof SaxBuilder and m.hasName("setFeature") ) } } -/** A safely configured `SAXBuilder`. */ -class SafeSAXBuilder extends VarAccess { - SafeSAXBuilder() { +/** DEPRECATED: Alias for SaxBuilderConfig */ +deprecated class SAXBuilderConfig = SaxBuilderConfig; + +/** A safely configured `SaxBuilder`. */ +class SafeSaxBuilder extends VarAccess { + SafeSaxBuilder() { exists(Variable v | v = this.getVariable() and - exists(SAXBuilderConfig config | config.getQualifier() = v.getAnAccess() | + exists(SaxBuilderConfig config | config.getQualifier() = v.getAnAccess() | config .enables(any(ConstantStringExpr s | s.getStringValue() = "http://apache.org/xml/features/disallow-doctype-decl" @@ -426,6 +435,9 @@ class SafeSAXBuilder extends VarAccess { } } +/** DEPRECATED: Alias for SafeSaxBuilder */ +deprecated class SafeSAXBuilder = SafeSaxBuilder; + /* * The case in * https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html#jaxb-unmarshaller @@ -435,21 +447,27 @@ class SafeSAXBuilder extends VarAccess { /** * The class `javax.xml.parsers.SAXParser`. */ -class SAXParser extends RefType { - SAXParser() { this.hasQualifiedName("javax.xml.parsers", "SAXParser") } +class SaxParser extends RefType { + SaxParser() { this.hasQualifiedName("javax.xml.parsers", "SAXParser") } } -/** The class `javax.xml.parsers.SAXParserFactory`. */ -class SAXParserFactory extends RefType { - SAXParserFactory() { this.hasQualifiedName("javax.xml.parsers", "SAXParserFactory") } +/** DEPRECATED: Alias for SaxParser */ +deprecated class SAXParser = SaxParser; + +/** The class `javax.xml.parsers.SaxParserFactory`. */ +class SaxParserFactory extends RefType { + SaxParserFactory() { this.hasQualifiedName("javax.xml.parsers", "SAXParserFactory") } } -/** A call to `SAXParser.parse`. */ -class SAXParserParse extends XmlParserCall { - SAXParserParse() { +/** DEPRECATED: Alias for SaxParserFactory */ +deprecated class SAXParserFactory = SaxParserFactory; + +/** A call to `SaxParser.parse`. */ +class SaxParserParse extends XmlParserCall { + SaxParserParse() { exists(Method m | m = this.getMethod() and - m.getDeclaringType() instanceof SAXParser and + m.getDeclaringType() instanceof SaxParser and m.hasName("parse") ) } @@ -457,44 +475,50 @@ class SAXParserParse extends XmlParserCall { override Expr getSink() { result = this.getArgument(0) } override predicate isSafe() { - exists(SafeSAXParserFlowConfig sp | sp.hasFlowToExpr(this.getQualifier())) + exists(SafeSaxParserFlowConfig sp | sp.hasFlowToExpr(this.getQualifier())) } } -/** A `ParserConfig` that is specific to `SAXParserFactory`. */ -class SAXParserFactoryConfig extends ParserConfig { - SAXParserFactoryConfig() { +/** DEPRECATED: Alias for SaxParserParse */ +deprecated class SAXParserParse = SaxParserParse; + +/** A `ParserConfig` that is specific to `SaxParserFactory`. */ +class SaxParserFactoryConfig extends ParserConfig { + SaxParserFactoryConfig() { exists(Method m | m = this.getMethod() and - m.getDeclaringType() instanceof SAXParserFactory and + m.getDeclaringType() instanceof SaxParserFactory and m.hasName("setFeature") ) } } +/** DEPRECATED: Alias for SaxParserFactoryConfig */ +deprecated class SAXParserFactoryConfig = SaxParserFactoryConfig; + /** * A safely configured `SAXParserFactory`. */ -class SafeSAXParserFactory extends VarAccess { - SafeSAXParserFactory() { +class SafeSaxParserFactory extends VarAccess { + SafeSaxParserFactory() { exists(Variable v | v = this.getVariable() | - exists(SAXParserFactoryConfig config | config.getQualifier() = v.getAnAccess() | + exists(SaxParserFactoryConfig config | config.getQualifier() = v.getAnAccess() | config.enables(singleSafeConfig()) ) or - exists(SAXParserFactoryConfig config | config.getQualifier() = v.getAnAccess() | + exists(SaxParserFactoryConfig config | config.getQualifier() = v.getAnAccess() | config .disables(any(ConstantStringExpr s | s.getStringValue() = "http://xml.org/sax/features/external-general-entities" )) ) and - exists(SAXParserFactoryConfig config | config.getQualifier() = v.getAnAccess() | + exists(SaxParserFactoryConfig config | config.getQualifier() = v.getAnAccess() | config .disables(any(ConstantStringExpr s | s.getStringValue() = "http://xml.org/sax/features/external-parameter-entities" )) ) and - exists(SAXParserFactoryConfig config | config.getQualifier() = v.getAnAccess() | + exists(SaxParserFactoryConfig config | config.getQualifier() = v.getAnAccess() | config .disables(any(ConstantStringExpr s | s.getStringValue() = @@ -505,18 +529,21 @@ class SafeSAXParserFactory extends VarAccess { } } -private class SafeSAXParserFactoryToNewSAXParserFlowConfig extends DataFlow5::Configuration { - SafeSAXParserFactoryToNewSAXParserFlowConfig() { +/** DEPRECATED: Alias for SafeSaxParserFactory */ +deprecated class SafeSAXParserFactory = SafeSaxParserFactory; + +private class SafeSaxParserFactoryToNewSaxParserFlowConfig extends DataFlow5::Configuration { + SafeSaxParserFactoryToNewSaxParserFlowConfig() { this = "XmlParsers::SafeSAXParserFactoryToNewSAXParserFlowConfig" } - override predicate isSource(DataFlow::Node src) { src.asExpr() instanceof SafeSAXParserFactory } + override predicate isSource(DataFlow::Node src) { src.asExpr() instanceof SafeSaxParserFactory } override predicate isSink(DataFlow::Node sink) { exists(MethodAccess ma, Method m | sink.asExpr() = ma.getQualifier() and ma.getMethod() = m and - m.getDeclaringType() instanceof SAXParserFactory and + m.getDeclaringType() instanceof SaxParserFactory and m.hasName("newSAXParser") ) } @@ -524,45 +551,51 @@ private class SafeSAXParserFactoryToNewSAXParserFlowConfig extends DataFlow5::Co override int fieldFlowBranchLimit() { result = 0 } } -private class SafeSAXParserFlowConfig extends DataFlow4::Configuration { - SafeSAXParserFlowConfig() { this = "XmlParsers::SafeSAXParserFlowConfig" } +private class SafeSaxParserFlowConfig extends DataFlow4::Configuration { + SafeSaxParserFlowConfig() { this = "XmlParsers::SafeSAXParserFlowConfig" } - override predicate isSource(DataFlow::Node src) { src.asExpr() instanceof SafeSAXParser } + override predicate isSource(DataFlow::Node src) { src.asExpr() instanceof SafeSaxParser } override predicate isSink(DataFlow::Node sink) { exists(MethodAccess ma | - sink.asExpr() = ma.getQualifier() and ma.getMethod().getDeclaringType() instanceof SAXParser + sink.asExpr() = ma.getQualifier() and ma.getMethod().getDeclaringType() instanceof SaxParser ) } override int fieldFlowBranchLimit() { result = 0 } } -/** A `SAXParser` created from a safely configured `SAXParserFactory`. */ -class SafeSAXParser extends MethodAccess { - SafeSAXParser() { - exists(SafeSAXParserFactoryToNewSAXParserFlowConfig sdf | - this.getMethod().getDeclaringType() instanceof SAXParserFactory and +/** A `SaxParser` created from a safely configured `SaxParserFactory`. */ +class SafeSaxParser extends MethodAccess { + SafeSaxParser() { + exists(SafeSaxParserFactoryToNewSaxParserFlowConfig sdf | + this.getMethod().getDeclaringType() instanceof SaxParserFactory and this.getMethod().hasName("newSAXParser") and sdf.hasFlowToExpr(this.getQualifier()) ) } } +/** DEPRECATED: Alias for SafeSaxParser */ +deprecated class SafeSAXParser = SafeSaxParser; + /* SAXReader: https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html#saxreader */ /** * The class `org.dom4j.io.SAXReader`. */ -class SAXReader extends RefType { - SAXReader() { this.hasQualifiedName("org.dom4j.io", "SAXReader") } +class SaxReader extends RefType { + SaxReader() { this.hasQualifiedName("org.dom4j.io", "SAXReader") } } -/** A call to `SAXReader.read`. */ -class SAXReaderRead extends XmlParserCall { - SAXReaderRead() { +/** DEPRECATED: Alias for SaxReader */ +deprecated class SAXReader = SaxReader; + +/** A call to `SaxReader.read`. */ +class SaxReaderRead extends XmlParserCall { + SaxReaderRead() { exists(Method m | m = this.getMethod() and - m.getDeclaringType() instanceof SAXReader and + m.getDeclaringType() instanceof SaxReader and m.hasName("read") ) } @@ -570,52 +603,58 @@ class SAXReaderRead extends XmlParserCall { override Expr getSink() { result = this.getArgument(0) } override predicate isSafe() { - exists(SafeSAXReaderFlowConfig sr | sr.hasFlowToExpr(this.getQualifier())) + exists(SafeSaxReaderFlowConfig sr | sr.hasFlowToExpr(this.getQualifier())) } } -/** A `ParserConfig` specific to `SAXReader`. */ -class SAXReaderConfig extends ParserConfig { - SAXReaderConfig() { +/** DEPRECATED: Alias for SaxReaderRead */ +deprecated class SAXReaderRead = SaxReaderRead; + +/** A `ParserConfig` specific to `SaxReader`. */ +class SaxReaderConfig extends ParserConfig { + SaxReaderConfig() { exists(Method m | m = this.getMethod() and - m.getDeclaringType() instanceof SAXReader and + m.getDeclaringType() instanceof SaxReader and m.hasName("setFeature") ) } } -private class SafeSAXReaderFlowConfig extends DataFlow4::Configuration { - SafeSAXReaderFlowConfig() { this = "XmlParsers::SafeSAXReaderFlowConfig" } +/** DEPRECATED: Alias for SaxReaderConfig */ +deprecated class SAXReaderConfig = SaxReaderConfig; - override predicate isSource(DataFlow::Node src) { src.asExpr() instanceof SafeSAXReader } +private class SafeSaxReaderFlowConfig extends DataFlow4::Configuration { + SafeSaxReaderFlowConfig() { this = "XmlParsers::SafeSAXReaderFlowConfig" } + + override predicate isSource(DataFlow::Node src) { src.asExpr() instanceof SafeSaxReader } override predicate isSink(DataFlow::Node sink) { exists(MethodAccess ma | - sink.asExpr() = ma.getQualifier() and ma.getMethod().getDeclaringType() instanceof SAXReader + sink.asExpr() = ma.getQualifier() and ma.getMethod().getDeclaringType() instanceof SaxReader ) } override int fieldFlowBranchLimit() { result = 0 } } -/** A safely configured `SAXReader`. */ -class SafeSAXReader extends VarAccess { - SafeSAXReader() { +/** A safely configured `SaxReader`. */ +class SafeSaxReader extends VarAccess { + SafeSaxReader() { exists(Variable v | v = this.getVariable() | - exists(SAXReaderConfig config | config.getQualifier() = v.getAnAccess() | + exists(SaxReaderConfig config | config.getQualifier() = v.getAnAccess() | config .disables(any(ConstantStringExpr s | s.getStringValue() = "http://xml.org/sax/features/external-general-entities" )) ) and - exists(SAXReaderConfig config | config.getQualifier() = v.getAnAccess() | + exists(SaxReaderConfig config | config.getQualifier() = v.getAnAccess() | config .disables(any(ConstantStringExpr s | s.getStringValue() = "http://xml.org/sax/features/external-parameter-entities" )) ) and - exists(SAXReaderConfig config | config.getQualifier() = v.getAnAccess() | + exists(SaxReaderConfig config | config.getQualifier() = v.getAnAccess() | config .enables(any(ConstantStringExpr s | s.getStringValue() = "http://apache.org/xml/features/disallow-doctype-decl" @@ -625,18 +664,24 @@ class SafeSAXReader extends VarAccess { } } +/** DEPRECATED: Alias for SafeSaxReader */ +deprecated class SafeSAXReader = SafeSaxReader; + /* https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html#xmlreader */ -/** The class `org.xml.sax.XMLReader`. */ -class XMLReader extends RefType { - XMLReader() { this.hasQualifiedName("org.xml.sax", "XMLReader") } +/** The class `org.xml.sax.XmlReader`. */ +class XmlReader extends RefType { + XmlReader() { this.hasQualifiedName("org.xml.sax", "XMLReader") } } -/** A call to `XMLReader.read`. */ -class XMLReaderParse extends XmlParserCall { - XMLReaderParse() { +/** DEPRECATED: Alias for XmlReader */ +deprecated class XMLReader = XmlReader; + +/** A call to `XmlReader.read`. */ +class XmlReaderParse extends XmlParserCall { + XmlReaderParse() { exists(Method m | m = this.getMethod() and - m.getDeclaringType() instanceof XMLReader and + m.getDeclaringType() instanceof XmlReader and m.hasName("parse") ) } @@ -644,59 +689,68 @@ class XMLReaderParse extends XmlParserCall { override Expr getSink() { result = this.getArgument(0) } override predicate isSafe() { - exists(ExplicitlySafeXMLReader sr | sr.flowsTo(this.getQualifier())) or - exists(CreatedSafeXMLReader cr | cr.flowsTo(this.getQualifier())) + exists(ExplicitlySafeXmlReader sr | sr.flowsTo(this.getQualifier())) or + exists(CreatedSafeXmlReader cr | cr.flowsTo(this.getQualifier())) } } -/** A `ParserConfig` specific to the `XMLReader`. */ -class XMLReaderConfig extends ParserConfig { - XMLReaderConfig() { +/** DEPRECATED: Alias for XmlReaderParse */ +deprecated class XMLReaderParse = XmlReaderParse; + +/** A `ParserConfig` specific to the `XmlReader`. */ +class XmlReaderConfig extends ParserConfig { + XmlReaderConfig() { exists(Method m | m = this.getMethod() and - m.getDeclaringType() instanceof XMLReader and + m.getDeclaringType() instanceof XmlReader and m.hasName("setFeature") ) } } -private class ExplicitlySafeXMLReaderFlowConfig extends DataFlow3::Configuration { - ExplicitlySafeXMLReaderFlowConfig() { this = "XmlParsers::ExplicitlySafeXMLReaderFlowConfig" } +/** DEPRECATED: Alias for XmlReaderConfig */ +deprecated class XMLReaderConfig = XmlReaderConfig; + +private class ExplicitlySafeXmlReaderFlowConfig extends DataFlow3::Configuration { + ExplicitlySafeXmlReaderFlowConfig() { this = "XmlParsers::ExplicitlySafeXMLReaderFlowConfig" } override predicate isSource(DataFlow::Node src) { - src.asExpr() instanceof ExplicitlySafeXMLReader + src.asExpr() instanceof ExplicitlySafeXmlReader } - override predicate isSink(DataFlow::Node sink) { sink.asExpr() instanceof SafeXMLReaderFlowSink } + override predicate isSink(DataFlow::Node sink) { sink.asExpr() instanceof SafeXmlReaderFlowSink } override int fieldFlowBranchLimit() { result = 0 } } -class SafeXMLReaderFlowSink extends Expr { - SafeXMLReaderFlowSink() { - this = any(XMLReaderParse p).getQualifier() or - this = any(ConstructedSAXSource s).getArgument(0) or - this = any(SAXSourceSetReader s).getArgument(0) +class SafeXmlReaderFlowSink extends Expr { + SafeXmlReaderFlowSink() { + this = any(XmlReaderParse p).getQualifier() or + this = any(ConstructedSaxSource s).getArgument(0) or + this = any(SaxSourceSetReader s).getArgument(0) } } -/** An `XMLReader` that is explicitly configured to be safe. */ -class ExplicitlySafeXMLReader extends VarAccess { - ExplicitlySafeXMLReader() { +/** DEPRECATED: Alias for SafeXmlReaderFlowSink */ +deprecated class SafeXMLReaderFlowSink = SafeXmlReaderFlowSink; + +/** An `XmlReader` that is explicitly configured to be safe. */ +class ExplicitlySafeXmlReader extends VarAccess { + ExplicitlySafeXmlReader() { exists(Variable v | v = this.getVariable() | - exists(XMLReaderConfig config | config.getQualifier() = v.getAnAccess() | + exists(XmlReaderConfig config | config.getQualifier() = v.getAnAccess() | config .disables(any(ConstantStringExpr s | s.getStringValue() = "http://xml.org/sax/features/external-general-entities" )) ) and - exists(XMLReaderConfig config | config.getQualifier() = v.getAnAccess() | + exists(XmlReaderConfig config | config.getQualifier() = v.getAnAccess() | config .disables(any(ConstantStringExpr s | s.getStringValue() = "http://xml.org/sax/features/external-parameter-entities" )) ) and - exists(XMLReaderConfig config | config.getQualifier() = v.getAnAccess() | + exists(XmlReaderConfig config | config.getQualifier() = v.getAnAccess() | config .disables(any(ConstantStringExpr s | s.getStringValue() = @@ -704,7 +758,7 @@ class ExplicitlySafeXMLReader extends VarAccess { )) ) or - exists(XMLReaderConfig config | config.getQualifier() = v.getAnAccess() | + exists(XmlReaderConfig config | config.getQualifier() = v.getAnAccess() | config .enables(any(ConstantStringExpr s | s.getStringValue() = "http://apache.org/xml/features/disallow-doctype-decl" @@ -713,35 +767,38 @@ class ExplicitlySafeXMLReader extends VarAccess { ) } - predicate flowsTo(SafeXMLReaderFlowSink sink) { - any(ExplicitlySafeXMLReaderFlowConfig conf) + predicate flowsTo(SafeXmlReaderFlowSink sink) { + any(ExplicitlySafeXmlReaderFlowConfig conf) .hasFlow(DataFlow::exprNode(this), DataFlow::exprNode(sink)) } } -private class CreatedSafeXMLReaderFlowConfig extends DataFlow3::Configuration { - CreatedSafeXMLReaderFlowConfig() { this = "XmlParsers::CreatedSafeXMLReaderFlowConfig" } +/** DEPRECATED: Alias for ExplicitlySafeXmlReader */ +deprecated class ExplicitlySafeXMLReader = ExplicitlySafeXmlReader; - override predicate isSource(DataFlow::Node src) { src.asExpr() instanceof CreatedSafeXMLReader } +private class CreatedSafeXmlReaderFlowConfig extends DataFlow3::Configuration { + CreatedSafeXmlReaderFlowConfig() { this = "XmlParsers::CreatedSafeXMLReaderFlowConfig" } - override predicate isSink(DataFlow::Node sink) { sink.asExpr() instanceof SafeXMLReaderFlowSink } + override predicate isSource(DataFlow::Node src) { src.asExpr() instanceof CreatedSafeXmlReader } + + override predicate isSink(DataFlow::Node sink) { sink.asExpr() instanceof SafeXmlReaderFlowSink } override int fieldFlowBranchLimit() { result = 0 } } -/** An `XMLReader` that is obtained from a safe source. */ -class CreatedSafeXMLReader extends Call { - CreatedSafeXMLReader() { +/** An `XmlReader` that is obtained from a safe source. */ +class CreatedSafeXmlReader extends Call { + CreatedSafeXmlReader() { //Obtained from SAXParser - exists(SafeSAXParserFlowConfig safeParser | - this.(MethodAccess).getMethod().getDeclaringType() instanceof SAXParser and + exists(SafeSaxParserFlowConfig safeParser | + this.(MethodAccess).getMethod().getDeclaringType() instanceof SaxParser and this.(MethodAccess).getMethod().hasName("getXMLReader") and safeParser.hasFlowToExpr(this.getQualifier()) ) or //Obtained from SAXReader - exists(SafeSAXReaderFlowConfig safeReader | - this.(MethodAccess).getMethod().getDeclaringType() instanceof SAXReader and + exists(SafeSaxReaderFlowConfig safeReader | + this.(MethodAccess).getMethod().getDeclaringType() instanceof SaxReader and this.(MethodAccess).getMethod().hasName("getXMLReader") and safeReader.hasFlowToExpr(this.getQualifier()) ) @@ -753,28 +810,34 @@ class CreatedSafeXMLReader extends Call { ) } - predicate flowsTo(SafeXMLReaderFlowSink sink) { - any(CreatedSafeXMLReaderFlowConfig conf) + predicate flowsTo(SafeXmlReaderFlowSink sink) { + any(CreatedSafeXmlReaderFlowConfig conf) .hasFlow(DataFlow::exprNode(this), DataFlow::exprNode(sink)) } } +/** DEPRECATED: Alias for CreatedSafeXmlReader */ +deprecated class CreatedSafeXMLReader = CreatedSafeXmlReader; + /* * SAXSource in * https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html#jaxb-unmarshaller */ -/** The class `javax.xml.transform.sax.SAXSource` */ -class SAXSource extends RefType { - SAXSource() { this.hasQualifiedName("javax.xml.transform.sax", "SAXSource") } +/** The class `javax.xml.transform.sax.SaxSource` */ +class SaxSource extends RefType { + SaxSource() { this.hasQualifiedName("javax.xml.transform.sax", "SAXSource") } } -/** A call to the constructor of `SAXSource` with `XMLReader` and `InputSource`. */ -class ConstructedSAXSource extends ClassInstanceExpr { - ConstructedSAXSource() { - this.getConstructedType() instanceof SAXSource and +/** DEPRECATED: Alias for SaxSource */ +deprecated class SAXSource = SaxSource; + +/** A call to the constructor of `SaxSource` with `XmlReader` and `InputSource`. */ +class ConstructedSaxSource extends ClassInstanceExpr { + ConstructedSaxSource() { + this.getConstructedType() instanceof SaxSource and this.getNumArgument() = 2 and - this.getArgument(0).getType() instanceof XMLReader + this.getArgument(0).getType() instanceof XmlReader } /** @@ -782,40 +845,49 @@ class ConstructedSAXSource extends ClassInstanceExpr { */ Expr getSink() { result = this.getArgument(1) } - /** Holds if the resulting `SAXSource` is safe. */ + /** Holds if the resulting `SaxSource` is safe. */ predicate isSafe() { - exists(CreatedSafeXMLReader safeReader | safeReader.flowsTo(this.getArgument(0))) or - exists(ExplicitlySafeXMLReader safeReader | safeReader.flowsTo(this.getArgument(0))) + exists(CreatedSafeXmlReader safeReader | safeReader.flowsTo(this.getArgument(0))) or + exists(ExplicitlySafeXmlReader safeReader | safeReader.flowsTo(this.getArgument(0))) } } -/** A call to the `SAXSource.setXMLReader` method. */ -class SAXSourceSetReader extends MethodAccess { - SAXSourceSetReader() { +/** DEPRECATED: Alias for ConstructedSaxSource */ +deprecated class ConstructedSAXSource = ConstructedSaxSource; + +/** A call to the `SaxSource.setXMLReader` method. */ +class SaxSourceSetReader extends MethodAccess { + SaxSourceSetReader() { exists(Method m | m = this.getMethod() and - m.getDeclaringType() instanceof SAXSource and + m.getDeclaringType() instanceof SaxSource and m.hasName("setXMLReader") ) } } -/** A `SAXSource` that is safe to use. */ -class SafeSAXSource extends Expr { - SafeSAXSource() { +/** DEPRECATED: Alias for SaxSourceSetReader */ +deprecated class SAXSourceSetReader = SaxSourceSetReader; + +/** A `SaxSource` that is safe to use. */ +class SafeSaxSource extends Expr { + SafeSaxSource() { exists(Variable v | v = this.(VarAccess).getVariable() | - exists(SAXSourceSetReader s | s.getQualifier() = v.getAnAccess() | + exists(SaxSourceSetReader s | s.getQualifier() = v.getAnAccess() | ( - exists(CreatedSafeXMLReader safeReader | safeReader.flowsTo(s.getArgument(0))) or - exists(ExplicitlySafeXMLReader safeReader | safeReader.flowsTo(s.getArgument(0))) + exists(CreatedSafeXmlReader safeReader | safeReader.flowsTo(s.getArgument(0))) or + exists(ExplicitlySafeXmlReader safeReader | safeReader.flowsTo(s.getArgument(0))) ) ) ) or - this.(ConstructedSAXSource).isSafe() + this.(ConstructedSaxSource).isSafe() } } +/** DEPRECATED: Alias for SafeSaxSource */ +deprecated class SafeSAXSource = SafeSaxSource; + /* Transformer: https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html#transformerfactory */ /** An access to a method use for configuring a transformer or schema. */ abstract class TransformerConfig extends MethodAccess { @@ -992,8 +1064,8 @@ class SafeTransformer extends MethodAccess { */ /** A call to `SAXTransformerFactory.newFilter`. */ -class SAXTransformerFactoryNewXMLFilter extends XmlParserCall { - SAXTransformerFactoryNewXMLFilter() { +class SaxTransformerFactoryNewXmlFilter extends XmlParserCall { + SaxTransformerFactoryNewXmlFilter() { exists(Method m | this.getMethod() = m and m.getDeclaringType().hasQualifiedName("javax.xml.transform.sax", "SAXTransformerFactory") and @@ -1008,6 +1080,9 @@ class SAXTransformerFactoryNewXMLFilter extends XmlParserCall { } } +/** DEPRECATED: Alias for SaxTransformerFactoryNewXmlFilter */ +deprecated class SAXTransformerFactoryNewXMLFilter = SaxTransformerFactoryNewXmlFilter; + /* Schema: https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html#schemafactory */ /** The class `javax.xml.validation.SchemaFactory`. */ class SchemaFactory extends RefType { @@ -1116,8 +1191,8 @@ class XPathEvaluate extends XmlParserCall { // Sink methods in simplexml http://simple.sourceforge.net/home.php /** A call to `read` or `validate` in `Persister`. */ -class SimpleXMLPersisterCall extends XmlParserCall { - SimpleXMLPersisterCall() { +class SimpleXmlPersisterCall extends XmlParserCall { + SimpleXmlPersisterCall() { exists(Method m | this.getMethod() = m and (m.hasName("validate") or m.hasName("read")) and @@ -1130,9 +1205,12 @@ class SimpleXMLPersisterCall extends XmlParserCall { override predicate isSafe() { none() } } +/** DEPRECATED: Alias for SimpleXmlPersisterCall */ +deprecated class SimpleXMLPersisterCall = SimpleXmlPersisterCall; + /** A call to `provide` in `Provider`. */ -class SimpleXMLProviderCall extends XmlParserCall { - SimpleXMLProviderCall() { +class SimpleXmlProviderCall extends XmlParserCall { + SimpleXmlProviderCall() { exists(Method m | this.getMethod() = m and m.hasName("provide") and @@ -1148,9 +1226,12 @@ class SimpleXMLProviderCall extends XmlParserCall { override predicate isSafe() { none() } } +/** DEPRECATED: Alias for SimpleXmlProviderCall */ +deprecated class SimpleXMLProviderCall = SimpleXmlProviderCall; + /** A call to `read` in `NodeBuilder`. */ -class SimpleXMLNodeBuilderCall extends XmlParserCall { - SimpleXMLNodeBuilderCall() { +class SimpleXmlNodeBuilderCall extends XmlParserCall { + SimpleXmlNodeBuilderCall() { exists(Method m | this.getMethod() = m and m.hasName("read") and @@ -1163,9 +1244,12 @@ class SimpleXMLNodeBuilderCall extends XmlParserCall { override predicate isSafe() { none() } } +/** DEPRECATED: Alias for SimpleXmlNodeBuilderCall */ +deprecated class SimpleXMLNodeBuilderCall = SimpleXmlNodeBuilderCall; + /** A call to the `format` method of the `Formatter`. */ -class SimpleXMLFormatterCall extends XmlParserCall { - SimpleXMLFormatterCall() { +class SimpleXmlFormatterCall extends XmlParserCall { + SimpleXmlFormatterCall() { exists(Method m | this.getMethod() = m and m.hasName("format") and @@ -1178,6 +1262,9 @@ class SimpleXMLFormatterCall extends XmlParserCall { override predicate isSafe() { none() } } +/** DEPRECATED: Alias for SimpleXmlFormatterCall */ +deprecated class SimpleXMLFormatterCall = SimpleXmlFormatterCall; + /** A configuration for secure processing. */ Expr configSecureProcessing() { result.(ConstantStringExpr).getStringValue() = diff --git a/java/ql/lib/semmle/code/java/security/XsltInjection.qll b/java/ql/lib/semmle/code/java/security/XsltInjection.qll index 75288492004..db96879181c 100644 --- a/java/ql/lib/semmle/code/java/security/XsltInjection.qll +++ b/java/ql/lib/semmle/code/java/security/XsltInjection.qll @@ -112,7 +112,7 @@ private predicate documentBuilderStep(DataFlow::Node n1, DataFlow::Node n2) { * `new DOMSource(tainted)`. */ private predicate domSourceStep(DataFlow::Node n1, DataFlow::Node n2) { - exists(ConstructorCall cc | cc.getConstructedType() instanceof TypeDOMSource | + exists(ConstructorCall cc | cc.getConstructedType() instanceof TypeDomSource | n1.asExpr() = cc.getAnArgument() and n2.asExpr() = cc ) @@ -179,8 +179,8 @@ private class TypeStAXSource extends Class { } /** The class `javax.xml.transform.dom.DOMSource`. */ -private class TypeDOMSource extends Class { - TypeDOMSource() { this.hasQualifiedName("javax.xml.transform.dom", "DOMSource") } +private class TypeDomSource extends Class { + TypeDomSource() { this.hasQualifiedName("javax.xml.transform.dom", "DOMSource") } } /** The interface `javax.xml.transform.Templates`. */ diff --git a/java/ql/lib/semmle/code/xml/WebXML.qll b/java/ql/lib/semmle/code/xml/WebXML.qll index c7dec5fd600..67e46b10026 100644 --- a/java/ql/lib/semmle/code/xml/WebXML.qll +++ b/java/ql/lib/semmle/code/xml/WebXML.qll @@ -3,13 +3,16 @@ import java /** * Holds if any `web.xml` files are included in this snapshot. */ -predicate isWebXMLIncluded() { exists(WebXMLFile webXML) } +predicate isWebXmlIncluded() { exists(WebXmlFile webXml) } + +/** DEPRECATED: Alias for isWebXmlIncluded */ +deprecated predicate isWebXMLIncluded = isWebXmlIncluded/0; /** * A deployment descriptor file, typically called `web.xml`. */ -class WebXMLFile extends XMLFile { - WebXMLFile() { +class WebXmlFile extends XMLFile { + WebXmlFile() { count(XMLElement e | e = this.getAChild()) = 1 and this.getAChild().getName() = "web-app" } @@ -28,11 +31,14 @@ class WebXMLFile extends XMLFile { } } +/** DEPRECATED: Alias for WebXmlFile */ +deprecated class WebXMLFile = WebXmlFile; + /** * An XML element in a `WebXMLFile`. */ -class WebXMLElement extends XMLElement { - WebXMLElement() { this.getFile() instanceof WebXMLFile } +class WebXmlElement extends XMLElement { + WebXmlElement() { this.getFile() instanceof WebXmlFile } /** * Gets the value for this element, with leading and trailing whitespace trimmed. @@ -40,10 +46,13 @@ class WebXMLElement extends XMLElement { string getValue() { result = this.allCharactersString().trim() } } +/** DEPRECATED: Alias for WebXmlElement */ +deprecated class WebXMLElement = WebXmlElement; + /** * A `` element in a `web.xml` file. */ -class WebContextParameter extends WebXMLElement { +class WebContextParameter extends WebXmlElement { WebContextParameter() { this.getName() = "context-param" } /** @@ -60,28 +69,28 @@ class WebContextParameter extends WebXMLElement { /** * A `` element in a `web.xml` file. */ -class WebContextParamName extends WebXMLElement { +class WebContextParamName extends WebXmlElement { WebContextParamName() { this.getName() = "param-name" } } /** * A `` element in a `web.xml` file. */ -class WebContextParamValue extends WebXMLElement { +class WebContextParamValue extends WebXmlElement { WebContextParamValue() { this.getName() = "param-value" } } /** * A `` element in a `web.xml` file. */ -class WebFilter extends WebXMLElement { +class WebFilter extends WebXmlElement { WebFilter() { this.getName() = "filter" } } /** * A `` element in a `web.xml` file, nested under a `` element. */ -class WebFilterClass extends WebXMLElement { +class WebFilterClass extends WebXmlElement { WebFilterClass() { this.getName() = "filter-class" and this.getParent() instanceof WebFilter @@ -93,14 +102,14 @@ class WebFilterClass extends WebXMLElement { /** * A `` element in a `web.xml` file. */ -class WebServlet extends WebXMLElement { +class WebServlet extends WebXmlElement { WebServlet() { this.getName() = "servlet" } } /** * A `` element in a `web.xml` file, nested under a `` element. */ -class WebServletClass extends WebXMLElement { +class WebServletClass extends WebXmlElement { WebServletClass() { this.getName() = "servlet-class" and this.getParent() instanceof WebServlet @@ -112,14 +121,14 @@ class WebServletClass extends WebXMLElement { /** * A `` element in a `web.xml` file. */ -class WebListener extends WebXMLElement { +class WebListener extends WebXmlElement { WebListener() { this.getName() = "listener" } } /** * A `` element in a `web.xml` file, nested under a `` element. */ -class WebListenerClass extends WebXMLElement { +class WebListenerClass extends WebXmlElement { WebListenerClass() { this.getName() = "listener-class" and this.getParent() instanceof WebListener @@ -134,7 +143,7 @@ class WebListenerClass extends WebXMLElement { /** * An `` element in a `web.xml` file. */ -class WebErrorPage extends WebXMLElement { +class WebErrorPage extends WebXmlElement { WebErrorPage() { this.getName() = "error-page" } /** @@ -151,7 +160,7 @@ class WebErrorPage extends WebXMLElement { /** * An `` element in a `web.xml` file, nested under an `` element. */ -class WebErrorPageType extends WebXMLElement { +class WebErrorPageType extends WebXmlElement { WebErrorPageType() { this.getName() = "exception-type" and this.getParent() instanceof WebErrorPage @@ -161,7 +170,7 @@ class WebErrorPageType extends WebXMLElement { /** * A `` element in a `web.xml` file, nested under an `` element. */ -class WebErrorPageLocation extends WebXMLElement { +class WebErrorPageLocation extends WebXmlElement { WebErrorPageLocation() { this.getName() = "location" and this.getParent() instanceof WebErrorPage diff --git a/java/ql/lib/semmle/code/xml/XML.qll b/java/ql/lib/semmle/code/xml/XML.qll index d2e6c44951f..fb781a4683f 100755 --- a/java/ql/lib/semmle/code/xml/XML.qll +++ b/java/ql/lib/semmle/code/xml/XML.qll @@ -4,11 +4,11 @@ import semmle.files.FileSystem -private class TXMLLocatable = +private class TXmlLocatable = @xmldtd or @xmlelement or @xmlattribute or @xmlnamespace or @xmlcomment or @xmlcharacters; /** An XML element that has a location. */ -class XMLLocatable extends @xmllocatable, TXMLLocatable { +class XMLLocatable extends @xmllocatable, TXmlLocatable { /** Gets the source location for this element. */ Location getLocation() { xmllocations(this, result) } diff --git a/java/ql/src/Frameworks/Spring/Architecture/Refactoring Opportunities/UnusedBean.ql b/java/ql/src/Frameworks/Spring/Architecture/Refactoring Opportunities/UnusedBean.ql index 32a83c26acf..504825807fd 100644 --- a/java/ql/src/Frameworks/Spring/Architecture/Refactoring Opportunities/UnusedBean.ql +++ b/java/ql/src/Frameworks/Spring/Architecture/Refactoring Opportunities/UnusedBean.ql @@ -100,7 +100,7 @@ class SpringPureClass extends Class { // Setter method by autowiring, either in the XML or by annotation c = this.getAMethod().(SpringBeanAutowiredCallable) or - c = this.getAMethod().(SpringBeanXMLAutowiredSetterMethod) + c = this.getAMethod().(SpringBeanXmlAutowiredSetterMethod) ) } } @@ -189,7 +189,7 @@ class LiveSpringBean extends SpringBean { ) or // Injected by autowired specified in XML - exists(SpringBeanXMLAutowiredSetterMethod setterMethod | + exists(SpringBeanXmlAutowiredSetterMethod setterMethod | // The config method must be on a live bean setterMethod.getDeclaringType().(SpringBeanRefType).getSpringBean() instanceof LiveSpringBean diff --git a/java/ql/src/Frameworks/Spring/Violations of Best Practice/UseShortcutForms.ql b/java/ql/src/Frameworks/Spring/Violations of Best Practice/UseShortcutForms.ql index 1d924dc9d6d..b7aad1b85fb 100644 --- a/java/ql/src/Frameworks/Spring/Violations of Best Practice/UseShortcutForms.ql +++ b/java/ql/src/Frameworks/Spring/Violations of Best Practice/UseShortcutForms.ql @@ -51,7 +51,7 @@ class SpringPropertyUseShortcut extends SpringProperty { } } -from SpringXMLElement springElement, string msg +from SpringXmlElement springElement, string msg where exists(SpringConstructorArgUseShortcut cons | cons = springElement and msg = cons.getMessage()) or diff --git a/java/ql/src/Likely Bugs/Termination/ConstantLoopCondition.ql b/java/ql/src/Likely Bugs/Termination/ConstantLoopCondition.ql index 41be2be2c52..3d0b45dabed 100644 --- a/java/ql/src/Likely Bugs/Termination/ConstantLoopCondition.ql +++ b/java/ql/src/Likely Bugs/Termination/ConstantLoopCondition.ql @@ -74,8 +74,8 @@ where ) and // None of the ssa variables in `cond` are updated inside the loop. forex(SsaVariable ssa, RValue use | ssa.getAUse() = use and use.getParent*() = cond | - not ssa.getCFGNode().getEnclosingStmt().getEnclosingStmt*() = loop or - ssa.getCFGNode().(Expr).getParent*() = loop.(ForStmt).getAnInit() + not ssa.getCfgNode().getEnclosingStmt().getEnclosingStmt*() = loop or + ssa.getCfgNode().(Expr).getParent*() = loop.(ForStmt).getAnInit() ) and // And `cond` does not use method calls, field reads, or array reads. not exists(MethodAccess ma | ma.getParent*() = cond) and diff --git a/java/ql/src/Security/CWE/CWE-020/ExternalAPIsUsedWithUntrustedData.ql b/java/ql/src/Security/CWE/CWE-020/ExternalAPIsUsedWithUntrustedData.ql index f9643429d72..23c82397de0 100644 --- a/java/ql/src/Security/CWE/CWE-020/ExternalAPIsUsedWithUntrustedData.ql +++ b/java/ql/src/Security/CWE/CWE-020/ExternalAPIsUsedWithUntrustedData.ql @@ -12,7 +12,7 @@ import java import semmle.code.java.security.ExternalAPIs import semmle.code.java.dataflow.DataFlow -from ExternalAPIUsedWithUntrustedData externalAPI -select externalAPI, count(externalAPI.getUntrustedDataNode()) as numberOfUses, - externalAPI.getNumberOfUntrustedSources() as numberOfUntrustedSources order by +from ExternalApiUsedWithUntrustedData externalApi +select externalApi, count(externalApi.getUntrustedDataNode()) as numberOfUses, + externalApi.getNumberOfUntrustedSources() as numberOfUntrustedSources order by numberOfUntrustedSources desc diff --git a/java/ql/src/Security/CWE/CWE-020/UntrustedDataToExternalAPI.ql b/java/ql/src/Security/CWE/CWE-020/UntrustedDataToExternalAPI.ql index 63c66ffa9d0..b4a2e209513 100644 --- a/java/ql/src/Security/CWE/CWE-020/UntrustedDataToExternalAPI.ql +++ b/java/ql/src/Security/CWE/CWE-020/UntrustedDataToExternalAPI.ql @@ -15,8 +15,8 @@ import semmle.code.java.dataflow.TaintTracking import semmle.code.java.security.ExternalAPIs import DataFlow::PathGraph -from UntrustedDataToExternalAPIConfig config, DataFlow::PathNode source, DataFlow::PathNode sink +from UntrustedDataToExternalApiConfig config, DataFlow::PathNode source, DataFlow::PathNode sink where config.hasFlowPath(source, sink) select sink, source, sink, - "Call to " + sink.getNode().(ExternalAPIDataNode).getMethodDescription() + + "Call to " + sink.getNode().(ExternalApiDataNode).getMethodDescription() + " with untrusted data from $@.", source, source.toString() diff --git a/java/ql/src/Security/CWE/CWE-079/XSS.ql b/java/ql/src/Security/CWE/CWE-079/XSS.ql index 885a6f7a47b..c488a5d08d4 100644 --- a/java/ql/src/Security/CWE/CWE-079/XSS.ql +++ b/java/ql/src/Security/CWE/CWE-079/XSS.ql @@ -16,8 +16,8 @@ import semmle.code.java.dataflow.FlowSources import semmle.code.java.security.XSS import DataFlow::PathGraph -class XSSConfig extends TaintTracking::Configuration { - XSSConfig() { this = "XSSConfig" } +class XssConfig extends TaintTracking::Configuration { + XssConfig() { this = "XSSConfig" } override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource } @@ -32,7 +32,7 @@ class XSSConfig extends TaintTracking::Configuration { } } -from DataFlow::PathNode source, DataFlow::PathNode sink, XSSConfig conf +from DataFlow::PathNode source, DataFlow::PathNode sink, XssConfig conf where conf.hasFlowPath(source, sink) select sink.getNode(), source, sink, "Cross-site scripting vulnerability due to $@.", source.getNode(), "user-provided value" diff --git a/java/ql/src/Security/CWE/CWE-079/XSSLocal.ql b/java/ql/src/Security/CWE/CWE-079/XSSLocal.ql index e16a9bbc2e9..da318a5b7cb 100644 --- a/java/ql/src/Security/CWE/CWE-079/XSSLocal.ql +++ b/java/ql/src/Security/CWE/CWE-079/XSSLocal.ql @@ -16,15 +16,15 @@ import semmle.code.java.dataflow.FlowSources import semmle.code.java.security.XSS import DataFlow::PathGraph -class XSSLocalConfig extends TaintTracking::Configuration { - XSSLocalConfig() { this = "XSSLocalConfig" } +class XssLocalConfig extends TaintTracking::Configuration { + XssLocalConfig() { this = "XSSLocalConfig" } override predicate isSource(DataFlow::Node source) { source instanceof LocalUserInput } override predicate isSink(DataFlow::Node sink) { sink instanceof XssSink } } -from DataFlow::PathNode source, DataFlow::PathNode sink, XSSLocalConfig conf +from DataFlow::PathNode source, DataFlow::PathNode sink, XssLocalConfig conf where conf.hasFlowPath(source, sink) select sink.getNode(), source, sink, "Cross-site scripting vulnerability due to $@.", source.getNode(), "user-provided value" diff --git a/java/ql/src/Security/CWE/CWE-319/UseSSL.ql b/java/ql/src/Security/CWE/CWE-319/UseSSL.ql index 1b267af52cf..ba3dee696dd 100644 --- a/java/ql/src/Security/CWE/CWE-319/UseSSL.ql +++ b/java/ql/src/Security/CWE/CWE-319/UseSSL.ql @@ -14,8 +14,8 @@ import java import semmle.code.java.dataflow.TypeFlow import semmle.code.java.security.Encryption -class URLConnection extends RefType { - URLConnection() { +class UrlConnection extends RefType { + UrlConnection() { this.getAnAncestor().hasQualifiedName("java.net", "URLConnection") and not this.hasName("JarURLConnection") } @@ -29,7 +29,7 @@ from MethodAccess m, Class c, string type where m.getQualifier().getType() = c and ( - c instanceof URLConnection and type = "connection" + c instanceof UrlConnection and type = "connection" or c instanceof Socket and type = "socket" ) and diff --git a/java/ql/src/Security/CWE/CWE-611/XXE.ql b/java/ql/src/Security/CWE/CWE-611/XXE.ql index bfcedb19d17..b50c9c7fef8 100644 --- a/java/ql/src/Security/CWE/CWE-611/XXE.ql +++ b/java/ql/src/Security/CWE/CWE-611/XXE.ql @@ -19,10 +19,10 @@ import semmle.code.java.dataflow.FlowSources import semmle.code.java.dataflow.TaintTracking2 import DataFlow::PathGraph -class SafeSAXSourceFlowConfig extends TaintTracking2::Configuration { - SafeSAXSourceFlowConfig() { this = "XmlParsers::SafeSAXSourceFlowConfig" } +class SafeSaxSourceFlowConfig extends TaintTracking2::Configuration { + SafeSaxSourceFlowConfig() { this = "XmlParsers::SafeSAXSourceFlowConfig" } - override predicate isSource(DataFlow::Node src) { src.asExpr() instanceof SafeSAXSource } + override predicate isSource(DataFlow::Node src) { src.asExpr() instanceof SafeSaxSource } override predicate isSink(DataFlow::Node sink) { sink.asExpr() = any(XmlParserCall parse).getSink() @@ -33,7 +33,7 @@ class SafeSAXSourceFlowConfig extends TaintTracking2::Configuration { class UnsafeXxeSink extends DataFlow::ExprNode { UnsafeXxeSink() { - not exists(SafeSAXSourceFlowConfig safeSource | safeSource.hasFlowTo(this)) and + not exists(SafeSaxSourceFlowConfig safeSource | safeSource.hasFlowTo(this)) and exists(XmlParserCall parse | parse.getSink() = this.getExpr() and not parse.isSafe() diff --git a/java/ql/src/Telemetry/ExternalAPI.qll b/java/ql/src/Telemetry/ExternalAPI.qll index c3bd101662d..e8a1e007c12 100644 --- a/java/ql/src/Telemetry/ExternalAPI.qll +++ b/java/ql/src/Telemetry/ExternalAPI.qll @@ -12,8 +12,8 @@ private import semmle.code.java.dataflow.TaintTracking /** * An external API from either the Java Standard Library or a 3rd party library. */ -class ExternalAPI extends Callable { - ExternalAPI() { not this.fromSource() } +class ExternalApi extends Callable { + ExternalApi() { not this.fromSource() } /** Holds if this API is not worth supporting */ predicate isUninteresting() { this.isTestLibrary() or this.isParameterlessConstructor() } @@ -80,6 +80,9 @@ class ExternalAPI extends Callable { predicate isSupported() { this.hasSummary() or this.isSource() or this.isSink() } } +/** DEPRECATED: Alias for ExternalApi */ +deprecated class ExternalAPI = ExternalApi; + private class TestLibrary extends RefType { TestLibrary() { this.getPackage() diff --git a/java/ql/src/Telemetry/ExternalLibraryUsage.ql b/java/ql/src/Telemetry/ExternalLibraryUsage.ql index 93052f19d3b..fd29d2fbea0 100644 --- a/java/ql/src/Telemetry/ExternalLibraryUsage.ql +++ b/java/ql/src/Telemetry/ExternalLibraryUsage.ql @@ -12,7 +12,7 @@ import ExternalAPI from int usages, string jarname where usages = - strictcount(Call c, ExternalAPI a | + strictcount(Call c, ExternalApi a | c.getCallee().getSourceDeclaration() = a and not c.getFile() instanceof GeneratedFile and a.jarContainer() = jarname and diff --git a/java/ql/src/Telemetry/SupportedExternalSinks.ql b/java/ql/src/Telemetry/SupportedExternalSinks.ql index f39794a23be..fc831f9fa59 100644 --- a/java/ql/src/Telemetry/SupportedExternalSinks.ql +++ b/java/ql/src/Telemetry/SupportedExternalSinks.ql @@ -10,7 +10,7 @@ import java import ExternalAPI import semmle.code.java.GeneratedFiles -from ExternalAPI api, int usages +from ExternalApi api, int usages where not api.isUninteresting() and api.isSink() and diff --git a/java/ql/src/Telemetry/SupportedExternalSources.ql b/java/ql/src/Telemetry/SupportedExternalSources.ql index 91d51cd72fa..9e526007b00 100644 --- a/java/ql/src/Telemetry/SupportedExternalSources.ql +++ b/java/ql/src/Telemetry/SupportedExternalSources.ql @@ -10,7 +10,7 @@ import java import ExternalAPI import semmle.code.java.GeneratedFiles -from ExternalAPI api, int usages +from ExternalApi api, int usages where not api.isUninteresting() and api.isSource() and diff --git a/java/ql/src/Telemetry/SupportedExternalTaint.ql b/java/ql/src/Telemetry/SupportedExternalTaint.ql index 71721923dea..7e7032a4730 100644 --- a/java/ql/src/Telemetry/SupportedExternalTaint.ql +++ b/java/ql/src/Telemetry/SupportedExternalTaint.ql @@ -10,7 +10,7 @@ import java import ExternalAPI import semmle.code.java.GeneratedFiles -from ExternalAPI api, int usages +from ExternalApi api, int usages where not api.isUninteresting() and api.hasSummary() and diff --git a/java/ql/src/Telemetry/UnsupportedExternalAPIs.ql b/java/ql/src/Telemetry/UnsupportedExternalAPIs.ql index e79e4938438..ab9df45091d 100644 --- a/java/ql/src/Telemetry/UnsupportedExternalAPIs.ql +++ b/java/ql/src/Telemetry/UnsupportedExternalAPIs.ql @@ -10,7 +10,7 @@ import java import ExternalAPI import semmle.code.java.GeneratedFiles -from ExternalAPI api, int usages +from ExternalApi api, int usages where not api.isUninteresting() and not api.isSupported() and diff --git a/java/ql/src/Violations of Best Practice/Dead Code/DeadLocals.qll b/java/ql/src/Violations of Best Practice/Dead Code/DeadLocals.qll index a138351e656..82933aa9bac 100644 --- a/java/ql/src/Violations of Best Practice/Dead Code/DeadLocals.qll +++ b/java/ql/src/Violations of Best Practice/Dead Code/DeadLocals.qll @@ -44,8 +44,8 @@ predicate overwritten(SsaExplicitUpdate ssa) { not deadLocal(overwrite) and not overwrite.getDefiningExpr() instanceof LocalVariableDeclExpr and exists(BasicBlock bb1, BasicBlock bb2, int i, int j | - bb1.getNode(i) = ssa.getCFGNode() and - bb2.getNode(j) = overwrite.getCFGNode() + bb1.getNode(i) = ssa.getCfgNode() and + bb2.getNode(j) = overwrite.getCfgNode() | bb1.getABBSuccessor+() = bb2 or diff --git a/java/ql/src/experimental/Security/CWE/CWE-036/OpenStream.ql b/java/ql/src/experimental/Security/CWE/CWE-036/OpenStream.ql index 871d6bb4737..efd2608f59c 100644 --- a/java/ql/src/experimental/Security/CWE/CWE-036/OpenStream.ql +++ b/java/ql/src/experimental/Security/CWE/CWE-036/OpenStream.ql @@ -16,8 +16,8 @@ import semmle.code.java.dataflow.FlowSources import semmle.code.java.dataflow.ExternalFlow import DataFlow::PathGraph -class URLConstructor extends ClassInstanceExpr { - URLConstructor() { this.getConstructor().getDeclaringType() instanceof TypeUrl } +class UrlConstructor extends ClassInstanceExpr { + UrlConstructor() { this.getConstructor().getDeclaringType() instanceof TypeUrl } Expr stringArg() { // Query only in URL's that were constructed by calling the single parameter string constructor. @@ -27,28 +27,28 @@ class URLConstructor extends ClassInstanceExpr { } } -class URLOpenStreamMethod extends Method { - URLOpenStreamMethod() { +class UrlOpenStreamMethod extends Method { + UrlOpenStreamMethod() { this.getDeclaringType() instanceof TypeUrl and this.getName() = "openStream" } } -class RemoteURLToOpenStreamFlowConfig extends TaintTracking::Configuration { - RemoteURLToOpenStreamFlowConfig() { this = "OpenStream::RemoteURLToOpenStreamFlowConfig" } +class RemoteUrlToOpenStreamFlowConfig extends TaintTracking::Configuration { + RemoteUrlToOpenStreamFlowConfig() { this = "OpenStream::RemoteURLToOpenStreamFlowConfig" } override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource } override predicate isSink(DataFlow::Node sink) { exists(MethodAccess m | - sink.asExpr() = m.getQualifier() and m.getMethod() instanceof URLOpenStreamMethod + sink.asExpr() = m.getQualifier() and m.getMethod() instanceof UrlOpenStreamMethod ) or sinkNode(sink, "url-open-stream") } override predicate isAdditionalTaintStep(DataFlow::Node node1, DataFlow::Node node2) { - exists(URLConstructor u | + exists(UrlConstructor u | node1.asExpr() = u.stringArg() and node2.asExpr() = u ) @@ -58,6 +58,6 @@ class RemoteURLToOpenStreamFlowConfig extends TaintTracking::Configuration { from DataFlow::PathNode source, DataFlow::PathNode sink, MethodAccess call where sink.getNode().asExpr() = call.getQualifier() and - any(RemoteURLToOpenStreamFlowConfig c).hasFlowPath(source, sink) + any(RemoteUrlToOpenStreamFlowConfig c).hasFlowPath(source, sink) select call, source, sink, "URL on which openStream is called may have been constructed from remote source" diff --git a/java/ql/src/experimental/Security/CWE/CWE-089/MyBatisCommonLib.qll b/java/ql/src/experimental/Security/CWE/CWE-089/MyBatisCommonLib.qll index f43f9a34128..b7f01ce06cd 100644 --- a/java/ql/src/experimental/Security/CWE/CWE-089/MyBatisCommonLib.qll +++ b/java/ql/src/experimental/Security/CWE/CWE-089/MyBatisCommonLib.qll @@ -45,7 +45,7 @@ class ListType extends RefType { } /** Holds if the specified `method` uses MyBatis Mapper XMLElement `mmxx`. */ -predicate myBatisMapperXMLElementFromMethod(Method method, MyBatisMapperXMLElement mmxx) { +predicate myBatisMapperXmlElementFromMethod(Method method, MyBatisMapperXmlElement mmxx) { exists(MyBatisMapperSqlOperation mbmxe | mbmxe.getMapperMethod() = method | mbmxe.getAChild*() = mmxx or @@ -56,6 +56,9 @@ predicate myBatisMapperXMLElementFromMethod(Method method, MyBatisMapperXMLEleme ) } +/** DEPRECATED: Alias for myBatisMapperXmlElementFromMethod */ +deprecated predicate myBatisMapperXMLElementFromMethod = myBatisMapperXmlElementFromMethod/2; + /** Holds if the specified `method` has Ibatis Sql operation annotation `isoa`. */ predicate myBatisSqlOperationAnnotationFromMethod(Method method, IbatisSqlOperationAnnotation isoa) { exists(MyBatisSqlOperationAnnotationMethod msoam | diff --git a/java/ql/src/experimental/Security/CWE/CWE-089/MyBatisMapperXmlSqlInjection.ql b/java/ql/src/experimental/Security/CWE/CWE-089/MyBatisMapperXmlSqlInjection.ql index 908234fa3f3..9aeb95ea94a 100644 --- a/java/ql/src/experimental/Security/CWE/CWE-089/MyBatisMapperXmlSqlInjection.ql +++ b/java/ql/src/experimental/Security/CWE/CWE-089/MyBatisMapperXmlSqlInjection.ql @@ -45,11 +45,11 @@ private class MyBatisMapperXmlSqlInjectionConfiguration extends TaintTracking::C from MyBatisMapperXmlSqlInjectionConfiguration cfg, DataFlow::PathNode source, DataFlow::PathNode sink, - MyBatisMapperXMLElement mmxe, MethodAccess ma, string unsafeExpression + MyBatisMapperXmlElement mmxe, MethodAccess ma, string unsafeExpression where cfg.hasFlowPath(source, sink) and ma.getAnArgument() = sink.getNode().asExpr() and - myBatisMapperXMLElementFromMethod(ma.getMethod(), mmxe) and + myBatisMapperXmlElementFromMethod(ma.getMethod(), mmxe) and unsafeExpression = getAMybatisXmlSetValue(mmxe) and ( isMybatisXmlOrAnnotationSqlInjection(sink.getNode(), ma, unsafeExpression) diff --git a/java/ql/src/experimental/Security/CWE/CWE-1004/InsecureTomcatConfig.ql b/java/ql/src/experimental/Security/CWE/CWE-1004/InsecureTomcatConfig.ql index c8bff52333d..fbc3e0536b1 100644 --- a/java/ql/src/experimental/Security/CWE/CWE-1004/InsecureTomcatConfig.ql +++ b/java/ql/src/experimental/Security/CWE/CWE-1004/InsecureTomcatConfig.ql @@ -17,10 +17,10 @@ private class HttpOnlyConfig extends WebContextParameter { string getParamValueElementValue() { result = this.getParamValue().getValue() } - predicate isHTTPOnlySet() { this.getParamValueElementValue().toLowerCase() = "false" } + predicate isHttpOnlySet() { this.getParamValueElementValue().toLowerCase() = "false" } } from HttpOnlyConfig config -where config.isHTTPOnlySet() +where config.isHttpOnlySet() select config, "httpOnly should be enabled in tomcat config file to help mitigate cross-site scripting (XSS) attacks" diff --git a/java/ql/src/experimental/Security/CWE/CWE-548/InsecureDirectoryConfig.ql b/java/ql/src/experimental/Security/CWE/CWE-548/InsecureDirectoryConfig.ql index c1667abdd3d..1ef4fb4d1f6 100644 --- a/java/ql/src/experimental/Security/CWE/CWE-548/InsecureDirectoryConfig.ql +++ b/java/ql/src/experimental/Security/CWE/CWE-548/InsecureDirectoryConfig.ql @@ -27,7 +27,7 @@ private class DefaultTomcatServlet extends WebServletClass { /** * The `` element in a `web.xml` file, nested under a `` element controlling directory listing. */ -class DirectoryListingInitParam extends WebXMLElement { +class DirectoryListingInitParam extends WebXmlElement { DirectoryListingInitParam() { this.getName() = "init-param" and this.getAChild("param-name").getTextValue() = "listings" and diff --git a/java/ql/src/experimental/Security/CWE/CWE-552/UnsafeUrlForward.ql b/java/ql/src/experimental/Security/CWE/CWE-552/UnsafeUrlForward.ql index 12f6b29d692..94cdaafa553 100644 --- a/java/ql/src/experimental/Security/CWE/CWE-552/UnsafeUrlForward.ql +++ b/java/ql/src/experimental/Security/CWE/CWE-552/UnsafeUrlForward.ql @@ -23,7 +23,7 @@ class UnsafeUrlForwardFlowConfig extends TaintTracking::Configuration { not exists(MethodAccess ma, Method m | ma.getMethod() = m | ( m instanceof HttpServletRequestGetRequestURIMethod or - m instanceof HttpServletRequestGetRequestURLMethod or + m instanceof HttpServletRequestGetRequestUrlMethod or m instanceof HttpServletRequestGetPathMethod ) and ma = source.asExpr() diff --git a/java/ql/src/experimental/Security/CWE/CWE-611/XXELib.qll b/java/ql/src/experimental/Security/CWE/CWE-611/XXELib.qll index 267b4bdef1d..996eca35850 100644 --- a/java/ql/src/experimental/Security/CWE/CWE-611/XXELib.qll +++ b/java/ql/src/experimental/Security/CWE/CWE-611/XXELib.qll @@ -204,17 +204,20 @@ private class SafeDigesterFlowConfig extends DataFlow4::Configuration { override int fieldFlowBranchLimit() { result = 0 } } -/** The class `java.beans.XMLDecoder`. */ -class XMLDecoder extends RefType { - XMLDecoder() { this.hasQualifiedName("java.beans", "XMLDecoder") } +/** The class `java.beans.XmlDecoder`. */ +class XmlDecoder extends RefType { + XmlDecoder() { this.hasQualifiedName("java.beans", "XMLDecoder") } } -/** A call to `XMLDecoder.readObject`. */ -class XMLDecoderReadObject extends XmlParserCall { - XMLDecoderReadObject() { +/** DEPRECATED: Alias for XmlDecoder */ +deprecated class XMLDecoder = XmlDecoder; + +/** A call to `XmlDecoder.readObject`. */ +class XmlDecoderReadObject extends XmlParserCall { + XmlDecoderReadObject() { exists(Method m | this.getMethod() = m and - m.getDeclaringType() instanceof XMLDecoder and + m.getDeclaringType() instanceof XmlDecoder and m.hasName("readObject") ) } @@ -224,6 +227,9 @@ class XMLDecoderReadObject extends XmlParserCall { override predicate isSafe() { none() } } +/** DEPRECATED: Alias for XmlDecoderReadObject */ +deprecated class XMLDecoderReadObject = XmlDecoderReadObject; + private predicate constantStringExpr(Expr e, string val) { e.(CompileTimeConstantExpr).getStringValue() = val or @@ -235,8 +241,8 @@ private predicate constantStringExpr(Expr e, string val) { } /** A call to `SAXTransformerFactory.newTransformerHandler`. */ -class SAXTransformerFactoryNewTransformerHandler extends XmlParserCall { - SAXTransformerFactoryNewTransformerHandler() { +class SaxTransformerFactoryNewTransformerHandler extends XmlParserCall { + SaxTransformerFactoryNewTransformerHandler() { exists(Method m | this.getMethod() = m and m.getDeclaringType().hasQualifiedName("javax.xml.transform.sax", "SAXTransformerFactory") and @@ -251,6 +257,10 @@ class SAXTransformerFactoryNewTransformerHandler extends XmlParserCall { } } +/** DEPRECATED: Alias for SaxTransformerFactoryNewTransformerHandler */ +deprecated class SAXTransformerFactoryNewTransformerHandler = + SaxTransformerFactoryNewTransformerHandler; + /** An expression that always has the same string value. */ private class ConstantStringExpr extends Expr { string value; diff --git a/java/ql/src/experimental/semmle/code/java/PathSanitizer.qll b/java/ql/src/experimental/semmle/code/java/PathSanitizer.qll index 9e76410a6ff..aba7bba5238 100644 --- a/java/ql/src/experimental/semmle/code/java/PathSanitizer.qll +++ b/java/ql/src/experimental/semmle/code/java/PathSanitizer.qll @@ -102,7 +102,7 @@ private class BlockListBarrierGuard extends PathTraversalBarrierGuard instanceof * A guard that considers a string safe because it is checked for URL encoding sequences, * having previously been checked against a block-list of forbidden values. */ -private class URLEncodingBarrierGuard extends PathTraversalBarrierGuard instanceof UrlEncodingGuard { +private class UrlEncodingBarrierGuard extends PathTraversalBarrierGuard instanceof UrlEncodingGuard { override predicate checks(Expr e, boolean branch) { e = super.getCheckedExpr() and branch = false and diff --git a/java/ql/src/experimental/semmle/code/xml/StrutsXML.qll b/java/ql/src/experimental/semmle/code/xml/StrutsXML.qll index 00580fe1e79..709a05dae0d 100644 --- a/java/ql/src/experimental/semmle/code/xml/StrutsXML.qll +++ b/java/ql/src/experimental/semmle/code/xml/StrutsXML.qll @@ -3,18 +3,21 @@ import java /** * A deployment descriptor file, typically called `struts.xml`. */ -class StrutsXMLFile extends XMLFile { - StrutsXMLFile() { +class StrutsXmlFile extends XMLFile { + StrutsXmlFile() { count(XMLElement e | e = this.getAChild()) = 1 and this.getAChild().getName() = "struts" } } +/** DEPRECATED: Alias for StrutsXmlFile */ +deprecated class StrutsXMLFile = StrutsXmlFile; + /** * An XML element in a `StrutsXMLFile`. */ -class StrutsXMLElement extends XMLElement { - StrutsXMLElement() { this.getFile() instanceof StrutsXMLFile } +class StrutsXmlElement extends XMLElement { + StrutsXmlElement() { this.getFile() instanceof StrutsXmlFile } /** * Gets the value for this element, with leading and trailing whitespace trimmed. @@ -22,10 +25,13 @@ class StrutsXMLElement extends XMLElement { string getValue() { result = this.allCharactersString().trim() } } +/** DEPRECATED: Alias for StrutsXmlElement */ +deprecated class StrutsXMLElement = StrutsXmlElement; + /** * A `` element in a `StrutsXMLFile`. */ -class ConstantParameter extends StrutsXMLElement { +class ConstantParameter extends StrutsXmlElement { ConstantParameter() { this.getName() = "constant" } /** diff --git a/java/ql/src/meta/ssa/AmbiguousToString.ql b/java/ql/src/meta/ssa/AmbiguousToString.ql index ef9439705de..817685cf609 100644 --- a/java/ql/src/meta/ssa/AmbiguousToString.ql +++ b/java/ql/src/meta/ssa/AmbiguousToString.ql @@ -22,6 +22,6 @@ where or multipleToString(ssa) and problem = "SSA variable with multiple 'toString()' results for " ) and - n = ssa.getCFGNode() and + n = ssa.getCfgNode() and v = ssa.getSourceVariable().getVariable() select n, problem + v diff --git a/java/ql/src/semmle/code/xml/MyBatisMapperXML.qll b/java/ql/src/semmle/code/xml/MyBatisMapperXML.qll index 5eff757a93d..856729dcce5 100644 --- a/java/ql/src/semmle/code/xml/MyBatisMapperXML.qll +++ b/java/ql/src/semmle/code/xml/MyBatisMapperXML.qll @@ -7,18 +7,21 @@ import java /** * MyBatis Mapper XML file. */ -class MyBatisMapperXMLFile extends XMLFile { - MyBatisMapperXMLFile() { +class MyBatisMapperXmlFile extends XMLFile { + MyBatisMapperXmlFile() { count(XMLElement e | e = this.getAChild()) = 1 and this.getAChild().getName() = "mapper" } } +/** DEPRECATED: Alias for MyBatisMapperXmlFile */ +deprecated class MyBatisMapperXMLFile = MyBatisMapperXmlFile; + /** * An XML element in a `MyBatisMapperXMLFile`. */ -class MyBatisMapperXMLElement extends XMLElement { - MyBatisMapperXMLElement() { this.getFile() instanceof MyBatisMapperXMLFile } +class MyBatisMapperXmlElement extends XMLElement { + MyBatisMapperXmlElement() { this.getFile() instanceof MyBatisMapperXmlFile } /** * Gets the value for this element, with leading and trailing whitespace trimmed. @@ -33,10 +36,13 @@ class MyBatisMapperXMLElement extends XMLElement { } } +/** DEPRECATED: Alias for MyBatisMapperXmlElement */ +deprecated class MyBatisMapperXMLElement = MyBatisMapperXmlElement; + /** * An MyBatis Mapper sql operation element. */ -abstract class MyBatisMapperSqlOperation extends MyBatisMapperXMLElement { +abstract class MyBatisMapperSqlOperation extends MyBatisMapperXmlElement { /** * Gets the value of the `id` attribute of MyBatis Mapper sql operation element. */ @@ -52,7 +58,7 @@ abstract class MyBatisMapperSqlOperation extends MyBatisMapperXMLElement { */ Method getMapperMethod() { result.getName() = this.getId() and - result.getDeclaringType() = this.getParent().(MyBatisMapperXMLElement).getNamespaceRefType() + result.getDeclaringType() = this.getParent().(MyBatisMapperXmlElement).getNamespaceRefType() } } @@ -87,7 +93,7 @@ class MyBatisMapperSelect extends MyBatisMapperSqlOperation { /** * A `` element in a `MyBatisMapperXMLElement`. */ -class MyBatisMapperSql extends MyBatisMapperXMLElement { +class MyBatisMapperSql extends MyBatisMapperXmlElement { MyBatisMapperSql() { this.getName() = "sql" } /** @@ -99,7 +105,7 @@ class MyBatisMapperSql extends MyBatisMapperXMLElement { /** * A `` element in a `MyBatisMapperXMLElement`. */ -class MyBatisMapperInclude extends MyBatisMapperXMLElement { +class MyBatisMapperInclude extends MyBatisMapperXmlElement { MyBatisMapperInclude() { this.getName() = "include" } /** @@ -111,6 +117,6 @@ class MyBatisMapperInclude extends MyBatisMapperXMLElement { /** * A `` element in a `MyBatisMapperXMLElement`. */ -class MyBatisMapperForeach extends MyBatisMapperXMLElement { +class MyBatisMapperForeach extends MyBatisMapperXmlElement { MyBatisMapperForeach() { this.getName() = "foreach" } } diff --git a/java/ql/src/utils/model-generator/CaptureSinkModels.ql b/java/ql/src/utils/model-generator/CaptureSinkModels.ql index aab52da3058..9f574cf84c9 100644 --- a/java/ql/src/utils/model-generator/CaptureSinkModels.ql +++ b/java/ql/src/utils/model-generator/CaptureSinkModels.ql @@ -43,7 +43,7 @@ string asInputArgument(DataFlow::Node source) { result = "Argument[-1]" } -string captureSink(TargetAPI api) { +string captureSink(TargetApi api) { exists(DataFlow::Node src, DataFlow::Node sink, PropagateToSinkConfiguration config, string kind | config.hasFlow(src, sink) and sinkNode(sink, kind) and @@ -53,6 +53,6 @@ string captureSink(TargetAPI api) { ) } -from TargetAPI api, string sink +from TargetApi api, string sink where sink = captureSink(api) select sink order by sink diff --git a/java/ql/src/utils/model-generator/CaptureSourceModels.ql b/java/ql/src/utils/model-generator/CaptureSourceModels.ql index 7cb9d2f19b3..e36ba324068 100644 --- a/java/ql/src/utils/model-generator/CaptureSourceModels.ql +++ b/java/ql/src/utils/model-generator/CaptureSourceModels.ql @@ -22,7 +22,7 @@ class FromSourceConfiguration extends TaintTracking::Configuration { override predicate isSource(DataFlow::Node source) { sourceNode(source, _) } override predicate isSink(DataFlow::Node sink) { - exists(TargetAPI c | + exists(TargetApi c | sink instanceof ReturnNodeExt and sink.getEnclosingCallable() = c and c.isPublic() and @@ -39,7 +39,7 @@ class FromSourceConfiguration extends TaintTracking::Configuration { } } -string captureSource(TargetAPI api) { +string captureSource(TargetApi api) { exists(DataFlow::Node source, DataFlow::Node sink, FromSourceConfiguration config, string kind | config.hasFlow(source, sink) and sourceNode(source, kind) and @@ -48,6 +48,6 @@ string captureSource(TargetAPI api) { ) } -from TargetAPI api, string sink +from TargetApi api, string sink where sink = captureSource(api) select sink order by sink diff --git a/java/ql/src/utils/model-generator/CaptureSummaryModels.ql b/java/ql/src/utils/model-generator/CaptureSummaryModels.ql index 280e0a19d7d..f190af7ba4b 100644 --- a/java/ql/src/utils/model-generator/CaptureSummaryModels.ql +++ b/java/ql/src/utils/model-generator/CaptureSummaryModels.ql @@ -12,7 +12,7 @@ import semmle.code.java.dataflow.internal.DataFlowPrivate import semmle.code.java.dataflow.InstanceAccess import ModelGeneratorUtils -string captureFlow(TargetAPI api) { +string captureFlow(TargetApi api) { result = captureQualifierFlow(api) or result = captureThroughFlow(api) } @@ -29,7 +29,7 @@ string captureFlow(TargetAPI api) { * } * ``` */ -string captureQualifierFlow(TargetAPI api) { +string captureQualifierFlow(TargetApi api) { exists(ReturnStmt rtn | rtn.getEnclosingCallable() = api and rtn.getResult().(ThisAccess).isOwnInstanceAccess() @@ -50,7 +50,7 @@ class ThroughFlowConfig extends TaintTracking::Configuration { override predicate isSource(DataFlow::Node source, DataFlow::FlowState state) { source instanceof DataFlow::ParameterNode and - source.getEnclosingCallable() instanceof TargetAPI and + source.getEnclosingCallable() instanceof TargetApi and state instanceof TaintRead } @@ -145,7 +145,7 @@ class ThroughFlowConfig extends TaintTracking::Configuration { * Captured Model: * `p;Foo;true;addToList;;Argument[0];Argument[1];taint` */ -string captureThroughFlow(TargetAPI api) { +string captureThroughFlow(TargetApi api) { exists( ThroughFlowConfig config, DataFlow::ParameterNode p, ReturnNodeExt returnNodeExt, string input, string output @@ -159,6 +159,6 @@ string captureThroughFlow(TargetAPI api) { ) } -from TargetAPI api, string flow +from TargetApi api, string flow where flow = captureFlow(api) select flow order by flow diff --git a/java/ql/src/utils/model-generator/ModelGeneratorUtils.qll b/java/ql/src/utils/model-generator/ModelGeneratorUtils.qll index f990a2e2fad..abfe750342f 100644 --- a/java/ql/src/utils/model-generator/ModelGeneratorUtils.qll +++ b/java/ql/src/utils/model-generator/ModelGeneratorUtils.qll @@ -11,8 +11,8 @@ Method superImpl(Method m) { not m instanceof ToStringMethod } -class TargetAPI extends Callable { - TargetAPI() { +class TargetApi extends Callable { + TargetApi() { this.isPublic() and this.fromSource() and ( @@ -23,6 +23,9 @@ class TargetAPI extends Callable { } } +/** DEPRECATED: Alias for TargetApi */ +deprecated class TargetAPI = TargetApi; + private string isExtensible(RefType ref) { if ref.isFinal() then result = "false" else result = "true" } @@ -59,17 +62,17 @@ private predicate isJdkInternal(CompilationUnit cu) { } bindingset[input, output] -string asTaintModel(TargetAPI api, string input, string output) { +string asTaintModel(TargetApi api, string input, string output) { result = asSummaryModel(api, input, output, "taint") } bindingset[input, output] -string asValueModel(TargetAPI api, string input, string output) { +string asValueModel(TargetApi api, string input, string output) { result = asSummaryModel(api, input, output, "value") } bindingset[input, output, kind] -string asSummaryModel(TargetAPI api, string input, string output, string kind) { +string asSummaryModel(TargetApi api, string input, string output, string kind) { result = asPartialModel(api) + input + ";" // + output + ";" // @@ -77,19 +80,19 @@ string asSummaryModel(TargetAPI api, string input, string output, string kind) { } bindingset[input, kind] -string asSinkModel(TargetAPI api, string input, string kind) { +string asSinkModel(TargetApi api, string input, string kind) { result = asPartialModel(api) + input + ";" + kind } bindingset[output, kind] -string asSourceModel(TargetAPI api, string output, string kind) { +string asSourceModel(TargetApi api, string output, string kind) { result = asPartialModel(api) + output + ";" + kind } /** * Computes the first 6 columns for CSV rows. */ -private string asPartialModel(TargetAPI api) { +private string asPartialModel(TargetApi api) { result = typeAsSummaryModel(api) + ";" // + isExtensible(bestTypeForModel(api)) + ";" // @@ -102,9 +105,9 @@ private string asPartialModel(TargetAPI api) { * Returns the appropriate type name for the model. Either the type * declaring the method or the supertype introducing the method. */ -private string typeAsSummaryModel(TargetAPI api) { result = typeAsModel(bestTypeForModel(api)) } +private string typeAsSummaryModel(TargetApi api) { result = typeAsModel(bestTypeForModel(api)) } -private RefType bestTypeForModel(TargetAPI api) { +private RefType bestTypeForModel(TargetApi api) { if exists(superImpl(api)) then superImpl(api).fromSource() and result = superImpl(api).getDeclaringType() else result = api.getDeclaringType() diff --git a/java/ql/test/library-tests/ssa/ssaDef.ql b/java/ql/test/library-tests/ssa/ssaDef.ql index 9f08ddc0c40..c487c539e78 100644 --- a/java/ql/test/library-tests/ssa/ssaDef.ql +++ b/java/ql/test/library-tests/ssa/ssaDef.ql @@ -9,4 +9,4 @@ where or not exists(ssa.toString()) and s = "error" ) -select v, ssa.getCFGNode(), s +select v, ssa.getCfgNode(), s diff --git a/java/ql/test/library-tests/ssa/ssaPhi.ql b/java/ql/test/library-tests/ssa/ssaPhi.ql index 11fc2d8d595..8aa0942e90a 100644 --- a/java/ql/test/library-tests/ssa/ssaPhi.ql +++ b/java/ql/test/library-tests/ssa/ssaPhi.ql @@ -3,4 +3,4 @@ import semmle.code.java.dataflow.SSA from SsaPhiNode ssa, SsaSourceVariable v, SsaVariable phiInput where ssa.getAPhiInput() = phiInput and ssa.getSourceVariable() = v -select v, ssa.getCFGNode(), phiInput.getCFGNode() +select v, ssa.getCfgNode(), phiInput.getCfgNode() diff --git a/java/ql/test/library-tests/ssa/ssaUse.ql b/java/ql/test/library-tests/ssa/ssaUse.ql index 53414a88064..cab6f47c955 100644 --- a/java/ql/test/library-tests/ssa/ssaUse.ql +++ b/java/ql/test/library-tests/ssa/ssaUse.ql @@ -3,4 +3,4 @@ import semmle.code.java.dataflow.SSA from SsaVariable ssa, SsaSourceVariable v, Expr use where use = ssa.getAUse() and ssa.getSourceVariable() = v -select v, ssa.getCFGNode(), ssa.toString(), use +select v, ssa.getCfgNode(), ssa.toString(), use diff --git a/java/ql/test/query-tests/security/CWE-079/semmle/tests/XSS.ql b/java/ql/test/query-tests/security/CWE-079/semmle/tests/XSS.ql index 6bfde865e85..afb0f7ae3e1 100644 --- a/java/ql/test/query-tests/security/CWE-079/semmle/tests/XSS.ql +++ b/java/ql/test/query-tests/security/CWE-079/semmle/tests/XSS.ql @@ -3,8 +3,8 @@ import semmle.code.java.dataflow.FlowSources import semmle.code.java.security.XSS import TestUtilities.InlineExpectationsTest -class XSSConfig extends TaintTracking::Configuration { - XSSConfig() { this = "XSSConfig" } +class XssConfig extends TaintTracking::Configuration { + XssConfig() { this = "XSSConfig" } override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource } @@ -24,7 +24,7 @@ class XssTest extends InlineExpectationsTest { override predicate hasActualResult(Location location, string element, string tag, string value) { tag = "xss" and - exists(DataFlow::Node src, DataFlow::Node sink, XSSConfig conf | conf.hasFlow(src, sink) | + exists(DataFlow::Node src, DataFlow::Node sink, XssConfig conf | conf.hasFlow(src, sink) | sink.getLocation() = location and element = sink.toString() and value = "" diff --git a/javascript/ql/examples/snippets/jsxattribute.ql b/javascript/ql/examples/snippets/jsxattribute.ql index ad7a6458667..b55abc09dd0 100644 --- a/javascript/ql/examples/snippets/jsxattribute.ql +++ b/javascript/ql/examples/snippets/jsxattribute.ql @@ -8,6 +8,6 @@ import javascript -from JSXAttribute a +from JsxAttribute a where a.getName() = "dangerouslySetInnerHTML" select a diff --git a/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/ATMConfig.qll b/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/ATMConfig.qll index bec90be46cc..4e07bec6536 100644 --- a/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/ATMConfig.qll +++ b/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/ATMConfig.qll @@ -28,9 +28,9 @@ import EndpointTypes * `isAdditionalFlowStep` with a more generalised definition of additional edges. See * `NosqlInjectionATM.qll` for an example of doing this. */ -abstract class ATMConfig extends string { +abstract class AtmConfig extends string { bindingset[this] - ATMConfig() { any() } + AtmConfig() { any() } /** * EXPERIMENTAL. This API may change in the future. @@ -110,3 +110,6 @@ abstract class ATMConfig extends string { */ float getScoreCutoff() { result = 0.0 } } + +/** DEPRECATED: Alias for AtmConfig */ +deprecated class ATMConfig = AtmConfig; diff --git a/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/BaseScoring.qll b/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/BaseScoring.qll index 1af5966997a..a6787196bbb 100644 --- a/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/BaseScoring.qll +++ b/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/BaseScoring.qll @@ -12,7 +12,7 @@ external predicate availableMlModels( ); /** Get the ATM configuration. */ -ATMConfig getCfg() { any() } +AtmConfig getCfg() { any() } /** * A string containing scoring information produced by a scoring model. diff --git a/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/CoreKnowledge.qll b/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/CoreKnowledge.qll index 4f0ad84b238..23ba238ff99 100644 --- a/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/CoreKnowledge.qll +++ b/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/CoreKnowledge.qll @@ -61,7 +61,7 @@ predicate isArgumentToKnownLibrarySinkFunction(DataFlow::Node n) { * This corresponds to known sinks from security queries whose sources include remote flow and * DOM-based sources. */ -predicate isKnownExternalAPIQuerySink(DataFlow::Node n) { +predicate isKnownExternalApiQuerySink(DataFlow::Node n) { n instanceof Xxe::Sink or n instanceof TaintedPath::Sink or n instanceof XpathInjection::Sink or @@ -86,11 +86,14 @@ predicate isKnownExternalAPIQuerySink(DataFlow::Node n) { n instanceof HttpToFileAccess::Sink } +/** DEPRECATED: Alias for isKnownExternalApiQuerySink */ +deprecated predicate isKnownExternalAPIQuerySink = isKnownExternalApiQuerySink/1; + /** * Holds if the node `n` is a known sink in a modeled library. */ predicate isKnownLibrarySink(DataFlow::Node n) { - isKnownExternalAPIQuerySink(n) or + isKnownExternalApiQuerySink(n) or n instanceof CleartextLogging::Sink or n instanceof StackTraceExposure::Sink or n instanceof ShellCommandInjectionFromEnvironment::Sink or @@ -207,7 +210,7 @@ predicate isOtherModeledArgument(DataFlow::Node n, FilteringReason reason) { DatabaseAccess and reason instanceof DatabaseAccessReason or - call = DOM::domValueRef() and reason instanceof DOMReason + call = DOM::domValueRef() and reason instanceof DomReason or call.getCalleeName() = "next" and exists(DataFlow::FunctionNode f | call = f.getLastParameter().getACall()) and diff --git a/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/FilteringReasons.qll b/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/FilteringReasons.qll index 063cf567fc9..4b0cdb986e8 100644 --- a/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/FilteringReasons.qll +++ b/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/FilteringReasons.qll @@ -24,7 +24,7 @@ newtype TFilteringReason = TMembershipCandidateTestReason() or TFileSystemAccessReason() or TDatabaseAccessReason() or - TDOMReason() or + TDomReason() or TNextFunctionCallReason() or TArgumentToArrayReason() or TArgumentToBuiltinGlobalVarRefReason() or @@ -161,12 +161,15 @@ class DatabaseAccessReason extends NotASinkReason, TDatabaseAccessReason { override int getEncoding() { result = 21 } } -class DOMReason extends NotASinkReason, TDOMReason { +class DomReason extends NotASinkReason, TDomReason { override string getDescription() { result = "DOM" } override int getEncoding() { result = 22 } } +/** DEPRECATED: Alias for DomReason */ +deprecated class DOMReason = DomReason; + class NextFunctionCallReason extends NotASinkReason, TNextFunctionCallReason { override string getDescription() { result = "NextFunctionCall" } diff --git a/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/FunctionBodyFeatures.qll b/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/FunctionBodyFeatures.qll index 6459a30250f..4b1a5778cc0 100644 --- a/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/FunctionBodyFeatures.qll +++ b/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/FunctionBodyFeatures.qll @@ -10,7 +10,7 @@ private import FeaturizationConfig /** * Gets a tokenized representation of the AST node for use in the `enclosingFunctionBody` feature. */ -string getTokenizedAstNode(ASTNode node) { +string getTokenizedAstNode(AstNode node) { // e.g. `x` -> "x" result = node.(Identifier).getName() or @@ -35,12 +35,15 @@ string getTokenizedAstNode(ASTNode node) { /** Gets an AST node within the function `f` that we should featurize. */ pragma[inline] -ASTNode getAnASTNodeToFeaturize(Function f) { +AstNode getAnAstNodeToFeaturize(Function f) { result.getParent*() = f and // Don't featurize the function name as part of the function body tokens not result = f.getIdentifier() } +/** DEPRECATED: Alias for getAnAstNodeToFeaturize */ +deprecated ASTNode getAnASTNodeToFeaturize(Function f) { result = getAnAstNodeToFeaturize(f) } + /** * Gets a function that contains the endpoint. * @@ -72,7 +75,7 @@ private int getMaxNumAstNodes() { result = 1024 } private int getNumAstNodesInFunction(Function function) { // Restrict the values `function` can take on function = getAFunctionForEndpoint(_) and - result = count(getAnASTNodeToFeaturize(function)) + result = count(getAnAstNodeToFeaturize(function)) } /** @@ -121,16 +124,19 @@ Function getRepresentativeFunctionForEndpoint(DataFlow::Node endpoint) { } /** Returns an AST node within the function `f` that an associated token feature. */ -ASTNode getAnASTNodeWithAFeature(Function f) { +AstNode getAnAstNodeWithAFeature(Function f) { // Performance optimization: Restrict the set of functions to those containing an endpoint to featurize. f = getRepresentativeFunctionForEndpoint(any(FeaturizationConfig cfg).getAnEndpointToFeaturize()) and - result = getAnASTNodeToFeaturize(f) + result = getAnAstNodeToFeaturize(f) } +/** DEPRECATED: Alias for getAnAstNodeWithAFeature */ +deprecated ASTNode getAnASTNodeWithAFeature(Function f) { result = getAnAstNodeWithAFeature(f) } + /** Returns the number of source-code characters in a function. */ int getNumCharsInFunction(Function f) { result = - strictsum(ASTNode node | node = getAnASTNodeWithAFeature(f) | getTokenizedAstNode(node).length()) + strictsum(AstNode node | node = getAnAstNodeWithAFeature(f) | getTokenizedAstNode(node).length()) } /** @@ -149,8 +155,8 @@ string getBodyTokensFeature(Function function) { // large body features are replaced by the absent token. // // We count nodes instead of tokens because tokens are often not unique. - strictcount(ASTNode node | - node = getAnASTNodeToFeaturize(function) and + strictcount(AstNode node | + node = getAnAstNodeToFeaturize(function) and exists(getTokenizedAstNode(node)) ) <= 256 and // Performance optimization: If a function has more than getMaxChars() characters in its body subtokens, @@ -161,8 +167,8 @@ string getBodyTokensFeature(Function function) { // The use of a nested exists here allows us to avoid duplicates due to two AST nodes in the // same location featurizing to the same token. By using a nested exists, we take only unique // (location, token) pairs. - exists(ASTNode node | - node = getAnASTNodeToFeaturize(function) and + exists(AstNode node | + node = getAnAstNodeToFeaturize(function) and token = getTokenizedAstNode(node) and l = node.getLocation() ) diff --git a/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/NosqlInjectionATM.qll b/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/NosqlInjectionATM.qll index 45128d9c4a7..2d5b2a58510 100644 --- a/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/NosqlInjectionATM.qll +++ b/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/NosqlInjectionATM.qll @@ -87,8 +87,8 @@ module SinkEndpointFilter { } } -class NosqlInjectionATMConfig extends ATMConfig { - NosqlInjectionATMConfig() { this = "NosqlInjectionATMConfig" } +class NosqlInjectionAtmConfig extends AtmConfig { + NosqlInjectionAtmConfig() { this = "NosqlInjectionATMConfig" } override predicate isKnownSource(DataFlow::Node source) { source instanceof NosqlInjection::Source or TaintedObject::isSource(source, _) @@ -103,7 +103,10 @@ class NosqlInjectionATMConfig extends ATMConfig { override EndpointType getASinkEndpointType() { result instanceof NosqlInjectionSinkType } } -/** Holds if src -> trg is an additional flow step in the non-boosted NoSQL injection security query. */ +/** DEPRECATED: Alias for NosqlInjectionAtmConfig */ +deprecated class NosqlInjectionATMConfig = NosqlInjectionAtmConfig; + +/** Holds if src -> trg is an additional flow step in the non-boosted NoSql injection security query. */ predicate isBaseAdditionalFlowStep( DataFlow::Node src, DataFlow::Node trg, DataFlow::FlowLabel inlbl, DataFlow::FlowLabel outlbl ) { @@ -112,7 +115,7 @@ predicate isBaseAdditionalFlowStep( // additional flow step to track taint through NoSQL query objects inlbl = TaintedObject::label() and outlbl = TaintedObject::label() and - exists(NoSQL::Query query, DataFlow::SourceNode queryObj | + exists(NoSql::Query query, DataFlow::SourceNode queryObj | queryObj.flowsToExpr(query) and queryObj.flowsTo(trg) and src = queryObj.getAPropertyWrite().getRhs() @@ -127,7 +130,7 @@ predicate isBaseAdditionalFlowStep( * involving more complex queries. */ DataFlow::Node getASubexpressionWithinQuery(DataFlow::Node query) { - any(NosqlInjectionATMConfig cfg).isEffectiveSink(query) and + any(NosqlInjectionAtmConfig cfg).isEffectiveSink(query) and exists(DataFlow::SourceNode receiver | receiver = [getASubexpressionWithinQuery(query), query].getALocalSource() | @@ -156,7 +159,7 @@ class Configuration extends TaintTracking::Configuration { sink.(NosqlInjection::Sink).getAFlowLabel() = label or // Allow effective sinks to have any taint label - any(NosqlInjectionATMConfig cfg).isEffectiveSink(sink) + any(NosqlInjectionAtmConfig cfg).isEffectiveSink(sink) } override predicate isSanitizer(DataFlow::Node node) { @@ -175,7 +178,7 @@ class Configuration extends TaintTracking::Configuration { isBaseAdditionalFlowStep(src, trg, inlbl, outlbl) or // relaxed version of previous step to track taint through unmodeled NoSQL query objects - any(NosqlInjectionATMConfig cfg).isEffectiveSink(trg) and + any(NosqlInjectionAtmConfig cfg).isEffectiveSink(trg) and src = getASubexpressionWithinQuery(trg) } } diff --git a/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/SqlInjectionATM.qll b/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/SqlInjectionATM.qll index 86ceadf4f84..b3b722fb0fc 100644 --- a/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/SqlInjectionATM.qll +++ b/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/SqlInjectionATM.qll @@ -60,8 +60,8 @@ module SinkEndpointFilter { } } -class SqlInjectionATMConfig extends ATMConfig { - SqlInjectionATMConfig() { this = "SqlInjectionATMConfig" } +class SqlInjectionAtmConfig extends AtmConfig { + SqlInjectionAtmConfig() { this = "SqlInjectionATMConfig" } override predicate isKnownSource(DataFlow::Node source) { source instanceof SqlInjection::Source } @@ -74,6 +74,9 @@ class SqlInjectionATMConfig extends ATMConfig { override EndpointType getASinkEndpointType() { result instanceof SqlInjectionSinkType } } +/** DEPRECATED: Alias for SqlInjectionAtmConfig */ +deprecated class SqlInjectionATMConfig = SqlInjectionAtmConfig; + /** * A taint-tracking configuration for reasoning about SQL injection vulnerabilities. * @@ -86,7 +89,7 @@ class Configuration extends TaintTracking::Configuration { override predicate isSource(DataFlow::Node source) { source instanceof SqlInjection::Source } override predicate isSink(DataFlow::Node sink) { - sink instanceof SqlInjection::Sink or any(SqlInjectionATMConfig cfg).isEffectiveSink(sink) + sink instanceof SqlInjection::Sink or any(SqlInjectionAtmConfig cfg).isEffectiveSink(sink) } override predicate isSanitizer(DataFlow::Node node) { diff --git a/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/TaintedPathATM.qll b/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/TaintedPathATM.qll index 908bab9fd51..109fd357007 100644 --- a/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/TaintedPathATM.qll +++ b/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/TaintedPathATM.qll @@ -59,8 +59,8 @@ module SinkEndpointFilter { } } -class TaintedPathATMConfig extends ATMConfig { - TaintedPathATMConfig() { this = "TaintedPathATMConfig" } +class TaintedPathAtmConfig extends AtmConfig { + TaintedPathAtmConfig() { this = "TaintedPathATMConfig" } override predicate isKnownSource(DataFlow::Node source) { source instanceof TaintedPath::Source } @@ -73,6 +73,9 @@ class TaintedPathATMConfig extends ATMConfig { override EndpointType getASinkEndpointType() { result instanceof TaintedPathSinkType } } +/** DEPRECATED: Alias for TaintedPathAtmConfig */ +deprecated class TaintedPathATMConfig = TaintedPathAtmConfig; + /** * A taint-tracking configuration for reasoning about path injection vulnerabilities. * @@ -88,7 +91,7 @@ class Configuration extends TaintTracking::Configuration { label = sink.(TaintedPath::Sink).getAFlowLabel() or // Allow effective sinks to have any taint label - any(TaintedPathATMConfig cfg).isEffectiveSink(sink) + any(TaintedPathAtmConfig cfg).isEffectiveSink(sink) } override predicate isSanitizer(DataFlow::Node node) { node instanceof TaintedPath::Sanitizer } diff --git a/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/XssATM.qll b/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/XssATM.qll index 009db55b86a..796fc94c64e 100644 --- a/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/XssATM.qll +++ b/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/XssATM.qll @@ -60,8 +60,8 @@ module SinkEndpointFilter { } } -class DomBasedXssATMConfig extends ATMConfig { - DomBasedXssATMConfig() { this = "DomBasedXssATMConfig" } +class DomBasedXssAtmConfig extends AtmConfig { + DomBasedXssAtmConfig() { this = "DomBasedXssATMConfig" } override predicate isKnownSource(DataFlow::Node source) { source instanceof DomBasedXss::Source } @@ -74,6 +74,9 @@ class DomBasedXssATMConfig extends ATMConfig { override EndpointType getASinkEndpointType() { result instanceof XssSinkType } } +/** DEPRECATED: Alias for DomBasedXssAtmConfig */ +deprecated class DomBasedXssATMConfig = DomBasedXssAtmConfig; + /** * A taint-tracking configuration for reasoning about XSS vulnerabilities. * @@ -87,7 +90,7 @@ class Configuration extends TaintTracking::Configuration { override predicate isSink(DataFlow::Node sink) { sink instanceof DomBasedXss::Sink or - any(DomBasedXssATMConfig cfg).isEffectiveSink(sink) + any(DomBasedXssAtmConfig cfg).isEffectiveSink(sink) } override predicate isSanitizer(DataFlow::Node node) { diff --git a/javascript/ql/experimental/adaptivethreatmodeling/modelbuilding/DebugResultInclusion.ql b/javascript/ql/experimental/adaptivethreatmodeling/modelbuilding/DebugResultInclusion.ql index 9be2929fd41..215103358ea 100644 --- a/javascript/ql/experimental/adaptivethreatmodeling/modelbuilding/DebugResultInclusion.ql +++ b/javascript/ql/experimental/adaptivethreatmodeling/modelbuilding/DebugResultInclusion.ql @@ -33,7 +33,7 @@ string getDescriptionForAlertCandidate( ) { result = "excluded[reason=" + getAReasonSinkExcluded(sinkCandidate, query) + "]" or - getATMCfg(query).isKnownSink(sinkCandidate) and + getAtmCfg(query).isKnownSink(sinkCandidate) and result = "excluded[reason=known-sink]" or not exists(getAReasonSinkExcluded(sinkCandidate, query)) and diff --git a/javascript/ql/experimental/adaptivethreatmodeling/modelbuilding/extraction/CountSourcesAndSinks.ql b/javascript/ql/experimental/adaptivethreatmodeling/modelbuilding/extraction/CountSourcesAndSinks.ql index 997c61bc096..dca511762b0 100644 --- a/javascript/ql/experimental/adaptivethreatmodeling/modelbuilding/extraction/CountSourcesAndSinks.ql +++ b/javascript/ql/experimental/adaptivethreatmodeling/modelbuilding/extraction/CountSourcesAndSinks.ql @@ -20,7 +20,7 @@ import semmle.javascript.security.dataflow.DeepObjectResourceExhaustionQuery as import semmle.javascript.security.dataflow.DifferentKindsComparisonBypassQuery as DifferentKindsComparisonBypass import semmle.javascript.security.dataflow.DomBasedXssQuery as DomBasedXss import semmle.javascript.security.dataflow.ExceptionXssQuery as ExceptionXss -import semmle.javascript.security.dataflow.ExternalAPIUsedWithUntrustedDataQuery as ExternalAPIUsedWithUntrustedData +import semmle.javascript.security.dataflow.ExternalAPIUsedWithUntrustedDataQuery as ExternalApiUsedWithUntrustedData import semmle.javascript.security.dataflow.FileAccessToHttpQuery as FileAccessToHttp import semmle.javascript.security.dataflow.HardcodedCredentialsQuery as HardcodedCredentials import semmle.javascript.security.dataflow.HardcodedDataInterpretedAsCodeQuery as HardcodedDataInterpretedAsCode diff --git a/javascript/ql/experimental/adaptivethreatmodeling/modelbuilding/extraction/ExtractEndpointData.qll b/javascript/ql/experimental/adaptivethreatmodeling/modelbuilding/extraction/ExtractEndpointData.qll index bea47423797..a0edb69f371 100644 --- a/javascript/ql/experimental/adaptivethreatmodeling/modelbuilding/extraction/ExtractEndpointData.qll +++ b/javascript/ql/experimental/adaptivethreatmodeling/modelbuilding/extraction/ExtractEndpointData.qll @@ -23,17 +23,20 @@ import NoFeaturizationRestrictionsConfig import Queries /** Gets the ATM configuration object for the specified query. */ -ATMConfig getATMCfg(Query query) { +AtmConfig getAtmCfg(Query query) { query instanceof NosqlInjectionQuery and - result instanceof NosqlInjectionATM::NosqlInjectionATMConfig + result instanceof NosqlInjectionATM::NosqlInjectionAtmConfig or - query instanceof SqlInjectionQuery and result instanceof SqlInjectionATM::SqlInjectionATMConfig + query instanceof SqlInjectionQuery and result instanceof SqlInjectionATM::SqlInjectionAtmConfig or - query instanceof TaintedPathQuery and result instanceof TaintedPathATM::TaintedPathATMConfig + query instanceof TaintedPathQuery and result instanceof TaintedPathATM::TaintedPathAtmConfig or - query instanceof XssQuery and result instanceof XssATM::DomBasedXssATMConfig + query instanceof XssQuery and result instanceof XssATM::DomBasedXssAtmConfig } +/** DEPRECATED: Alias for getAtmCfg */ +deprecated ATMConfig getATMCfg(Query query) { result = getAtmCfg(query) } + /** Gets the ATM data flow configuration for the specified query. */ DataFlow::Configuration getDataFlowCfg(Query query) { query instanceof NosqlInjectionQuery and result instanceof NosqlInjectionATM::Configuration @@ -47,7 +50,7 @@ DataFlow::Configuration getDataFlowCfg(Query query) { /** Gets a known sink for the specified query. */ private DataFlow::Node getASink(Query query) { - getATMCfg(query).isKnownSink(result) and + getAtmCfg(query).isKnownSink(result) and // Only consider the source code for the project being analyzed. exists(result.getFile().getRelativePath()) } @@ -72,8 +75,8 @@ private DataFlow::Node getANotASink(NotASinkReason reason) { */ private DataFlow::Node getAnUnknown(Query query) { ( - getATMCfg(query).isEffectiveSink(result) or - getATMCfg(query).isEffectiveSinkWithOverridingScore(result, _, _) + getAtmCfg(query).isEffectiveSink(result) or + getAtmCfg(query).isEffectiveSinkWithOverridingScore(result, _, _) ) and not result = getASink(query) and // Only consider the source code for the project being analyzed. diff --git a/javascript/ql/experimental/adaptivethreatmodeling/modelbuilding/extraction/ExtractEndpointMapping.ql b/javascript/ql/experimental/adaptivethreatmodeling/modelbuilding/extraction/ExtractEndpointMapping.ql index 879fdeaca1c..ce9a12acf88 100644 --- a/javascript/ql/experimental/adaptivethreatmodeling/modelbuilding/extraction/ExtractEndpointMapping.ql +++ b/javascript/ql/experimental/adaptivethreatmodeling/modelbuilding/extraction/ExtractEndpointMapping.ql @@ -4,19 +4,19 @@ import experimental.adaptivethreatmodeling.TaintedPathATM as TaintedPathATM import experimental.adaptivethreatmodeling.XssATM as XssATM import experimental.adaptivethreatmodeling.AdaptiveThreatModeling -from string queryName, ATMConfig c, EndpointType e +from string queryName, AtmConfig c, EndpointType e where ( queryName = "SqlInjectionATM.ql" and - c instanceof SqlInjectionATM::SqlInjectionATMConfig + c instanceof SqlInjectionATM::SqlInjectionAtmConfig or queryName = "NosqlInjectionATM.ql" and - c instanceof NosqlInjectionATM::NosqlInjectionATMConfig + c instanceof NosqlInjectionATM::NosqlInjectionAtmConfig or queryName = "TaintedPathInjectionATM.ql" and - c instanceof TaintedPathATM::TaintedPathATMConfig + c instanceof TaintedPathATM::TaintedPathAtmConfig or - queryName = "XssATM.ql" and c instanceof XssATM::DomBasedXssATMConfig + queryName = "XssATM.ql" and c instanceof XssATM::DomBasedXssAtmConfig ) and e = c.getASinkEndpointType() select queryName, e.getEncoding() as endpointTypeEncoded diff --git a/javascript/ql/experimental/adaptivethreatmodeling/modelbuilding/extraction/ExtractMisclassifiedEndpointFeatures.ql b/javascript/ql/experimental/adaptivethreatmodeling/modelbuilding/extraction/ExtractMisclassifiedEndpointFeatures.ql index f05048f8cdc..b09eed5964d 100644 --- a/javascript/ql/experimental/adaptivethreatmodeling/modelbuilding/extraction/ExtractMisclassifiedEndpointFeatures.ql +++ b/javascript/ql/experimental/adaptivethreatmodeling/modelbuilding/extraction/ExtractMisclassifiedEndpointFeatures.ql @@ -19,8 +19,8 @@ EndpointType getEndpointType() { result instanceof NosqlInjectionSinkType } DataFlow::Node getAPositiveEndpoint() { result instanceof NosqlInjection::Sink } /** An ATM configuration to find misclassified endpoints of type `getEndpointType()`. */ -class ExtractMisclassifiedEndpointsATMConfig extends ATMConfig { - ExtractMisclassifiedEndpointsATMConfig() { this = "ExtractMisclassifiedEndpointsATMConfig" } +class ExtractMisclassifiedEndpointsAtmConfig extends AtmConfig { + ExtractMisclassifiedEndpointsAtmConfig() { this = "ExtractMisclassifiedEndpointsATMConfig" } override predicate isEffectiveSink(DataFlow::Node sinkCandidate) { sinkCandidate = getAPositiveEndpoint() @@ -31,7 +31,7 @@ class ExtractMisclassifiedEndpointsATMConfig extends ATMConfig { /** Get an endpoint from `getAPositiveEndpoint()` that is incorrectly excluded from the results. */ DataFlow::Node getAMisclassifedEndpoint() { - any(ExtractMisclassifiedEndpointsATMConfig config).isEffectiveSink(result) and + any(ExtractMisclassifiedEndpointsAtmConfig config).isEffectiveSink(result) and not any(ScoringResults results).shouldResultBeIncluded(_, result) } diff --git a/javascript/ql/lib/Expressions/DOMProperties.qll b/javascript/ql/lib/Expressions/DOMProperties.qll index 7ff1884fb1b..d0671c932b5 100644 --- a/javascript/ql/lib/Expressions/DOMProperties.qll +++ b/javascript/ql/lib/Expressions/DOMProperties.qll @@ -5,14 +5,20 @@ import semmle.javascript.Externs /** Holds if `et` is a root interface of the DOM type hierarchy. */ -predicate isDOMRootType(ExternalType et) { +predicate isDomRootType(ExternalType et) { exists(string n | n = et.getName() | n = "EventTarget" or n = "StyleSheet") } +/** DEPRECATED: Alias for isDomRootType */ +deprecated predicate isDOMRootType = isDomRootType/1; + /** Holds if `p` is declared as a property of a DOM class or interface. */ pragma[nomagic] -predicate isDOMProperty(string p) { +predicate isDomProperty(string p) { exists(ExternalMemberDecl emd | emd.getName() = p | - isDOMRootType(emd.getDeclaringType().getASupertype*()) + isDomRootType(emd.getDeclaringType().getASupertype*()) ) } + +/** DEPRECATED: Alias for isDomProperty */ +deprecated predicate isDOMProperty = isDomProperty/1; diff --git a/javascript/ql/lib/Expressions/ExprHasNoEffect.qll b/javascript/ql/lib/Expressions/ExprHasNoEffect.qll index 220eef15a4a..691424f3b71 100644 --- a/javascript/ql/lib/Expressions/ExprHasNoEffect.qll +++ b/javascript/ql/lib/Expressions/ExprHasNoEffect.qll @@ -143,7 +143,7 @@ predicate hasNoEffect(Expr e) { // don't complain about declarations not isDeclaration(e) and // exclude DOM properties, which sometimes have magical auto-update properties - not isDOMProperty(e.(PropAccess).getPropertyName()) and + not isDomProperty(e.(PropAccess).getPropertyName()) and // exclude xUnit.js annotations not e instanceof XUnitAnnotation and // exclude common patterns that are most likely intentional diff --git a/javascript/ql/lib/semmle/javascript/AST.qll b/javascript/ql/lib/semmle/javascript/AST.qll index d4f2de4b170..895922f952f 100644 --- a/javascript/ql/lib/semmle/javascript/AST.qll +++ b/javascript/ql/lib/semmle/javascript/AST.qll @@ -22,7 +22,7 @@ private import semmle.javascript.internal.CachedStages * abs(-42); * ``` */ -class ASTNode extends @ast_node, NodeInStmtContainer { +class AstNode extends @ast_node, NodeInStmtContainer { override Location getLocation() { hasLocation(this, result) } override File getFile() { @@ -84,7 +84,7 @@ class ASTNode extends @ast_node, NodeInStmtContainer { * _Note_: The indices of child nodes are considered an implementation detail and may * change between versions of the extractor. */ - ASTNode getChild(int i) { + AstNode getChild(int i) { result = this.getChildExpr(i) or result = this.getChildStmt(i) or properties(result, this, i, _, _) or @@ -101,7 +101,7 @@ class ASTNode extends @ast_node, NodeInStmtContainer { TypeExpr getChildTypeExpr(int i) { typeexprs(result, _, this, i, _) } /** Gets a child node of this node. */ - ASTNode getAChild() { result = this.getChild(_) } + AstNode getAChild() { result = this.getChild(_) } /** Gets a child expression of this node. */ Expr getAChildExpr() { result = this.getChildExpr(_) } @@ -120,7 +120,7 @@ class ASTNode extends @ast_node, NodeInStmtContainer { /** Gets the parent node of this node, if any. */ cached - ASTNode getParent() { Stages::Ast::ref() and this = result.getAChild() } + AstNode getParent() { Stages::Ast::ref() and this = result.getAChild() } /** Gets the first control flow node belonging to this syntactic entity. */ ControlFlowNode getFirstControlFlowNode() { result = this } @@ -184,6 +184,9 @@ class ASTNode extends @ast_node, NodeInStmtContainer { } } +/** DEPRECATED: Alias for AstNode */ +deprecated class ASTNode = AstNode; + /** * Holds if the given file is a `.d.ts` file. */ @@ -334,7 +337,10 @@ class EventHandlerCode extends @event_handler, CodeInAttribute { } * Click me * ``` */ -class JavaScriptURL extends @javascript_url, CodeInAttribute { } +class JavaScriptUrl extends @javascript_url, CodeInAttribute { } + +/** DEPRECATED: Alias for JavaScriptUrl */ +deprecated class JavaScriptURL = JavaScriptUrl; /** * A toplevel syntactic entity containing Closure-style externs definitions. @@ -361,7 +367,7 @@ class Externs extends TopLevel { * i = 9 * ``` */ -class ExprOrStmt extends @expr_or_stmt, ControlFlowNode, ASTNode { } +class ExprOrStmt extends @expr_or_stmt, ControlFlowNode, AstNode { } /** * A program element that contains statements, but isn't itself @@ -375,7 +381,7 @@ class ExprOrStmt extends @expr_or_stmt, ControlFlowNode, ASTNode { } * } * ``` */ -class StmtContainer extends @stmt_container, ASTNode { +class StmtContainer extends @stmt_container, AstNode { /** Gets the innermost enclosing container in which this container is nested. */ cached StmtContainer getEnclosingContainer() { none() } @@ -405,7 +411,7 @@ class StmtContainer extends @stmt_container, ASTNode { * For scripts or modules, this is the container itself; for functions, * it is the function body. */ - ASTNode getBody() { result = this } + AstNode getBody() { result = this } /** * Gets the (unique) entry node of the control flow graph for this toplevel or function. @@ -470,7 +476,7 @@ module AST { * function id(x) { return x; } // function declaration * ``` */ - class ValueNode extends ASTNode, @dataflownode { + class ValueNode extends AstNode, @dataflownode { /** Gets type inference results for this element. */ DataFlow::AnalyzedNode analyze() { result = DataFlow::valueNode(this).analyze() } diff --git a/javascript/ql/lib/semmle/javascript/ApiGraphs.qll b/javascript/ql/lib/semmle/javascript/ApiGraphs.qll index 57dcf6f2eec..c9c283746db 100644 --- a/javascript/ql/lib/semmle/javascript/ApiGraphs.qll +++ b/javascript/ql/lib/semmle/javascript/ApiGraphs.qll @@ -109,7 +109,7 @@ module API { */ cached Node getMember(string m) { - Stages::APIStage::ref() and + Stages::ApiStage::ref() and result = this.getASuccessor(Label::member(m)) } @@ -119,7 +119,7 @@ module API { */ cached Node getUnknownMember() { - Stages::APIStage::ref() and + Stages::ApiStage::ref() and result = this.getASuccessor(Label::unknownMember()) } @@ -129,7 +129,7 @@ module API { */ cached Node getAMember() { - Stages::APIStage::ref() and + Stages::ApiStage::ref() and result = this.getMember(_) or result = this.getUnknownMember() @@ -148,7 +148,7 @@ module API { */ cached Node getInstance() { - Stages::APIStage::ref() and + Stages::ApiStage::ref() and result = this.getASuccessor(Label::instance()) } @@ -160,7 +160,7 @@ module API { */ cached Node getParameter(int i) { - Stages::APIStage::ref() and + Stages::ApiStage::ref() and result = this.getASuccessor(Label::parameter(i)) } @@ -182,7 +182,7 @@ module API { */ cached Node getReceiver() { - Stages::APIStage::ref() and + Stages::ApiStage::ref() and result = this.getASuccessor(Label::receiver()) } @@ -196,7 +196,7 @@ module API { */ cached Node getAParameter() { - Stages::APIStage::ref() and + Stages::ApiStage::ref() and result = this.getParameter(_) or result = this.getReceiver() @@ -210,7 +210,7 @@ module API { */ cached Node getReturn() { - Stages::APIStage::ref() and + Stages::ApiStage::ref() and result = this.getASuccessor(Label::return()) } @@ -220,7 +220,7 @@ module API { */ cached Node getPromised() { - Stages::APIStage::ref() and + Stages::ApiStage::ref() and result = this.getASuccessor(Label::promised()) } @@ -229,7 +229,7 @@ module API { */ cached Node getPromisedError() { - Stages::APIStage::ref() and + Stages::ApiStage::ref() and result = this.getASuccessor(Label::promisedError()) } @@ -892,7 +892,7 @@ module API { */ cached predicate edge(TApiNode pred, Label::ApiLabel lbl, TApiNode succ) { - Stages::APIStage::ref() and + Stages::ApiStage::ref() and exists(string m | pred = MkRoot() and lbl = Label::moduleLabel(m) @@ -1251,7 +1251,7 @@ private predicate exports(string m, string prop, DataFlow::Node rhs) { /** Gets the definition of module `m`. */ private Module importableModule(string m) { - exists(NPMPackage pkg, PackageJSON json | json = pkg.getPackageJSON() and not json.isPrivate() | + exists(NpmPackage pkg, PackageJson json | json = pkg.getPackageJson() and not json.isPrivate() | result = pkg.getMainModule() and not result.isExterns() and m = pkg.getPackageName() diff --git a/javascript/ql/lib/semmle/javascript/CFG.qll b/javascript/ql/lib/semmle/javascript/CFG.qll index a37fedc1ec0..4daf849bc3d 100644 --- a/javascript/ql/lib/semmle/javascript/CFG.qll +++ b/javascript/ql/lib/semmle/javascript/CFG.qll @@ -347,7 +347,7 @@ class ControlFlowNode extends @cfg_node, Locatable, NodeInStmtContainer { then result = "function in " + any(MethodDeclaration mem | mem.getBody() = this) else if this instanceof @decorator_list - then result = "parameter decorators of " + this.(ASTNode).getParent().(Function).describe() + then result = "parameter decorators of " + this.(AstNode).getParent().(Function).describe() else result = toString() } } diff --git a/javascript/ql/lib/semmle/javascript/CanonicalNames.qll b/javascript/ql/lib/semmle/javascript/CanonicalNames.qll index 7435be7131a..fc25314af95 100644 --- a/javascript/ql/lib/semmle/javascript/CanonicalNames.qll +++ b/javascript/ql/lib/semmle/javascript/CanonicalNames.qll @@ -48,7 +48,7 @@ class CanonicalName extends @symbol { string getExternalModuleName() { symbol_module(this, result) or - exists(PackageJSON pkg | + exists(PackageJson pkg | getModule() = pkg.getMainModule() and result = pkg.getPackageName() ) @@ -160,7 +160,7 @@ class CanonicalName extends @symbol { /** * Gets a definition of the entity with this canonical name. */ - ASTNode getADefinition() { none() } + AstNode getADefinition() { none() } /** * Gets a use that refers to the entity with this canonical name. diff --git a/javascript/ql/lib/semmle/javascript/CharacterEscapes.qll b/javascript/ql/lib/semmle/javascript/CharacterEscapes.qll index 6f95ed1c30a..1a19112cee3 100644 --- a/javascript/ql/lib/semmle/javascript/CharacterEscapes.qll +++ b/javascript/ql/lib/semmle/javascript/CharacterEscapes.qll @@ -32,7 +32,7 @@ module CharacterEscapes { * Holds if `n` is delimited by `delim` and contains `rawStringNode` with the raw string value `raw`. */ private predicate hasRawStringAndQuote( - DataFlow::ValueNode n, string delim, ASTNode rawStringNode, string raw + DataFlow::ValueNode n, string delim, AstNode rawStringNode, string raw ) { rawStringNode = n.asExpr() and raw = rawStringNode.(StringLiteral).getRawValue() and @@ -52,7 +52,7 @@ module CharacterEscapes { * * The character is the `i`th character of `rawStringNode`'s raw string value. */ - string getAnIdentityEscapedCharacter(DataFlow::Node n, ASTNode rawStringNode, int i) { + string getAnIdentityEscapedCharacter(DataFlow::Node n, AstNode rawStringNode, int i) { exists(string delim, string raw, string additionalEscapeChars | hasRawStringAndQuote(n, delim, rawStringNode, raw) and if rawStringNode instanceof RegExpLiteral @@ -80,7 +80,7 @@ module CharacterEscapes { * The character is the `i`th character of the raw string value of `rawStringNode`. */ string getALikelyRegExpPatternMistake( - RegExpPatternSource src, string mistake, ASTNode rawStringNode, int i + RegExpPatternSource src, string mistake, AstNode rawStringNode, int i ) { result = getAnIdentityEscapedCharacter(src, rawStringNode, i) and ( diff --git a/javascript/ql/lib/semmle/javascript/DOM.qll b/javascript/ql/lib/semmle/javascript/DOM.qll index 67f75ce7fa9..bca70363c67 100644 --- a/javascript/ql/lib/semmle/javascript/DOM.qll +++ b/javascript/ql/lib/semmle/javascript/DOM.qll @@ -76,10 +76,10 @@ module DOM { /** * A JSX element, viewed as an `ElementDefinition`. */ - private class JsxElementDefinition extends ElementDefinition, @jsx_element instanceof JSXElement { - override string getName() { result = JSXElement.super.getName() } + private class JsxElementDefinition extends ElementDefinition, @jsx_element instanceof JsxElement { + override string getName() { result = JsxElement.super.getName() } - override AttributeDefinition getAttribute(int i) { result = JSXElement.super.getAttribute(i) } + override AttributeDefinition getAttribute(int i) { result = JsxElement.super.getAttribute(i) } override ElementDefinition getParent() { result = super.getJsxParent() } } @@ -139,7 +139,7 @@ module DOM { * A JSX attribute, viewed as an `AttributeDefinition`. */ private class JsxAttributeDefinition extends AttributeDefinition, @jsx_attribute { - JSXAttribute attr; + JsxAttribute attr; JsxAttributeDefinition() { this = attr } @@ -323,7 +323,7 @@ module DOM { private class DefaultRange extends Range { DefaultRange() { - this.asExpr().(VarAccess).getVariable() instanceof DOMGlobalVariable + this.asExpr().(VarAccess).getVariable() instanceof DomGlobalVariable or exists(DataFlow::PropRead read | this = read and @@ -392,7 +392,7 @@ module DOM { */ private DataFlow::SourceNode domEventSource() { // e.g.
e.target}/> - exists(JSXAttribute attr | attr.getName().matches("on%") | + exists(JsxAttribute attr | attr.getName().matches("on%") | result = attr.getValue().flow().getABoundFunctionValue(0).getParameter(0) ) or diff --git a/javascript/ql/lib/semmle/javascript/E4X.qll b/javascript/ql/lib/semmle/javascript/E4X.qll index e8e224e1e51..f69990138c8 100644 --- a/javascript/ql/lib/semmle/javascript/E4X.qll +++ b/javascript/ql/lib/semmle/javascript/E4X.qll @@ -14,7 +14,10 @@ module E4X { * * * ``` */ - class XMLAnyName extends Expr, @e4x_xml_anyname { } + class XmlAnyName extends Expr, @e4x_xml_anyname { } + + /** DEPRECATED: Alias for XmlAnyName */ + deprecated class XMLAnyName = XmlAnyName; /** * An E4X qualified identifier. @@ -29,7 +32,7 @@ module E4X { * Note that qualified identifiers are not currently supported by the parser, so snapshots * will not usually contain any. */ - class XMLQualifiedIdentifier extends Expr, @e4x_xml_qualident { + class XmlQualifiedIdentifier extends Expr, @e4x_xml_qualident { /** * Gets the left operand of this qualified identifier, which is either * an identifier or a wildcard. @@ -54,6 +57,9 @@ module E4X { } } + /** DEPRECATED: Alias for XmlQualifiedIdentifier */ + deprecated class XMLQualifiedIdentifier = XmlQualifiedIdentifier; + /** * An E4X attribute selector. * @@ -64,7 +70,7 @@ module E4X { * @[p] * ``` */ - class XMLAttributeSelector extends Expr, @e4x_xml_attribute_selector { + class XmlAttributeSelector extends Expr, @e4x_xml_attribute_selector { /** * Gets the selected attribute, which is either a static name (that is, a * wildcard identifier or a possibly qualified name), or an arbitrary @@ -83,6 +89,9 @@ module E4X { } } + /** DEPRECATED: Alias for XmlAttributeSelector */ + deprecated class XMLAttributeSelector = XmlAttributeSelector; + /** * An E4X filter expression. * @@ -92,7 +101,7 @@ module E4X { * employees.(@id == 0 || @id == 1) * ``` */ - class XMLFilterExpression extends Expr, @e4x_xml_filter_expression { + class XmlFilterExpression extends Expr, @e4x_xml_filter_expression { /** * Gets the left operand of this filter expression. */ @@ -108,6 +117,9 @@ module E4X { } } + /** DEPRECATED: Alias for XmlFilterExpression */ + deprecated class XMLFilterExpression = XmlFilterExpression; + /** * An E4X "dot-dot" expression. * @@ -117,7 +129,7 @@ module E4X { * e..name * ``` */ - class XMLDotDotExpression extends Expr, @e4x_xml_dotdotexpr { + class XmlDotDotExpression extends Expr, @e4x_xml_dotdotexpr { /** * Gets the base expression of this dot-dot expression. */ @@ -132,4 +144,7 @@ module E4X { result = getBase().getFirstControlFlowNode() } } + + /** DEPRECATED: Alias for XmlDotDotExpression */ + deprecated class XMLDotDotExpression = XmlDotDotExpression; } diff --git a/javascript/ql/lib/semmle/javascript/Expr.qll b/javascript/ql/lib/semmle/javascript/Expr.qll index b99b4c71be8..69dbdd11451 100644 --- a/javascript/ql/lib/semmle/javascript/Expr.qll +++ b/javascript/ql/lib/semmle/javascript/Expr.qll @@ -2744,7 +2744,7 @@ class Decorator extends @decorator, Expr { * } * ``` */ -class Decoratable extends ASTNode { +class Decoratable extends AstNode { Decoratable() { this instanceof ClassDefinition or this instanceof Property or diff --git a/javascript/ql/lib/semmle/javascript/Externs.qll b/javascript/ql/lib/semmle/javascript/Externs.qll index 5fe855a46a8..157b4b3f4cf 100644 --- a/javascript/ql/lib/semmle/javascript/Externs.qll +++ b/javascript/ql/lib/semmle/javascript/Externs.qll @@ -64,7 +64,7 @@ import javascript * Object.prototype.hasOwnProperty = function(p) {}; * */ -abstract class ExternalDecl extends ASTNode { +abstract class ExternalDecl extends AstNode { /** Gets the name of this declaration. */ abstract string getName(); @@ -125,7 +125,7 @@ abstract class ExternalVarDecl extends ExternalDecl { * * The result can be either a function or an expression. */ - abstract ASTNode getInit(); + abstract AstNode getInit(); /** * Gets a JSDoc tag associated with this declaration. @@ -179,7 +179,7 @@ class ExternalGlobalFunctionDecl extends ExternalGlobalDecl, FunctionDeclStmt { /** Gets the name of this declaration. */ override string getName() { result = FunctionDeclStmt.super.getName() } - override ASTNode getInit() { result = this } + override AstNode getInit() { result = this } } /** @@ -336,7 +336,7 @@ class ExternalInstanceMemberDecl extends ExternalMemberDecl { * function(p) {}; // external function entity * */ -class ExternalEntity extends ASTNode { +class ExternalEntity extends AstNode { ExternalEntity() { exists(ExternalVarDecl d | d.getInit() = this) } /** Gets the variable declaration to which this entity belongs. */ diff --git a/javascript/ql/lib/semmle/javascript/JSDoc.qll b/javascript/ql/lib/semmle/javascript/JSDoc.qll index 2621c92e3c6..b2b7548886f 100644 --- a/javascript/ql/lib/semmle/javascript/JSDoc.qll +++ b/javascript/ql/lib/semmle/javascript/JSDoc.qll @@ -55,7 +55,7 @@ class JSDoc extends @jsdoc, Locatable { * } * */ -abstract class Documentable extends ASTNode { +abstract class Documentable extends AstNode { /** Gets the JSDoc comment for this element, if any. */ cached JSDoc getDocumentation() { diff --git a/javascript/ql/lib/semmle/javascript/JSON.qll b/javascript/ql/lib/semmle/javascript/JSON.qll index ed3f6f69637..1e6e259f3eb 100644 --- a/javascript/ql/lib/semmle/javascript/JSON.qll +++ b/javascript/ql/lib/semmle/javascript/JSON.qll @@ -19,14 +19,14 @@ import javascript * { "value": 0 } * ``` */ -class JSONValue extends @json_value, Locatable { +class JsonValue extends @json_value, Locatable { override Location getLocation() { json_locations(this, result) } /** Gets the parent value to which this value belongs, if any. */ - JSONValue getParent() { json(this, _, result, _, _) } + JsonValue getParent() { json(this, _, result, _, _) } /** Gets the `i`th child value of this value. */ - JSONValue getChild(int i) { json(result, _, this, i, _) } + JsonValue getChild(int i) { json(result, _, this, i, _) } /** Holds if this JSON value is the top level element in its enclosing file. */ predicate isTopLevel() { not exists(getParent()) } @@ -42,23 +42,26 @@ class JSONValue extends @json_value, Locatable { } /** If this is an object, gets the value of property `name`. */ - JSONValue getPropValue(string name) { json_properties(this, name, result) } + JsonValue getPropValue(string name) { json_properties(this, name, result) } /** If this is an array, gets the value of the `i`th element. */ - JSONValue getElementValue(int i) { result = this.(JSONArray).getChild(i) } + JsonValue getElementValue(int i) { result = this.(JsonArray).getChild(i) } /** If this is a string constant, gets the value of the string. */ - string getStringValue() { result = this.(JSONString).getValue() } + string getStringValue() { result = this.(JsonString).getValue() } /** If this is an integer constant, gets its numeric value. */ - int getIntValue() { result = this.(JSONNumber).getValue().toInt() } + int getIntValue() { result = this.(JsonNumber).getValue().toInt() } /** If this is a boolean constant, gets its boolean value. */ - boolean getBooleanValue() { result.toString() = this.(JSONBoolean).getValue() } + boolean getBooleanValue() { result.toString() = this.(JsonBoolean).getValue() } override string getAPrimaryQlClass() { result = "JSONValue" } } +/** DEPRECATED: Alias for JsonValue */ +deprecated class JSONValue = JsonValue; + /** * A JSON-encoded primitive value. * @@ -72,7 +75,7 @@ class JSONValue extends @json_value, Locatable { * "a string" * ``` */ -abstract class JSONPrimitiveValue extends JSONValue { +abstract class JsonPrimitiveValue extends JsonValue { /** Gets a string representation of the encoded value. */ string getValue() { json_literals(result, _, this) } @@ -80,6 +83,9 @@ abstract class JSONPrimitiveValue extends JSONValue { string getRawValue() { json_literals(_, result, this) } } +/** DEPRECATED: Alias for JsonPrimitiveValue */ +deprecated class JSONPrimitiveValue = JsonPrimitiveValue; + /** * A JSON-encoded null value. * @@ -89,10 +95,13 @@ abstract class JSONPrimitiveValue extends JSONValue { * null * ``` */ -class JSONNull extends @json_null, JSONPrimitiveValue { +class JsonNull extends @json_null, JsonPrimitiveValue { override string getAPrimaryQlClass() { result = "JSONNull" } } +/** DEPRECATED: Alias for JsonNull */ +deprecated class JSONNull = JsonNull; + /** * A JSON-encoded Boolean value. * @@ -103,10 +112,13 @@ class JSONNull extends @json_null, JSONPrimitiveValue { * false * ``` */ -class JSONBoolean extends @json_boolean, JSONPrimitiveValue { +class JsonBoolean extends @json_boolean, JsonPrimitiveValue { override string getAPrimaryQlClass() { result = "JSONBoolean" } } +/** DEPRECATED: Alias for JsonBoolean */ +deprecated class JSONBoolean = JsonBoolean; + /** * A JSON-encoded number. * @@ -117,10 +129,13 @@ class JSONBoolean extends @json_boolean, JSONPrimitiveValue { * 1.0 * ``` */ -class JSONNumber extends @json_number, JSONPrimitiveValue { +class JsonNumber extends @json_number, JsonPrimitiveValue { override string getAPrimaryQlClass() { result = "JSONNumber" } } +/** DEPRECATED: Alias for JsonNumber */ +deprecated class JSONNumber = JsonNumber; + /** * A JSON-encoded string value. * @@ -130,10 +145,13 @@ class JSONNumber extends @json_number, JSONPrimitiveValue { * "a string" * ``` */ -class JSONString extends @json_string, JSONPrimitiveValue { +class JsonString extends @json_string, JsonPrimitiveValue { override string getAPrimaryQlClass() { result = "JSONString" } } +/** DEPRECATED: Alias for JsonString */ +deprecated class JSONString = JsonString; + /** * A JSON-encoded array. * @@ -143,13 +161,16 @@ class JSONString extends @json_string, JSONPrimitiveValue { * [ 1, 2, 3 ] * ``` */ -class JSONArray extends @json_array, JSONValue { +class JsonArray extends @json_array, JsonValue { override string getAPrimaryQlClass() { result = "JSONArray" } /** Gets the string value of the `i`th element of this array. */ string getElementStringValue(int i) { result = getElementValue(i).getStringValue() } } +/** DEPRECATED: Alias for JsonArray */ +deprecated class JSONArray = JsonArray; + /** * A JSON-encoded object. * @@ -159,18 +180,24 @@ class JSONArray extends @json_array, JSONValue { * { "value": 0 } * ``` */ -class JSONObject extends @json_object, JSONValue { +class JsonObject extends @json_object, JsonValue { override string getAPrimaryQlClass() { result = "JSONObject" } /** Gets the string value of property `name` of this object. */ string getPropStringValue(string name) { result = getPropValue(name).getStringValue() } } +/** DEPRECATED: Alias for JsonObject */ +deprecated class JSONObject = JsonObject; + /** * An error reported by the JSON parser. */ -class JSONParseError extends @json_parse_error, Error { +class JsonParseError extends @json_parse_error, Error { override Location getLocation() { json_locations(this, result) } override string getMessage() { json_errors(this, result) } } + +/** DEPRECATED: Alias for JsonParseError */ +deprecated class JSONParseError = JsonParseError; diff --git a/javascript/ql/lib/semmle/javascript/JSX.qll b/javascript/ql/lib/semmle/javascript/JSX.qll index 4080964886e..e8a33bde257 100644 --- a/javascript/ql/lib/semmle/javascript/JSX.qll +++ b/javascript/ql/lib/semmle/javascript/JSX.qll @@ -15,7 +15,7 @@ import javascript * <>

Title

Some text * ``` */ -class JSXNode extends Expr, @jsx_element { +class JsxNode extends Expr, @jsx_element { /** Gets the `i`th element in the body of this element or fragment. */ Expr getBodyElement(int i) { i >= 0 and result = getChildExpr(-i - 2) } @@ -25,11 +25,14 @@ class JSXNode extends Expr, @jsx_element { /** * Gets the parent JSX element or fragment of this element. */ - JSXNode getJsxParent() { this = result.getABodyElement() } + JsxNode getJsxParent() { this = result.getABodyElement() } override string getAPrimaryQlClass() { result = "JSXNode" } } +/** DEPRECATED: Alias for JsxNode */ +deprecated class JSXNode = JsxNode; + /** * A JSX element. * @@ -40,25 +43,25 @@ class JSXNode extends Expr, @jsx_element { * * ``` */ -class JSXElement extends JSXNode { - JSXName name; +class JsxElement extends JsxNode { + JsxName name; - JSXElement() { name = getChildExpr(-1) } + JsxElement() { name = getChildExpr(-1) } /** Gets the expression denoting the name of this element. */ - JSXName getNameExpr() { result = name } + JsxName getNameExpr() { result = name } /** Gets the name of this element. */ string getName() { result = name.getValue() } /** Gets the `i`th attribute of this element. */ - JSXAttribute getAttribute(int i) { properties(result, this, i, _, _) } + JsxAttribute getAttribute(int i) { properties(result, this, i, _, _) } /** Gets an attribute of this element. */ - JSXAttribute getAnAttribute() { result = getAttribute(_) } + JsxAttribute getAnAttribute() { result = getAttribute(_) } /** Gets the attribute of this element with the given name, if any. */ - JSXAttribute getAttributeByName(string n) { result = getAnAttribute() and result.getName() = n } + JsxAttribute getAttributeByName(string n) { result = getAnAttribute() and result.getName() = n } override ControlFlowNode getFirstControlFlowNode() { result = getNameExpr().getFirstControlFlowNode() @@ -70,9 +73,15 @@ class JSXElement extends JSXNode { * Holds if this JSX element is a HTML element. * That is, the name starts with a lowercase letter. */ - predicate isHTMLElement() { getName().regexpMatch("[a-z].*") } + predicate isHtmlElement() { getName().regexpMatch("[a-z].*") } + + /** DEPRECATED: Alias for isHtmlElement */ + deprecated predicate isHTMLElement() { isHtmlElement() } } +/** DEPRECATED: Alias for JsxElement */ +deprecated class JSXElement = JsxElement; + /** * A JSX fragment. * @@ -82,8 +91,8 @@ class JSXElement extends JSXNode { * <>

Title

Some text * ``` */ -class JSXFragment extends JSXNode { - JSXFragment() { not exists(getChildExpr(-1)) } +class JsxFragment extends JsxNode { + JsxFragment() { not exists(getChildExpr(-1)) } override ControlFlowNode getFirstControlFlowNode() { result = getBodyElement(0).getFirstControlFlowNode() @@ -94,6 +103,9 @@ class JSXFragment extends JSXNode { override string getAPrimaryQlClass() { result = "JSXFragment" } } +/** DEPRECATED: Alias for JsxFragment */ +deprecated class JSXFragment = JsxFragment; + /** * An attribute of a JSX element, including spread attributes. * @@ -105,13 +117,13 @@ class JSXFragment extends JSXNode { *
// `{...attrs}` is a (spread) attribute * ``` */ -class JSXAttribute extends ASTNode, @jsx_attribute { +class JsxAttribute extends AstNode, @jsx_attribute { /** * Gets the expression denoting the name of this attribute. * * This is not defined for spread attributes. */ - JSXName getNameExpr() { result = getChildExpr(0) } + JsxName getNameExpr() { result = getChildExpr(0) } /** * Gets the name of this attribute. @@ -127,7 +139,7 @@ class JSXAttribute extends ASTNode, @jsx_attribute { string getStringValue() { result = getValue().getStringValue() } /** Gets the JSX element to which this attribute belongs. */ - JSXElement getElement() { this = result.getAnAttribute() } + JsxElement getElement() { this = result.getAnAttribute() } override ControlFlowNode getFirstControlFlowNode() { result = getNameExpr().getFirstControlFlowNode() @@ -140,6 +152,9 @@ class JSXAttribute extends ASTNode, @jsx_attribute { override string getAPrimaryQlClass() { result = "JSXAttribute" } } +/** DEPRECATED: Alias for JsxAttribute */ +deprecated class JSXAttribute = JsxAttribute; + /** * A spread attribute of a JSX element. * @@ -149,8 +164,8 @@ class JSXAttribute extends ASTNode, @jsx_attribute { *
// `{...attrs}` is a spread attribute * ``` */ -class JSXSpreadAttribute extends JSXAttribute { - JSXSpreadAttribute() { not exists(getNameExpr()) } +class JsxSpreadAttribute extends JsxAttribute { + JsxSpreadAttribute() { not exists(getNameExpr()) } override SpreadElement getValue() { // override for more precise result type @@ -158,6 +173,9 @@ class JSXSpreadAttribute extends JSXAttribute { } } +/** DEPRECATED: Alias for JsxSpreadAttribute */ +deprecated class JSXSpreadAttribute = JsxSpreadAttribute; + /** * A namespace-qualified name such as `n:a`. * @@ -167,7 +185,7 @@ class JSXSpreadAttribute extends JSXAttribute { * html:href * ``` */ -class JSXQualifiedName extends Expr, @jsx_qualified_name { +class JsxQualifiedName extends Expr, @jsx_qualified_name { /** Gets the namespace component of this qualified name. */ Identifier getNamespace() { result = getChildExpr(0) } @@ -181,6 +199,9 @@ class JSXQualifiedName extends Expr, @jsx_qualified_name { override string getAPrimaryQlClass() { result = "JSXQualifiedName" } } +/** DEPRECATED: Alias for JsxQualifiedName */ +deprecated class JSXQualifiedName = JsxQualifiedName; + /** * A name of an JSX element or attribute (which is * always an identifier, a dot expression, or a qualified @@ -194,12 +215,12 @@ class JSXQualifiedName extends Expr, @jsx_qualified_name { * data.path * ``` */ -class JSXName extends Expr { - JSXName() { +class JsxName extends Expr { + JsxName() { this instanceof Identifier or this instanceof ThisExpr or - this.(DotExpr).getBase() instanceof JSXName or - this instanceof JSXQualifiedName + this.(DotExpr).getBase() instanceof JsxName or + this instanceof JsxQualifiedName } /** @@ -209,10 +230,10 @@ class JSXName extends Expr { result = this.(Identifier).getName() or exists(DotExpr dot | dot = this | - result = dot.getBase().(JSXName).getValue() + "." + dot.getPropertyName() + result = dot.getBase().(JsxName).getValue() + "." + dot.getPropertyName() ) or - exists(JSXQualifiedName qual | qual = this | + exists(JsxQualifiedName qual | qual = this | result = qual.getNamespace().getName() + ":" + qual.getName().getName() ) or @@ -221,6 +242,9 @@ class JSXName extends Expr { } } +/** DEPRECATED: Alias for JsxName */ +deprecated class JSXName = JsxName; + /** * An interpolating expression that interpolates nothing. * @@ -230,10 +254,13 @@ class JSXName extends Expr { * { /* TBD */ } * */ -class JSXEmptyExpr extends Expr, @jsx_empty_expr { +class JsxEmptyExpr extends Expr, @jsx_empty_expr { override string getAPrimaryQlClass() { result = "JSXEmptyExpr" } } +/** DEPRECATED: Alias for JsxEmptyExpr */ +deprecated class JSXEmptyExpr = JsxEmptyExpr; + /** * A legacy `@jsx` pragma. * @@ -243,12 +270,18 @@ class JSXEmptyExpr extends Expr, @jsx_empty_expr { * @jsx React.DOM * ``` */ -class JSXPragma extends JSDocTag { - JSXPragma() { getTitle() = "jsx" } +class JsxPragma extends JSDocTag { + JsxPragma() { getTitle() = "jsx" } /** * Gets the DOM name specified by the pragma; for `@jsx React.DOM`, * the result is `React.DOM`. */ - string getDOMName() { result = getDescription().trim() } + string getDomName() { result = getDescription().trim() } + + /** DEPRECATED: Alias for getDomName */ + deprecated string getDOMName() { result = getDomName() } } + +/** DEPRECATED: Alias for JsxPragma */ +deprecated class JSXPragma = JsxPragma; diff --git a/javascript/ql/lib/semmle/javascript/JsonStringifiers.qll b/javascript/ql/lib/semmle/javascript/JsonStringifiers.qll index 8f6edd312cd..03ca152471f 100644 --- a/javascript/ql/lib/semmle/javascript/JsonStringifiers.qll +++ b/javascript/ql/lib/semmle/javascript/JsonStringifiers.qll @@ -64,7 +64,7 @@ class JSON2CSVTaintStep extends TaintTracking::SharedTaintStep { * This is not quite a `JSON.stringify` call, as it e.g. does not wrap keys in double quotes. * It's therefore modeled as a taint-step rather than as a `JSON.stringify` call. */ -class PrettyJSONTaintStep extends TaintTracking::SharedTaintStep { +class PrettyJsonTaintStep extends TaintTracking::SharedTaintStep { override predicate step(DataFlow::Node pred, DataFlow::Node succ) { exists(API::CallNode call | call = API::moduleImport("prettyjson").getMember("render").getACall() @@ -74,3 +74,6 @@ class PrettyJSONTaintStep extends TaintTracking::SharedTaintStep { ) } } + +/** DEPRECATED: Alias for PrettyJsonTaintStep */ +deprecated class PrettyJSONTaintStep = PrettyJsonTaintStep; diff --git a/javascript/ql/lib/semmle/javascript/Modules.qll b/javascript/ql/lib/semmle/javascript/Modules.qll index a811f6689e9..8c36044bb24 100644 --- a/javascript/ql/lib/semmle/javascript/Modules.qll +++ b/javascript/ql/lib/semmle/javascript/Modules.qll @@ -118,7 +118,7 @@ abstract class Module extends TopLevel { * An import in a module, which may be an ECMAScript 2015-style * `import` statement, a CommonJS-style `require` import, or an AMD dependency. */ -abstract class Import extends ASTNode { +abstract class Import extends AstNode { /** Gets the module in which this import appears. */ abstract Module getEnclosingModule(); @@ -211,7 +211,7 @@ abstract class Import extends ASTNode { * No support for importing from folders inside the other package. */ private Module resolveNeighbourPackage(PathString importPath) { - exists(PackageJSON json | importPath = json.getPackageName() and result = json.getMainModule()) + exists(PackageJson json | importPath = json.getPackageName() and result = json.getMainModule()) or exists(string package | result.getFile().getParentContainer() = getPackageFolder(package) and @@ -224,7 +224,7 @@ private Module resolveNeighbourPackage(PathString importPath) { */ pragma[noinline] private Folder getPackageFolder(string package) { - exists(PackageJSON json | + exists(PackageJson json | json.getPackageName() = package and result = json.getFile().getParentContainer() ) diff --git a/javascript/ql/lib/semmle/javascript/NPM.qll b/javascript/ql/lib/semmle/javascript/NPM.qll index 03d62b3aac6..8644ad5c15c 100644 --- a/javascript/ql/lib/semmle/javascript/NPM.qll +++ b/javascript/ql/lib/semmle/javascript/NPM.qll @@ -6,8 +6,8 @@ import javascript private import NodeModuleResolutionImpl /** A `package.json` configuration object. */ -class PackageJSON extends JSONObject { - PackageJSON() { +class PackageJson extends JsonObject { + PackageJson() { this.getJsonFile().getBaseName() = "package.json" and this.isTopLevel() } @@ -22,7 +22,7 @@ class PackageJSON extends JSONObject { string getDescription() { result = this.getPropStringValue("description") } /** Gets the array of keywords for this package. */ - JSONArray getKeywords() { result = this.getPropValue("keywords") } + JsonArray getKeywords() { result = this.getPropValue("keywords") } /** Gets a keyword for this package. */ string getAKeyword() { result = this.getKeywords().getElementStringValue(_) } @@ -45,7 +45,7 @@ class PackageJSON extends JSONObject { } /** Gets the array of files for this package. */ - JSONArray getFiles() { result = this.getPropValue("files") } + JsonArray getFiles() { result = this.getPropValue("files") } /** Gets a file for this package. */ string getAFile() { result = this.getFiles().getElementStringValue(_) } @@ -67,16 +67,16 @@ class PackageJSON extends JSONObject { } /** Gets information about the directories of this package. */ - JSONObject getDirectories() { result = this.getPropValue("directories") } + JsonObject getDirectories() { result = this.getPropValue("directories") } /** Gets repository information for this package. */ RepositoryInfo getRepository() { result = this.getPropValue("repository") } /** Gets information about the scripts of this package. */ - JSONObject getScripts() { result = this.getPropValue("scripts") } + JsonObject getScripts() { result = this.getPropValue("scripts") } /** Gets configuration information for this package. */ - JSONObject getConfig() { result = this.getPropValue("config") } + JsonObject getConfig() { result = this.getPropValue("config") } /** Gets the dependencies of this package. */ PackageDependencies getDependencies() { result = this.getPropValue("dependencies") } @@ -131,10 +131,10 @@ class PackageJSON extends JSONObject { PackageDependencies getEngines() { result = this.getPropValue("engines") } /** Holds if this package has strict engine requirements. */ - predicate isEngineStrict() { this.getPropValue("engineStrict").(JSONBoolean).getValue() = "true" } + predicate isEngineStrict() { this.getPropValue("engineStrict").(JsonBoolean).getValue() = "true" } /** Gets information about operating systems supported by this package. */ - JSONArray getOSs() { result = this.getPropValue("os") } + JsonArray getOSs() { result = this.getPropValue("os") } /** Gets an operating system supported by this package. */ string getWhitelistedOS() { @@ -150,7 +150,7 @@ class PackageJSON extends JSONObject { } /** Gets information about platforms supported by this package. */ - JSONArray getCPUs() { result = this.getPropValue("cpu") } + JsonArray getCPUs() { result = this.getPropValue("cpu") } /** Gets a platform supported by this package. */ string getWhitelistedCPU() { @@ -166,13 +166,13 @@ class PackageJSON extends JSONObject { } /** Holds if this package prefers to be installed globally. */ - predicate isPreferGlobal() { this.getPropValue("preferGlobal").(JSONBoolean).getValue() = "true" } + predicate isPreferGlobal() { this.getPropValue("preferGlobal").(JsonBoolean).getValue() = "true" } /** Holds if this is a private package. */ - predicate isPrivate() { this.getPropValue("private").(JSONBoolean).getValue() = "true" } + predicate isPrivate() { this.getPropValue("private").(JsonBoolean).getValue() = "true" } /** Gets publishing configuration information about this package. */ - JSONValue getPublishConfig() { result = this.getPropValue("publishConfig") } + JsonValue getPublishConfig() { result = this.getPropValue("publishConfig") } /** * Gets the main module of this package. @@ -182,13 +182,16 @@ class PackageJSON extends JSONObject { } } +/** DEPRECATED: Alias for PackageJson */ +deprecated class PackageJSON = PackageJson; + /** * A representation of bug tracker information for an NPM package. */ -class BugTrackerInfo extends JSONValue { +class BugTrackerInfo extends JsonValue { BugTrackerInfo() { - exists(PackageJSON pkg | pkg.getPropValue("bugs") = this) and - (this instanceof JSONObject or this instanceof JSONString) + exists(PackageJson pkg | pkg.getPropValue("bugs") = this) and + (this instanceof JsonObject or this instanceof JsonString) } /** Gets the bug tracker URL. */ @@ -204,13 +207,13 @@ class BugTrackerInfo extends JSONValue { /** * A representation of contributor information for an NPM package. */ -class ContributorInfo extends JSONValue { +class ContributorInfo extends JsonValue { ContributorInfo() { - exists(PackageJSON pkg | + exists(PackageJson pkg | this = pkg.getPropValue("author") or this = pkg.getPropValue("contributors").getElementValue(_) ) and - (this instanceof JSONObject or this instanceof JSONString) + (this instanceof JsonObject or this instanceof JsonString) } /** @@ -244,8 +247,8 @@ class ContributorInfo extends JSONValue { /** * A representation of repository information for an NPM package. */ -class RepositoryInfo extends JSONObject { - RepositoryInfo() { exists(PackageJSON pkg | this = pkg.getPropValue("repository")) } +class RepositoryInfo extends JsonObject { + RepositoryInfo() { exists(PackageJson pkg | this = pkg.getPropValue("repository")) } /** Gets the repository type. */ string getType() { result = this.getPropStringValue("type") } @@ -257,9 +260,9 @@ class RepositoryInfo extends JSONObject { /** * A representation of package dependencies for an NPM package. */ -class PackageDependencies extends JSONObject { +class PackageDependencies extends JsonObject { PackageDependencies() { - exists(PackageJSON pkg, string name | + exists(PackageJson pkg, string name | name.regexpMatch("(.+D|d)ependencies|engines") and this = pkg.getPropValue(name) ) @@ -272,11 +275,11 @@ class PackageDependencies extends JSONObject { /** * An NPM package. */ -class NPMPackage extends @folder { +class NpmPackage extends @folder { /** The `package.json` file of this package. */ - PackageJSON pkg; + PackageJson pkg; - NPMPackage() { pkg.getJsonFile().getParentContainer() = this } + NpmPackage() { pkg.getJsonFile().getParentContainer() = this } /** Gets a textual representation of this package. */ string toString() { result = this.(Folder).toString() } @@ -285,10 +288,13 @@ class NPMPackage extends @folder { string getPath() { result = this.(Folder).getAbsolutePath() } /** Gets the `package.json` object of this package. */ - PackageJSON getPackageJSON() { result = pkg } + PackageJson getPackageJson() { result = pkg } + + /** DEPRECATED: Alias for getPackageJson */ + deprecated PackageJSON getPackageJSON() { result = getPackageJson() } /** Gets the name of this package. */ - string getPackageName() { result = this.getPackageJSON().getPackageName() } + string getPackageName() { result = this.getPackageJson().getPackageName() } /** Gets the `node_modules` folder of this package. */ Folder getNodeModulesFolder() { @@ -325,6 +331,9 @@ class NPMPackage extends @folder { predicate declaresDependency(string p, string v) { pkg.declaresDependency(p, v) } } +/** DEPRECATED: Alias for NpmPackage */ +deprecated class NPMPackage = NpmPackage; + /** * Gets the parent folder of `c`, provided that they belong to the same NPM * package; that is, `c` must not be a `node_modules` folder. diff --git a/javascript/ql/lib/semmle/javascript/NodeModuleResolutionImpl.qll b/javascript/ql/lib/semmle/javascript/NodeModuleResolutionImpl.qll index cb2481861ee..6df85792a56 100644 --- a/javascript/ql/lib/semmle/javascript/NodeModuleResolutionImpl.qll +++ b/javascript/ql/lib/semmle/javascript/NodeModuleResolutionImpl.qll @@ -60,7 +60,7 @@ File loadAsFile(Require req, int rootPriority, int priority) { */ File loadAsDirectory(Require req, int rootPriority, int priority) { exists(Folder dir | dir = req.getImportedPath().resolve(rootPriority) | - result = resolveMainModule(dir.(NPMPackage).getPackageJSON(), priority) or + result = resolveMainModule(dir.(NpmPackage).getPackageJson(), priority) or result = tryExtensions(dir, "index", priority - (numberOfExtensions() + 1)) ) } @@ -90,7 +90,7 @@ private string getStem(string name) { result = name.regexpCapture("(.+?)(?:\\.([ /** * Gets the main module described by `pkg` with the given `priority`. */ -File resolveMainModule(PackageJSON pkg, int priority) { +File resolveMainModule(PackageJson pkg, int priority) { exists(PathExpr main | main = MainModulePath::of(pkg) | result = main.resolve() and priority = 0 or @@ -144,14 +144,17 @@ private string getASrcFolderName() { result = ["ts", "js", "src", "lib"] } * module of the package. */ class MainModulePath extends PathExpr, @json_string { - PackageJSON pkg; + PackageJson pkg; MainModulePath() { this = pkg.getPropValue(["main", "module"]) } /** Gets the `package.json` file in which this path occurs. */ - PackageJSON getPackageJSON() { result = pkg } + PackageJson getPackageJson() { result = pkg } - override string getValue() { result = this.(JSONString).getValue() } + /** DEPRECATED: Alias for getPackageJson */ + deprecated PackageJSON getPackageJSON() { result = getPackageJson() } + + override string getValue() { result = this.(JsonString).getValue() } override Folder getAdditionalSearchRoot(int priority) { priority = 0 and @@ -160,7 +163,7 @@ class MainModulePath extends PathExpr, @json_string { } module MainModulePath { - MainModulePath of(PackageJSON pkg) { result.getPackageJSON() = pkg } + MainModulePath of(PackageJson pkg) { result.getPackageJson() = pkg } } /** @@ -169,17 +172,20 @@ module MainModulePath { * For performance reasons this only exists if there is no "main" field in the `package.json` file. */ private class FilesPath extends PathExpr, @json_string { - PackageJSON pkg; + PackageJson pkg; FilesPath() { - this = pkg.getPropValue("files").(JSONArray).getElementValue(_) and + this = pkg.getPropValue("files").(JsonArray).getElementValue(_) and not exists(MainModulePath::of(pkg)) } /** Gets the `package.json` file in which this path occurs. */ - PackageJSON getPackageJSON() { result = pkg } + PackageJson getPackageJson() { result = pkg } - override string getValue() { result = this.(JSONString).getValue() } + /** DEPRECATED: Alias for getPackageJson */ + deprecated PackageJSON getPackageJSON() { result = getPackageJson() } + + override string getValue() { result = this.(JsonString).getValue() } override Folder getAdditionalSearchRoot(int priority) { priority = 0 and @@ -188,5 +194,5 @@ private class FilesPath extends PathExpr, @json_string { } private module FilesPath { - FilesPath of(PackageJSON pkg) { result.getPackageJSON() = pkg } + FilesPath of(PackageJson pkg) { result.getPackageJson() = pkg } } diff --git a/javascript/ql/lib/semmle/javascript/PackageExports.qll b/javascript/ql/lib/semmle/javascript/PackageExports.qll index 2895ad7232c..82bcb842859 100644 --- a/javascript/ql/lib/semmle/javascript/PackageExports.qll +++ b/javascript/ql/lib/semmle/javascript/PackageExports.qll @@ -52,7 +52,7 @@ private import NodeModuleResolutionImpl as NodeModule private DataFlow::Node getAValueExportedByPackage() { // The base case, an export from a named `package.json` file. result = - getAnExportFromModule(any(PackageJSON pack | exists(pack.getPackageName())).getMainModule()) + getAnExportFromModule(any(PackageJson pack | exists(pack.getPackageName())).getMainModule()) or // module.exports.bar.baz = result; exists(DataFlow::PropWrite write | @@ -133,7 +133,7 @@ private DataFlow::Node getAValueExportedByPackage() { DataFlow::globalVarRef("define").getACall().getArgument(1) = prev.getALocalUse() and func.getFile() = min(int j, File f | - f = NodeModule::resolveMainModule(any(PackageJSON pack | exists(pack.getPackageName())), j) + f = NodeModule::resolveMainModule(any(PackageJson pack | exists(pack.getPackageName())), j) | f order by j ) diff --git a/javascript/ql/lib/semmle/javascript/Paths.qll b/javascript/ql/lib/semmle/javascript/Paths.qll index 11904b3069e..e22d5ad6132 100644 --- a/javascript/ql/lib/semmle/javascript/Paths.qll +++ b/javascript/ql/lib/semmle/javascript/Paths.qll @@ -212,7 +212,7 @@ private module TypeScriptOutDir { * Gets a folder of TypeScript files that is compiled to JavaScript files in `outdir` relative to a `parent`. */ string getOriginalTypeScriptFolder(string outdir, Folder parent) { - exists(JSONObject tsconfig | + exists(JsonObject tsconfig | outdir = removeLeadingSlash(getOutDir(tsconfig, parent)) and result = removeLeadingSlash(getEffectiveRootDirFromTSConfig(tsconfig)) ) @@ -229,7 +229,7 @@ private module TypeScriptOutDir { /** * Gets the `outDir` option from a tsconfig file from the folder `parent`. */ - private string getOutDir(JSONObject tsconfig, Folder parent) { + private string getOutDir(JsonObject tsconfig, Folder parent) { tsconfig.getFile().getBaseName().regexpMatch("tsconfig.*\\.json") and tsconfig.isTopLevel() and tsconfig.getFile().getParentContainer() = parent and @@ -241,7 +241,7 @@ private module TypeScriptOutDir { * Based on the tsconfig.json file `tsconfig`. */ pragma[inline] - private string getEffectiveRootDirFromTSConfig(JSONObject tsconfig) { + private string getEffectiveRootDirFromTSConfig(JsonObject tsconfig) { // if an explicit "rootDir" option exists, then use that. result = getRootDir(tsconfig) or @@ -273,7 +273,7 @@ private module TypeScriptOutDir { * Can have multiple results if the includes are from multiple folders. */ pragma[inline] - private string getARootDirFromInclude(JSONObject tsconfig) { + private string getARootDirFromInclude(JsonObject tsconfig) { result = getRootFolderFromPath(tsconfig.getPropValue("include").getElementValue(_).getStringValue()) } @@ -282,7 +282,7 @@ private module TypeScriptOutDir { * Gets the value of the "rootDir" option from a tsconfig.json. */ pragma[inline] - private string getRootDir(JSONObject tsconfig) { + private string getRootDir(JsonObject tsconfig) { result = tsconfig.getPropValue("compilerOptions").getPropValue("rootDir").getStringValue() } } diff --git a/javascript/ql/lib/semmle/javascript/PrintAst.qll b/javascript/ql/lib/semmle/javascript/PrintAst.qll index 98abe183af1..8c2e0ff1d92 100644 --- a/javascript/ql/lib/semmle/javascript/PrintAst.qll +++ b/javascript/ql/lib/semmle/javascript/PrintAst.qll @@ -54,26 +54,26 @@ private string getQlClass(Locatable el) { */ private newtype TPrintAstNode = // JavaScript / TypeScript - TElementNode(ASTNode el) { shouldPrint(el, _) and not isNotNeeded(el) } or + TElementNode(AstNode el) { shouldPrint(el, _) and not isNotNeeded(el) } or TParametersNode(Function f) { shouldPrint(f, _) and not isNotNeeded(f) } or TTypeParametersNode(TypeParameterized f) { shouldPrint(f, _) and not isNotNeeded(f) } or - TJSXAttributesNode(JSXElement n) { shouldPrint(n, _) and not isNotNeeded(n) } or - TJSXBodyElementsNode(JSXNode n) { shouldPrint(n, _) and not isNotNeeded(n) } or + TJsxAttributesNode(JsxElement n) { shouldPrint(n, _) and not isNotNeeded(n) } or + TJsxBodyElementsNode(JsxNode n) { shouldPrint(n, _) and not isNotNeeded(n) } or TInvokeArgumentsNode(InvokeExpr n) { shouldPrint(n, _) and not isNotNeeded(n) } or TInvokeTypeArgumentsNode(InvokeExpr invk) { shouldPrint(invk, _) and not isNotNeeded(invk) } or // JSON - TJSONNode(JSONValue value) { shouldPrint(value, _) and not isNotNeeded(value) } or + TJsonNode(JsonValue value) { shouldPrint(value, _) and not isNotNeeded(value) } or // YAML - TYAMLNode(YAMLNode n) { shouldPrint(n, _) and not isNotNeeded(n) } or - TYAMLMappingNode(YAMLMapping mapping, int i) { + TYamlNode(YAMLNode n) { shouldPrint(n, _) and not isNotNeeded(n) } or + TYamlMappingNode(YAMLMapping mapping, int i) { shouldPrint(mapping, _) and not isNotNeeded(mapping) and exists(mapping.getKeyNode(i)) } or // HTML - THTMLElementNode(HTML::Element e) { shouldPrint(e, _) and not isNotNeeded(e) } or - THTMLAttributesNodes(HTML::Element e) { shouldPrint(e, _) and not isNotNeeded(e) } or - THTMLAttributeNode(HTML::Attribute attr) { shouldPrint(attr, _) and not isNotNeeded(attr) } or - THTMLScript(Script script) { shouldPrint(script, _) and not isNotNeeded(script) } or - THTMLCodeInAttr(CodeInAttribute attr) { shouldPrint(attr, _) and not isNotNeeded(attr) } or + THtmlElementNode(HTML::Element e) { shouldPrint(e, _) and not isNotNeeded(e) } or + THtmlAttributesNodes(HTML::Element e) { shouldPrint(e, _) and not isNotNeeded(e) } or + THtmlAttributeNode(HTML::Attribute attr) { shouldPrint(attr, _) and not isNotNeeded(attr) } or + THtmlScript(Script script) { shouldPrint(script, _) and not isNotNeeded(script) } or + THtmlCodeInAttr(CodeInAttribute attr) { shouldPrint(attr, _) and not isNotNeeded(attr) } or TRegExpTermNode(RegExpTerm term) { shouldPrint(term, _) and term.isUsedAsRegExp() and @@ -168,7 +168,7 @@ private module PrintJavaScript { * For example by aggregating all the parameters of a function under a single child node. */ class ElementNode extends PrintAstNode, TElementNode { - ASTNode element; + AstNode element; ElementNode() { this = TElementNode(element) and @@ -183,10 +183,10 @@ private module PrintJavaScript { /** * Gets the `ASTNode` represented by this node. */ - final ASTNode getElement() { result = element } + final AstNode getElement() { result = element } override PrintAstNode getChild(int childIndex) { - exists(ASTNode el | result.(ElementNode).getElement() = el | + exists(AstNode el | result.(ElementNode).getElement() = el | el = this.getChildNode(childIndex) ) } @@ -195,16 +195,16 @@ private module PrintJavaScript { * Gets the `i`th child of `element`. * Can be overriden in subclasses to get more specific behavior for `getChild()`. */ - ASTNode getChildNode(int childIndex) { result = getLocationSortedChild(element, childIndex) } + AstNode getChildNode(int childIndex) { result = getLocationSortedChild(element, childIndex) } } - /** Provides predicates for pretty printing `ASTNode`s. */ + /** Provides predicates for pretty printing `AstNode`s. */ private module PrettyPrinting { /** * Gets a pretty string representation of `element`. * Either the result is `ASTNode::toString`, or a custom made string representation of `element`. */ - string print(ASTNode element) { + string print(AstNode element) { shouldPrint(element, _) and ( result = element.toString().regexpReplaceAll("(\\\\n|\\\\r|\\\\t| )+", " ") and @@ -217,7 +217,7 @@ private module PrintJavaScript { /** * Gets a string representing `a`. */ - private string repr(ASTNode a) { + private string repr(AstNode a) { shouldPrint(a, _) and ( exists(DeclStmt decl | decl = a | @@ -252,9 +252,9 @@ private module PrintJavaScript { } } - private ASTNode getLocationSortedChild(ASTNode parent, int i) { + private AstNode getLocationSortedChild(AstNode parent, int i) { result = - rank[i](ASTNode child, int childIndex | + rank[i](AstNode child, int childIndex | child = parent.getChild(childIndex) | child @@ -370,62 +370,77 @@ private module PrintJavaScript { * 2: An aggregate node for all the attributes (for example `href={foo}` in ``). * 3: An aggregate node for all the body element (for example `foo` in `foo`). */ - class JSXNodeNode extends ElementNode { - override JSXNode element; + class JsxNodeNode extends ElementNode { + override JsxNode element; override PrintAstNode getChild(int childIndex) { - childIndex = 0 and result.(ElementNode).getElement() = element.(JSXElement).getNameExpr() + childIndex = 0 and result.(ElementNode).getElement() = element.(JsxElement).getNameExpr() or childIndex = 1 and exists(element.getABodyElement()) and - result.(JSXBodyElementsNode).getJSXNode() = element + result.(JsxBodyElementsNode).getJsxNode() = element or childIndex = 2 and - exists(element.(JSXElement).getAttribute(_)) and - result.(JSXAttributesNode).getJSXElement() = element + exists(element.(JsxElement).getAttribute(_)) and + result.(JsxAttributesNode).getJsxElement() = element } } + /** DEPRECATED: Alias for JsxNodeNode */ + deprecated class JSXNodeNode = JsxNodeNode; + /** * An aggregate node representing all the attributes in a `JSXNode`. */ - class JSXAttributesNode extends PrintAstNode, TJSXAttributesNode { - JSXElement n; + class JsxAttributesNode extends PrintAstNode, TJsxAttributesNode { + JsxElement n; - JSXAttributesNode() { this = TJSXAttributesNode(n) and exists(n.getAttribute(_)) } + JsxAttributesNode() { this = TJsxAttributesNode(n) and exists(n.getAttribute(_)) } override string toString() { result = "(Attributes)" } /** * Gets the `JSXElement` for which this node represents the attributes. */ - JSXElement getJSXElement() { result = n } + JsxElement getJsxElement() { result = n } + + /** DEPRECATED: Alias for getJsxElement */ + deprecated JSXElement getJSXElement() { result = getJsxElement() } override PrintAstNode getChild(int childIndex) { result.(ElementNode).getElement() = n.getAttribute(childIndex) } } + /** DEPRECATED: Alias for JsxAttributesNode */ + deprecated class JSXAttributesNode = JsxAttributesNode; + /** * An aggregate node representing all the body elements in a `JSXNode`. */ - class JSXBodyElementsNode extends PrintAstNode, TJSXBodyElementsNode { - JSXNode n; + class JsxBodyElementsNode extends PrintAstNode, TJsxBodyElementsNode { + JsxNode n; - JSXBodyElementsNode() { this = TJSXBodyElementsNode(n) and exists(n.getBodyElement(_)) } + JsxBodyElementsNode() { this = TJsxBodyElementsNode(n) and exists(n.getBodyElement(_)) } override string toString() { result = "(Body)" } /** * Gets the `JSXNode` for which this node represents the body elements. */ - JSXNode getJSXNode() { result = n } + JsxNode getJsxNode() { result = n } + + /** DEPRECATED: Alias for getJsxNode */ + deprecated JSXNode getJSXNode() { result = getJsxNode() } override PrintAstNode getChild(int childIndex) { result.(ElementNode).getElement() = n.getBodyElement(childIndex) } } + /** DEPRECATED: Alias for JsxBodyElementsNode */ + deprecated class JSXBodyElementsNode = JsxBodyElementsNode; + /** * A node representing any `ASTNode` that has type-parameters. * @@ -484,7 +499,7 @@ private module PrintJavaScript { class ParameterNode extends ElementNode { override Parameter element; - override ASTNode getChildNode(int childIndex) { + override AstNode getChildNode(int childIndex) { childIndex = 0 and result = element.getTypeAnnotation() or childIndex = 1 and result = element.getDefault() @@ -535,14 +550,14 @@ private module PrintJavaScript { /** * Classes for printing JSON AST. */ -private module PrintJSON { +private module PrintJson { /** * A print node representing a JSON value in a .json file. */ - class JSONNode extends PrintAstNode, TJSONNode { - JSONValue value; + class JsonNode extends PrintAstNode, TJsonNode { + JsonValue value; - JSONNode() { this = TJSONNode(value) } + JsonNode() { this = TJsonNode(value) } override string toString() { result = getQlClass(value) + PrettyPrinting::print(value) } @@ -551,22 +566,25 @@ private module PrintJSON { /** * Gets the `JSONValue` represented by this node. */ - final JSONValue getValue() { result = value } + final JsonValue getValue() { result = value } override PrintAstNode getChild(int childIndex) { - exists(JSONValue child | result.(JSONNode).getValue() = child | + exists(JsonValue child | result.(JsonNode).getValue() = child | child = value.getChild(childIndex) ) } } + /** DEPRECATED: Alias for JsonNode */ + deprecated class JSONNode = JsonNode; + /** Provied predicates for pretty printing JSON. */ private module PrettyPrinting { /** * Gets a string representation of `n`. * Either using the default `JSONValue::toString`, or a custom printing of the JSON value. */ - string print(JSONValue n) { + string print(JsonValue n) { shouldPrint(n, _) and ( result = n.toString().regexpReplaceAll("(\\\\n|\\\\r|\\\\t| )+", " ") and @@ -577,20 +595,20 @@ private module PrintJSON { } /** Gets a string representing `n`. */ - private string repr(JSONValue n) { + private string repr(JsonValue n) { shouldPrint(n, _) and ( - exists(JSONObject obj, string name, JSONValue prop | obj = n | + exists(JsonObject obj, string name, JsonValue prop | obj = n | prop = obj.getPropValue(name) and prop = obj.getChild(0) and result = "{" + name + ": ...}" ) or - n instanceof JSONObject and not exists(n.getChild(_)) and result = "{}" + n instanceof JsonObject and not exists(n.getChild(_)) and result = "{}" or - result = n.(JSONPrimitiveValue).getRawValue() + result = n.(JsonPrimitiveValue).getRawValue() or - exists(JSONArray arr | arr = n | + exists(JsonArray arr | arr = n | result = "[]" and not exists(arr.getChild(_)) or result = "[" + repr(arr.getChild(0)) + "]" and not exists(arr.getChild(1)) @@ -605,14 +623,14 @@ private module PrintJSON { /** * Classes for printing YAML AST. */ -module PrintYAML { +module PrintYaml { /** * A print node representing a YAML value in a .yml file. */ - class YAMLNodeNode extends PrintAstNode, TYAMLNode { + class YamlNodeNode extends PrintAstNode, TYamlNode { YAMLNode node; - YAMLNodeNode() { this = TYAMLNode(node) } + YamlNodeNode() { this = TYamlNode(node) } override string toString() { result = getQlClass(node) + node.toString() } @@ -624,33 +642,39 @@ module PrintYAML { final YAMLNode getValue() { result = node } override PrintAstNode getChild(int childIndex) { - exists(YAMLNode child | result.(YAMLNodeNode).getValue() = child | + exists(YAMLNode child | result.(YamlNodeNode).getValue() = child | child = node.getChildNode(childIndex) ) } } + /** DEPRECATED: Alias for YamlNodeNode */ + deprecated class YAMLNodeNode = YamlNodeNode; + /** * A print node representing a `YAMLMapping`. * * Each child of this node aggregates the key and value of a mapping. */ - class YAMLMappingNode extends YAMLNodeNode { + class YamlMappingNode extends YamlNodeNode { override YAMLMapping node; override PrintAstNode getChild(int childIndex) { - exists(YAMLMappingMapNode map | map = result | map.maps(node, childIndex)) + exists(YamlMappingMapNode map | map = result | map.maps(node, childIndex)) } } + /** DEPRECATED: Alias for YamlMappingNode */ + deprecated class YAMLMappingNode = YamlMappingNode; + /** * A print node representing the `i`th mapping in `mapping`. */ - class YAMLMappingMapNode extends PrintAstNode, TYAMLMappingNode { + class YamlMappingMapNode extends PrintAstNode, TYamlMappingNode { YAMLMapping mapping; int i; - YAMLMappingMapNode() { this = TYAMLMappingNode(mapping, i) } + YamlMappingMapNode() { this = TYamlMappingNode(mapping, i) } override string toString() { result = "(Mapping " + i + ")" and not exists(mapping.getKeyNode(i).(YAMLScalar).getValue()) @@ -667,24 +691,30 @@ module PrintYAML { } override PrintAstNode getChild(int childIndex) { - childIndex = 0 and result.(YAMLNodeNode).getValue() = mapping.getKeyNode(i) + childIndex = 0 and result.(YamlNodeNode).getValue() = mapping.getKeyNode(i) or - childIndex = 1 and result.(YAMLNodeNode).getValue() = mapping.getValueNode(i) + childIndex = 1 and result.(YamlNodeNode).getValue() = mapping.getValueNode(i) } } + + /** DEPRECATED: Alias for YamlMappingMapNode */ + deprecated class YAMLMappingMapNode = YamlMappingMapNode; } +/** DEPRECATED: Alias for PrintYaml */ +deprecated module PrintYAML = PrintYaml; + /** * Classes for printing HTML AST. */ -module PrintHTML { +module PrintHtml { /** * A print node representing an HTML node in a .html file. */ - class HTMLElementNode extends PrintAstNode, THTMLElementNode { + class HtmlElementNode extends PrintAstNode, THtmlElementNode { HTML::Element element; - HTMLElementNode() { this = THTMLElementNode(element) } + HtmlElementNode() { this = THtmlElementNode(element) } override string toString() { result = getQlClass(element) + "<" + element.getName() + " ..." } @@ -696,36 +726,42 @@ module PrintHTML { final HTML::Element getElement() { result = element } override PrintAstNode getChild(int childIndex) { - childIndex = -1 and result.(HTMLAttributesNodes).getElement() = element + childIndex = -1 and result.(HtmlAttributesNodes).getElement() = element or - exists(HTML::Element child | result.(HTMLElementNode).getElement() = child | + exists(HTML::Element child | result.(HtmlElementNode).getElement() = child | child = element.getChild(childIndex) ) } } + /** DEPRECATED: Alias for HtmlElementNode */ + deprecated class HTMLElementNode = HtmlElementNode; + /** * A print node representing an HTML node in a .html file. */ - class HTMLScriptElementNode extends HTMLElementNode { + class HtmlScriptElementNode extends HtmlElementNode { override HTML::ScriptElement element; override PrintAstNode getChild(int childIndex) { - childIndex = -200 and result.(HTMLScript).getScript() = element.getScript() + childIndex = -200 and result.(HtmlScript).getScript() = element.getScript() or result = super.getChild(childIndex) } } + /** DEPRECATED: Alias for HtmlScriptElementNode */ + deprecated class HTMLScriptElementNode = HtmlScriptElementNode; + /** * A print node representing the code inside a `