Changeset 0.28.4 (#190)

This commit is contained in:
2026-03-14 19:36:33 +00:00
parent fa6b04434a
commit 85d5e3cc13
54 changed files with 7355 additions and 102 deletions

View File

@@ -0,0 +1,33 @@
package middleware
import (
"net/http"
"strings"
"github.com/gin-gonic/gin"
)
const maxParamLen = 255
// ValidatePathParams rejects requests with null bytes or excessively long
// path parameters. This prevents 500s from invalid UUIDs reaching the
// database layer.
func ValidatePathParams() gin.HandlerFunc {
return func(c *gin.Context) {
for _, p := range c.Params {
if len(p.Value) > maxParamLen {
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{
"error": "path parameter too long",
})
return
}
if strings.ContainsRune(p.Value, 0) {
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{
"error": "invalid character in path parameter",
})
return
}
}
c.Next()
}
}