-
Notifications
You must be signed in to change notification settings - Fork 225
Turn server sdk config #1715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: webrtc-python-sdk-webcam
Are you sure you want to change the base?
Turn server sdk config #1715
Conversation
| return self._config.turn_server | ||
|
|
||
| # 2. Skip TURN for localhost connections | ||
| if not self._api_url.startswith(("https://serverless.roboflow.com")): |
Check failure
Code scanning / CodeQL
Incomplete URL substring sanitization High
https://serverless.roboflow.com
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 days ago
To fix this vulnerability safely, we should parse the _api_url using Python's urllib.parse module and compare the extracted hostname property, rather than relying on prefix substring checks. This ensures that checks are made against the actual host and not against potentially misleading prefixes or embedded substrings elsewhere in the URL. Specifically, replace .startswith(("https://serverless.roboflow.com")) with a check like urlparse(self._api_url).hostname == "serverless.roboflow.com". If you want to also allow subdomains (e.g., api.serverless.roboflow.com), use .endswith(".serverless.roboflow.com") or an explicit allow-list. You will need to import urlparse from urllib.parse if not already imported in this file.
-
Copy modified line R17 -
Copy modified lines R544-R545
| @@ -14,6 +14,7 @@ | ||
|
|
||
| import numpy as np | ||
| import requests | ||
| from urllib.parse import urlparse | ||
|
|
||
| from inference_sdk.webrtc.config import StreamConfig | ||
| from inference_sdk.webrtc.sources import StreamSource | ||
| @@ -540,7 +541,8 @@ | ||
| return self._config.turn_server | ||
|
|
||
| # 2. Skip TURN for localhost connections | ||
| if not self._api_url.startswith(("https://serverless.roboflow.com")): | ||
| hostname = urlparse(self._api_url).hostname | ||
| if hostname != "serverless.roboflow.com": | ||
| logger.debug("Skipping TURN for localhost connection") | ||
| return None | ||
|
|
PawelPeczek-Roboflow
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please clarify how this PR stands in context of #1701
|
Security issue to be adressed |
Description
Configuring turn server by default
Type of change
How has this change been tested, please provide a testcase or example of how you tested the change?
locally
Any specific deployment considerations
nobne
Docs