mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Merge pull request #7985 from github/nickrolfe/constant_regexp
Ruby: separate constant propagation of regexps from strings
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,10 @@
|
||||
import ruby
|
||||
import codeql.ruby.controlflow.CfgNodes
|
||||
|
||||
query predicate exprValue(Expr e, ConstantValue v) { v = e.getConstantValue() }
|
||||
query predicate exprValue(Expr e, ConstantValue v, string t) {
|
||||
v = e.getConstantValue() and t = v.getValueType()
|
||||
}
|
||||
|
||||
query predicate exprCfgNodeValue(ExprCfgNode n, ConstantValue v) { v = n.getConstantValue() }
|
||||
query predicate exprCfgNodeValue(ExprCfgNode n, ConstantValue v, string t) {
|
||||
v = n.getConstantValue() and t = v.getValueType()
|
||||
}
|
||||
|
||||
@@ -89,12 +89,12 @@ stringlikeLiterals
|
||||
| escapes.rb:38:1:38:6 | "\\C-?" | C-? | string |
|
||||
| escapes.rb:43:5:43:9 | "\\\\." | \\. | string |
|
||||
| escapes.rb:44:1:44:6 | "#{...}" | \\. | string |
|
||||
| escapes.rb:48:1:48:4 | /\\n/ | \\n | string |
|
||||
| escapes.rb:49:1:49:4 | /\\p/ | \\p | string |
|
||||
| escapes.rb:50:1:50:8 | /\\u0061/ | \\u0061 | string |
|
||||
| escapes.rb:48:1:48:4 | /\\n/ | \\n | regexp |
|
||||
| escapes.rb:49:1:49:4 | /\\p/ | \\p | regexp |
|
||||
| escapes.rb:50:1:50:8 | /\\u0061/ | \\u0061 | regexp |
|
||||
| escapes.rb:53:5:53:9 | "\\\\." | \\. | string |
|
||||
| escapes.rb:54:5:54:8 | /\\./ | \\. | string |
|
||||
| escapes.rb:55:1:55:10 | /#{...}#{...}/ | \\.\\. | string |
|
||||
| escapes.rb:54:5:54:8 | /\\./ | \\. | regexp |
|
||||
| escapes.rb:55:1:55:10 | /#{...}#{...}/ | \\.\\. | regexp |
|
||||
| escapes.rb:58:4:58:9 | "foo \\n" | foo\\n | string |
|
||||
| escapes.rb:58:11:58:13 | "bar" | bar | string |
|
||||
| escapes.rb:61:1:61:5 | :"\\'" | ' | symbol |
|
||||
|
||||
@@ -18,7 +18,7 @@ query predicate regexpEscapeSequenceComponents(RegExpEscapeSequenceComponent c,
|
||||
}
|
||||
|
||||
query predicate stringlikeLiterals(StringlikeLiteral l, string value, string kind) {
|
||||
value = l.getConstantValue().getString() and kind = "string"
|
||||
or
|
||||
value = l.getConstantValue().getSymbol() and kind = "symbol"
|
||||
exists(ConstantValue v |
|
||||
v = l.getConstantValue() and value = v.getStringlikeValue() and kind = v.getValueType()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import ruby
|
||||
|
||||
private string getValueText(MethodName m) {
|
||||
result = m.getConstantValue().getStringOrSymbol()
|
||||
result = m.getConstantValue().getStringlikeValue()
|
||||
or
|
||||
not exists(m.getConstantValue()) and result = "(none)"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user