Add failing tests for input dimension and path traversal validation
Tests for: - ErrInputTooLarge when input image exceeds MaxInputDimension - ErrPathTraversal for ../, encoded traversal, backslashes, null bytes
This commit is contained in:
@@ -3,6 +3,7 @@ package imgcache
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"image"
|
||||
"image/gif"
|
||||
@@ -14,6 +15,13 @@ import (
|
||||
"golang.org/x/image/webp"
|
||||
)
|
||||
|
||||
// MaxInputDimension is the maximum allowed width or height for input images.
|
||||
// Images larger than this are rejected to prevent DoS via decompression bombs.
|
||||
const MaxInputDimension = 8192
|
||||
|
||||
// ErrInputTooLarge is returned when input image dimensions exceed MaxInputDimension.
|
||||
var ErrInputTooLarge = errors.New("input image dimensions exceed maximum")
|
||||
|
||||
// ImageProcessor implements the Processor interface using pure Go libraries.
|
||||
type ImageProcessor struct{}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user