mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Redact ?auth= url parameters in stream sources when logged (#60438)
This commit is contained in:
parent
622d9606a5
commit
5e86c78c46
@ -55,12 +55,17 @@ from .hls import HlsStreamOutput, async_setup_hls
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
STREAM_SOURCE_RE = re.compile("//.*:.*@")
|
STREAM_SOURCE_REDACT_PATTERN = [
|
||||||
|
(re.compile(r"//.*:.*@"), "//****:****@"),
|
||||||
|
(re.compile(r"\?auth=.*"), "?auth=****"),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def redact_credentials(data: str) -> str:
|
def redact_credentials(data: str) -> str:
|
||||||
"""Redact credentials from string data."""
|
"""Redact credentials from string data."""
|
||||||
return STREAM_SOURCE_RE.sub("//****:****@", data)
|
for (pattern, repl) in STREAM_SOURCE_REDACT_PATTERN:
|
||||||
|
data = pattern.sub(repl, data)
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
def create_stream(
|
def create_stream(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user