Merge remote-tracking branch 'origin/master' into dev
CI / AMD64 Build (push) Canceled after 0s
CI / AMD64 Smoke Test (push) Canceled after 0s
CI / ARM Build (push) Canceled after 0s
CI / Jetson Jetpack 6 (push) Canceled after 0s
CI / AMD64 Extra Build (push) Canceled after 0s
CI / ARM Extra Build (push) Canceled after 0s
CI / Synaptics Build (push) Canceled after 0s
CI / Assemble and push default build (push) Canceled after 0s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E4iDiYSpWJD13YQUdNKC5o
This commit is contained in:
Blake Blackshear
2026-11-07 07:49:43 -06:00
co-authored by Claude Opus 5.5
22 changed files with 558 additions and 103 deletions
+18 -14
View File
@@ -81,6 +81,7 @@ from frigate.util.object_names import get_categorized_object_names
from frigate.util.schema import get_config_schema
from frigate.util.services import (
Go2rtcStreamIssue,
find_restricted_go2rtc_exec_changes,
find_restricted_go2rtc_stream_changes,
get_nvidia_driver_info,
process_logs,
@@ -576,26 +577,26 @@ def config_raw():
)
def _go2rtc_streams(raw_config: str) -> Any:
"""Load go2rtc.streams with the same loader Frigate and go2rtc startup use.
def _go2rtc_config(raw_config: str) -> dict[str, Any]:
"""Load the go2rtc section with the same loader Frigate and go2rtc startup use.
Raises ruamel.yaml.YAMLError when the config cannot be parsed.
"""
loaded = ruamel.yaml.YAML().load(raw_config)
go2rtc = loaded.get("go2rtc") if isinstance(loaded, dict) else None
return go2rtc.get("streams") if isinstance(go2rtc, dict) else None
return go2rtc if isinstance(go2rtc, dict) else {}
def _restricted_go2rtc_streams_response(
def _restricted_go2rtc_response(
old_raw_config: str, new_raw_config: str
) -> JSONResponse | None:
"""Reject config changes that add restricted go2rtc stream sources.
"""Reject config changes that add restricted go2rtc sources or options.
The same sources are rejected by PUT /go2rtc/streams, and go2rtc would
otherwise load them from the saved config on the next restart.
"""
try:
new_streams = _go2rtc_streams(new_raw_config)
new_go2rtc = _go2rtc_config(new_raw_config)
except ruamel.yaml.YAMLError:
logger.warning("Rejected config change that could not be parsed")
return JSONResponse(
@@ -604,16 +605,21 @@ def _restricted_go2rtc_streams_response(
)
try:
old_streams = _go2rtc_streams(old_raw_config)
old_go2rtc = _go2rtc_config(old_raw_config)
except ruamel.yaml.YAMLError:
# with no readable saved config, every source is treated as new
old_streams = None
old_go2rtc = {}
issues = find_restricted_go2rtc_stream_changes(old_streams, new_streams)
if not issues:
issues = find_restricted_go2rtc_stream_changes(
old_go2rtc.get("streams"), new_go2rtc.get("streams")
)
exec_keys = find_restricted_go2rtc_exec_changes(old_go2rtc, new_go2rtc)
if not issues and not exec_keys:
return None
messages = []
if exec_keys:
messages.append(f"Restricted go2rtc option: {', '.join(exec_keys)}")
for issue, label in (
(Go2rtcStreamIssue.restricted, "Restricted go2rtc stream source in"),
(Go2rtcStreamIssue.unknown_variable, "Unknown variable in go2rtc stream"),
@@ -717,9 +723,7 @@ def config_save(save_option: str, body: Any = Body(media_type="text/plain")):
except OSError:
old_raw_config = ""
restricted_response = _restricted_go2rtc_streams_response(
old_raw_config, new_config
)
restricted_response = _restricted_go2rtc_response(old_raw_config, new_config)
if restricted_response is not None:
return restricted_response
@@ -1172,7 +1176,7 @@ def config_set(request: Request, body: AppConfigSetBody):
),
status_code=400,
)
restricted_response = _restricted_go2rtc_streams_response(
restricted_response = _restricted_go2rtc_response(
old_raw_config, new_raw_config
)
if restricted_response is not None:
+16 -7
View File
@@ -56,6 +56,7 @@ from frigate.genai.utils import (
)
from frigate.jobs.export import ExportQueueFullError, start_export_job
from frigate.jobs.vlm_watch import (
VLMWatchJob,
get_vlm_watch_job,
start_vlm_watch_job,
stop_vlm_watch_job,
@@ -999,7 +1000,7 @@ async def _execute_tool_internal(
elif tool_name == "start_camera_watch":
return await _execute_start_camera_watch(request, arguments)
elif tool_name == "stop_camera_watch":
return _execute_stop_camera_watch()
return _execute_stop_camera_watch(request)
elif tool_name == "get_profile_status":
return _execute_get_profile_status(request)
elif tool_name == "get_recap":
@@ -1060,6 +1061,7 @@ async def _execute_start_camera_watch(
dispatcher=request.app.dispatcher,
labels=labels,
zones=zones,
username=request.headers.get("remote-user", ""),
)
except RuntimeError as e:
logger.exception("Failed to start VLM watch job: %s", e)
@@ -1075,7 +1077,18 @@ async def _execute_start_camera_watch(
}
def _execute_stop_camera_watch() -> dict[str, Any]:
def _can_cancel_watch_job(request: Request, job: VLMWatchJob) -> bool:
"""Admins can cancel any watch job; other users only jobs they started."""
role = request.headers.get("remote-role", "viewer")
username = request.headers.get("remote-user", "")
return role == "admin" or username == job.username
def _execute_stop_camera_watch(request: Request) -> dict[str, Any]:
job = get_vlm_watch_job()
if job is not None and not _can_cancel_watch_job(request, job):
return {"success": False, "message": "Not authorized to cancel this watch job."}
cancelled = stop_vlm_watch_job()
if cancelled:
return {"success": True, "message": "Watch job cancelled."}
@@ -1908,11 +1921,7 @@ async def cancel_vlm_monitor(request: Request) -> JSONResponse:
status_code=404,
)
role = request.headers.get("remote-role", "viewer")
username = request.headers.get("remote-user", "")
# Admin can cancel any job; other users can only cancel jobs they started.
if role != "admin" and username != job.username:
if not _can_cancel_watch_job(request, job):
return JSONResponse(
content={
"success": False,