Skip to main content

Module security

Module security 

Source
Expand description

Security utilities: URL credential redaction, error sanitization, and RTSP transport security policy.

§Credential redaction

redact_url strips user:password@ from URLs while preserving the host, port, and path for diagnostic purposes. This prevents credentials from leaking into logs, health events, or error messages.

§Error sanitization

sanitize_error_string cleans untrusted backend error/debug strings by:

  • Stripping control characters and bare newlines.
  • Capping to a configurable maximum length.
  • Redacting patterns that resemble secrets (e.g., password=..., token=..., key=...).

§RTSP security policy

RtspSecurityPolicy controls whether rtsps:// (TLS) is preferred, required, or explicitly opted-out for RTSP sources.

§Threat model

RTSP streams carry both video data and sometimes credentials in the URL. Without TLS:

  • Credentials may be visible to network observers (man-in-the-middle).
  • Video data is transmitted in the clear.
  • An attacker on the network can spoof or tamper with the stream.

PreferTls (the default) upgrades bare rtsp:// URLs to rtsps:// so that production deployments default to encrypted transport without requiring code changes. Field deployments behind firewalls or with cameras that don’t support TLS can opt out with AllowInsecure.

§Migration path

  1. Existing code that passes explicit rtsp:// URLs will continue to work — the URL is promoted to rtsps:// unless AllowInsecure is set or the URL already uses rtsps://.
  2. If a camera does not support TLS, set AllowInsecure on the source spec. A health warning will be emitted.
  3. For high-security deployments, set RequireTls to reject any unencrypted RTSP source at config validation time.

Enums§

CustomPipelinePolicy
Whether SourceSpec::Custom pipeline fragments are trusted.
RtspSecurityPolicy
RTSP transport security policy.

Functions§

is_insecure_rtsp
Check whether an RTSP URL uses insecure (non-TLS) transport.
promote_rtsp_to_tls
Apply URL scheme promotion for RTSP sources under RtspSecurityPolicy::PreferTls.
redact_url
Redact credentials from a URL string.
redact_urls_in_string
Apply redact_url to all URL-like substrings in a string.
sanitize_error_string
Sanitize an untrusted error/debug string from a backend.