This commit is contained in:
oliver committed 2026-10-14 18:35:16 -03:00
1 parent 4868517abb
commit 8772004ff6
3 files changed
+31 -5

No files matched your search

+25
View File
@@ -36,9 +36,34 @@ def read_file(path):
return None
def read_env_file(path, keys):
"""Read KEY=VALUE lines from path and return the requested keys."""
result = {key: None for key in keys}
try:
with open(path) as f:
for line in f:
line = line.strip()
if not line or line.startswith("#") or "=" not in line:
continue
if line.startswith("export "):
line = line[len("export "):].lstrip()
key, value = line.split("=", 1)
key = key.strip()
if key in result:
result[key] = value.strip().strip("\"'")
except (FileNotFoundError, PermissionError):
pass
return result
def main():
audit = {}
# Contract info from /etc/4server
audit.update(
read_env_file("/etc/4server", ["PROVIDER", "COST", "CONTRACT_END"])
)
# Container identity
audit["container_id"] = os.environ.get("HOSTNAME")