Skip to main content

Module util

Module util 

Source

ConstantsΒ§

REDACTED πŸ”’
Placeholder substituted for any password found in a connection string.
REDACTED_CONNECTION_STRING πŸ”’
Substituted for a whole connection string that cannot be safely sanitized.

FunctionsΒ§

is_keyword_at πŸ”’
True if keyword starts at byte i preceded by a keyword boundary. In addition to valid libpq whitespace separators, ; and & are treated as conservative boundaries so malformed DSNs cannot leak credentials. Other punctuation, such as the = in application_name=password=x, is handled by the fail-closed path.
is_uri_like πŸ”’
True if s, ignoring leading whitespace, begins with a valid URI scheme followed by :// (scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )). Leading whitespace (including Unicode, e.g. U+2003) does not stop a value from being a URI, so it is trimmed first; a bare contains("://") would instead misfire on a :// inside a keyword value.
keyword_matches_at πŸ”’
redact_keyword_password πŸ”’
Redacts password values in a keyword string. A standalone, case-insensitive password assignment outside a recognized keyword boundary causes the whole string to be redacted, since another option’s value may otherwise retain it. Keys are separated by Unicode whitespace; a value is single/double quoted or runs to the next unescaped whitespace, with \ escaping the next character.
redact_url πŸ”’
Redacts the userinfo password and any password query parameter of a parsed URL.
sanitize_connection_string
Removes sensitive information (passwords) from a connection string before it is logged.
skip_value πŸ”’
Returns the byte index just past a keyword value beginning at start.
skip_ws πŸ”’