{"record":{"id":"128cc60ffa9f7076","repo":"odysseus-dev/odysseus","slug":"invalid-ssh-port-128cc6","errorCode":null,"errorMessage":"invalid ssh port","messagePattern":"invalid ssh port","errorType":"validation","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"routes/shell_routes.py","lineNumber":90,"sourceCode":"def _reject_cross_site(request: Request):\n    \"\"\"Reject browser cross-site navigations to shell-touching endpoints.\"\"\"\n    if request.headers.get(\"sec-fetch-site\") == \"cross-site\":\n        raise HTTPException(403, \"Cross-site request rejected\")\n\n\n_SSH_PORT_RE = re.compile(r\"^\\d{1,5}$\")\n_SAFE_VENV_RE = re.compile(r\"^[A-Za-z0-9_./~-]+$\")\n\n\ndef _ssh_base_argv(host: str, ssh_port: str | None) -> list[str]:\n    \"\"\"Build an ssh argv prefix for remote probes without local-shell parsing.\"\"\"\n    if not host or not str(host).strip() or str(host).lstrip().startswith(\"-\"):\n        raise ValueError(\"invalid ssh host\")\n    argv = [\"ssh\", \"-o\", \"ConnectTimeout=6\", \"-o\", \"StrictHostKeyChecking=no\"]\n    if ssh_port and str(ssh_port).strip() not in (\"\", \"22\"):\n        port = str(ssh_port).strip()\n        if not _SSH_PORT_RE.match(port) or not (1 <= int(port) <= 65535):\n            raise ValueError(\"invalid ssh port\")\n        argv += [\"-p\", port]\n    argv.append(str(host).strip())\n    return argv\n\n\ndef _venv_activate_prefix(venv: str | None) -> str:\n    \"\"\"Return a remote activation prefix while preserving shell expansion of ~.\"\"\"\n    if not venv:\n        return \"\"\n    if not _SAFE_VENV_RE.match(venv):\n        raise ValueError(\"invalid venv path\")\n    act = venv if venv.endswith(\"/bin/activate\") else venv.rstrip(\"/\") + \"/bin/activate\"\n    return f\". {act} && \"\n\n\nlogger = logging.getLogger(__name__)\n\nPTY_SUPPORTED = pty is not None and fcntl is not None and hasattr(os, \"setsid\")","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/routes/shell_routes.py#L72-L108","documentation":"Error \"invalid ssh port\" thrown in odysseus-dev/odysseus.","triggerScenarios":"Triggered when the corresponding server-side validation or runtime check at the recorded location rejects the request or operation and returns this error message to the caller.","commonSituations":"See trigger scenarios.","solutions":["Enter a port number between 1 and 65535.","Leave the port empty to use the SSH default of 22."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f9235ebbf13f693a6fd29ce70b097f6ec83705bf","analyzedAt":"2026-08-14T21:47:48.359Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}