From 8d1ed4bf8985c6835d8ef93911bd3885ed5a5881 Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Thu, 12 Nov 2020 10:25:36 +0100 Subject: [PATCH] Run: cargo update This pulls in improvements to the tree-sitter-ruby repository. --- Cargo.lock | 16 ++++++++-------- ql/src/codeql_ruby/ast.qll | 30 ++++++++++++++++++------------ ql/src/ruby.dbscheme | 7 +++++-- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1a3975349f4..3e298c18832 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,9 +8,9 @@ checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" [[package]] name = "aho-corasick" -version = "0.7.14" +version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b476ce7103678b0c6d3d395dbbae31d48ff910bd28be979ba5d48c6351131d0d" +checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" dependencies = [ "memchr", ] @@ -64,9 +64,9 @@ checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" [[package]] name = "cc" -version = "1.0.61" +version = "1.0.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed67cbde08356238e75fc4656be4749481eeffb09e19f320a25237d5221c985d" +checksum = "f1770ced377336a88a67c473594ccc14eca6f4559217c34f64aac8f83d641b40" [[package]] name = "cfg-if" @@ -119,11 +119,11 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da80be589a72651dcda34d8b35bcdc9b7254ad06325611074d9cc0fbb19f60ee" +checksum = "7411863d55df97a419aa64cb4d2f167103ea9d767e2c54a1868b7ac3f6b47129" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "crc32fast", "libc", "miniz_oxide", @@ -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#df5e5024ecdf81c52eca9d70919c39cb5ab71d20" +source = "git+https://github.com/tree-sitter/tree-sitter-ruby.git#93632008c63e0577413bbedf120fb92a96397785" dependencies = [ "cc", "tree-sitter", diff --git a/ql/src/codeql_ruby/ast.qll b/ql/src/codeql_ruby/ast.qll index 1956676a936..110c83e31f1 100644 --- a/ql/src/codeql_ruby/ast.qll +++ b/ql/src/codeql_ruby/ast.qll @@ -34,7 +34,7 @@ class UnderscoreArg extends @underscore_arg, AstNode, ArgumentListChildType, Arr AssignmentRightType, BinaryLeftType, BinaryRightType, ElementReferenceChildType, ExceptionsChildType, IfModifierConditionType, OperatorAssignmentRightType, PairKeyType, PatternChildType, RescueModifierHandlerType, RightAssignmentListChildType, - SingletonMethodObjectType, SuperclassChildType, UnaryChildType, UnderscoreStatement, + SingletonMethodObjectType, SuperclassChildType, UnaryOperandType, UnderscoreStatement, UnlessModifierConditionType, UntilModifierConditionType, WhileModifierConditionType { } class UnderscoreLhs extends @underscore_lhs, AstNode, AssignmentLeftType, @@ -230,7 +230,7 @@ class BlockParameters extends @block_parameters, AstNode, BlockChildType, DoBloc class Break extends @break, AstNode, ArgumentListChildType, ArrayChildType, AssignmentRightType, BinaryLeftType, BinaryRightType, ElementReferenceChildType, IfModifierConditionType, - OperatorAssignmentRightType, RescueModifierHandlerType, SuperclassChildType, UnaryChildType, + OperatorAssignmentRightType, RescueModifierHandlerType, SuperclassChildType, UnaryOperandType, UnderscorePrimary, UnderscoreStatement, UnlessModifierConditionType, UntilModifierConditionType, WhileModifierConditionType { override string describeQlClass() { result = "Break" } @@ -249,7 +249,7 @@ class CallReceiverType extends @call_receiver_type, AstNode { } class Call extends @call, AstNode, ArgumentListChildType, ArrayChildType, AssignmentRightType, BinaryLeftType, BinaryRightType, ElementReferenceChildType, IfModifierConditionType, MethodCallMethodType, OperatorAssignmentRightType, RescueModifierHandlerType, SuperclassChildType, - UnaryChildType, UnderscoreLhs, UnderscoreStatement, UnlessModifierConditionType, + UnaryOperandType, UnderscoreLhs, UnderscoreStatement, UnlessModifierConditionType, UntilModifierConditionType, WhileModifierConditionType { override string describeQlClass() { result = "Call" } @@ -669,7 +669,7 @@ class MethodCallMethodType extends @method_call_method_type, AstNode { } class MethodCall extends @method_call, AstNode, ArgumentListChildType, ArrayChildType, AssignmentRightType, BinaryLeftType, BinaryRightType, CallReceiverType, ElementReferenceChildType, IfModifierConditionType, OperatorAssignmentRightType, RescueModifierHandlerType, - SuperclassChildType, UnaryChildType, UnderscoreLhs, UnderscoreStatement, + SuperclassChildType, UnaryOperandType, UnderscoreLhs, UnderscoreStatement, UnlessModifierConditionType, UntilModifierConditionType, WhileModifierConditionType { override string describeQlClass() { result = "MethodCall" } @@ -720,7 +720,7 @@ class Module extends @module, AstNode, UnderscorePrimary { class Next extends @next, AstNode, ArgumentListChildType, ArrayChildType, AssignmentRightType, BinaryLeftType, BinaryRightType, ElementReferenceChildType, IfModifierConditionType, - OperatorAssignmentRightType, RescueModifierHandlerType, SuperclassChildType, UnaryChildType, + OperatorAssignmentRightType, RescueModifierHandlerType, SuperclassChildType, UnaryOperandType, UnderscorePrimary, UnderscoreStatement, UnlessModifierConditionType, UntilModifierConditionType, WhileModifierConditionType { override string describeQlClass() { result = "Next" } @@ -782,7 +782,7 @@ class Pair extends @pair, AstNode, ArgumentListChildType, ArrayChildType, Elemen class ParenthesizedStatementsChildType extends @parenthesized_statements_child_type, AstNode { } -class ParenthesizedStatements extends @parenthesized_statements, AstNode, UnaryChildType, +class ParenthesizedStatements extends @parenthesized_statements, AstNode, UnaryOperandType, UnderscorePrimary { override string describeQlClass() { result = "ParenthesizedStatements" } @@ -917,7 +917,7 @@ class Retry extends @retry, AstNode, UnderscorePrimary { class Return extends @return, AstNode, ArgumentListChildType, ArrayChildType, AssignmentRightType, BinaryLeftType, BinaryRightType, ElementReferenceChildType, IfModifierConditionType, - OperatorAssignmentRightType, RescueModifierHandlerType, SuperclassChildType, UnaryChildType, + OperatorAssignmentRightType, RescueModifierHandlerType, SuperclassChildType, UnaryOperandType, UnderscorePrimary, UnderscoreStatement, UnlessModifierConditionType, UntilModifierConditionType, WhileModifierConditionType { override string describeQlClass() { result = "Return" } @@ -1112,16 +1112,22 @@ class Then extends @then, AstNode { override AstNode getAFieldOrChild() { then_child(this, _, result) } } -class UnaryChildType extends @unary_child_type, AstNode { } +class UnaryOperandType extends @unary_operand_type, AstNode { } + +class UnaryOperatorType extends @unary_operator_type, AstNode { } class Unary extends @unary, AstNode, UnderscoreArg, UnderscorePrimary, UnderscoreStatement { override string describeQlClass() { result = "Unary" } - override Location getLocation() { unary_def(this, _, result) } + override Location getLocation() { unary_def(this, _, _, result) } - UnaryChildType getChild() { unary_def(this, result, _) } + UnaryOperandType getOperand() { unary_def(this, result, _, _) } - override AstNode getAFieldOrChild() { unary_def(this, result, _) } + UnaryOperatorType getOperator() { unary_def(this, _, result, _) } + + override AstNode getAFieldOrChild() { + unary_def(this, result, _, _) or unary_def(this, _, result, _) + } } class Undef extends @undef, AstNode, UnderscoreStatement { @@ -1246,7 +1252,7 @@ class WhileModifier extends @while_modifier, AstNode, UnderscoreStatement { class Yield extends @yield, AstNode, ArgumentListChildType, ArrayChildType, AssignmentRightType, BinaryLeftType, BinaryRightType, ElementReferenceChildType, IfModifierConditionType, - OperatorAssignmentRightType, RescueModifierHandlerType, SuperclassChildType, UnaryChildType, + OperatorAssignmentRightType, RescueModifierHandlerType, SuperclassChildType, UnaryOperandType, UnderscorePrimary, UnderscoreStatement, UnlessModifierConditionType, UntilModifierConditionType, WhileModifierConditionType { override string describeQlClass() { result = "Yield" } diff --git a/ql/src/ruby.dbscheme b/ql/src/ruby.dbscheme index e3c313f827f..ba7bfe41dc6 100644 --- a/ql/src/ruby.dbscheme +++ b/ql/src/ruby.dbscheme @@ -1011,11 +1011,14 @@ then_def( int loc: @location ref ); -@unary_child_type = @break | @call | @method_call | @next | @parenthesized_statements | @return | @token_float | @token_integer | @underscore_arg | @yield +@unary_operand_type = @break | @call | @method_call | @next | @parenthesized_statements | @return | @token_float | @token_integer | @underscore_arg | @yield + +@unary_operator_type = @reserved_word unary_def( unique int id: @unary, - int child: @unary_child_type ref, + int operand: @unary_operand_type ref, + int operator: @unary_operator_type ref, int loc: @location ref );