module

CrImage::InputValidation

InputValidation provides security-focused validation for user inputs to prevent DoS attacks and resource exhaustion

Constants

MAX_SAFE_AREA = 100000000_i64

Maximum reasonable image area (100 megapixels) A 10000x10000 image at 4 bytes/pixel = 400MB

MAX_SAFE_DIMENSION = 100000

Maximum reasonable image dimension (100,000 pixels) Prevents memory exhaustion attacks

MAX_SAFE_FILE_SIZE = 500000000_i64

Maximum reasonable file size for reading (500MB)

Class methods

validate_adjustment(adjustment : Int32, min : Int32, max : Int32, name : String = "adjustment")

Validate adjustment parameter for brightness/contrast

Source
validate_color_stops(stops : Array)

Validate color stop positions for gradients

Source
validate_factor(factor : Float64, min : Float64, max : Float64, name : String = "factor")

Validate factor parameter for contrast/scale operations

Source
validate_image_dimensions(width : Int32, height : Int32, context : String = "image")

Validate image dimensions are reasonable

Source
validate_polygon_points(points : Array(Point), min_points : Int32 = 3)

Validate polygon has sufficient points

Source
validate_quality(quality : Int32, min : Int32 = 1, max : Int32 = 100)

Validate quality parameter for JPEG/WebP encoding

Source
validate_radius(radius : Int32, max : Int32 = 1000)

Validate radius parameter for blur operations

Source