validateSessionName checks the session name against security rules (L4).
(name string)
| 49 | |
| 50 | // validateSessionName checks the session name against security rules (L4). |
| 51 | func validateSessionName(name string) error { |
| 52 | if name == "" { |
| 53 | return fmt.Errorf("session name cannot be empty") |
| 54 | } |
| 55 | // Reject null bytes, control characters |
| 56 | for _, c := range name { |
| 57 | if c < 0x20 || c == 0x7f || c == 0x00 { |
| 58 | return fmt.Errorf("session name contains invalid control characters") |
| 59 | } |
| 60 | } |
| 61 | if !validSessionName.MatchString(name) { |
| 62 | return fmt.Errorf("session name must be alphanumeric with dash/underscore/dot only (max 255 chars)") |
| 63 | } |
| 64 | return nil |
| 65 | } |
| 66 | |
| 67 | // getSessionPath retorna o caminho completo para um arquivo de sessão. |
| 68 | func (sm *SessionManager) getSessionPath(name string) string { |