From 05adfec03d4423fa4be98a5c9bb789409967f60b Mon Sep 17 00:00:00 2001 From: Alex Ford Date: Thu, 29 Apr 2021 17:02:54 +0100 Subject: [PATCH] account for more patterns in IntegerLiteral.getValue --- ql/src/codeql_ruby/ast/Literal.qll | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ql/src/codeql_ruby/ast/Literal.qll b/ql/src/codeql_ruby/ast/Literal.qll index 615b0b16210..a169c4f3780 100644 --- a/ql/src/codeql_ruby/ast/Literal.qll +++ b/ql/src/codeql_ruby/ast/Literal.qll @@ -51,15 +51,23 @@ class IntegerLiteral extends NumericLiteral, TIntegerLiteral { exists(string s, string values, string str | s = this.getValueText() and ( - s.matches("0b%") and values = "01" and str = s.suffix(2) + (s.matches("0b%") or s.matches("0B%")) and + values = "01" and + str = s.suffix(2) or - s.matches("0x%") and values = "0123456789abcdef" and str = s.suffix(2) + (s.matches("0x%") or s.matches("0X%")) and + values = "0123456789abcdef" and + str = s.suffix(2) or s.charAt(0) = "0" and - not s.charAt(1) = ["b", "x"] and + not s.charAt(1) = ["b", "B", "x", "X"] and values = "01234567" and str = s.suffix(1) or + (s.matches("0o%") or s.matches("0O%")) and + values = "01234567" and + str = s.suffix(2) + or s.charAt(0) != "0" and values = "0123456789" and str = s ) |