Support special characters in passwords, redacted logs & debug config (#4057)

* Consts for regex

* Add regex for camera username and password

* Redact user:pass from ffmpeg logs

* Redact ffmpeg commands

* Move common function to util

* Add tests

* Formatting

* Remove unused imports

* Fix test

* Add port to test

* Support special characters in passwords

* Add tests for special character handling

* Remove docs about not supporting special characters
This commit is contained in:
Nicolas Mowen
2022-11-02 06:00:54 -06:00
committed by GitHub
parent 11624d4759
commit 1bc9efd529
7 changed files with 83 additions and 20 deletions

View File

@@ -2,7 +2,6 @@
import logging
import threading
import os
import signal
import queue
from multiprocessing.queues import Queue
from logging import handlers
@@ -10,6 +9,8 @@ from setproctitle import setproctitle
from typing import Deque
from collections import deque
from frigate.util import clean_camera_user_pass
def listener_configurer() -> None:
root = logging.getLogger()
@@ -55,6 +56,11 @@ class LogPipe(threading.Thread):
self.pipeReader = os.fdopen(self.fdRead)
self.start()
def cleanup_log(self, log: str) -> str:
"""Cleanup the log line to remove sensitive info and string tokens."""
log = clean_camera_user_pass(log).strip("\n")
return log
def fileno(self) -> int:
"""Return the write file descriptor of the pipe"""
return self.fdWrite
@@ -62,7 +68,7 @@ class LogPipe(threading.Thread):
def run(self) -> None:
"""Run the thread, logging everything."""
for line in iter(self.pipeReader.readline, ""):
self.deque.append(line.strip("\n"))
self.deque.append(self.cleanup_log(line))
self.pipeReader.close()