-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat: alpha Streamlit product #38005
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: master
Are you sure you want to change the base?
Conversation
Size Change: +568 B (+0.02%) Total Size: 2.73 MB ℹ️ View Unchanged
|
def _get_available_port(self) -> int: | ||
"""Get an available port for the container""" | ||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: | ||
s.bind(('', 0)) |
Check warning
Code scanning / CodeQL
Binding a socket to all network interfaces Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
To fix the problem, the socket used to discover an available port should be bound to the loopback interface (127.0.0.1
) instead of all interfaces (''
). This change is very safe, because the intention is merely to discover a free port; restricting binding to localhost prevents any other machine from connecting to this temporary socket, even during its brief existence. The change is minimal: simply replace s.bind(('', 0))
with s.bind(('127.0.0.1', 0))
in the function _get_available_port
within products/streamlit/backend/container_service.py
. No other code changes or dependency updates are needed.
-
Copy modified line R28
@@ -25,7 +25,7 @@ | ||
def _get_available_port(self) -> int: | ||
"""Get an available port for the container""" | ||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: | ||
s.bind(('', 0)) | ||
s.bind(('127.0.0.1', 0)) | ||
s.listen(1) | ||
port = s.getsockname()[1] | ||
return port |
Migration SQL ChangesHey 👋, we've detected some migrations on this PR. Here's the SQL output for each migration, make sure they make sense:
|
📸 UI snapshots have been updated3 snapshot changes in total. 0 added, 3 modified, 0 deleted:
Triggered by this commit. |
Problem
Customers that want more flexibility and ability to run Python code on their PostHog data.
Changes
How did you test this code?
👉 Stay up-to-date with PostHog coding conventions for a smoother review.