False positive: go/uncontrolled-allocation-size, even though length is limited via `min` function
- Ngôn ngữ chính
- CodeQL
- Star
- 10.1k
- Fork
- 2.1k
- Merge trung bình
- 2 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 141
Mô tả
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
Hướng dẫn đóng góp
Hướng nghiên cứu
Start by inspecting the go/uncontrolled-allocation-size query and reproduce the report using the event.go example at the linked commit. Confirm that the min-limited allocation is handled correctly and that the alert is no longer produced for this case.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- go
- Lĩnh vực
- security
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100