From 43d2a16ac42b8d8ca8643d81b4ae58605bca9594 Mon Sep 17 00:00:00 2001 From: oliver Date: Fri, 19 Jun 2026 13:06:18 -0300 Subject: [PATCH] works --- app/sbin/api | 36 ------------------------------------ app/sbin/audit | 14 ++++---------- 2 files changed, 4 insertions(+), 46 deletions(-) diff --git a/app/sbin/api b/app/sbin/api index f28864d..011a894 100755 --- a/app/sbin/api +++ b/app/sbin/api @@ -396,42 +396,6 @@ def server_audit(): return {"raw_output": output} -@app.get("/system/info", dependencies=[Depends(verify_api_key)]) -def get_system_info(): - try: - alpine_version = None - last_update = None - bump_dates = execute_db( - "SELECT MAX(bump) AS latest_bump FROM containers", fetch=True - )[0]["latest_bump"] - if os.path.exists("/4server/data/update"): - with open("/4server/data/update") as f: - last_update = f.read().strip() - if os.path.exists("/etc/alpine-release"): - with open("/etc/alpine-release") as f: - alpine_version = f.read().strip() - mem = psutil.virtual_memory() - disk = psutil.disk_usage("/") - cpu_count = psutil.cpu_count(logical=True) - return { - "alpine_version": alpine_version, - "last_update": last_update, - "latest_bump": bump_dates, - "version": VERSION, - "resources": { - "memory": { - "total": mem.total, - "available": mem.available, - "used": mem.used, - }, - "disk": {"total": disk.total, "used": disk.used, "free": disk.free}, - "cpu_count": cpu_count, - }, - } - except Exception as e: - raise HTTPException(status_code=500, detail=str(e)) - - @app.post("/system/pull", dependencies=[Depends(verify_api_key)]) def pull_all_images(): return {"message": run_command([f"{BIN_PATH}/pullAllContainers"])} diff --git a/app/sbin/audit b/app/sbin/audit index aaecb2d..097dff9 100755 --- a/app/sbin/audit +++ b/app/sbin/audit @@ -41,7 +41,6 @@ def main(): # Container identity audit["container_id"] = os.environ.get("HOSTNAME") - audit["environment"] = dict(os.environ) # OS information inside container audit["os_release"] = read_file("/etc/os-release") @@ -52,9 +51,7 @@ def main(): if os.path.exists("/etc/alpine-release"): audit["packages"]["manager"] = "apk" - audit["packages"]["installed"] = cmd( - ["apk", "info", "-v"] - ).splitlines() + audit["packages"]["installed"] = cmd(["apk", "info", "-v"]).splitlines() audit["packages"]["upgradeable"] = cmd( ["apk", "version", "-l", "<"] ).splitlines() @@ -67,9 +64,7 @@ def main(): elif os.path.exists("/etc/redhat-release"): audit["packages"]["manager"] = "rpm" - audit["packages"]["installed"] = cmd( - ["rpm", "-qa"] - ).splitlines() + audit["packages"]["installed"] = cmd(["rpm", "-qa"]).splitlines() # Docker engine information audit["docker_version"] = cmd( @@ -132,15 +127,14 @@ def main(): audit["docker_logs"] = logs # SSH config if present - audit["sshd_config"] = cmd( - ["sshd", "-T"] - ).splitlines() + audit["sshd_config"] = cmd(["sshd", "-T"]).splitlines() # Users audit["passwd"] = read_file("/etc/passwd") # Runtime info audit["uptime"] = cmd(["uptime"]) + audit["top"] = cmd(["top", "-b", "-n", "1"]).splitlines() # cgroups (useful in Docker) audit["cgroup"] = read_file("/proc/self/cgroup")