mirror of
https://github.com/github/codeql.git
synced 2026-05-02 12:15:17 +02:00
@@ -253,7 +253,7 @@ class Lambda extends Callable, BodyStmt, TLambda {
|
||||
/** A block. */
|
||||
class Block extends Callable, StmtSequence, Scope, TBlock {
|
||||
/**
|
||||
* Get a local variable declared by this block.
|
||||
* Gets a local variable declared by this block.
|
||||
* For example `local` in `{ | param; local| puts param }`.
|
||||
*/
|
||||
LocalVariableWriteAccess getALocalVariable() { result = this.getLocalVariable(_) }
|
||||
|
||||
@@ -18,12 +18,6 @@ class NormalRubyCall extends RubyCall, @ruby_call {
|
||||
override RubyMethod getMethod() { result = method }
|
||||
}
|
||||
|
||||
class ImplicitRubyCall extends RubyCall, @ruby_call {
|
||||
ImplicitRubyCall() { ruby_call_def(this, any(@ruby_argument_list a)) }
|
||||
|
||||
override RubyMethod getMethod() { none() }
|
||||
}
|
||||
|
||||
class ScopeResolutionCall extends RubyCall, @ruby_scope_resolution {
|
||||
private @ruby_token_identifier method;
|
||||
|
||||
|
||||
@@ -2,22 +2,37 @@
|
||||
* @kind graph
|
||||
*/
|
||||
|
||||
import codeql.ruby.ast.internal.TreeSitter::Ruby
|
||||
import codeql.ruby.ast.internal.TreeSitter
|
||||
import codeql.Locations
|
||||
|
||||
/**
|
||||
* Holds if `node` belongs to the output tree, and its property `key` has the
|
||||
* given `value`.
|
||||
*/
|
||||
query predicate nodes(AstNode node, string key, string value) {
|
||||
query predicate nodes(Ruby::AstNode node, string key, string value) {
|
||||
key = "semmle.label" and
|
||||
value = "[" + node.getPrimaryQlClasses() + "] " + node.toString()
|
||||
or
|
||||
key = "semmle.order" and
|
||||
value =
|
||||
any(int i |
|
||||
node =
|
||||
rank[i](Ruby::AstNode n, Location l |
|
||||
l = n.getLocation()
|
||||
|
|
||||
n
|
||||
order by
|
||||
l.getFile().getRelativePath(), l.getFile().getAbsolutePath(), l.getStartLine(),
|
||||
l.getStartColumn(), l.getEndLine() desc, l.getEndColumn() desc, n.toString()
|
||||
)
|
||||
).toString()
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `target` is a child of `source` in the AST, and property `key` of
|
||||
* the edge has the given `value`.
|
||||
*/
|
||||
query predicate edges(AstNode source, AstNode target, string key, string value) {
|
||||
query predicate edges(Ruby::AstNode source, Ruby::AstNode target, string key, string value) {
|
||||
source = target.getParent() and
|
||||
key = ["semmle.label", "semmle.order"] and
|
||||
value = target.getParentIndex().toString()
|
||||
|
||||
Reference in New Issue
Block a user