Documentation
Security
Reference docs for pydantic-fixturegen.
Security: sandbox and safe-import guarantees
Run untrusted models with network, filesystem, and resource guarantees.
Safe-import sandbox
- Executes discovery and generation inside a subprocess with restricted permissions.
- Blocks socket creation by monkey-patching
socket.socketand related APIs. - Scrubs proxy environment variables (
NO_PROXY=*,HTTP(S)_PROXYremoved) and setsPYTHONSAFEPATH=1. - Redirects HOME and temporary directories into a sandbox-local path.
- Denies writes outside the working directory by overriding
open,io.open, andos.open. - Applies memory caps via
resource.RLIMIT_ASandresource.RLIMIT_DATAwhen available. - Times out imports and emits exit code
40when the timeout is exceeded. Configure via--timeout.
Discovery modes
--astkeeps imports disabled and parses source directly.- Default mode combines AST pre-flight with sandboxed imports to resolve dynamic attributes safely.
--hybridensures both methods run and merges results.
Hardened commands
pfg list,pfg gen *,pfg diff, andpfg checkall rely on the sandbox from the same core implementation.pfg doctorsurfaces sandbox breaches, risky imports, and coverage gaps; use--fail-on-gapsto fail CI.- Atomic IO protects JSON, schema, and fixture outputs: a generation failure leaves previous files untouched.
Operating the sandbox
- Adjust timeouts with
--timeoutand memory limits with--memory-limit-mbonpfg list. - When debugging blocked writes, move your output path inside the project root or use templates that avoid
../. - Sandbox exit codes:
0success,20structured discovery errors,40timeout, others bubble up from Python exceptions.
Pair this with doctor diagnostics for a full audit trail and record structured logs via logging.
Edit this page