Skip to content

NVR with realtime local object detection for IP cameras

Fix cleaning logs with rtsp in middle (#5800)

Nicolas Mowen3f17f871fa25
diff --git a/frigate/test/test_camera_pw.py b/frigate/test/test_camera_pw.py
index dd72fcc7d7..92aec48d87 100644
--- a/frigate/test/test_camera_pw.py
+++ b/frigate/test/test_camera_pw.py
@@ -36,3 +36,14 @@ class TestUserPassCleanup(unittest.TestCase):
"""Test that no change is made to path with no special characters."""
escaped = escape_special_characters(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:[email protected]: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"
diff --git a/frigate/util.py b/frigate/util.py
index 6a44811bad..a6fe4b2943 100755
--- a/frigate/util.py
+++ b/frigate/util.py
@@ -722,7 +722,7 @@ def load_labels(path, encoding="utf-8"):
def clean_camera_user_pass(line: str) -> str:
"""Removes user and password from line."""
- if line.startswith("rtsp://"):
+ if "rtsp://" in line:
return re.sub(REGEX_RTSP_CAMERA_USER_PASS, "://*:*@", line)
else:
return re.sub(REGEX_HTTP_CAMERA_USER_PASS, "user=*&password=*", line)