mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 01:35:22 +03:00
Redact user:pass from ffmpeg logs
This commit is contained in:
parent
bb8dc2d09c
commit
31a9d705b4
@ -1,5 +1,6 @@
|
|||||||
# adapted from https://medium.com/@jonathonbao/python3-logging-with-multiprocessing-f51f460b8778
|
# adapted from https://medium.com/@jonathonbao/python3-logging-with-multiprocessing-f51f460b8778
|
||||||
import logging
|
import logging
|
||||||
|
import re
|
||||||
import threading
|
import threading
|
||||||
import os
|
import os
|
||||||
import signal
|
import signal
|
||||||
@ -10,6 +11,8 @@ from setproctitle import setproctitle
|
|||||||
from typing import Deque
|
from typing import Deque
|
||||||
from collections import deque
|
from collections import deque
|
||||||
|
|
||||||
|
from frigate.const import REGEX_CAMERA_USER_PASS
|
||||||
|
|
||||||
|
|
||||||
def listener_configurer() -> None:
|
def listener_configurer() -> None:
|
||||||
root = logging.getLogger()
|
root = logging.getLogger()
|
||||||
@ -55,6 +58,11 @@ class LogPipe(threading.Thread):
|
|||||||
self.pipeReader = os.fdopen(self.fdRead)
|
self.pipeReader = os.fdopen(self.fdRead)
|
||||||
self.start()
|
self.start()
|
||||||
|
|
||||||
|
def cleanup_log(self, log: str) -> str:
|
||||||
|
"""Cleanup the log line to remove sensitive info and string tokens."""
|
||||||
|
log = re.sub(REGEX_CAMERA_USER_PASS, "*:*@", log).strip("\n")
|
||||||
|
return log
|
||||||
|
|
||||||
def fileno(self) -> int:
|
def fileno(self) -> int:
|
||||||
"""Return the write file descriptor of the pipe"""
|
"""Return the write file descriptor of the pipe"""
|
||||||
return self.fdWrite
|
return self.fdWrite
|
||||||
@ -62,7 +70,7 @@ class LogPipe(threading.Thread):
|
|||||||
def run(self) -> None:
|
def run(self) -> None:
|
||||||
"""Run the thread, logging everything."""
|
"""Run the thread, logging everything."""
|
||||||
for line in iter(self.pipeReader.readline, ""):
|
for line in iter(self.pipeReader.readline, ""):
|
||||||
self.deque.append(line.strip("\n"))
|
self.deque.append(self.cleanup_log(line))
|
||||||
|
|
||||||
self.pipeReader.close()
|
self.pipeReader.close()
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user