feat: implement player editing, security hardening, and director proxy
- Add 7 player-edit endpoints: faction, XP, tech knowledge, currency, item edit/delete/add - Password hashing with Argon2 (setup.ps1, setup.sh, auth.py, config.py) - Rate limiting on all sensitive endpoints (Flask-Limiter) - IP validation for ban/unban/kick operations - Audit logging for admin actions - File browser path traversal protection - Login_required on all debug endpoints - Director API proxy via NodePort with _director_request helper - SSH tunnel includes director port forward in start.ps1 - Currency editing now sets exact balance instead of delta - Fix undefined values in success alert messages
This commit is contained in:
1 parent
6c77512470
commit
99864b4d8f
13 files changed
+630
-69
No files matched your search
@@ -12,6 +12,7 @@ class SSHService:
|
||||
self.host = host
|
||||
self.user = user
|
||||
self.ssh_key = ssh_key
|
||||
logger.info(f"SSHService initialized: {user}@{host}")
|
||||
|
||||
def run(self, command, timeout=30):
|
||||
args = [
|
||||
@@ -23,6 +24,7 @@ class SSHService:
|
||||
f'{self.user}@{self.host}',
|
||||
command
|
||||
]
|
||||
logger.debug(f"SSH command: {command[:100]}...")
|
||||
try:
|
||||
result = subprocess.run(
|
||||
args,
|
||||
@@ -30,14 +32,23 @@ class SSHService:
|
||||
text=True,
|
||||
timeout=timeout
|
||||
)
|
||||
if result.returncode != 0:
|
||||
logger.warning(f"SSH command failed (rc={result.returncode}): {result.stderr[:200]}")
|
||||
return result.stdout, result.stderr, result.returncode
|
||||
except FileNotFoundError:
|
||||
logger.error("SSH command not found. Is OpenSSH installed?")
|
||||
return '', 'ssh command not found', -1
|
||||
except subprocess.TimeoutExpired:
|
||||
logger.error(f"SSH command timed out after {timeout}s: {command[:100]}")
|
||||
return '', 'SSH command timed out', -1
|
||||
except Exception as ex:
|
||||
logger.error(f"SSH command error: {ex}")
|
||||
return '', str(ex), -1
|
||||
|
||||
def check_connection(self):
|
||||
out, err, rc = self.run('echo ok', timeout=5)
|
||||
if rc == 0 and 'ok' in out:
|
||||
logger.debug("SSH connection check passed")
|
||||
else:
|
||||
logger.warning("SSH connection check failed")
|
||||
return rc == 0 and 'ok' in out
|
||||
Reference in new issue
Block a user