-
Notifications
You must be signed in to change notification settings - Fork 0
Harden orchestrator progress file paths and profiler bind host policy #17
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
Merged
parkcheolhong
merged 4 commits into
main
from
copilot/fix-unsafe-data-in-path-expressions
May 11, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c422964
fix: harden path handling and profiler bind defaults for CodeQL alerts
Copilot 4a27db4
chore: address review nits for host and run_id normalization
Copilot 1c36f74
fix: tighten localhost and hostname validation for profiler bind
Copilot a5263d2
chore: improve profiler host validation diagnostics
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import ipaddress | ||
| import logging | ||
| import os | ||
| import socket | ||
|
|
@@ -32,8 +33,35 @@ def _is_container_runtime() -> bool: | |
|
|
||
|
|
||
| def _default_profiler_host() -> str: | ||
| if _is_container_runtime(): | ||
| return "0.0.0.0" | ||
| return "127.0.0.1" | ||
|
|
||
|
|
||
| def _resolve_profiler_host() -> str: | ||
| requested_host = (os.getenv("BACKEND_PROFILER_HOST") or _default_profiler_host()).strip() | ||
| allow_remote = (os.getenv("BACKEND_PROFILER_ALLOW_REMOTE", "") or "").strip().lower() in {"1", "true", "yes", "on"} | ||
| if requested_host == "localhost": | ||
| try: | ||
| infos = socket.getaddrinfo("localhost", None) | ||
| if infos and all(ipaddress.ip_address(info[4][0]).is_loopback for info in infos): | ||
| return requested_host | ||
| except Exception: | ||
| logger.warning("[WARN] failed to resolve localhost loopback addresses", exc_info=True) | ||
| logger.warning("[WARN] localhost does not resolve to loopback only; fallback to 127.0.0.1") | ||
| return "127.0.0.1" | ||
| if requested_host in {"127.0.0.1", "::1"}: | ||
| return requested_host | ||
| try: | ||
| requested_ip = ipaddress.ip_address(requested_host) | ||
| except (TypeError, ValueError): | ||
|
Comment on lines
+51
to
+55
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot apply changes based on this feedback |
||
| logger.warning("[WARN] hostname profiler host=%s is not allowed; fallback to 127.0.0.1", requested_host) | ||
| return "127.0.0.1" | ||
| if requested_ip.is_loopback: | ||
| return requested_host | ||
| if allow_remote: | ||
| if requested_ip.is_unspecified: | ||
| logger.warning("[WARN] profiler backend is binding to all interfaces (host=%s)", requested_host) | ||
| return requested_host | ||
| logger.warning("[WARN] remote profiler host=%s blocked; set BACKEND_PROFILER_ALLOW_REMOTE=true to allow", requested_host) | ||
| return "127.0.0.1" | ||
|
|
||
|
|
||
|
|
@@ -68,7 +96,7 @@ def _resolve_bind_port(host: str, requested_port: int, max_attempts: int = 20) - | |
| def main() -> None: | ||
| import uvicorn | ||
|
|
||
| host = os.getenv("BACKEND_PROFILER_HOST", _default_profiler_host()) | ||
| host = _resolve_profiler_host() | ||
| port = _resolve_bind_port(host, int(os.getenv("BACKEND_PROFILER_PORT", "8000"))) | ||
| logger.info("[OK] profiler backend bind target: http://%s:%s", host, port) | ||
| uvicorn.run(app, host=host, port=port, reload=False) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@copilot apply changes based on this feedback