github / github/codeql

False positive - Log entries created from user input

Đang mở
#10,922 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
Go question
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ả

**Description of the issue**

in-place sanitization code is not recognized and constantly reports false positives with "Log entries created from user input"

For example, when using the following sanitization, logging sanitized user input produces a false positive.
```
// contain at most 60 characters
// contain only lowercase alphanumeric characters or '-'
// start with an alphanumeric character
// end with an alphanumeric character
func Sanitize(in string) string {
if len(in) > 60 {
return ""
}
var alphanumeric bool
for i, r := range in {
if (97 <= r && r <= 122) || (48 <= r && r <= 57) {
alphanumeric = true
continue
}
if r == 45 {
alphanumeric = false
// first letter
if i == 0 {
return ""
}
continue
}
return ""
}
// last letter
if !alphanumeric {
return ""
}
return in
}
```

is there a workaround or a way to signal to CodeQL that this is in-place sanitization and no alert is needed?
That is, without moving to a less efficient non-in-place sanitization...

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.