From 57f3dd896fd5da2654fae3fec150092d1aad73cb Mon Sep 17 00:00:00 2001 From: max Date: Sat, 3 Oct 2026 20:26:26 +0200 Subject: [PATCH] Bootstrap sys.path in root proxy files and add PYTHONPATH to CI workflow --- .gitea/workflows/ci.yml | 2 ++ src/Linux_Client.py | 8 ++++++++ src/Server.py | 8 ++++++++ src/Win_Client.py | 8 ++++++++ src/__init__.py | 7 +++++++ src/auth_manager.py | 7 +++++++ src/client_transport.py | 7 +++++++ src/client_updater.py | 7 +++++++ src/hub/Server.py | 18 ++++++++++++++---- src/ingest_queue.py | 7 +++++++ src/license_manager.py | 7 +++++++ src/log_collector.py | 7 +++++++ src/pki_manager.py | 7 +++++++ src/server_enrollment.py | 7 +++++++ src/server_models.py | 7 +++++++ src/storage_engine.py | 7 +++++++ src/update_manager.py | 7 +++++++ src/version.py | 7 +++++++ src/web_ui.py | 7 +++++++ 19 files changed, 138 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 032e78c..d8c554f 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -16,6 +16,8 @@ jobs: name: Run Component Tests & Pipeline Verification if: "!startsWith(github.ref, 'refs/tags/')" runs-on: logar + env: + PYTHONPATH: . steps: - name: Checkout Code uses: actions/checkout@v3 diff --git a/src/Linux_Client.py b/src/Linux_Client.py index eb3d540..408ebce 100644 --- a/src/Linux_Client.py +++ b/src/Linux_Client.py @@ -1,3 +1,11 @@ +import os +import sys + +_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +if _ROOT not in sys.path: + sys.path.insert(0, _ROOT) + from src.clients.Linux_Client import * + if __name__ == '__main__': main() \ No newline at end of file diff --git a/src/Server.py b/src/Server.py index eab821b..2875ee7 100644 --- a/src/Server.py +++ b/src/Server.py @@ -1,3 +1,11 @@ +import os +import sys + +_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +if _ROOT not in sys.path: + sys.path.insert(0, _ROOT) + from src.hub.Server import * + if __name__ == '__main__': main() \ No newline at end of file diff --git a/src/Win_Client.py b/src/Win_Client.py index 0470a4b..5021200 100644 --- a/src/Win_Client.py +++ b/src/Win_Client.py @@ -1,3 +1,11 @@ +import os +import sys + +_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +if _ROOT not in sys.path: + sys.path.insert(0, _ROOT) + from src.clients.Win_Client import * + if __name__ == '__main__': main() \ No newline at end of file diff --git a/src/__init__.py b/src/__init__.py index 99f7185..18ed83f 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -6,6 +6,13 @@ Modular package namespace exposing: - common: Versioning and shared utilities """ +import os +import sys + +_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +if _ROOT not in sys.path: + sys.path.insert(0, _ROOT) + from src import hub from src import clients from src import common diff --git a/src/auth_manager.py b/src/auth_manager.py index 4e5f166..61c52df 100644 --- a/src/auth_manager.py +++ b/src/auth_manager.py @@ -1 +1,8 @@ +import os +import sys + +_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +if _ROOT not in sys.path: + sys.path.insert(0, _ROOT) + from src.hub.auth_manager import * \ No newline at end of file diff --git a/src/client_transport.py b/src/client_transport.py index 1bfdcf3..226afad 100644 --- a/src/client_transport.py +++ b/src/client_transport.py @@ -1 +1,8 @@ +import os +import sys + +_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +if _ROOT not in sys.path: + sys.path.insert(0, _ROOT) + from src.clients.client_transport import * \ No newline at end of file diff --git a/src/client_updater.py b/src/client_updater.py index 9b89b46..f56d492 100644 --- a/src/client_updater.py +++ b/src/client_updater.py @@ -1 +1,8 @@ +import os +import sys + +_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +if _ROOT not in sys.path: + sys.path.insert(0, _ROOT) + from src.clients.client_updater import * \ No newline at end of file diff --git a/src/hub/Server.py b/src/hub/Server.py index 029e746..e781efe 100644 --- a/src/hub/Server.py +++ b/src/hub/Server.py @@ -448,6 +448,16 @@ def load_or_init_config(config_path: str = CONFIG_FILE_NAME) -> Dict[str, Any]: config["cache_mode"] = "direct" if "encrypt_at_rest" not in config: config["encrypt_at_rest"] = False + if "auth_token" not in config: + config["auth_token"] = secrets.token_hex(24) + if "enrollment_secret" not in config: + config["enrollment_secret"] = secrets.token_hex(24) + if "server_fingerprint" not in config and "public_key" in config: + try: + pub, _ = pgpy.PGPKey.from_blob(config["public_key"]) + config["server_fingerprint"] = str(pub.fingerprint) + except Exception: + config["server_fingerprint"] = "" config["db_path"] = resolve_writable_path(config["db_path"], "LOGAR-Server", DEFAULT_DB_FILE) config["cert_dir"] = resolve_writable_path(config["cert_dir"], "LOGAR-Server", "certs") @@ -592,11 +602,11 @@ def create_client_config( "server_port": server_port, "hermes_host": effective_hermes_host, "hermes_port": hermes_port or server_conf.get("hermes_port", 8443), - "enrollment_secret": server_conf.get("enrollment_secret"), + "enrollment_secret": server_conf.get("enrollment_secret", ""), "cert_dir": "certs", - "server_fingerprint": server_conf["server_fingerprint"], - "server_public_key": server_conf["public_key"], - "auth_token": server_conf["auth_token"] + "server_fingerprint": server_conf.get("server_fingerprint", ""), + "server_public_key": server_conf.get("public_key", ""), + "auth_token": server_conf.get("auth_token", "") } out_dir = os.path.dirname(os.path.abspath(output_path)) diff --git a/src/ingest_queue.py b/src/ingest_queue.py index bb551f9..4db3841 100644 --- a/src/ingest_queue.py +++ b/src/ingest_queue.py @@ -1 +1,8 @@ +import os +import sys + +_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +if _ROOT not in sys.path: + sys.path.insert(0, _ROOT) + from src.hub.ingest_queue import * \ No newline at end of file diff --git a/src/license_manager.py b/src/license_manager.py index 0abc8f2..427c526 100644 --- a/src/license_manager.py +++ b/src/license_manager.py @@ -1 +1,8 @@ +import os +import sys + +_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +if _ROOT not in sys.path: + sys.path.insert(0, _ROOT) + from src.hub.license_manager import * \ No newline at end of file diff --git a/src/log_collector.py b/src/log_collector.py index 37137ad..fbe2b07 100644 --- a/src/log_collector.py +++ b/src/log_collector.py @@ -1 +1,8 @@ +import os +import sys + +_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +if _ROOT not in sys.path: + sys.path.insert(0, _ROOT) + from src.clients.log_collector import * \ No newline at end of file diff --git a/src/pki_manager.py b/src/pki_manager.py index 12684a9..edcd2ab 100644 --- a/src/pki_manager.py +++ b/src/pki_manager.py @@ -1 +1,8 @@ +import os +import sys + +_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +if _ROOT not in sys.path: + sys.path.insert(0, _ROOT) + from src.hub.pki_manager import * \ No newline at end of file diff --git a/src/server_enrollment.py b/src/server_enrollment.py index c7d2c38..b46a4bb 100644 --- a/src/server_enrollment.py +++ b/src/server_enrollment.py @@ -1 +1,8 @@ +import os +import sys + +_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +if _ROOT not in sys.path: + sys.path.insert(0, _ROOT) + from src.hub.server_enrollment import * \ No newline at end of file diff --git a/src/server_models.py b/src/server_models.py index 1adeb05..adc8e69 100644 --- a/src/server_models.py +++ b/src/server_models.py @@ -1 +1,8 @@ +import os +import sys + +_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +if _ROOT not in sys.path: + sys.path.insert(0, _ROOT) + from src.hub.server_models import * \ No newline at end of file diff --git a/src/storage_engine.py b/src/storage_engine.py index 56166d3..58a22df 100644 --- a/src/storage_engine.py +++ b/src/storage_engine.py @@ -1 +1,8 @@ +import os +import sys + +_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +if _ROOT not in sys.path: + sys.path.insert(0, _ROOT) + from src.hub.storage_engine import * \ No newline at end of file diff --git a/src/update_manager.py b/src/update_manager.py index 5275f97..3366ebe 100644 --- a/src/update_manager.py +++ b/src/update_manager.py @@ -1 +1,8 @@ +import os +import sys + +_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +if _ROOT not in sys.path: + sys.path.insert(0, _ROOT) + from src.hub.update_manager import * \ No newline at end of file diff --git a/src/version.py b/src/version.py index 3d4490b..7b80a2f 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1,8 @@ +import os +import sys + +_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +if _ROOT not in sys.path: + sys.path.insert(0, _ROOT) + from src.common.version import * \ No newline at end of file diff --git a/src/web_ui.py b/src/web_ui.py index 4e1f7cc..ac2b603 100644 --- a/src/web_ui.py +++ b/src/web_ui.py @@ -1 +1,8 @@ +import os +import sys + +_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +if _ROOT not in sys.path: + sys.path.insert(0, _ROOT) + from src.hub.web_ui import * \ No newline at end of file