IsValidCacheKey returns true if key is a 64-char lowercase hex string.
(key string)
| 25 | // Cache keys arrive from untrusted peers via HTTP query params; anything |
| 26 | // that isn't a clean hex digest is rejected to prevent filepath traversal |
| 27 | // when composing the on-disk path. |
| 28 | var validCacheKey = regexp.MustCompile(`^[0-9a-f]{64}$`) |
| 29 | |
| 30 | // IsValidCacheKey returns true if key is a 64-char lowercase hex string. |
| 31 | func IsValidCacheKey(key string) bool { |
| 32 | return validCacheKey.MatchString(key) |
no outgoing calls