github / github/codeql

False positive: go/uncontrolled-allocation-size, even though length is limited via `min` function

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

描述

A false positive of "Slice memory allocation with excessive size value" in Go (Rule ID: go/uncontrolled-allocation-size).

It's a false positive, because the length of the allocated slice is explicitly limited via the `min` function, so it should not be reported. Link to source code:

https://github.com/fzipp/canvas/blob/9bf9f5531d570cf664d7c0f931b02dd3749f4fce/event.go#L402

```go
const maxTouchListLength = 10
length := buf.readByte()
limitedLength := min(length, maxTouchListLength)
list := make(TouchList, limitedLength)
```

URL to the alert on GitHub code scanning:
https://github.com/fzipp/canvas/security/code-scanning/2

貢獻指南

開啟貢獻指南

研究方向

先檢查 go/uncontrolled-allocation-size 查詢,並使用連結 commit 中的 event.go 範例重現該報告。確認受 min 限制的 allocation 已正確處理,且此案例不再產生警示。

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

評估

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

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

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