1.5 KiB
TODO — Code Logic Errors
Critical
-
Login: nil pointer dereference (
http.go:111)CacheGetClientByNamereturnsnilon miss, thenDbSetClientByNameis called with that nilclient→ panic. Should query DB by username directly. -
Login: password never verified (
http.go:87–131) No call toPasswordVerify/bcrypt.CompareHashAndPassword. Anyone with a valid username can log in.
High
-
Login: validates
usernamelength instead ofpassword(http.go:98)if len(username) < 8should beif len(password) < 8. Password is never length-checked. -
DB: missing
&inScanforpronouns(database.go:87)client.Pronounsshould be&client.Pronouns. Compare withDbSetClientByIdwhich does it correctly. -
WS: 30s context kills entire connection (
wsServer.go:23) A single 30s timeout context is shared across all reads in the loop. Should use per-read deadlines orcontext.Background()for the loop.
Medium
-
NewUser: missing
returnafter bad color error (http.go:54–56) OnparseRgberror,http.Erroris called but execution continues withcolor = [0,0,0]. -
WS: unauth disconnect deletes ID=0 from cache (
wsServer.go:115)closeConnectioncallsCacheDeleteClient(client.Id)but unauthenticated clients haveId=0, wiping whatever sits at key 0.
Low
CacheSetGroupis a no-op (cache.go:59) Function body is empty. TheGroupscache is never populated, so everyCacheGetGroupcall misses and falls back to DB.