mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Fix cleaning logs with rtsp in middle (#5800)
This commit is contained in:
parent
e454daf727
commit
3f17f871fa
@ -36,3 +36,14 @@ class TestUserPassCleanup(unittest.TestCase):
|
|||||||
"""Test that no change is made to path with no special characters."""
|
"""Test that no change is made to path with no special characters."""
|
||||||
escaped = escape_special_characters(self.rtsp_with_pass)
|
escaped = escape_special_characters(self.rtsp_with_pass)
|
||||||
assert escaped == self.rtsp_with_pass
|
assert escaped == self.rtsp_with_pass
|
||||||
|
|
||||||
|
|
||||||
|
class TestUserPassMasking(unittest.TestCase):
|
||||||
|
def setUp(self) -> None:
|
||||||
|
self.rtsp_log_message = "Did you mean file:rtsp://user:password@192.168.1.3:554"
|
||||||
|
|
||||||
|
def test_rtsp_in_log_message(self):
|
||||||
|
"""Test that the rtsp url in a log message is espaced."""
|
||||||
|
escaped = clean_camera_user_pass(self.rtsp_log_message)
|
||||||
|
print(f"The escaped is {escaped}")
|
||||||
|
assert escaped == "Did you mean file:rtsp://*:*@192.168.1.3:554"
|
||||||
|
@ -722,7 +722,7 @@ def load_labels(path, encoding="utf-8"):
|
|||||||
|
|
||||||
def clean_camera_user_pass(line: str) -> str:
|
def clean_camera_user_pass(line: str) -> str:
|
||||||
"""Removes user and password from line."""
|
"""Removes user and password from line."""
|
||||||
if line.startswith("rtsp://"):
|
if "rtsp://" in line:
|
||||||
return re.sub(REGEX_RTSP_CAMERA_USER_PASS, "://*:*@", line)
|
return re.sub(REGEX_RTSP_CAMERA_USER_PASS, "://*:*@", line)
|
||||||
else:
|
else:
|
||||||
return re.sub(REGEX_HTTP_CAMERA_USER_PASS, "user=*&password=*", line)
|
return re.sub(REGEX_HTTP_CAMERA_USER_PASS, "user=*&password=*", line)
|
||||||
|
Loading…
Reference in New Issue
Block a user