Merge pull request #10531 from github/nickrolfe/title-case

Ruby: use consistent capitalization with `import ... as`
This commit is contained in:
Nick Rolfe
2022-09-22 12:05:44 +01:00
committed by GitHub
9 changed files with 103 additions and 103 deletions

View File

@@ -4,7 +4,7 @@ private import codeql.ruby.ast.internal.Call
private import codeql.ruby.ast.internal.Parameter
private import codeql.ruby.ast.internal.Pattern
private import codeql.ruby.ast.internal.Variable
private import codeql.ruby.AST as AST
private import codeql.ruby.AST as Ast
private import Synthesis
module MethodName {
@@ -20,7 +20,7 @@ module MethodName {
@ruby_token_operator;
}
private predicate mkSynthChild(SynthKind kind, AST::AstNode parent, int i) {
private predicate mkSynthChild(SynthKind kind, Ast::AstNode parent, int i) {
any(Synthesis s).child(parent, i, SynthChild(kind))
}
@@ -29,7 +29,7 @@ private module Cached {
cached
newtype TAstNode =
TAddExprReal(Ruby::Binary g) { g instanceof @ruby_binary_plus } or
TAddExprSynth(AST::AstNode parent, int i) { mkSynthChild(AddExprKind(), parent, i) } or
TAddExprSynth(Ast::AstNode parent, int i) { mkSynthChild(AddExprKind(), parent, i) } or
TAliasStmt(Ruby::Alias g) or
TAlternativePattern(Ruby::AlternativePattern g) or
TArgumentList(Ruby::AstNode g) {
@@ -62,7 +62,7 @@ private module Cached {
g instanceof @ruby_operator_assignment_starstarequal
} or
TAssignExprReal(Ruby::Assignment g) or
TAssignExprSynth(AST::AstNode parent, int i) { mkSynthChild(AssignExprKind(), parent, i) } or
TAssignExprSynth(Ast::AstNode parent, int i) { mkSynthChild(AssignExprKind(), parent, i) } or
TAssignLShiftExpr(Ruby::OperatorAssignment g) {
g instanceof @ruby_operator_assignment_langlelangleequal
} or
@@ -86,18 +86,18 @@ private module Cached {
TBeginBlock(Ruby::BeginBlock g) or
TBeginExpr(Ruby::Begin g) or
TBitwiseAndExprReal(Ruby::Binary g) { g instanceof @ruby_binary_ampersand } or
TBitwiseAndExprSynth(AST::AstNode parent, int i) {
TBitwiseAndExprSynth(Ast::AstNode parent, int i) {
mkSynthChild(BitwiseAndExprKind(), parent, i)
} or
TBitwiseOrExprReal(Ruby::Binary g) { g instanceof @ruby_binary_pipe } or
TBitwiseOrExprSynth(AST::AstNode parent, int i) { mkSynthChild(BitwiseOrExprKind(), parent, i) } or
TBitwiseOrExprSynth(Ast::AstNode parent, int i) { mkSynthChild(BitwiseOrExprKind(), parent, i) } or
TBitwiseXorExprReal(Ruby::Binary g) { g instanceof @ruby_binary_caret } or
TBitwiseXorExprSynth(AST::AstNode parent, int i) {
TBitwiseXorExprSynth(Ast::AstNode parent, int i) {
mkSynthChild(BitwiseXorExprKind(), parent, i)
} or
TBlockArgument(Ruby::BlockArgument g) or
TBlockParameter(Ruby::BlockParameter g) or
TBraceBlockSynth(AST::AstNode parent, int i) { mkSynthChild(BraceBlockKind(), parent, i) } or
TBraceBlockSynth(Ast::AstNode parent, int i) { mkSynthChild(BraceBlockKind(), parent, i) } or
TBraceBlockReal(Ruby::Block g) { not g.getParent() instanceof Ruby::Lambda } or
TBreakStmt(Ruby::Break g) or
TCaseEqExpr(Ruby::Binary g) { g instanceof @ruby_binary_equalequalequal } or
@@ -105,15 +105,15 @@ private module Cached {
TCaseMatch(Ruby::CaseMatch g) or
TCharacterLiteral(Ruby::Character g) or
TClassDeclaration(Ruby::Class g) or
TClassVariableAccessReal(Ruby::ClassVariable g, AST::ClassVariable v) {
TClassVariableAccessReal(Ruby::ClassVariable g, Ast::ClassVariable v) {
ClassVariableAccess::range(g, v)
} or
TClassVariableAccessSynth(AST::AstNode parent, int i, AST::ClassVariable v) {
TClassVariableAccessSynth(Ast::AstNode parent, int i, Ast::ClassVariable v) {
mkSynthChild(ClassVariableAccessKind(v), parent, i)
} or
TComplementExpr(Ruby::Unary g) { g instanceof @ruby_unary_tilde } or
TComplexLiteral(Ruby::Complex g) or
TConstantReadAccessSynth(AST::AstNode parent, int i, string value) {
TConstantReadAccessSynth(Ast::AstNode parent, int i, string value) {
mkSynthChild(ConstantReadAccessKind(value), parent, i)
} or
TDefinedExpr(Ruby::Unary g) { g instanceof @ruby_unary_definedquestion } or
@@ -122,7 +122,7 @@ private module Cached {
not strictcount(int i | exists(g.getParent().(Ruby::LeftAssignmentList).getChild(i))) = 1
} or
TDivExprReal(Ruby::Binary g) { g instanceof @ruby_binary_slash } or
TDivExprSynth(AST::AstNode parent, int i) { mkSynthChild(DivExprKind(), parent, i) } or
TDivExprSynth(Ast::AstNode parent, int i) { mkSynthChild(DivExprKind(), parent, i) } or
TDo(Ruby::Do g) or
TDoBlock(Ruby::DoBlock g) { not g.getParent() instanceof Ruby::Lambda } or
TElementReference(Ruby::ElementReference g) or
@@ -134,7 +134,7 @@ private module Cached {
TEnsure(Ruby::Ensure g) or
TEqExpr(Ruby::Binary g) { g instanceof @ruby_binary_equalequal } or
TExponentExprReal(Ruby::Binary g) { g instanceof @ruby_binary_starstar } or
TExponentExprSynth(AST::AstNode parent, int i) { mkSynthChild(ExponentExprKind(), parent, i) } or
TExponentExprSynth(Ast::AstNode parent, int i) { mkSynthChild(ExponentExprKind(), parent, i) } or
TFalseLiteral(Ruby::False g) or
TFile(Ruby::File g) or
TFindPattern(Ruby::FindPattern g) or
@@ -146,10 +146,10 @@ private module Cached {
TForwardArgument(Ruby::ForwardArgument g) or
TGEExpr(Ruby::Binary g) { g instanceof @ruby_binary_rangleequal } or
TGTExpr(Ruby::Binary g) { g instanceof @ruby_binary_rangle } or
TGlobalVariableAccessReal(Ruby::GlobalVariable g, AST::GlobalVariable v) {
TGlobalVariableAccessReal(Ruby::GlobalVariable g, Ast::GlobalVariable v) {
GlobalVariableAccess::range(g, v)
} or
TGlobalVariableAccessSynth(AST::AstNode parent, int i, AST::GlobalVariable v) {
TGlobalVariableAccessSynth(Ast::AstNode parent, int i, Ast::GlobalVariable v) {
mkSynthChild(GlobalVariableAccessKind(v), parent, i)
} or
THashKeySymbolLiteral(Ruby::HashKeySymbol g) or
@@ -163,25 +163,25 @@ private module Cached {
THereDoc(Ruby::HeredocBeginning g) or
TIdentifierMethodCall(Ruby::Identifier g) { isIdentifierMethodCall(g) } or
TIfReal(Ruby::If g) or
TIfSynth(AST::AstNode parent, int i) { mkSynthChild(IfKind(), parent, i) } or
TIfSynth(Ast::AstNode parent, int i) { mkSynthChild(IfKind(), parent, i) } or
TIfModifierExpr(Ruby::IfModifier g) or
TInClause(Ruby::InClause g) or
TInstanceVariableAccessReal(Ruby::InstanceVariable g, AST::InstanceVariable v) {
TInstanceVariableAccessReal(Ruby::InstanceVariable g, Ast::InstanceVariable v) {
InstanceVariableAccess::range(g, v)
} or
TInstanceVariableAccessSynth(AST::AstNode parent, int i, AST::InstanceVariable v) {
TInstanceVariableAccessSynth(Ast::AstNode parent, int i, Ast::InstanceVariable v) {
mkSynthChild(InstanceVariableAccessKind(v), parent, i)
} or
TIntegerLiteralReal(Ruby::Integer g) {
not any(Ruby::Complex r).getChild() = g and not any(Ruby::Rational r).getChild() = g
} or
TIntegerLiteralSynth(AST::AstNode parent, int i, int value) {
TIntegerLiteralSynth(Ast::AstNode parent, int i, int value) {
mkSynthChild(IntegerLiteralKind(value), parent, i)
} or
TKeywordParameter(Ruby::KeywordParameter g) or
TLEExpr(Ruby::Binary g) { g instanceof @ruby_binary_langleequal } or
TLShiftExprReal(Ruby::Binary g) { g instanceof @ruby_binary_langlelangle } or
TLShiftExprSynth(AST::AstNode parent, int i) { mkSynthChild(LShiftExprKind(), parent, i) } or
TLShiftExprSynth(Ast::AstNode parent, int i) { mkSynthChild(LShiftExprKind(), parent, i) } or
TLTExpr(Ruby::Binary g) { g instanceof @ruby_binary_langle } or
TLambda(Ruby::Lambda g) or
TLine(Ruby::Line g) or
@@ -189,7 +189,7 @@ private module Cached {
TLocalVariableAccessReal(Ruby::Identifier g, TLocalVariableReal v) {
LocalVariableAccess::range(g, v)
} or
TLocalVariableAccessSynth(AST::AstNode parent, int i, AST::LocalVariable v) {
TLocalVariableAccessSynth(Ast::AstNode parent, int i, Ast::LocalVariable v) {
mkSynthChild(LocalVariableAccessRealKind(v), parent, i)
or
mkSynthChild(LocalVariableAccessSynthKind(v), parent, i)
@@ -197,26 +197,26 @@ private module Cached {
TLogicalAndExprReal(Ruby::Binary g) {
g instanceof @ruby_binary_and or g instanceof @ruby_binary_ampersandampersand
} or
TLogicalAndExprSynth(AST::AstNode parent, int i) {
TLogicalAndExprSynth(Ast::AstNode parent, int i) {
mkSynthChild(LogicalAndExprKind(), parent, i)
} or
TLogicalOrExprReal(Ruby::Binary g) {
g instanceof @ruby_binary_or or g instanceof @ruby_binary_pipepipe
} or
TLogicalOrExprSynth(AST::AstNode parent, int i) { mkSynthChild(LogicalOrExprKind(), parent, i) } or
TLogicalOrExprSynth(Ast::AstNode parent, int i) { mkSynthChild(LogicalOrExprKind(), parent, i) } or
TMethod(Ruby::Method g) or
TMethodCallSynth(AST::AstNode parent, int i, string name, boolean setter, int arity) {
TMethodCallSynth(Ast::AstNode parent, int i, string name, boolean setter, int arity) {
mkSynthChild(MethodCallKind(name, setter, arity), parent, i)
} or
TModuleDeclaration(Ruby::Module g) or
TModuloExprReal(Ruby::Binary g) { g instanceof @ruby_binary_percent } or
TModuloExprSynth(AST::AstNode parent, int i) { mkSynthChild(ModuloExprKind(), parent, i) } or
TModuloExprSynth(Ast::AstNode parent, int i) { mkSynthChild(ModuloExprKind(), parent, i) } or
TMulExprReal(Ruby::Binary g) { g instanceof @ruby_binary_star } or
TMulExprSynth(AST::AstNode parent, int i) { mkSynthChild(MulExprKind(), parent, i) } or
TMulExprSynth(Ast::AstNode parent, int i) { mkSynthChild(MulExprKind(), parent, i) } or
TNEExpr(Ruby::Binary g) { g instanceof @ruby_binary_bangequal } or
TNextStmt(Ruby::Next g) or
TNilLiteralReal(Ruby::Nil g) or
TNilLiteralSynth(AST::AstNode parent, int i) { mkSynthChild(NilLiteralKind(), parent, i) } or
TNilLiteralSynth(Ast::AstNode parent, int i) { mkSynthChild(NilLiteralKind(), parent, i) } or
TNoRegExpMatchExpr(Ruby::Binary g) { g instanceof @ruby_binary_bangtilde } or
TNotExpr(Ruby::Unary g) { g instanceof @ruby_unary_bang or g instanceof @ruby_unary_not } or
TOptionalParameter(Ruby::OptionalParameter g) or
@@ -224,9 +224,9 @@ private module Cached {
TParenthesizedExpr(Ruby::ParenthesizedStatements g) or
TParenthesizedPattern(Ruby::ParenthesizedPattern g) or
TRShiftExprReal(Ruby::Binary g) { g instanceof @ruby_binary_ranglerangle } or
TRShiftExprSynth(AST::AstNode parent, int i) { mkSynthChild(RShiftExprKind(), parent, i) } or
TRShiftExprSynth(Ast::AstNode parent, int i) { mkSynthChild(RShiftExprKind(), parent, i) } or
TRangeLiteralReal(Ruby::Range g) or
TRangeLiteralSynth(AST::AstNode parent, int i, boolean inclusive) {
TRangeLiteralSynth(Ast::AstNode parent, int i, boolean inclusive) {
mkSynthChild(RangeLiteralKind(inclusive), parent, i)
} or
TRationalLiteral(Ruby::Rational g) { not any(Ruby::Complex r).getChild() = g } or
@@ -255,11 +255,11 @@ private module Cached {
)
} or
TSelfReal(Ruby::Self g) or
TSelfSynth(AST::AstNode parent, int i, AST::SelfVariable v) {
TSelfSynth(Ast::AstNode parent, int i, Ast::SelfVariable v) {
mkSynthChild(SelfKind(v), parent, i)
} or
TSimpleParameterReal(Ruby::Identifier g) { g instanceof Parameter::Range } or
TSimpleParameterSynth(AST::AstNode parent, int i) {
TSimpleParameterSynth(Ast::AstNode parent, int i) {
mkSynthChild(SimpleParameterKind(), parent, i)
} or
TSimpleSymbolLiteral(Ruby::SimpleSymbol g) or
@@ -267,12 +267,12 @@ private module Cached {
TSingletonMethod(Ruby::SingletonMethod g) or
TSpaceshipExpr(Ruby::Binary g) { g instanceof @ruby_binary_langleequalrangle } or
TSplatExprReal(Ruby::SplatArgument g) or
TSplatExprSynth(AST::AstNode parent, int i) { mkSynthChild(SplatExprKind(), parent, i) } or
TSplatExprSynth(Ast::AstNode parent, int i) { mkSynthChild(SplatExprKind(), parent, i) } or
TSplatParameter(Ruby::SplatParameter g) {
not g.getParent() instanceof Ruby::ArrayPattern and
not g.getParent() instanceof Ruby::FindPattern
} or
TStmtSequenceSynth(AST::AstNode parent, int i) { mkSynthChild(StmtSequenceKind(), parent, i) } or
TStmtSequenceSynth(Ast::AstNode parent, int i) { mkSynthChild(StmtSequenceKind(), parent, i) } or
TStringArrayLiteral(Ruby::StringArray g) or
TStringConcatenation(Ruby::ChainedString g) or
TStringEscapeSequenceComponentNonRegexp(Ruby::EscapeSequence g) {
@@ -298,7 +298,7 @@ private module Cached {
g.getParent() instanceof Ruby::Regex
} or
TSubExprReal(Ruby::Binary g) { g instanceof @ruby_binary_minus } or
TSubExprSynth(AST::AstNode parent, int i) { mkSynthChild(SubExprKind(), parent, i) } or
TSubExprSynth(Ast::AstNode parent, int i) { mkSynthChild(SubExprKind(), parent, i) } or
TSubshellLiteral(Ruby::Subshell g) or
TSymbolArrayLiteral(Ruby::SymbolArray g) or
TTernaryIfExpr(Ruby::Conditional g) or
@@ -548,7 +548,7 @@ private module Cached {
/** Gets the `i`th synthesized child of `parent`. */
cached
AST::AstNode getSynthChild(AST::AstNode parent, int i) {
Ast::AstNode getSynthChild(Ast::AstNode parent, int i) {
result = TAddExprSynth(parent, i)
or
result = TAssignExprSynth(parent, i)
@@ -613,7 +613,7 @@ private module Cached {
* `child` (or both) is a synthesized node.
*/
cached
predicate synthChild(AST::AstNode parent, int i, AST::AstNode child) {
predicate synthChild(Ast::AstNode parent, int i, Ast::AstNode child) {
child = getSynthChild(parent, i)
or
any(Synthesis s).child(parent, i, RealChildRef(child))
@@ -626,18 +626,18 @@ private module Cached {
* nodes.
*/
cached
Ruby::AstNode toGeneratedInclSynth(AST::AstNode n) {
Ruby::AstNode toGeneratedInclSynth(Ast::AstNode n) {
result = toGenerated(n)
or
not exists(toGenerated(n)) and
exists(AST::AstNode parent |
exists(Ast::AstNode parent |
synthChild(parent, _, n) and
result = toGeneratedInclSynth(parent)
)
}
cached
Location getLocation(AST::AstNode n) {
Location getLocation(Ast::AstNode n) {
synthLocation(n, result)
or
n.isSynthesized() and
@@ -648,12 +648,12 @@ private module Cached {
}
cached
predicate lhsExpr(AST::Expr e) {
predicate lhsExpr(Ast::Expr e) {
explicitAssignmentNode(toGenerated(e), _)
or
implicitAssignmentNode(toGenerated(e))
or
e = getSynthChild(any(AST::AssignExpr ae), 0)
e = getSynthChild(any(Ast::AssignExpr ae), 0)
}
}

View File

@@ -3,7 +3,7 @@ private import ControlFlowGraphImpl as Impl
private import Completion as Comp
private import codeql.ruby.ast.internal.Synthesis
private import Splitting as Splitting
private import codeql.ruby.CFG as CFG
private import codeql.ruby.CFG as Cfg
/** The base class for `ControlFlowTree`. */
class ControlFlowTreeBase extends RB::AstNode {
@@ -29,7 +29,7 @@ predicate completionIsSimple(Completion c) { c instanceof Comp::SimpleCompletion
/** Holds if `c` is a valid completion for `e`. */
predicate completionIsValidFor(Completion c, ControlFlowElement e) { c.isValidFor(e) }
class CfgScope = CFG::CfgScope;
class CfgScope = Cfg::CfgScope;
predicate getCfgScope = Impl::getCfgScope/1;
@@ -50,7 +50,7 @@ class SplitKindBase = Splitting::TSplitKind;
class Split = Splitting::Split;
class SuccessorType = CFG::SuccessorType;
class SuccessorType = Cfg::SuccessorType;
/** Gets a successor type that matches completion `c`. */
SuccessorType getAMatchingSuccessorType(Completion c) { result = c.getAMatchingSuccessorType() }
@@ -60,15 +60,15 @@ SuccessorType getAMatchingSuccessorType(Completion c) { result = c.getAMatchingS
* expression.
*/
predicate successorTypeIsSimple(SuccessorType t) {
t instanceof CFG::SuccessorTypes::NormalSuccessor
t instanceof Cfg::SuccessorTypes::NormalSuccessor
}
/** Holds if `t` is an abnormal exit type out of a CFG scope. */
predicate isAbnormalExitType(SuccessorType t) {
t instanceof CFG::SuccessorTypes::RaiseSuccessor or
t instanceof CFG::SuccessorTypes::ExitSuccessor
t instanceof Cfg::SuccessorTypes::RaiseSuccessor or
t instanceof Cfg::SuccessorTypes::ExitSuccessor
}
class Location = RB::Location;
class Node = CFG::CfgNode;
class Node = Cfg::CfgNode;

View File

@@ -1,8 +1,8 @@
private import codeql.ssa.Ssa as SsaImplCommon
private import codeql.ruby.AST
private import codeql.ruby.CFG as CFG
private import codeql.ruby.CFG as Cfg
private import codeql.ruby.ast.Variable
private import CFG::CfgNodes::ExprNodes
private import Cfg::CfgNodes::ExprNodes
private module SsaInput implements SsaImplCommon::InputSig {
private import codeql.ruby.controlflow.BasicBlocks as BasicBlocks
@@ -59,14 +59,14 @@ private module SsaInput implements SsaImplCommon::InputSig {
import SsaImplCommon::Make<SsaInput>
/** Holds if `v` is uninitialized at index `i` in entry block `bb`. */
predicate uninitializedWrite(CFG::EntryBasicBlock bb, int i, LocalVariable v) {
predicate uninitializedWrite(Cfg::EntryBasicBlock bb, int i, LocalVariable v) {
v.getDeclaringScope() = bb.getScope() and
i = -1
}
/** Holds if `bb` contains a caputured read of variable `v`. */
pragma[noinline]
private predicate hasCapturedVariableRead(CFG::BasicBlock bb, LocalVariable v) {
private predicate hasCapturedVariableRead(Cfg::BasicBlock bb, LocalVariable v) {
exists(LocalVariableReadAccess read |
read = bb.getANode().getNode() and
read.isCapturedAccess() and
@@ -76,7 +76,7 @@ private predicate hasCapturedVariableRead(CFG::BasicBlock bb, LocalVariable v) {
/** Holds if `bb` contains a caputured write to variable `v`. */
pragma[noinline]
private predicate writesCapturedVariable(CFG::BasicBlock bb, LocalVariable v) {
private predicate writesCapturedVariable(Cfg::BasicBlock bb, LocalVariable v) {
exists(LocalVariableWriteAccess write |
write = bb.getANode().getNode() and
write.isCapturedAccess() and
@@ -88,7 +88,7 @@ private predicate writesCapturedVariable(CFG::BasicBlock bb, LocalVariable v) {
* Holds if a pseudo read of captured variable `v` should be inserted
* at index `i` in exit block `bb`.
*/
private predicate capturedExitRead(CFG::AnnotatedExitBasicBlock bb, int i, LocalVariable v) {
private predicate capturedExitRead(Cfg::AnnotatedExitBasicBlock bb, int i, LocalVariable v) {
bb.isNormal() and
writesCapturedVariable(bb.getAPredecessor*(), v) and
i = bb.length()
@@ -99,7 +99,7 @@ private predicate capturedExitRead(CFG::AnnotatedExitBasicBlock bb, int i, Local
* or inside a (transitively) nested scope of `scope`.
*/
pragma[noinline]
private predicate hasCapturedRead(Variable v, CFG::CfgScope scope) {
private predicate hasCapturedRead(Variable v, Cfg::CfgScope scope) {
any(LocalVariableReadAccess read |
read.getVariable() = v and scope = read.getCfgScope().getOuterCfgScope*()
).isCapturedAccess()
@@ -110,14 +110,14 @@ private predicate hasCapturedRead(Variable v, CFG::CfgScope scope) {
* outer scope of `scope`.
*/
pragma[noinline]
private predicate variableWriteInOuterScope(CFG::BasicBlock bb, LocalVariable v, CFG::CfgScope scope) {
private predicate variableWriteInOuterScope(Cfg::BasicBlock bb, LocalVariable v, Cfg::CfgScope scope) {
SsaInput::variableWrite(bb, _, v, _) and
scope.getOuterCfgScope() = bb.getScope()
}
pragma[noinline]
private predicate hasVariableWriteWithCapturedRead(
CFG::BasicBlock bb, LocalVariable v, CFG::CfgScope scope
Cfg::BasicBlock bb, LocalVariable v, Cfg::CfgScope scope
) {
hasCapturedRead(v, scope) and
variableWriteInOuterScope(bb, v, scope)
@@ -127,8 +127,8 @@ private predicate hasVariableWriteWithCapturedRead(
* Holds if the call `call` at index `i` in basic block `bb` may reach
* a callable that reads captured variable `v`.
*/
private predicate capturedCallRead(CallCfgNode call, CFG::BasicBlock bb, int i, LocalVariable v) {
exists(CFG::CfgScope scope |
private predicate capturedCallRead(CallCfgNode call, Cfg::BasicBlock bb, int i, LocalVariable v) {
exists(Cfg::CfgScope scope |
hasVariableWriteWithCapturedRead(bb.getAPredecessor*(), v, scope) and
call = bb.getNode(i)
|
@@ -141,7 +141,7 @@ private predicate capturedCallRead(CallCfgNode call, CFG::BasicBlock bb, int i,
}
/** Holds if `v` is read at index `i` in basic block `bb`. */
private predicate variableReadActual(CFG::BasicBlock bb, int i, LocalVariable v) {
private predicate variableReadActual(Cfg::BasicBlock bb, int i, LocalVariable v) {
exists(VariableReadAccess read |
read.getVariable() = v and
read = bb.getNode(i).getNode()
@@ -153,7 +153,7 @@ private predicate variableReadActual(CFG::BasicBlock bb, int i, LocalVariable v)
* or inside a (transitively) nested scope of `scope`.
*/
pragma[noinline]
private predicate hasCapturedWrite(Variable v, CFG::CfgScope scope) {
private predicate hasCapturedWrite(Variable v, Cfg::CfgScope scope) {
any(LocalVariableWriteAccess write |
write.getVariable() = v and scope = write.getCfgScope().getOuterCfgScope*()
).isCapturedAccess()
@@ -165,7 +165,7 @@ private predicate hasCapturedWrite(Variable v, CFG::CfgScope scope) {
*/
pragma[noinline]
private predicate variableReadActualInOuterScope(
CFG::BasicBlock bb, LocalVariable v, CFG::CfgScope scope
Cfg::BasicBlock bb, LocalVariable v, Cfg::CfgScope scope
) {
variableReadActual(bb, _, v) and
bb.getScope() = scope.getOuterCfgScope()
@@ -173,7 +173,7 @@ private predicate variableReadActualInOuterScope(
pragma[noinline]
private predicate hasVariableReadWithCapturedWrite(
CFG::BasicBlock bb, LocalVariable v, CFG::CfgScope scope
Cfg::BasicBlock bb, LocalVariable v, Cfg::CfgScope scope
) {
hasCapturedWrite(v, scope) and
variableReadActualInOuterScope(bb, v, scope)
@@ -186,7 +186,7 @@ private module Cached {
* `i` in entry block `bb`.
*/
cached
predicate capturedEntryWrite(CFG::EntryBasicBlock bb, int i, LocalVariable v) {
predicate capturedEntryWrite(Cfg::EntryBasicBlock bb, int i, LocalVariable v) {
hasCapturedVariableRead(bb.getASuccessor*(), v) and
i = -1
}
@@ -196,8 +196,8 @@ private module Cached {
* that writes captured variable `v`.
*/
cached
predicate capturedCallWrite(CallCfgNode call, CFG::BasicBlock bb, int i, LocalVariable v) {
exists(CFG::CfgScope scope |
predicate capturedCallWrite(CallCfgNode call, Cfg::BasicBlock bb, int i, LocalVariable v) {
exists(Cfg::CfgScope scope |
hasVariableReadWithCapturedWrite(bb.getASuccessor*(), v, scope) and
call = bb.getNode(i)
|
@@ -215,7 +215,7 @@ private module Cached {
*/
cached
predicate variableWriteActual(
CFG::BasicBlock bb, int i, LocalVariable v, VariableWriteAccess write
Cfg::BasicBlock bb, int i, LocalVariable v, VariableWriteAccess write
) {
exists(AstNode n |
write.getVariable() = v and
@@ -230,7 +230,7 @@ private module Cached {
cached
VariableReadAccessCfgNode getARead(Definition def) {
exists(LocalVariable v, CFG::BasicBlock bb, int i |
exists(LocalVariable v, Cfg::BasicBlock bb, int i |
ssaDefReachesRead(v, def, bb, i) and
variableReadActual(bb, i, v) and
result = bb.getNode(i)
@@ -239,9 +239,9 @@ private module Cached {
pragma[noinline]
private predicate defReachesCallReadInOuterScope(
Definition def, CallCfgNode call, LocalVariable v, CFG::CfgScope scope
Definition def, CallCfgNode call, LocalVariable v, Cfg::CfgScope scope
) {
exists(CFG::BasicBlock bb, int i |
exists(Cfg::BasicBlock bb, int i |
ssaDefReachesRead(v, def, bb, i) and
capturedCallRead(call, bb, i, v) and
scope.getOuterCfgScope() = bb.getScope()
@@ -249,8 +249,8 @@ private module Cached {
}
pragma[noinline]
private predicate hasCapturedEntryWrite(Definition entry, LocalVariable v, CFG::CfgScope scope) {
exists(CFG::BasicBlock bb, int i |
private predicate hasCapturedEntryWrite(Definition entry, LocalVariable v, Cfg::CfgScope scope) {
exists(Cfg::BasicBlock bb, int i |
capturedEntryWrite(bb, i, v) and
entry.definesAt(v, bb, i) and
bb.getScope().getOuterCfgScope*() = scope
@@ -268,7 +268,7 @@ private module Cached {
*/
cached
predicate captureFlowIn(CallCfgNode call, Definition def, Definition entry) {
exists(LocalVariable v, CFG::CfgScope scope |
exists(LocalVariable v, Cfg::CfgScope scope |
defReachesCallReadInOuterScope(def, call, v, scope) and
hasCapturedEntryWrite(entry, v, scope)
|
@@ -284,9 +284,9 @@ private module Cached {
pragma[noinline]
private predicate defReachesExitReadInInnerScope(
Definition def, LocalVariable v, CFG::CfgScope scope
Definition def, LocalVariable v, Cfg::CfgScope scope
) {
exists(CFG::BasicBlock bb, int i |
exists(Cfg::BasicBlock bb, int i |
ssaDefReachesRead(v, def, bb, i) and
capturedExitRead(bb, i, v) and
scope = bb.getScope().getOuterCfgScope*()
@@ -295,9 +295,9 @@ private module Cached {
pragma[noinline]
private predicate hasCapturedExitRead(
Definition exit, CallCfgNode call, LocalVariable v, CFG::CfgScope scope
Definition exit, CallCfgNode call, LocalVariable v, Cfg::CfgScope scope
) {
exists(CFG::BasicBlock bb, int i |
exists(Cfg::BasicBlock bb, int i |
capturedCallWrite(call, bb, i, v) and
exit.definesAt(v, bb, i) and
bb.getScope() = scope.getOuterCfgScope()
@@ -316,7 +316,7 @@ private module Cached {
*/
cached
predicate captureFlowOut(CallCfgNode call, Definition def, Definition exit) {
exists(LocalVariable v, CFG::CfgScope scope |
exists(LocalVariable v, Cfg::CfgScope scope |
defReachesExitReadInInnerScope(def, v, scope) and
hasCapturedExitRead(exit, call, v, _)
|
@@ -329,7 +329,7 @@ private module Cached {
}
cached
Definition phiHasInputFromBlock(PhiNode phi, CFG::BasicBlock bb) {
Definition phiHasInputFromBlock(PhiNode phi, Cfg::BasicBlock bb) {
phiHasInputFromBlock(phi, result, bb)
}
@@ -339,7 +339,7 @@ private module Cached {
*/
cached
predicate firstRead(Definition def, VariableReadAccessCfgNode read) {
exists(CFG::BasicBlock bb1, int i1, CFG::BasicBlock bb2, int i2 |
exists(Cfg::BasicBlock bb1, int i1, Cfg::BasicBlock bb2, int i2 |
def.definesAt(_, bb1, i1) and
adjacentDefNoUncertainReads(def, bb1, i1, bb2, i2) and
read = bb2.getNode(i2)
@@ -355,7 +355,7 @@ private module Cached {
predicate adjacentReadPair(
Definition def, VariableReadAccessCfgNode read1, VariableReadAccessCfgNode read2
) {
exists(CFG::BasicBlock bb1, int i1, CFG::BasicBlock bb2, int i2 |
exists(Cfg::BasicBlock bb1, int i1, Cfg::BasicBlock bb2, int i2 |
read1 = bb1.getNode(i1) and
variableReadActual(bb1, i1, _) and
adjacentDefNoUncertainReads(def, bb1, i1, bb2, i2) and
@@ -370,7 +370,7 @@ private module Cached {
*/
cached
predicate lastRead(Definition def, VariableReadAccessCfgNode read) {
exists(CFG::BasicBlock bb, int i |
exists(Cfg::BasicBlock bb, int i |
lastRefNoUncertainReads(def, bb, i) and
variableReadActual(bb, i, _) and
read = bb.getNode(i)
@@ -385,7 +385,7 @@ private module Cached {
* The reference is either a read of `def` or `def` itself.
*/
cached
predicate lastRefBeforeRedef(Definition def, CFG::BasicBlock bb, int i, Definition next) {
predicate lastRefBeforeRedef(Definition def, Cfg::BasicBlock bb, int i, Definition next) {
lastRefRedefNoUncertainReads(def, bb, i, next)
}

View File

@@ -2,7 +2,7 @@
private import internal.ParseRegExp
private import codeql.NumberUtils
private import codeql.ruby.ast.Literal as AST
private import codeql.ruby.ast.Literal as Ast
private import codeql.Locations
/**
@@ -1146,6 +1146,6 @@ class RegExpNamedCharacterProperty extends RegExpTerm, TRegExpNamedCharacterProp
}
/** Gets the parse tree resulting from parsing `re`, if such has been constructed. */
RegExpTerm getParsedRegExp(AST::RegExpLiteral re) {
RegExpTerm getParsedRegExp(Ast::RegExpLiteral re) {
result.getRegExp() = re and result.isRootTerm()
}

View File

@@ -5,7 +5,7 @@
* the `x` (free-spacing) flag.
*/
private import codeql.ruby.AST as AST
private import codeql.ruby.AST as Ast
private import codeql.Locations
/**
@@ -13,7 +13,7 @@ private import codeql.Locations
* a regular expression literal, or a string literal used in a context where
* it is parsed as regular expression.
*/
abstract class RegExp extends AST::StringlikeLiteral {
abstract class RegExp extends Ast::StringlikeLiteral {
/**
* Holds if this `RegExp` has the `s` flag for multi-line matching.
*/
@@ -255,7 +255,7 @@ abstract class RegExp extends AST::StringlikeLiteral {
/** Gets the text of this regex */
string getText() {
exists(AST::ConstantValue c | c = this.getConstantValue() |
exists(Ast::ConstantValue c | c = this.getConstantValue() |
result = [this.getConstantValue().getString(), this.getConstantValue().getRegExp()]
)
}

View File

@@ -6,7 +6,7 @@
private import codeql.ruby.DataFlow
private import codeql.ruby.security.CodeInjectionCustomizations
private import codeql.ruby.AST as AST
private import codeql.ruby.AST as Ast
private import codeql.ruby.controlflow.CfgNodes
/**
@@ -79,7 +79,7 @@ module HardcodedDataInterpretedAsCode {
forex(StringComponentCfgNode c |
c = this.asExpr().(ExprNodes::StringlikeLiteralCfgNode).getAComponent()
|
c.getNode().(AST::StringEscapeSequenceComponent).getRawText().matches("\\x%")
c.getNode().(Ast::StringEscapeSequenceComponent).getRawText().matches("\\x%")
)
}
}
@@ -99,7 +99,7 @@ module HardcodedDataInterpretedAsCode {
private class RequireArgumentSink extends Sink {
RequireArgumentSink() {
exists(DataFlow::CallNode require |
require.getReceiver().getExprNode().getExpr() instanceof AST::SelfVariableAccess and
require.getReceiver().getExprNode().getExpr() instanceof Ast::SelfVariableAccess and
require.getMethodName() = "require"
|
this = require.getArgument(0)

View File

@@ -4,7 +4,7 @@
import codeql.ruby.Regexp
import codeql.Locations
private import codeql.ruby.ast.Literal as AST
private import codeql.ruby.ast.Literal as Ast
/**
* Holds if `term` is an ecape class representing e.g. `\d`.
@@ -30,7 +30,7 @@ predicate isEscapeClass(RegExpTerm term, string clazz) {
* Holds if the regular expression should not be considered.
*/
predicate isExcluded(RegExpParent parent) {
parent.(RegExpTerm).getRegExp().(AST::RegExpLiteral).hasFreeSpacingFlag() // exclude free-spacing mode regexes
parent.(RegExpTerm).getRegExp().(Ast::RegExpLiteral).hasFreeSpacingFlag() // exclude free-spacing mode regexes
}
/**

View File

@@ -4,7 +4,7 @@
* as extension points for adding your own.
*/
private import codeql.ruby.AST as AST
private import codeql.ruby.AST as Ast
private import codeql.ruby.CFG
private import codeql.ruby.DataFlow
private import codeql.ruby.dataflow.RemoteFlowSources
@@ -77,8 +77,8 @@ module PolynomialReDoS {
exists(CfgNodes::ExprNodes::BinaryOperationCfgNode op |
matchNode.asExpr() = op and
(
op.getExpr() instanceof AST::RegExpMatchExpr or
op.getExpr() instanceof AST::NoRegExpMatchExpr
op.getExpr() instanceof Ast::RegExpMatchExpr or
op.getExpr() instanceof Ast::NoRegExpMatchExpr
) and
(
this.asExpr() = op.getLeftOperand() and regexp.asExpr() = op.getRightOperand()
@@ -117,7 +117,7 @@ module PolynomialReDoS {
private predicate lengthGuard(CfgNodes::ExprCfgNode g, CfgNode node, boolean branch) {
exists(DataFlow::Node input, DataFlow::CallNode length, DataFlow::ExprNode operand |
length.asExpr().getExpr().(AST::MethodCall).getMethodName() = "length" and
length.asExpr().getExpr().(Ast::MethodCall).getMethodName() = "length" and
length.getReceiver() = input and
length.flowsTo(operand) and
operand.getExprNode() = g.(CfgNodes::ExprNodes::RelationalOperationCfgNode).getAnOperand() and

View File

@@ -1,6 +1,6 @@
private import codeql.ruby.AST as AST
private import codeql.ruby.CFG as CFG
private import CFG::CfgNodes
private import codeql.ruby.AST as Ast
private import codeql.ruby.CFG as Cfg
private import Cfg::CfgNodes
private import codeql.ruby.dataflow.internal.DataFlowImplCommon as DataFlowImplCommon
private import codeql.ruby.dataflow.internal.DataFlowPublic as DataFlowPublic
private import codeql.ruby.dataflow.internal.DataFlowPrivate as DataFlowPrivate
@@ -61,7 +61,7 @@ private predicate viableParam(
ExprNodes::CallCfgNode call, DataFlowPrivate::ParameterNodeImpl p,
DataFlowDispatch::ParameterPosition ppos
) {
exists(CFG::CfgScope callable |
exists(Cfg::CfgScope callable |
DataFlowDispatch::getTarget(call) = callable and
p.isSourceParameterOf(callable, ppos)
)
@@ -150,7 +150,7 @@ predicate basicStoreStep(Node nodeFrom, Node nodeTo, string content) {
exists(ExprNodes::MethodCallCfgNode call |
content = getSetterCallAttributeName(call.getExpr()) and
nodeTo.(DataFlowPublic::PostUpdateNode).getPreUpdateNode().asExpr() = call.getReceiver() and
call.getExpr() instanceof AST::SetterMethodCall and
call.getExpr() instanceof Ast::SetterMethodCall and
call.getArgument(call.getNumberOfArguments() - 1) =
nodeFrom.(DataFlowPublic::ExprNode).getExprNode()
)
@@ -165,7 +165,7 @@ predicate basicStoreStep(Node nodeFrom, Node nodeTo, string content) {
* foo.bar = 1
* ```
*/
private string getSetterCallAttributeName(AST::SetterMethodCall call) {
private string getSetterCallAttributeName(Ast::SetterMethodCall call) {
// TODO: this should be exposed in `SetterMethodCall`
exists(string setterName |
setterName = call.getMethodName() and result = setterName.prefix(setterName.length() - 1)