MCPcopy Create free account
hub / github.com/PostHog/duckgres / IsValidCacheKey

Function IsValidCacheKey

cmd/cache-proxy/cache.go:27–29  ·  view source on GitHub ↗

IsValidCacheKey returns true if key is a 64-char lowercase hex string.

(key string)

Source from the content-addressed store, hash-verified

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.
28var validCacheKey = regexp.MustCompile(`^[0-9a-f]{64}$`)
29
30// IsValidCacheKey returns true if key is a 64-char lowercase hex string.
31func IsValidCacheKey(key string) bool {
32 return validCacheKey.MatchString(key)

Callers 10

HandlePeerHasMethod · 0.85
HandlePeerGetMethod · 0.85
scanExistingMethod · 0.85
HasMethod · 0.85
GetMethod · 0.85
PutMethod · 0.85
PutStreamMethod · 0.85
openFileMethod · 0.85
TestIsValidCacheKeyFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestIsValidCacheKeyFunction · 0.68