github / github/codeql

False positive for `go/incomplete-hostname-regexp` and `\Q`

オープン
#15,894 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
false-positive Go
主要言語
CodeQL
スター
10.1k
フォーク
2.1k
平均マージ
2日 15時間
マージ済み PR(30日)
141

説明

**Description of the false positive**

```go
var todoRE = regexp.MustCompile(`^// TODO (\Qhttps://github.com/FerretDB/\E([-\w]+)/issues/(\d+))$`)
```

That line is annotated with: "This regular expression has an unescaped dot before 'com', so it might match more hosts than expected when the regular expression is used."

What it misses is [`\Q...\E` escape syntax](https://pkg.go.dev/regexp/syntax).

**Code samples or links to source code**

https://github.com/FerretDB/FerretDB/blob/ea9c5bda8f3f80a9263e006995d4257084a600a5/tools/checkcomments/checkcomments.go#L32

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

https://github.com/FerretDB/FerretDB/security/code-scanning/9

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Start with tools/checkcomments/checkcomments.go at the linked location and review the regexp/syntax documentation for \Q...\E escaping. Trace where the incomplete-hostname-regexp alert is produced in CodeQL, then verify that the supplied Go expression is no longer reported as a false positive.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
go
領域
security
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。