require url safe camera names

This commit is contained in:
Blake Blackshear 2022-02-02 07:21:03 -06:00
parent a10970d7c9
commit 69aaf1f8e6
2 changed files with 25 additions and 1 deletions

View File

@ -473,7 +473,7 @@ class CameraLiveConfig(FrigateBaseModel):
class CameraConfig(FrigateBaseModel):
name: Optional[str] = Field(title="Camera name.")
name: Optional[str] = Field(title="Camera name.", regex="^[a-zA-Z0-9_]+$")
ffmpeg: CameraFfmpegConfig = Field(title="FFmpeg configuration for the camera.")
best_image_timeout: int = Field(
default=60,

View File

@ -1244,6 +1244,30 @@ class TestConfig(unittest.TestCase):
runtime_config = frigate_config.runtime_config
assert runtime_config.cameras["back"].snapshots.retain.default == 1.5
def test_fails_on_bad_camera_name(self):
config = {
"mqtt": {"host": "mqtt"},
"snapshots": {"retain": {"default": 1.5}},
"cameras": {
"back camer#": {
"ffmpeg": {
"inputs": [
{
"path": "rtsp://10.0.0.1:554/video",
"roles": ["detect"],
},
]
},
}
},
}
frigate_config = FrigateConfig(**config)
self.assertRaises(
ValidationError, lambda: frigate_config.runtime_config.cameras
)
if __name__ == "__main__":
unittest.main(verbosity=2)