ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
fix(files): address PR review — literal grep match, tail clamp, extend RBAC coverage
Juan Denise3c4fa778dbe
diff --git a/backend/app/services/log_service.py b/backend/app/services/log_service.pyindex 5a265e6f..3120bdc3 100644--- a/backend/app/services/log_service.py+++ b/backend/app/services/log_service.py@@ -318,8 +318,10 @@ class LogService:# No shell: list2cmdline() is cmd.exe-style quoting and does# not protect against $(...)/backtick expansion under bash.# grep runs as argv and the tail happens in Python instead.+ # -F: the unit name is a literal string, not a regex — names+ # like 'nginx.service' must not have '.' match any character.result = run_privileged(- ['grep', '-i', '--', service, filepath],+ ['grep', '-F', '-i', '--', service, filepath],timeout=60,)else:@@ -333,7 +335,10 @@ class LogService:if log_lines and log_lines[-1] == '':log_lines.pop() # trailing newline artifactif service:- log_lines = log_lines[-int(lines):]+ # Clamp like `tail -n`: -0 would slice as [0:] (all+ # lines) and a negative count would keep nearly all.+ tail_lines = max(0, int(lines))+ log_lines = log_lines[-tail_lines:] if tail_lines else []return sourced_result(log_lines, 'syslog', filepath)else:return {'success': False, 'error': result.stderr}diff --git a/backend/tests/test_files_rbac.py b/backend/tests/test_files_rbac.pyindex 0cf3b4ce..8be34026 100644--- a/backend/tests/test_files_rbac.py+++ b/backend/tests/test_files_rbac.py@@ -49,7 +49,9 @@ WRITE_CASES = [('post', '/api/v1/files/copy', {'json': {'src': '/tmp/x', 'dest': '/tmp/y'}}),('post', '/api/v1/files/move', {'json': {'src': '/tmp/x', 'dest': '/tmp/y'}}),('post', '/api/v1/files/chmod', {'json': {'path': '/tmp/x', 'mode': '755'}}),+ ('post', '/api/v1/files/upload', {}),('post', '/api/v1/files/s3/write', {'json': {'path': '/x', 'content': 'x'}}),+ ('post', '/api/v1/files/s3/upload', {}),('delete', '/api/v1/files/s3/delete?path=/x', {}),]@@ -102,6 +104,10 @@ READ_CASES = ['/api/v1/files/info?path=/tmp/x','/api/v1/files/read?path=/tmp/x','/api/v1/files/search?path=/tmp&query=x',+ '/api/v1/files/disk-usage',+ '/api/v1/files/disk-mounts',+ '/api/v1/files/analyze?path=/tmp',+ '/api/v1/files/type-breakdown?path=/tmp','/api/v1/files/download?path=/tmp/x','/api/v1/files/s3/browse?path=/','/api/v1/files/s3/read?path=/x',