File tree Expand file tree Collapse file tree 2 files changed +19
-15
lines changed
ruby/ql/lib/codeql/ruby/ast Expand file tree Collapse file tree 2 files changed +19
-15
lines changed Original file line number Diff line number Diff line change @@ -224,21 +224,7 @@ class ConstantReadAccess extends ConstantAccess {
224
224
*
225
225
* the value being read at `M::CONST` is `"const"`.
226
226
*/
227
- Expr getValue ( ) {
228
- not exists ( this .getScopeExpr ( ) ) and
229
- result = lookupConst ( this .getEnclosingModule + ( ) .getModule ( ) , this .getName ( ) ) and
230
- // For now, we restrict the scope of top-level declarations to their file.
231
- // This may remove some plausible targets, but also removes a lot of
232
- // implausible targets
233
- if result .getEnclosingModule ( ) instanceof Toplevel
234
- then result .getFile ( ) = this .getFile ( )
235
- else any ( )
236
- or
237
- this .hasGlobalScope ( ) and
238
- result = lookupConst ( TResolved ( "Object" ) , this .getName ( ) )
239
- or
240
- result = lookupConst ( resolveConstantReadAccess ( this .getScopeExpr ( ) ) , this .getName ( ) )
241
- }
227
+ Expr getValue ( ) { result = getConstantReadAccessValue ( this ) }
242
228
243
229
final override string getAPrimaryQlClass ( ) { result = "ConstantReadAccess" }
244
230
}
Original file line number Diff line number Diff line change 1
1
private import codeql.ruby.AST
2
2
private import codeql.ruby.ast.internal.Literal
3
+ private import codeql.ruby.ast.internal.Module
3
4
private import codeql.ruby.controlflow.CfgNodes
4
5
private import codeql.ruby.dataflow.SSA
5
6
private import ExprNodes
@@ -441,6 +442,23 @@ private module Cached {
441
442
result .isNil ( ) and
442
443
isNilExpr ( e )
443
444
}
445
+
446
+ cached
447
+ Expr getConstantReadAccessValue ( ConstantReadAccess read ) {
448
+ not exists ( read .getScopeExpr ( ) ) and
449
+ result = lookupConst ( read .getEnclosingModule + ( ) .getModule ( ) , read .getName ( ) ) and
450
+ // For now, we restrict the scope of top-level declarations to their file.
451
+ // This may remove some plausible targets, but also removes a lot of
452
+ // implausible targets
453
+ if result .getEnclosingModule ( ) instanceof Toplevel
454
+ then result .getFile ( ) = read .getFile ( )
455
+ else any ( )
456
+ or
457
+ read .hasGlobalScope ( ) and
458
+ result = lookupConst ( TResolved ( "Object" ) , read .getName ( ) )
459
+ or
460
+ result = lookupConst ( resolveConstantReadAccess ( read .getScopeExpr ( ) ) , read .getName ( ) )
461
+ }
444
462
}
445
463
446
464
import Cached
You can’t perform that action at this time.
0 commit comments