From 6bacac75981ca825a9ba6aa6905802ef87c77b1e Mon Sep 17 00:00:00 2001 From: Nick Rolfe Date: Tue, 8 Dec 2020 18:28:54 +0000 Subject: [PATCH] Bump tree-sitter-ruby revision to get operator_assignment field --- Cargo.lock | 2 +- extractor/Cargo.toml | 2 +- generator/Cargo.toml | 2 +- .../codeql_ruby/ast/internal/TreeSitter.qll | 19 +++++++++++-------- ql/src/ruby.dbscheme | 7 ++++++- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 529493fe346..f546f46805f 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=b92e1f80e5a838aa78f19faab6350157beb6fcd6#b92e1f80e5a838aa78f19faab6350157beb6fcd6" +source = "git+https://github.com/tree-sitter/tree-sitter-ruby.git?rev=694f81cbc552d2c2e928d909652544e0a2d60613#694f81cbc552d2c2e928d909652544e0a2d60613" dependencies = [ "cc", "tree-sitter", diff --git a/extractor/Cargo.toml b/extractor/Cargo.toml index e79449b05b0..098fca91551 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 = "b92e1f80e5a838aa78f19faab6350157beb6fcd6" } +tree-sitter-ruby = { git = "https://github.com/tree-sitter/tree-sitter-ruby.git", rev = "694f81cbc552d2c2e928d909652544e0a2d60613" } 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 25e013127f5..246d675d21f 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 = "b92e1f80e5a838aa78f19faab6350157beb6fcd6" } +tree-sitter-ruby = { git = "https://github.com/tree-sitter/tree-sitter-ruby.git", rev = "694f81cbc552d2c2e928d909652544e0a2d60613" } diff --git a/ql/src/codeql_ruby/ast/internal/TreeSitter.qll b/ql/src/codeql_ruby/ast/internal/TreeSitter.qll index d1e4b714be8..0a9604b919b 100644 --- a/ql/src/codeql_ruby/ast/internal/TreeSitter.qll +++ b/ql/src/codeql_ruby/ast/internal/TreeSitter.qll @@ -898,19 +898,22 @@ module Generated { class OperatorAssignment extends @operator_assignment, AstNode { override string getAPrimaryQlClass() { result = "OperatorAssignment" } - override Location getLocation() { operator_assignment_def(this, _, _, _, _, result) } + override Location getLocation() { operator_assignment_def(this, _, _, _, _, _, result) } - UnderscoreLhs getLeft() { operator_assignment_def(this, _, _, result, _, _) } + UnderscoreLhs getLeft() { operator_assignment_def(this, _, _, result, _, _, _) } - AstNode getRight() { operator_assignment_def(this, _, _, _, result, _) } + AstNode getOperator() { operator_assignment_def(this, _, _, _, result, _, _) } - override AstNode getParent() { operator_assignment_def(this, result, _, _, _, _) } + AstNode getRight() { operator_assignment_def(this, _, _, _, _, result, _) } - override int getParentIndex() { operator_assignment_def(this, _, result, _, _, _) } + override AstNode getParent() { operator_assignment_def(this, result, _, _, _, _, _) } + + override int getParentIndex() { operator_assignment_def(this, _, result, _, _, _, _) } override AstNode getAFieldOrChild() { - operator_assignment_def(this, _, _, result, _, _) or - operator_assignment_def(this, _, _, _, result, _) + operator_assignment_def(this, _, _, result, _, _, _) or + operator_assignment_def(this, _, _, _, result, _, _) or + operator_assignment_def(this, _, _, _, _, result, _) } } @@ -1012,7 +1015,7 @@ module Generated { override Location getLocation() { rational_def(this, _, _, _, result) } - Integer getChild() { rational_def(this, _, _, result, _) } + AstNode getChild() { rational_def(this, _, _, result, _) } override AstNode getParent() { rational_def(this, result, _, _, _) } diff --git a/ql/src/ruby.dbscheme b/ql/src/ruby.dbscheme index d7a254c338c..165fbc121ad 100644 --- a/ql/src/ruby.dbscheme +++ b/ql/src/ruby.dbscheme @@ -828,6 +828,8 @@ next_def( int loc: @location ref ); +@operator_assignment_operator_type = @reserved_word + @operator_assignment_right_type = @break | @call | @method_call | @next | @return | @underscore_arg | @yield #keyset[parent, parent_index] @@ -836,6 +838,7 @@ operator_assignment_def( int parent: @ast_node_parent ref, int parent_index: int ref, int left: @underscore_lhs ref, + int operator: @operator_assignment_operator_type ref, int right: @operator_assignment_right_type ref, int loc: @location ref ); @@ -922,12 +925,14 @@ range_def( int loc: @location ref ); +@rational_child_type = @token_float | @token_integer + #keyset[parent, parent_index] rational_def( unique int id: @rational, int parent: @ast_node_parent ref, int parent_index: int ref, - int child: @token_integer ref, + int child: @rational_child_type ref, int loc: @location ref );