github / github/codeql

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

未關閉
#15,894 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
false-positive Go
主要語言
CodeQL
星號
10.1k
分支
2.1k
平均合併
2 天 15 小時
30 天內合併 PR
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

貢獻指南

開啟貢獻指南

研究方向

從連結位置的 tools/checkcomments/checkcomments.go 開始,查閱 regexp/syntax 關於 \Q...\E 跳脫的文件。追蹤 incomplete-hostname-regexp 警報在 CodeQL 中產生的位置,然後驗證所提供的 Go 運算式不再被回報為誤判。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
go
領域
security
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
42/100

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

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