False positive: go/uncontrolled-allocation-size, even though length is limited via `min` function
- Langage dominant
- CodeQL
- Étoiles
- 10.1k
- Forks
- 2.1k
- Merge moyen
- 2 j 15 h
- PR mergées (30 j)
- 141
Description
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
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par inspecter la requête go/uncontrolled-allocation-size et reproduisez le rapport à l’aide de l’exemple event.go du commit lié. Confirmez que l’allocation limitée par min est correctement traitée et que l’alerte n’est plus produite pour ce cas.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- go
- Domaine
- security
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100