diff --git a/Cargo.lock b/Cargo.lock index f546f46805f..a493f322a57 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -535,7 +535,7 @@ dependencies = [ [[package]] name = "tree-sitter-ruby" version = "0.17.0" -source = "git+https://github.com/tree-sitter/tree-sitter-ruby.git?rev=694f81cbc552d2c2e928d909652544e0a2d60613#694f81cbc552d2c2e928d909652544e0a2d60613" +source = "git+https://github.com/tree-sitter/tree-sitter-ruby.git?rev=49c5f6e9cc9ea1a3b9fb5414ba0c2d697acb2448#49c5f6e9cc9ea1a3b9fb5414ba0c2d697acb2448" dependencies = [ "cc", "tree-sitter", diff --git a/extractor/Cargo.toml b/extractor/Cargo.toml index 098fca91551..180e767b53b 100644 --- a/extractor/Cargo.toml +++ b/extractor/Cargo.toml @@ -10,7 +10,7 @@ edition = "2018" flate2 = "1.0" node-types = { path = "../node-types" } tree-sitter = "0.17" -tree-sitter-ruby = { git = "https://github.com/tree-sitter/tree-sitter-ruby.git", rev = "694f81cbc552d2c2e928d909652544e0a2d60613" } +tree-sitter-ruby = { git = "https://github.com/tree-sitter/tree-sitter-ruby.git", rev = "49c5f6e9cc9ea1a3b9fb5414ba0c2d697acb2448" } clap = "2.33" tracing = "0.1" tracing-subscriber = { version = "0.2", features = ["env-filter"] } diff --git a/generator/Cargo.toml b/generator/Cargo.toml index 246d675d21f..e751b444fe7 100644 --- a/generator/Cargo.toml +++ b/generator/Cargo.toml @@ -10,4 +10,4 @@ edition = "2018" node-types = { path = "../node-types" } tracing = "0.1" tracing-subscriber = { version = "0.2", features = ["env-filter"] } -tree-sitter-ruby = { git = "https://github.com/tree-sitter/tree-sitter-ruby.git", rev = "694f81cbc552d2c2e928d909652544e0a2d60613" } +tree-sitter-ruby = { git = "https://github.com/tree-sitter/tree-sitter-ruby.git", rev = "49c5f6e9cc9ea1a3b9fb5414ba0c2d697acb2448" } diff --git a/ql/src/codeql_ruby/ast/internal/TreeSitter.qll b/ql/src/codeql_ruby/ast/internal/TreeSitter.qll index 0a9604b919b..19f1d4ea65e 100644 --- a/ql/src/codeql_ruby/ast/internal/TreeSitter.qll +++ b/ql/src/codeql_ruby/ast/internal/TreeSitter.qll @@ -270,18 +270,25 @@ module Generated { class Call extends @call, AstNode { override string getAPrimaryQlClass() { result = "Call" } - override Location getLocation() { call_def(this, _, _, _, _, result) } + override Location getLocation() { call_def(this, _, _, _, result) } - AstNode getMethod() { call_def(this, _, _, result, _, _) } + ArgumentList getArguments() { call_arguments(this, result) } - AstNode getReceiver() { call_def(this, _, _, _, result, _) } + AstNode getBlock() { call_block(this, result) } - override AstNode getParent() { call_def(this, result, _, _, _, _) } + AstNode getMethod() { call_def(this, _, _, result, _) } - override int getParentIndex() { call_def(this, _, result, _, _, _) } + AstNode getReceiver() { call_receiver(this, result) } + + override AstNode getParent() { call_def(this, result, _, _, _) } + + override int getParentIndex() { call_def(this, _, result, _, _) } override AstNode getAFieldOrChild() { - call_def(this, _, _, result, _, _) or call_def(this, _, _, _, result, _) + call_arguments(this, result) or + call_block(this, result) or + call_def(this, _, _, result, _) or + call_receiver(this, result) } } @@ -819,28 +826,6 @@ module Generated { } } - class MethodCall extends @method_call, AstNode { - override string getAPrimaryQlClass() { result = "MethodCall" } - - override Location getLocation() { method_call_def(this, _, _, _, result) } - - ArgumentList getArguments() { method_call_arguments(this, result) } - - AstNode getBlock() { method_call_block(this, result) } - - AstNode getMethod() { method_call_def(this, _, _, result, _) } - - override AstNode getParent() { method_call_def(this, result, _, _, _) } - - override int getParentIndex() { method_call_def(this, _, result, _, _) } - - override AstNode getAFieldOrChild() { - method_call_arguments(this, result) or - method_call_block(this, result) or - method_call_def(this, _, _, result, _) - } - } - class MethodParameters extends @method_parameters, AstNode { override string getAPrimaryQlClass() { result = "MethodParameters" } diff --git a/ql/src/ruby.dbscheme b/ql/src/ruby.dbscheme index 165fbc121ad..a65eeaa018d 100644 --- a/ql/src/ruby.dbscheme +++ b/ql/src/ruby.dbscheme @@ -48,13 +48,13 @@ sourceLocationPrefix( @underscore_arg = @assignment | @binary | @conditional | @operator_assignment | @range | @unary | @underscore_primary -@underscore_lhs = @call | @element_reference | @method_call | @scope_resolution | @token_false | @token_nil | @token_true | @underscore_variable +@underscore_lhs = @call | @element_reference | @scope_resolution | @token_false | @token_nil | @token_true | @underscore_variable @underscore_method_name = @setter | @symbol | @token_class_variable | @token_constant | @token_global_variable | @token_identifier | @token_instance_variable | @token_operator @underscore_primary = @array | @begin | @break | @case__ | @chained_string | @class | @for | @hash | @if | @lambda | @method | @module | @next | @parenthesized_statements | @rational | @redo | @regex | @retry | @return | @singleton_class | @singleton_method | @string__ | @string_array | @subshell | @symbol | @symbol_array | @token_character | @token_complex | @token_float | @token_heredoc_beginning | @token_integer | @unary | @underscore_lhs | @unless | @until | @while | @yield -@underscore_statement = @alias | @assignment | @begin_block | @binary | @break | @call | @end_block | @if_modifier | @method_call | @next | @operator_assignment | @rescue_modifier | @return | @unary | @undef | @underscore_arg | @unless_modifier | @until_modifier | @while_modifier | @yield +@underscore_statement = @alias | @assignment | @begin_block | @binary | @break | @call | @end_block | @if_modifier | @next | @operator_assignment | @rescue_modifier | @return | @unary | @undef | @underscore_arg | @unless_modifier | @until_modifier | @while_modifier | @yield @underscore_variable = @token_class_variable | @token_constant | @token_global_variable | @token_identifier | @token_instance_variable | @token_self | @token_super @@ -68,7 +68,7 @@ alias_def( int loc: @location ref ); -@argument_list_child_type = @block_argument | @break | @call | @hash_splat_argument | @method_call | @next | @pair | @return | @splat_argument | @underscore_arg | @yield +@argument_list_child_type = @block_argument | @break | @call | @hash_splat_argument | @next | @pair | @return | @splat_argument | @underscore_arg | @yield #keyset[argument_list, index] argument_list_child( @@ -85,7 +85,7 @@ argument_list_def( int loc: @location ref ); -@array_child_type = @block_argument | @break | @call | @hash_splat_argument | @method_call | @next | @pair | @return | @splat_argument | @underscore_arg | @yield +@array_child_type = @block_argument | @break | @call | @hash_splat_argument | @next | @pair | @return | @splat_argument | @underscore_arg | @yield #keyset[array, index] array_child( @@ -104,7 +104,7 @@ array_def( @assignment_left_type = @left_assignment_list | @underscore_lhs -@assignment_right_type = @break | @call | @method_call | @next | @return | @right_assignment_list | @splat_argument | @underscore_arg | @yield +@assignment_right_type = @break | @call | @next | @return | @right_assignment_list | @splat_argument | @underscore_arg | @yield #keyset[parent, parent_index] assignment_def( @@ -184,11 +184,11 @@ begin_block_def( int loc: @location ref ); -@binary_left_type = @break | @call | @method_call | @next | @return | @underscore_arg | @yield +@binary_left_type = @break | @call | @next | @return | @underscore_arg | @yield @binary_operator_type = @reserved_word -@binary_right_type = @break | @call | @method_call | @next | @return | @underscore_arg | @yield +@binary_right_type = @break | @call | @next | @return | @underscore_arg | @yield #keyset[parent, parent_index] binary_def( @@ -271,9 +271,26 @@ break_def( int loc: @location ref ); -@call_method_type = @argument_list | @token_constant | @token_identifier | @token_operator +call_arguments( + unique int call: @call ref, + unique int argument_list: @argument_list ref +); -@call_receiver_type = @method_call | @underscore_primary +@call_block_type = @block | @do_block + +call_block( + unique int call: @call ref, + unique int call_block_type: @call_block_type ref +); + +@call_method_type = @argument_list | @scope_resolution | @token_operator | @underscore_variable + +@call_receiver_type = @call | @underscore_primary + +call_receiver( + unique int call: @call ref, + unique int call_receiver_type: @call_receiver_type ref +); #keyset[parent, parent_index] call_def( @@ -281,7 +298,6 @@ call_def( int parent: @ast_node_parent ref, int parent_index: int ref, int method: @call_method_type ref, - int receiver: @call_receiver_type ref, int loc: @location ref ); @@ -426,7 +442,7 @@ do_block_def( int loc: @location ref ); -@element_reference_child_type = @block_argument | @break | @call | @hash_splat_argument | @method_call | @next | @pair | @return | @splat_argument | @underscore_arg | @yield +@element_reference_child_type = @block_argument | @break | @call | @hash_splat_argument | @next | @pair | @return | @splat_argument | @underscore_arg | @yield #keyset[element_reference, index] element_reference_child( @@ -638,7 +654,7 @@ if_def( int loc: @location ref ); -@if_modifier_condition_type = @break | @call | @method_call | @next | @return | @underscore_arg | @yield +@if_modifier_condition_type = @break | @call | @next | @return | @underscore_arg | @yield #keyset[parent, parent_index] if_modifier_def( @@ -755,29 +771,6 @@ method_def( int loc: @location ref ); -method_call_arguments( - unique int method_call: @method_call ref, - unique int argument_list: @argument_list ref -); - -@method_call_block_type = @block | @do_block - -method_call_block( - unique int method_call: @method_call ref, - unique int method_call_block_type: @method_call_block_type ref -); - -@method_call_method_type = @call | @scope_resolution | @underscore_variable - -#keyset[parent, parent_index] -method_call_def( - unique int id: @method_call, - int parent: @ast_node_parent ref, - int parent_index: int ref, - int method: @method_call_method_type ref, - int loc: @location ref -); - @method_parameters_child_type = @block_parameter | @destructured_parameter | @hash_splat_parameter | @keyword_parameter | @optional_parameter | @splat_parameter | @token_identifier #keyset[method_parameters, index] @@ -830,7 +823,7 @@ next_def( @operator_assignment_operator_type = @reserved_word -@operator_assignment_right_type = @break | @call | @method_call | @next | @return | @underscore_arg | @yield +@operator_assignment_right_type = @break | @call | @next | @return | @underscore_arg | @yield #keyset[parent, parent_index] operator_assignment_def( @@ -989,7 +982,7 @@ rescue_def( int loc: @location ref ); -@rescue_modifier_handler_type = @break | @call | @method_call | @next | @return | @underscore_arg | @yield +@rescue_modifier_handler_type = @break | @call | @next | @return | @underscore_arg | @yield #keyset[parent, parent_index] rescue_modifier_def( @@ -1197,7 +1190,7 @@ subshell_def( int loc: @location ref ); -@superclass_child_type = @break | @call | @method_call | @next | @return | @underscore_arg | @yield +@superclass_child_type = @break | @call | @next | @return | @underscore_arg | @yield #keyset[parent, parent_index] superclass_def( @@ -1257,7 +1250,7 @@ then_def( int loc: @location ref ); -@unary_operand_type = @break | @call | @method_call | @next | @parenthesized_statements | @return | @token_float | @token_integer | @underscore_arg | @yield +@unary_operand_type = @break | @call | @next | @parenthesized_statements | @return | @token_float | @token_integer | @underscore_arg | @yield @unary_operator_type = @reserved_word @@ -1307,7 +1300,7 @@ unless_def( int loc: @location ref ); -@unless_modifier_condition_type = @break | @call | @method_call | @next | @return | @underscore_arg | @yield +@unless_modifier_condition_type = @break | @call | @next | @return | @underscore_arg | @yield #keyset[parent, parent_index] unless_modifier_def( @@ -1329,7 +1322,7 @@ until_def( int loc: @location ref ); -@until_modifier_condition_type = @break | @call | @method_call | @next | @return | @underscore_arg | @yield +@until_modifier_condition_type = @break | @call | @next | @return | @underscore_arg | @yield #keyset[parent, parent_index] until_modifier_def( @@ -1371,7 +1364,7 @@ while_def( int loc: @location ref ); -@while_modifier_condition_type = @break | @call | @method_call | @next | @return | @underscore_arg | @yield +@while_modifier_condition_type = @break | @call | @next | @return | @underscore_arg | @yield #keyset[parent, parent_index] while_modifier_def( @@ -1436,7 +1429,7 @@ case @token.kind of ; -@ast_node = @alias | @argument_list | @array | @assignment | @bare_string | @bare_symbol | @begin | @begin_block | @binary | @block | @block_argument | @block_parameter | @block_parameters | @break | @call | @case__ | @chained_string | @class | @conditional | @destructured_left_assignment | @destructured_parameter | @do | @do_block | @element_reference | @else | @elsif | @end_block | @ensure | @exception_variable | @exceptions | @for | @hash | @hash_splat_argument | @hash_splat_parameter | @heredoc_body | @if | @if_modifier | @in | @interpolation | @keyword_parameter | @lambda | @lambda_parameters | @left_assignment_list | @method | @method_call | @method_parameters | @module | @next | @operator_assignment | @optional_parameter | @pair | @parenthesized_statements | @pattern | @program | @range | @rational | @redo | @regex | @rescue | @rescue_modifier | @rest_assignment | @retry | @return | @right_assignment_list | @scope_resolution | @setter | @singleton_class | @singleton_method | @splat_argument | @splat_parameter | @string__ | @string_array | @subshell | @superclass | @symbol | @symbol_array | @then | @token | @unary | @undef | @unless | @unless_modifier | @until | @until_modifier | @when | @while | @while_modifier | @yield +@ast_node = @alias | @argument_list | @array | @assignment | @bare_string | @bare_symbol | @begin | @begin_block | @binary | @block | @block_argument | @block_parameter | @block_parameters | @break | @call | @case__ | @chained_string | @class | @conditional | @destructured_left_assignment | @destructured_parameter | @do | @do_block | @element_reference | @else | @elsif | @end_block | @ensure | @exception_variable | @exceptions | @for | @hash | @hash_splat_argument | @hash_splat_parameter | @heredoc_body | @if | @if_modifier | @in | @interpolation | @keyword_parameter | @lambda | @lambda_parameters | @left_assignment_list | @method | @method_parameters | @module | @next | @operator_assignment | @optional_parameter | @pair | @parenthesized_statements | @pattern | @program | @range | @rational | @redo | @regex | @rescue | @rescue_modifier | @rest_assignment | @retry | @return | @right_assignment_list | @scope_resolution | @setter | @singleton_class | @singleton_method | @splat_argument | @splat_parameter | @string__ | @string_array | @subshell | @superclass | @symbol | @symbol_array | @then | @token | @unary | @undef | @unless | @unless_modifier | @until | @until_modifier | @when | @while | @while_modifier | @yield @ast_node_parent = @ast_node | @file