-
Notifications
You must be signed in to change notification settings - Fork 7
simplify configuration for performix #76
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: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -34,12 +34,14 @@ Validate SSH access: | |||||||||
| ssh -i /path/to/key <remote_user>@<target_ip> | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| ### 2. MCP server runtime must have SSH config | ||||||||||
| ### 2. MCP server runtime must have the SSH files mounted | ||||||||||
|
|
||||||||||
| Your MCP server/container configuration must include: | ||||||||||
| Your MCP server/container configuration must mount: | ||||||||||
|
|
||||||||||
| - `SSH_KEY_PATH` | ||||||||||
| - `KNOWN_HOSTS_PATH` | ||||||||||
| - the private key file under `/run/keys` | ||||||||||
| - the `known_hosts` file under `/run/keys` | ||||||||||
|
|
||||||||||
| The MCP container will discover these mounts from `/proc/self/mounts` and set the internal `SSH_KEY_PATH` and `KNOWN_HOSTS_PATH` values automatically. | ||||||||||
|
|
||||||||||
|
Comment on lines
+44
to
45
|
||||||||||
| The MCP container will discover these mounts from `/proc/self/mounts` and set the internal `SSH_KEY_PATH` and `KNOWN_HOSTS_PATH` values automatically. | |
| The MCP container attempts to discover these mounts from `/proc/self/mounts` and set the internal `SSH_KEY_PATH` and `KNOWN_HOSTS_PATH` values automatically. | |
| If discovery is ambiguous or does not succeed (for example, if `/run/keys` is mounted as a directory or multiple candidate mounts exist), set `SSH_KEY_PATH` and `KNOWN_HOSTS_PATH` explicitly in the MCP server/container configuration. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ | |
| from utils.config import METADATA_PATH, USEARCH_INDEX_PATH, MODEL_NAME, SUPPORTED_SCANNERS, DEFAULT_ARCH | ||
| from utils.search_utils import build_bm25_index, deduplicate_urls, hybrid_search, load_metadata, load_usearch_index | ||
| from utils.docker_utils import check_docker_image_architectures | ||
| from utils.apx import prepare_target, run_workload, get_results | ||
| from utils.apx import prepare_target, run_workload, get_results, resolve_apx_ssh_mount_env | ||
| from utils.migrate_ease_utils import run_migrate_ease_scan | ||
| from utils.skopeo_tool import skopeo_help, skopeo_inspect | ||
| from utils.llvm_mca_tool import mca_help, llvm_mca_analyze | ||
|
|
@@ -292,19 +292,20 @@ def apx_recipe_run(cmd:str, remote_ip_addr:str, remote_usr:str, recipe:str="code | |
| }, | ||
| ) | ||
| apx_dir = os.environ.get("APX_HOME", "/opt/apx") | ||
| key_path = os.getenv("SSH_KEY_PATH") | ||
| known_hosts_path = os.getenv("KNOWN_HOSTS_PATH") | ||
| ssh_mount_env = resolve_apx_ssh_mount_env() | ||
| key_path = ssh_mount_env["key_path"] | ||
| known_hosts_path = ssh_mount_env["known_hosts_path"] | ||
|
|
||
| if not key_path or not known_hosts_path: | ||
| return { | ||
| "status": "error", | ||
| "recipe": recipe, | ||
| "stage": "config_validation", | ||
| "message": "Missing SSH configuration for APX target access.", | ||
| "suggestion": "Set SSH_KEY_PATH and KNOWN_HOSTS_PATH in the MCP docker run configuration, then retry.", | ||
| "suggestion": "Mount both the SSH private key and known_hosts file into /run/keys, then retry.", | ||
| "details": ( | ||
| "SSH_KEY_PATH and KNOWN_HOSTS_PATH environment variables must be set in the docker run " | ||
| "command in the MCP config file to mount in the container to use APX." | ||
| "APX looks for SSH_KEY_PATH and KNOWN_HOSTS_PATH first, then auto-discovers mounted files " | ||
| f"under /run/keys from /proc/self/mounts. Discovered mounts: {ssh_mount_env['mount_targets']}" | ||
| ), | ||
| } | ||
|
Comment on lines
294
to
310
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,6 +9,8 @@ | |||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| QUERY_REGISTRY_PATH = Path(__file__).resolve().parent.parent / "sql" / "queries.sql" | ||||||||||||||||||||||||||||||||||||
| ANSI_ESCAPE_RE = re.compile(r"\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])") | ||||||||||||||||||||||||||||||||||||
| RUN_KEYS_DIR = Path("/run/keys") | ||||||||||||||||||||||||||||||||||||
| PROC_MOUNTS_PATH = Path("/proc/self/mounts") | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| def load_recipe_query_map(sql_file_path: Path) -> Dict[str, Dict[str, str]]: | ||||||||||||||||||||||||||||||||||||
|
|
@@ -248,6 +250,91 @@ def _build_atp_error_response( | |||||||||||||||||||||||||||||||||||
| response["raw_output"] = _trim_output(raw_output) | ||||||||||||||||||||||||||||||||||||
| return response | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| def _decode_mount_field(field: str) -> str: | ||||||||||||||||||||||||||||||||||||
| return re.sub( | ||||||||||||||||||||||||||||||||||||
| r"\\([0-7]{3})", | ||||||||||||||||||||||||||||||||||||
| lambda match: chr(int(match.group(1), 8)), | ||||||||||||||||||||||||||||||||||||
| field, | ||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| def discover_run_keys_mounts( | ||||||||||||||||||||||||||||||||||||
| mounts_path: Optional[Path] = None, | ||||||||||||||||||||||||||||||||||||
| run_keys_dir: Optional[Path] = None, | ||||||||||||||||||||||||||||||||||||
| ) -> List[str]: | ||||||||||||||||||||||||||||||||||||
| mounts_path = mounts_path or PROC_MOUNTS_PATH | ||||||||||||||||||||||||||||||||||||
| run_keys_dir = run_keys_dir or RUN_KEYS_DIR | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| if not mounts_path.exists(): | ||||||||||||||||||||||||||||||||||||
| return [] | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| mount_targets: List[str] = [] | ||||||||||||||||||||||||||||||||||||
| for line in mounts_path.read_text(encoding="utf-8").splitlines(): | ||||||||||||||||||||||||||||||||||||
| parts = line.split() | ||||||||||||||||||||||||||||||||||||
| if len(parts) < 2: | ||||||||||||||||||||||||||||||||||||
| continue | ||||||||||||||||||||||||||||||||||||
| target = _decode_mount_field(parts[1]) | ||||||||||||||||||||||||||||||||||||
| if target == str(run_keys_dir) or target.startswith(f"{run_keys_dir}/"): | ||||||||||||||||||||||||||||||||||||
| mount_targets.append(target) | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+273
to
+279
|
||||||||||||||||||||||||||||||||||||
| for line in mounts_path.read_text(encoding="utf-8").splitlines(): | |
| parts = line.split() | |
| if len(parts) < 2: | |
| continue | |
| target = _decode_mount_field(parts[1]) | |
| if target == str(run_keys_dir) or target.startswith(f"{run_keys_dir}/"): | |
| mount_targets.append(target) | |
| try: | |
| for line in mounts_path.read_text(encoding="utf-8").splitlines(): | |
| parts = line.split() | |
| if len(parts) < 2: | |
| continue | |
| target = _decode_mount_field(parts[1]) | |
| if target == str(run_keys_dir) or target.startswith(f"{run_keys_dir}/"): | |
| mount_targets.append(target) | |
| except (OSError, UnicodeDecodeError): | |
| return [] |
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.
@JoeStech This seems like a worthwhile addition
Copilot
AI
Apr 10, 2026
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.
Auto-discovery currently depends on mount targets under /run/keys. If users mount a directory (e.g. -v ~/.ssh:/run/keys:ro), /proc/self/mounts will typically only contain /run/keys and not per-file mountpoints, so _select_known_hosts_path/_select_ssh_key_path will fail to resolve paths. Either (a) update discovery to also scan the /run/keys directory contents when /run/keys itself is mounted, or (b) clarify in docs that individual files must be bind-mounted.
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.
I think this is true. I saw that separately and was wondering the same thing. Commented on the exact line below.
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.
If this ends up being a directory, then we would pass that through and continue the mcp tool, as mentioned above
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.
For this line, we end up checking in server.py if ssh path is set. If there is more than one key, then we return None, however in the error message returned to the agent, we don't mention that there can only be one key in the mount targets. And then second to that, I wonder about the candidates above if someone doesn't follow those naming conventions (i.e. renames an rsa key to anything else and the name ends up being ec2, for example).
An option could be to check the beginning of the file contents for the ------BEGIN ... ---- style thing. But that is much slower and maybe not necessary.
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.
The note implies auto-discovery will always work for anything mounted under
/run/keys, but the implementation only setsSSH_KEY_PATH/KNOWN_HOSTS_PATHwhen it can uniquely identify aknown_hostsmount and a single key-like mount. Consider clarifying the constraints (expected filenames/uniqueness) and documenting that users can still setSSH_KEY_PATHandKNOWN_HOSTS_PATHexplicitly when auto-discovery is ambiguous.