Repository navigation
feat(rust): honor --allowed-media-domains and --allowed-local-media-path - #1811
Conversation
sonar-rs now accepts both options from the CLI and from the Python launcher's JSON args instead of refusing to start. The domain list goes to the media connector, which checks it on every redirect hop and still refuses non-public addresses. file:// media URLs are read in the chat crate under the canonical allowed directory (symlink and `..` escapes, non-regular files and files over the media input cap are refused with a 400) and handed to the tracker as data URLs, because the pinned llm-multimodal tracker fetches every other URL over HTTP. The local path must be an existing directory at startup, as in Python. Signed-off-by: AlpinDale <alpindale@gmail.com>
Media the request got wrong or the media policy refuses (disallowed domain, non-public host, refused redirect, too many redirects, unsupported scheme, invalid URL, malformed data URL, undecodable image) is now a 400 instead of a 500. As in Python's `_wrap_media_fetch_error`, an origin 4xx other than 408 and 429 and a download over the size cap are a 422 with `param: image_url`. Connection failures, timeouts, 5xx answers and audio or video decode failures stay server errors. Signed-off-by: AlpinDale <alpindale@gmail.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ed11f92dbc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if !fs::metadata(&canonical).map_err(read_error)?.is_file() { | ||
| return Err(not_regular()); | ||
| } | ||
| let file = File::open(&canonical).map_err(read_error)?; |
There was a problem hiding this comment.
Prevent symlink swaps when opening local media
If an untrusted local process can modify the allowed media directory while requests are running, it can replace a path component with a symlink after the canonical-path check but before this open. File::open then follows the replacement and can read a file outside the configured root; open relative to a pinned root with beneath/no-follow semantics, or verify the opened file itself remains confined.
Useful? React with 👍 / 👎.
--allowed-media-domains and --allowed-local-media-path
Python frontend already has this feature but it wasn't ported to Rust.