diff --git a/Cargo.lock b/Cargo.lock index a74037b1320..1a3975349f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -535,8 +535,7 @@ dependencies = [ [[package]] name = "tree-sitter-ruby" version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "428e841bb6dc0fafd1f4f5732b11e89c3449fce73a207545034d1541aa9163ce" +source = "git+https://github.com/tree-sitter/tree-sitter-ruby.git#df5e5024ecdf81c52eca9d70919c39cb5ab71d20" dependencies = [ "cc", "tree-sitter", diff --git a/extractor/Cargo.toml b/extractor/Cargo.toml index 1d970c95544..083217aef0b 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 = "0.17" +tree-sitter-ruby = { git = "https://github.com/tree-sitter/tree-sitter-ruby.git" } 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 8f95dbe95dc..1881204182e 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 = "0.17" +tree-sitter-ruby = { git = "https://github.com/tree-sitter/tree-sitter-ruby.git" } diff --git a/ql/src/codeql_ruby/ast.qll b/ql/src/codeql_ruby/ast.qll index d9000565764..1956676a936 100644 --- a/ql/src/codeql_ruby/ast.qll +++ b/ql/src/codeql_ruby/ast.qll @@ -400,13 +400,9 @@ class Else extends @else, AstNode, BeginChildType, CaseChildType, ClassChildType override Location getLocation() { else_def(this, result) } - Token getCondition() { else_condition(this, result) } - ElseChildType getChild(int i) { else_child(this, i, result) } - override AstNode getAFieldOrChild() { - else_condition(this, result) or else_child(this, _, result) - } + override AstNode getAFieldOrChild() { else_child(this, _, result) } } class ElsifAlternativeType extends @elsif_alternative_type, AstNode { } @@ -1306,6 +1302,10 @@ class HeredocBeginning extends Token, @token_heredoc_beginning { override string describeQlClass() { result = "HeredocBeginning" } } +class HeredocContent extends Token, @token_heredoc_content { + override string describeQlClass() { result = "HeredocContent" } +} + class HeredocEnd extends Token, @token_heredoc_end { override string describeQlClass() { result = "HeredocEnd" } } @@ -1334,6 +1334,10 @@ class Self extends Token, @token_self { override string describeQlClass() { result = "Self" } } +class StringContent extends Token, @token_string_content { + override string describeQlClass() { result = "StringContent" } +} + class Super extends Token, @token_super { override string describeQlClass() { result = "Super" } } diff --git a/ql/src/ruby.dbscheme b/ql/src/ruby.dbscheme index f4d12c68dee..e3c313f827f 100644 --- a/ql/src/ruby.dbscheme +++ b/ql/src/ruby.dbscheme @@ -104,7 +104,7 @@ assignment_def( int loc: @location ref ); -@bare_string_child_type = @interpolation | @token_escape_sequence +@bare_string_child_type = @interpolation | @token_escape_sequence | @token_string_content #keyset[bare_string, index] bare_string_child( @@ -118,7 +118,7 @@ bare_string_def( int loc: @location ref ); -@bare_symbol_child_type = @interpolation | @token_escape_sequence +@bare_symbol_child_type = @interpolation | @token_escape_sequence | @token_string_content #keyset[bare_symbol, index] bare_symbol_child( @@ -362,11 +362,6 @@ element_reference_def( int loc: @location ref ); -else_condition( - unique int else: @else ref, - unique int reserved_word: @reserved_word ref -); - @else_child_type = @token_empty_statement | @underscore_statement #keyset[else, index] @@ -493,7 +488,7 @@ hash_splat_parameter_def( int loc: @location ref ); -@heredoc_body_child_type = @interpolation | @token_escape_sequence | @token_heredoc_end +@heredoc_body_child_type = @interpolation | @token_escape_sequence | @token_heredoc_content | @token_heredoc_end #keyset[heredoc_body, index] heredoc_body_child( @@ -768,7 +763,7 @@ redo_def( int loc: @location ref ); -@regex_child_type = @interpolation | @token_escape_sequence +@regex_child_type = @interpolation | @token_escape_sequence | @token_string_content #keyset[regex, index] regex_child( @@ -928,7 +923,7 @@ splat_parameter_def( int loc: @location ref ); -@string_child_type = @interpolation | @token_escape_sequence +@string_child_type = @interpolation | @token_escape_sequence | @token_string_content #keyset[string__, index] string_child( @@ -954,7 +949,7 @@ string_array_def( int loc: @location ref ); -@subshell_child_type = @interpolation | @token_escape_sequence +@subshell_child_type = @interpolation | @token_escape_sequence | @token_string_content #keyset[subshell, index] subshell_child( @@ -976,7 +971,7 @@ superclass_def( int loc: @location ref ); -@symbol_child_type = @interpolation | @token_escape_sequence +@symbol_child_type = @interpolation | @token_escape_sequence | @token_string_content #keyset[symbol, index] symbol_child( @@ -1146,16 +1141,18 @@ case @token.kind of | 9 = @token_float | 10 = @token_global_variable | 11 = @token_heredoc_beginning -| 12 = @token_heredoc_end -| 13 = @token_identifier -| 14 = @token_instance_variable -| 15 = @token_integer -| 16 = @token_nil -| 17 = @token_operator -| 18 = @token_self -| 19 = @token_super -| 20 = @token_true -| 21 = @token_uninterpreted +| 12 = @token_heredoc_content +| 13 = @token_heredoc_end +| 14 = @token_identifier +| 15 = @token_instance_variable +| 16 = @token_integer +| 17 = @token_nil +| 18 = @token_operator +| 19 = @token_self +| 20 = @token_string_content +| 21 = @token_super +| 22 = @token_true +| 23 = @token_uninterpreted ;