Ushka

API reference

ushka.guard.sinks

Checks run by dangerous sinks before they use a value.

A framework (or an application) calls these right before doing something that would be exploitable with attacker-controlled input. They raise UnsafeValueError with a concrete fix when the value is Untrusted, and do nothing otherwise.

def check_html(value: Any, sink: str = 'an HTML response body') -> None

Refuses untrusted text that is about to be served as HTML.

def check_markup(value: Any) -> None

Refuses untrusted text that is about to be marked as safe HTML.

def check_redirect(value: Any) -> None

Refuses an untrusted redirect target.

def check_path(value: Any) -> None

Refuses an untrusted file-system path.

def check_sql(value: Any) -> None

Refuses untrusted text that is about to be executed as raw SQL.

Call it on the SQL string: sqlalchemy.text() copies its input through re.sub, so a TextClause no longer carries the mark.