Skip to content

Commit 525ed65

Browse files
committed
Rename getNode to getAstNode
1 parent 2f3e526 commit 525ed65

File tree

15 files changed

+60
-48
lines changed

15 files changed

+60
-48
lines changed

ruby/ql/lib/codeql/ruby/ast/Statement.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ private import codeql.ruby.controlflow.internal.ControlFlowGraphImpl as CfgImpl
1212
*/
1313
class Stmt extends AstNode, TStmt {
1414
/** Gets a control-flow node for this statement, if any. */
15-
CfgNodes::AstCfgNode getAControlFlowNode() { result.getNode() = this }
15+
CfgNodes::AstCfgNode getAControlFlowNode() { result.getAstNode() = this }
1616

1717
/** Gets a control-flow entry node for this statement, if any */
1818
AstNode getAControlFlowEntryNode() { result = CfgImpl::getAControlFlowEntryNode(this) }

ruby/ql/lib/codeql/ruby/ast/internal/Constant.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ private module Propagation {
214214
any(StringComponentCfgNode c |
215215
isString(c, result)
216216
or
217-
result = c.getNode().(StringComponentImpl).getValue()
217+
result = c.getAstNode().(StringComponentImpl).getValue()
218218
)
219219
}
220220

ruby/ql/lib/codeql/ruby/controlflow/BasicBlocks.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ private module JoinBlockPredecessors {
389389
private predicate idOf(Ruby::AstNode x, int y) = equivalenceRelation(id/2)(x, y)
390390

391391
int getId(JoinBlockPredecessor jbp) {
392-
idOf(toGeneratedInclSynth(jbp.getFirstNode().(AstCfgNode).getNode()), result)
392+
idOf(toGeneratedInclSynth(jbp.getFirstNode().(AstCfgNode).getAstNode()), result)
393393
or
394394
idOf(toGeneratedInclSynth(jbp.(EntryBasicBlock).getScope()), result)
395395
}

ruby/ql/lib/codeql/ruby/controlflow/CfgNodes.qll

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ExprCfgNode extends AstCfgNode {
4646

4747
Expr e;
4848

49-
ExprCfgNode() { e = this.getNode() }
49+
ExprCfgNode() { e = this.getAstNode() }
5050

5151
/** Gets the underlying expression. */
5252
Expr getExpr() { result = e }
@@ -61,30 +61,32 @@ class ReturningCfgNode extends AstCfgNode {
6161

6262
ReturningStmt s;
6363

64-
ReturningCfgNode() { s = this.getNode() }
64+
ReturningCfgNode() { s = this.getAstNode() }
6565

6666
/** Gets the node of the returned value, if any. */
6767
ExprCfgNode getReturnedValueNode() {
6868
result = this.getAPredecessor() and
69-
result.getNode() = s.getValue()
69+
result.getAstNode() = s.getValue()
7070
}
7171
}
7272

7373
/** A control-flow node that wraps a `StringComponent` AST expression. */
7474
class StringComponentCfgNode extends AstCfgNode {
7575
override string getAPrimaryQlClass() { result = "StringComponentCfgNode" }
7676

77-
StringComponentCfgNode() { this.getNode() instanceof StringComponent }
77+
StringComponentCfgNode() { this.getAstNode() instanceof StringComponent }
7878

7979
/** Gets the constant value of this string component. */
80-
ConstantValue getConstantValue() { result = this.getNode().(StringComponent).getConstantValue() }
80+
ConstantValue getConstantValue() {
81+
result = this.getAstNode().(StringComponent).getConstantValue()
82+
}
8183
}
8284

8385
/** A control-flow node that wraps a `RegExpComponent` AST expression. */
8486
class RegExpComponentCfgNode extends StringComponentCfgNode {
8587
override string getAPrimaryQlClass() { result = "RegExpComponentCfgNode" }
8688

87-
RegExpComponentCfgNode() { this.getNode() instanceof RegExpComponent }
89+
RegExpComponentCfgNode() { this.getAstNode() instanceof RegExpComponent }
8890
}
8991

9092
private AstNode desugar(AstNode n) {
@@ -117,7 +119,7 @@ abstract private class ChildMapping extends AstNode {
117119
cached
118120
predicate hasCfgChild(AstNode child, CfgNode cfn, CfgNode cfnChild) {
119121
this.reachesBasicBlock(child, cfn, cfnChild.getBasicBlock()) and
120-
cfnChild.getNode() = desugar(child)
122+
cfnChild.getAstNode() = desugar(child)
121123
}
122124
}
123125

@@ -134,7 +136,7 @@ abstract private class ExprChildMapping extends Expr, ChildMapping {
134136
exists(BasicBlock mid |
135137
this.reachesBasicBlock(child, cfn, mid) and
136138
bb = mid.getAPredecessor() and
137-
not mid.getANode().getNode() = child
139+
not mid.getANode().getAstNode() = child
138140
)
139141
}
140142
}
@@ -148,13 +150,13 @@ abstract private class NonExprChildMapping extends ChildMapping {
148150
pragma[nomagic]
149151
override predicate reachesBasicBlock(AstNode child, CfgNode cfn, BasicBlock bb) {
150152
this.relevantChild(child) and
151-
cfn.getNode() = this and
153+
cfn.getAstNode() = this and
152154
bb.getANode() = cfn
153155
or
154156
exists(BasicBlock mid |
155157
this.reachesBasicBlock(child, cfn, mid) and
156158
bb = mid.getASuccessor() and
157-
not mid.getANode().getNode() = child
159+
not mid.getANode().getAstNode() = child
158160
)
159161
}
160162
}
@@ -380,7 +382,7 @@ module ExprNodes {
380382
class InClauseCfgNode extends AstCfgNode {
381383
private InClauseChildMapping e;
382384

383-
InClauseCfgNode() { e = this.getNode() }
385+
InClauseCfgNode() { e = this.getAstNode() }
384386

385387
override string getAPrimaryQlClass() { result = "InClauseCfgNode" }
386388

@@ -400,28 +402,28 @@ module ExprNodes {
400402
predicate patternReachesBasicBlock(int i, CfgNode cfnPattern, BasicBlock bb) {
401403
exists(Expr pattern |
402404
pattern = this.getPattern(i) and
403-
cfnPattern.getNode() = pattern and
405+
cfnPattern.getAstNode() = pattern and
404406
bb.getANode() = cfnPattern
405407
)
406408
or
407409
exists(BasicBlock mid |
408410
this.patternReachesBasicBlock(i, cfnPattern, mid) and
409411
bb = mid.getASuccessor() and
410-
not mid.getANode().getNode() = this
412+
not mid.getANode().getAstNode() = this
411413
)
412414
}
413415

414416
predicate bodyReachesBasicBlock(CfgNode cfnBody, BasicBlock bb) {
415417
exists(Stmt body |
416418
body = this.getBody() and
417-
cfnBody.getNode() = body and
419+
cfnBody.getAstNode() = body and
418420
bb.getANode() = cfnBody
419421
)
420422
or
421423
exists(BasicBlock mid |
422424
this.bodyReachesBasicBlock(cfnBody, mid) and
423425
bb = mid.getAPredecessor() and
424-
not mid.getANode().getNode() = this
426+
not mid.getANode().getAstNode() = this
425427
)
426428
}
427429
}
@@ -430,19 +432,19 @@ module ExprNodes {
430432
class WhenClauseCfgNode extends AstCfgNode {
431433
private WhenClauseChildMapping e;
432434

433-
WhenClauseCfgNode() { e = this.getNode() }
435+
WhenClauseCfgNode() { e = this.getAstNode() }
434436

435437
override string getAPrimaryQlClass() { result = "WhenClauseCfgNode" }
436438

437439
/** Gets the body of this `when`-clause. */
438440
final ExprCfgNode getBody() {
439-
result.getNode() = desugar(e.getBody()) and
441+
result.getAstNode() = desugar(e.getBody()) and
440442
e.bodyReachesBasicBlock(result, this.getBasicBlock())
441443
}
442444

443445
/** Gets the `i`th pattern this `when`-clause. */
444446
final ExprCfgNode getPattern(int i) {
445-
result.getNode() = desugar(e.getPattern(i)) and
447+
result.getAstNode() = desugar(e.getPattern(i)) and
446448
e.patternReachesBasicBlock(i, result, this.getBasicBlock())
447449
}
448450
}
@@ -451,7 +453,7 @@ module ExprNodes {
451453
class CasePatternCfgNode extends AstCfgNode {
452454
CasePattern e;
453455

454-
CasePatternCfgNode() { e = this.getNode() }
456+
CasePatternCfgNode() { e = this.getAstNode() }
455457

456458
override string getAPrimaryQlClass() { result = "CasePatternCfgNode" }
457459
}
@@ -815,7 +817,7 @@ module ExprNodes {
815817

816818
/** A control-flow node that wraps an `InstanceVariableReadAccess` AST expression. */
817819
class InstanceVariableReadAccessCfgNode extends InstanceVariableAccessCfgNode {
818-
InstanceVariableReadAccessCfgNode() { this.getNode() instanceof InstanceVariableReadAccess }
820+
InstanceVariableReadAccessCfgNode() { this.getAstNode() instanceof InstanceVariableReadAccess }
819821

820822
override string getAPrimaryQlClass() { result = "InstanceVariableReadAccessCfgNode" }
821823

@@ -824,7 +826,9 @@ module ExprNodes {
824826

825827
/** A control-flow node that wraps an `InstanceVariableWriteAccess` AST expression. */
826828
class InstanceVariableWriteAccessCfgNode extends InstanceVariableAccessCfgNode {
827-
InstanceVariableWriteAccessCfgNode() { this.getNode() instanceof InstanceVariableWriteAccess }
829+
InstanceVariableWriteAccessCfgNode() {
830+
this.getAstNode() instanceof InstanceVariableWriteAccess
831+
}
828832

829833
override string getAPrimaryQlClass() { result = "InstanceVariableWriteAccessCfgNode" }
830834

@@ -835,7 +839,9 @@ module ExprNodes {
835839
class StringInterpolationComponentCfgNode extends StringComponentCfgNode, StmtSequenceCfgNode {
836840
override string getAPrimaryQlClass() { result = "StringInterpolationComponentCfgNode" }
837841

838-
StringInterpolationComponentCfgNode() { this.getNode() instanceof StringInterpolationComponent }
842+
StringInterpolationComponentCfgNode() {
843+
this.getAstNode() instanceof StringInterpolationComponent
844+
}
839845

840846
final override ConstantValue getConstantValue() {
841847
result = StmtSequenceCfgNode.super.getConstantValue()
@@ -846,7 +852,9 @@ module ExprNodes {
846852
class RegExpInterpolationComponentCfgNode extends RegExpComponentCfgNode, StmtSequenceCfgNode {
847853
override string getAPrimaryQlClass() { result = "RegExpInterpolationComponentCfgNode" }
848854

849-
RegExpInterpolationComponentCfgNode() { this.getNode() instanceof RegExpInterpolationComponent }
855+
RegExpInterpolationComponentCfgNode() {
856+
this.getAstNode() instanceof RegExpInterpolationComponent
857+
}
850858

851859
final override ConstantValue getConstantValue() {
852860
result = StmtSequenceCfgNode.super.getConstantValue()

ruby/ql/lib/codeql/ruby/controlflow/ControlFlowGraph.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ class CfgNode extends CfgImpl::Node {
4040
/** Gets the file of this control flow node. */
4141
final File getFile() { result = this.getLocation().getFile() }
4242

43+
/** DEPRECATED: Use `getAstNode` instead. */
44+
deprecated AstNode getNode() { result = this.getAstNode() }
45+
4346
/** Gets a successor node of a given type, if any. */
4447
final CfgNode getASuccessor(SuccessorType t) { result = super.getASuccessor(t) }
4548

ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowDispatch.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ private predicate selfInToplevel(SelfVariable self, Module m) {
264264
private predicate asModulePattern(SsaDefinitionExtNode def, Module m) {
265265
exists(AsPattern ap |
266266
m = resolveConstantReadAccess(ap.getPattern()) and
267-
def.getDefinitionExt().(Ssa::WriteDefinition).getWriteAccess().getNode() =
267+
def.getDefinitionExt().(Ssa::WriteDefinition).getWriteAccess().getAstNode() =
268268
ap.getVariableAccess()
269269
)
270270
}

ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPrivate.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ module LocalFlow {
118118
/** Gets the SSA definition node corresponding to parameter `p`. */
119119
SsaDefinitionExtNode getParameterDefNode(NamedParameter p) {
120120
exists(BasicBlock bb, int i |
121-
bb.getNode(i).getNode() = p.getDefiningAccess() and
121+
bb.getNode(i).getAstNode() = p.getDefiningAccess() and
122122
result.getDefinitionExt().definesAt(_, bb, i, _)
123123
)
124124
}
@@ -203,8 +203,8 @@ module LocalFlow {
203203
exists(CfgNodes::ExprCfgNode exprTo, ReturningStatementNode n |
204204
nodeFrom = n and
205205
exprTo = nodeTo.asExpr() and
206-
n.getReturningNode().getNode() instanceof BreakStmt and
207-
exprTo.getNode() instanceof Loop and
206+
n.getReturningNode().getAstNode() instanceof BreakStmt and
207+
exprTo.getAstNode() instanceof Loop and
208208
nodeTo.asExpr().getAPredecessor(any(SuccessorTypes::BreakSuccessor s)) = n.getReturningNode()
209209
)
210210
or
@@ -926,7 +926,7 @@ abstract class SourceReturnNode extends ReturnNode {
926926
private module ReturnNodes {
927927
private predicate isValid(CfgNodes::ReturningCfgNode node) {
928928
exists(ReturningStmt stmt, Callable scope |
929-
stmt = node.getNode() and
929+
stmt = node.getAstNode() and
930930
scope = node.getScope()
931931
|
932932
stmt instanceof ReturnStmt and
@@ -952,7 +952,7 @@ private module ReturnNodes {
952952
}
953953

954954
override ReturnKind getKindSource() {
955-
if n.getNode() instanceof BreakStmt
955+
if n.getAstNode() instanceof BreakStmt
956956
then result instanceof BreakReturnKind
957957
else
958958
exists(CfgScope scope | scope = this.getCfgScope() |

ruby/ql/lib/codeql/ruby/dataflow/internal/SsaImpl.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ private module SsaInput implements SsaImplCommon::InputSig {
3131
i = 0
3232
or
3333
// ...or a class or module block.
34-
bb.getNode(i).getNode() = scope.(ModuleBase).getAControlFlowEntryNode() and
34+
bb.getNode(i).getAstNode() = scope.(ModuleBase).getAControlFlowEntryNode() and
3535
not scope instanceof Toplevel // handled by case above
3636
)
3737
or
@@ -126,8 +126,8 @@ private predicate namespaceSelfExitRead(Cfg::AnnotatedExitBasicBlock bb, int i,
126126
v.getDeclaringScope() = ns and
127127
last = ControlFlowGraphImpl::getAControlFlowExitNode(ns) and
128128
if last = ns
129-
then bb.getNode(i).getAPredecessor().getNode() = last
130-
else bb.getNode(i).getNode() = last
129+
then bb.getNode(i).getAPredecessor().getAstNode() = last
130+
else bb.getNode(i).getAstNode() = last
131131
)
132132
}
133133

@@ -183,7 +183,7 @@ private predicate capturedCallRead(CallCfgNode call, Cfg::BasicBlock bb, int i,
183183
private predicate variableReadActual(Cfg::BasicBlock bb, int i, LocalVariable v) {
184184
exists(VariableReadAccess read |
185185
read.getVariable() = v and
186-
read = bb.getNode(i).getNode()
186+
read = bb.getNode(i).getAstNode()
187187
)
188188
}
189189

ruby/ql/lib/codeql/ruby/security/HardcodedDataInterpretedAsCodeCustomizations.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ module HardcodedDataInterpretedAsCode {
7979
forex(StringComponentCfgNode c |
8080
c = this.asExpr().(ExprNodes::StringlikeLiteralCfgNode).getAComponent()
8181
|
82-
c.getNode().(Ast::StringEscapeSequenceComponent).getRawText().matches("\\x%")
82+
c.getAstNode().(Ast::StringEscapeSequenceComponent).getRawText().matches("\\x%")
8383
)
8484
}
8585
}

ruby/ql/lib/codeql/ruby/typetracking/TypeTrackerSpecific.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ predicate returnStep(Node nodeFrom, Node nodeTo) {
230230
// deliberately do not include `getInitializeTarget`, since calls to `new` should not
231231
// get the return value from `initialize`. Any fields being set in the initializer
232232
// will reach all reads via `callStep` and `localFieldStep`.
233-
nodeTo.asExpr().getNode() = call.getNode()
233+
nodeTo.asExpr().getAstNode() = call.getAstNode()
234234
)
235235
}
236236

0 commit comments

Comments
 (0)