github / github/codeql

False positive for IncompleteHostnameRegExp in Ruby

未關閉
#13,749 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
false-positive Ruby
主要語言
CodeQL
星號
10.1k
分支
2.1k
平均合併
2 天 15 小時
30 天內合併 PR
141

描述

**Description of the false positive**

There's a problem with the current implementation of `IncompleteHostnameRegExp` for Ruby. Specifically, it seems that the rule with report false positives for any `X.match(Y)` method call where `Y` is a `String` and `X` is any object with a `match` method.

The rule incorrectly "thinks" that `Y` is a regex being used for matching, likely because in Ruby's `String` class has a `match` method which takes a `String` parameter for defining the regex:

https://ruby-doc.org/3.2.2/String.html#method-i-match

In other words, the rule doesn't check that `X` is a known type for which the `match` method accepts a string argument which is used as a regex, and instead matches on any type for `X`.

**Code samples or links to source code**

Please see https://github.com/github/codeql/pull/13748 which includes a failing test which demonstrates the problem.

**URL to the alert on GitHub code scanning (optional)**

Can't share it since it's in a private repository 😬

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。