Ushka

API reference

ushka.guard.errors

The error raised when an untrusted value reaches a dangerous sink.

The message is written for two readers at once: a developer reading a traceback, and a coding agent that has to fix the code on the next try. That is why every error carries the sink, the source, a concrete fix and a stable code, and why to_dict() exists.

class UnsafeValueError(Exception)

An Untrusted value was about to be used somewhere it could do harm.

Attributes

codestr

Stable identifier, e.g. "USHKA-G001". Safe to match on.

sinkstr

Where the value was going, e.g. "redirect".

sourcestr

Where the value came from, e.g. "query:next".

riskstr

The attack this prevents, e.g. "open redirect".

fixstr

A concrete line of code that makes the call safe.

to_dict(self) -> dict[str, Any]

A JSON-ready description, for tools and coding agents.