forgejo/modules/util
Gusted 53df0bf9a4 chore(sec): unify usage of crypto/rand.Read (#7453)
- Unify the usage of [`crypto/rand.Read`](https://pkg.go.dev/crypto/rand#Read) to `util.CryptoRandomBytes`.
- Refactor `util.CryptoRandomBytes` to never return an error. It is documented by Go, https://go.dev/issue/66821, to always succeed. So if we still receive a error or if the returned bytes read is not equal to the expected bytes to be read we panic (just to be on the safe side).
- This simplifies a lot of code to no longer care about error handling.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7453
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: Gusted <postmaster@gusted.xyz>
Co-committed-by: Gusted <postmaster@gusted.xyz>
2025-04-04 03:31:37 +00:00
..
filebuffer Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
rotatingfilewriter chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
color.go [PORT] gitea##30237: Fix and rewrite contrast color calculation, fix project-related bugs 2024-04-15 16:11:34 +02:00
color_test.go Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
error.go Replace interface{} with any (#25686) 2023-07-04 18:36:08 +00:00
file_unix.go Drop SSPI auth support and more Windows files (#7148) 2025-03-08 00:43:41 +00:00
file_unix_test.go Drop SSPI auth support and more Windows files (#7148) 2025-03-08 00:43:41 +00:00
io.go
io_test.go Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
keypair.go Enable unparam linter (#31277) 2024-06-16 13:42:58 +02:00
keypair_test.go test: fix test linting 2024-11-11 12:44:36 +01:00
legacy.go [DEADCODE] Add deadcode linter 2024-02-05 14:45:09 +01:00
legacy_test.go Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
pack.go Replace interface{} with any (#25686) 2023-07-04 18:36:08 +00:00
pack_test.go Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
paginate.go Replace interface{} with any (#25686) 2023-07-04 18:36:08 +00:00
paginate_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
path.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
path_test.go Drop SSPI auth support and more Windows files (#7148) 2025-03-08 00:43:41 +00:00
remove.go Drop SSPI auth support and more Windows files (#7148) 2025-03-08 00:43:41 +00:00
sanitize.go Refactor to use UnsafeStringToBytes (#31358) 2024-06-16 13:42:58 +02:00
sanitize_test.go
sec_to_time.go
sec_to_time_test.go
shellquote.go
shellquote_test.go
slice.go chore: teach set module about iter.Seq (#6676) 2025-01-24 16:45:46 +00:00
slice_test.go Replace util.SliceXxx with slices.Xxx (#26958) 2023-09-07 09:37:47 +00:00
string.go Refactor to use UnsafeStringToBytes (#31358) 2024-06-16 13:42:58 +02:00
string_test.go
timer.go
timer_test.go
truncate.go Validate OAuth Redirect URIs (#32643) 2024-12-03 10:19:22 +01:00
truncate_test.go
url.go Add RemoteAddress to mirrors (#26952) 2023-09-16 16:03:02 +00:00
util.go chore(sec): unify usage of crypto/rand.Read (#7453) 2025-04-04 03:31:37 +00:00
util_test.go chore(sec): unify usage of crypto/rand.Read (#7453) 2025-04-04 03:31:37 +00:00