Replace redacted stream recorder credentials with '****' (#48832)

This commit is contained in:
Erik Montnemery 2021-04-08 21:44:17 +02:00 committed by GitHub
parent 2dc46d4516
commit b0aa64d59c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 13 deletions

View file

@ -39,7 +39,12 @@ from .hls import async_setup_hls
_LOGGER = logging.getLogger(__name__)
STREAM_SOURCE_RE = re.compile("//(.*):(.*)@")
STREAM_SOURCE_RE = re.compile("//.*:.*@")
def redact_credentials(data):
"""Redact credentials from string data."""
return STREAM_SOURCE_RE.sub("//****:****@", data)
def create_stream(hass, stream_source, options=None):
@ -176,9 +181,7 @@ class Stream:
target=self._run_worker,
)
self._thread.start()
_LOGGER.info(
"Started stream: %s", STREAM_SOURCE_RE.sub("//", str(self.source))
)
_LOGGER.info("Started stream: %s", redact_credentials(str(self.source)))
def update_source(self, new_source):
"""Restart the stream with a new stream source."""
@ -244,9 +247,7 @@ class Stream:
self._thread_quit.set()
self._thread.join()
self._thread = None
_LOGGER.info(
"Stopped stream: %s", STREAM_SOURCE_RE.sub("//", str(self.source))
)
_LOGGER.info("Stopped stream: %s", redact_credentials(str(self.source)))
async def async_record(self, video_path, duration=30, lookback=5):
"""Make a .mp4 recording from a provided stream."""