github / github/codeql

Ruby: Traditional if-else not detected as `StringConstArrayInclusionCallBarrier` compared to conditional assignment.

未关闭
#11,558 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
question Ruby
主要语言
CodeQL
星标
10.1k
派生
2.1k
平均合并
2 天 15 小时
30 天内合并 PR
141

描述

**Information**
CodeQL Version:
7f5df4fc0e9ec8ffed0e8eefe78fb5544be46dc4

**Description of the issue**
Create a database for this ruby code:
```ruby
aaa = "imagine this is derived from a remote source"
if ["fff", "eee"].include?(aaa) # {1}
# accept aaa as is
else
aaa = "Value"
end

aaa = if ["fff", "eee"].include?(aaa) # {2}
aaa
else
"Value"
end
```

**Expected**
1. {1} and {2} are detected as a `StringConstArrayInclusionCall` (using quick-eval)
2. {1} and {2} are detected as a `StringConstArrayInclusionCallBarrier` (using quick-eval)

**Actual**
1. {1} and {2} are detected as a `StringConstArrayInclusionCall` (using quick-eval)
2. {1} **is not** detected as a `StringConstArrayInclusionCallBarrier` (using quick-eval)
3. {2} **is** detected as a `StringConstArrayInclusionCallBarrier` (using quick-eval)

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。