connect fix 4
This commit is contained in:
@ -17,9 +17,11 @@ from app.rbac import user_has_role_for_host
|
||||
from app.security.audit import write_audit_event
|
||||
from app.security.av_scan import scan_bytes
|
||||
from app.ssh_proxy.proxy import (
|
||||
SSH_SETUP_ERRORS,
|
||||
HostNotConfiguredError,
|
||||
PrivateKeyUnusableError,
|
||||
connect_to_host,
|
||||
describe_connection_error,
|
||||
load_host,
|
||||
)
|
||||
|
||||
@ -102,15 +104,13 @@ async def upload_file(
|
||||
await remote_file.write(data)
|
||||
finally:
|
||||
ssh_conn.close()
|
||||
except HostNotConfiguredError as exc:
|
||||
raise HTTPException(status.HTTP_400_BAD_REQUEST, str(exc))
|
||||
except PrivateKeyUnusableError as exc:
|
||||
# Gleiche Ursache wie bei einer scheiternden Terminalsitzung (siehe
|
||||
# app/ssh_proxy/terminal_ws.py): passphrasegeschuetzter Schluessel
|
||||
# ohne hinterlegte Passphrase. Hier als 400 mit Klartext statt als
|
||||
# unbehandelter 500.
|
||||
except SSH_SETUP_ERRORS as exc:
|
||||
# Alles, was den Verbindungsaufbau verhindert und in der Konfiguration
|
||||
# begruendet ist (fehlender Benutzername/Schluessel, unbrauchbarer
|
||||
# Schluessel, nicht gepinnter oder abweichender Host-Key, Ziel nicht
|
||||
# erreichbar): 400 mit Klartext statt eines unbehandelten 500.
|
||||
logger.warning("Dateitransfer fuer Host %s nicht moeglich: %s", host_id, exc)
|
||||
raise HTTPException(status.HTTP_400_BAD_REQUEST, str(exc))
|
||||
raise HTTPException(status.HTTP_400_BAD_REQUEST, describe_connection_error(exc))
|
||||
|
||||
await _log_transfer(
|
||||
conn, user=user, host_id=host_id, client_ip=_client_ip(request), direction="upload",
|
||||
@ -139,15 +139,13 @@ async def download_file(
|
||||
data = await remote_file.read()
|
||||
finally:
|
||||
ssh_conn.close()
|
||||
except HostNotConfiguredError as exc:
|
||||
raise HTTPException(status.HTTP_400_BAD_REQUEST, str(exc))
|
||||
except PrivateKeyUnusableError as exc:
|
||||
# Gleiche Ursache wie bei einer scheiternden Terminalsitzung (siehe
|
||||
# app/ssh_proxy/terminal_ws.py): passphrasegeschuetzter Schluessel
|
||||
# ohne hinterlegte Passphrase. Hier als 400 mit Klartext statt als
|
||||
# unbehandelter 500.
|
||||
except SSH_SETUP_ERRORS as exc:
|
||||
# Alles, was den Verbindungsaufbau verhindert und in der Konfiguration
|
||||
# begruendet ist (fehlender Benutzername/Schluessel, unbrauchbarer
|
||||
# Schluessel, nicht gepinnter oder abweichender Host-Key, Ziel nicht
|
||||
# erreichbar): 400 mit Klartext statt eines unbehandelten 500.
|
||||
logger.warning("Dateitransfer fuer Host %s nicht moeglich: %s", host_id, exc)
|
||||
raise HTTPException(status.HTTP_400_BAD_REQUEST, str(exc))
|
||||
raise HTTPException(status.HTTP_400_BAD_REQUEST, describe_connection_error(exc))
|
||||
|
||||
sha256 = hashlib.sha256(data).hexdigest()
|
||||
filename = remote_path.rsplit("/", 1)[-1]
|
||||
|
||||
Reference in New Issue
Block a user