mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 09:45:22 +03:00
Clean http passwords too
This commit is contained in:
parent
39c8564750
commit
7f93712e73
@ -9,4 +9,5 @@ PLUS_API_HOST = "https://api.frigate.video"
|
||||
# Regex Consts
|
||||
|
||||
REGEX_CAMERA_NAME = "^[a-zA-Z0-9_-]+$"
|
||||
REGEX_CAMERA_USER_PASS = ":\/\/[a-zA-Z0-9_-]+:[\S]+@"
|
||||
REGEX_RTSP_CAMERA_USER_PASS = ":\/\/[a-zA-Z0-9_-]+:[\S]+@"
|
||||
REGEX_HTTP_CAMERA_USER_PASS = "user=[a-zA-Z0-9_-]+&password=[\S]+"
|
||||
|
||||
@ -20,7 +20,7 @@ import numpy as np
|
||||
import os
|
||||
import psutil
|
||||
|
||||
from frigate.const import REGEX_CAMERA_USER_PASS
|
||||
from frigate.const import REGEX_HTTP_CAMERA_USER_PASS, REGEX_RTSP_CAMERA_USER_PASS
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -666,14 +666,16 @@ def load_labels(path, encoding="utf-8"):
|
||||
|
||||
def clean_camera_user_pass(line: str) -> str:
|
||||
"""Removes user and password from line."""
|
||||
# todo also remove http password like reolink
|
||||
return re.sub(REGEX_CAMERA_USER_PASS, "://*:*@", line)
|
||||
if line.startswith("rtsp://"):
|
||||
return re.sub(REGEX_RTSP_CAMERA_USER_PASS, "://*:*@", line)
|
||||
else:
|
||||
return re.sub(REGEX_HTTP_CAMERA_USER_PASS, "user=*&password=*", line)
|
||||
|
||||
|
||||
def escape_special_characters(path: str) -> str:
|
||||
"""Cleans reserved characters to encodings for ffmpeg."""
|
||||
try:
|
||||
found = re.search(REGEX_CAMERA_USER_PASS, path).group(0)[3:-1]
|
||||
found = re.search(REGEX_RTSP_CAMERA_USER_PASS, path).group(0)[3:-1]
|
||||
pw = found[(found.index(":") + 1) :]
|
||||
return path.replace(pw, urllib.parse.quote_plus(pw))
|
||||
except AttributeError:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user