secval

package
v11.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package secval provides JSON security validation: dangerous key detection and nesting depth limits. It has NO cross-module dependencies — errors are module-local sentinel types.

Do not use secval on file uploads or streaming endpoints. It parses the entire input into memory. Enforce body size limits (e.g., MaxBytesReader at 1-2MB) BEFORE passing data to secval.

Index

Constants

View Source
const MaxNestingDepth = 20

MaxNestingDepth is the maximum allowed depth for nested structures.

Variables

View Source
var (
	ErrDangerousKey = errors.New("secval: dangerous key detected")
	ErrNestingDepth = errors.New("secval: nesting depth exceeded")
	ErrInvalidJSON  = errors.New("secval: invalid JSON")
)

Sentinel errors — module-local, NOT from the chassis errors package.

View Source
var ErrInvalidIdentifier = errors.New("secval: invalid SQL identifier")

Functions

func RedactSecrets

func RedactSecrets(s string) string

RedactSecrets replaces secret values in a string with [REDACTED].

func SafeFilename

func SafeFilename(s string) string

SafeFilename removes path separators, null bytes, and control characters.

func SafeFilenameURL

func SafeFilenameURL(s string) string

SafeFilenameURL returns a URL-safe filename.

func ValidateIdentifier

func ValidateIdentifier(s string) error

ValidateIdentifier checks that s is a safe SQL identifier.

func ValidateJSON

func ValidateJSON(data []byte) error

ValidateJSON parses data as JSON and scans it for dangerous keys and excessive nesting. Returns nil on success, or an error wrapping one of the sentinel errors (ErrDangerousKey, ErrNestingDepth, ErrInvalidJSON).

Types

This section is empty.

Jump to

Keyboard shortcuts

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