safety

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package safety contains hard limits and validation helpers used by the image preprocessing pipeline. These checks intentionally fail closed: an unknown or unbounded image reference is never sent to an upstream service.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyImageReference       = errors.New("image reference is empty")
	ErrImageReferenceTooLarge    = errors.New("image reference exceeds size limit")
	ErrUnsupportedImageReference = errors.New("image reference must be an http(s) URL or image data URI")
	ErrResultTooLarge            = errors.New("visual result exceeds size limit")
)

Functions

func ValidateImageReference

func ValidateImageReference(ref string, maxBytes int) error

ValidateImageReference validates the complete external image reference and applies an optional byte limit. It is the shared validator for discovery and the final host-model callback boundary.

Types

type Limits

type Limits struct {
	MaxImages              int
	MaxImageReferenceBytes int
	MaxResultChars         int
}

Limits are hard safety limits. A zero value means that the corresponding check is disabled; callers should normally provide explicit non-zero values.

func (Limits) ValidateImageCount

func (l Limits) ValidateImageCount(n int) error

func (Limits) ValidateImageReference

func (l Limits) ValidateImageReference(ref string) error

ValidateImageReference accepts only a network URL or a data URI carrying an image. file://, javascript://, credentials and other schemes are rejected.

func (Limits) ValidateResult

func (l Limits) ValidateResult(text string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL