forked from blakeblackshear/frigate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support special characters in passwords, redacted logs & debug config (…
…blakeblackshear#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
- Loading branch information
Showing
7 changed files
with
83 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""Test camera user and password cleanup.""" | ||
|
||
import unittest | ||
|
||
from frigate.util import clean_camera_user_pass, escape_special_characters | ||
|
||
|
||
class TestUserPassCleanup(unittest.TestCase): | ||
def setUp(self) -> None: | ||
self.rtsp_with_pass = "rtsp:https://user:[email protected]:554/live" | ||
self.rtsp_with_special_pass = "rtsp:https://user:password#$@@192.168.0.2:554/live" | ||
self.rtsp_no_pass = "rtsp:https://192.168.0.3:554/live" | ||
|
||
def test_cleanup(self): | ||
"""Test that user / pass are cleaned up.""" | ||
clean = clean_camera_user_pass(self.rtsp_with_pass) | ||
assert clean != self.rtsp_with_pass | ||
assert "user:password" not in clean | ||
|
||
def test_no_cleanup(self): | ||
"""Test that nothing changes when no user / pass are defined.""" | ||
clean = clean_camera_user_pass(self.rtsp_no_pass) | ||
assert clean == self.rtsp_no_pass | ||
|
||
def test_special_char_password(self): | ||
"""Test that special characters in pw are escaped, but not others.""" | ||
escaped = escape_special_characters(self.rtsp_with_special_pass) | ||
assert escaped == "rtsp:https://user:password%23%24%[email protected]:554/live" | ||
|
||
def test_no_special_char_password(self): | ||
"""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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters