setup: copia config glob-driven dai .example (idempotente, skip generati, 600 sui segreti)

This commit is contained in:
tecnotel 2026-06-25 18:06:07 +02:00
parent adcafbd13c
commit 3996a9e769
1 changed files with 30 additions and 19 deletions

View File

@ -356,25 +356,36 @@ def install(data):
chown(integ_path) chown(integ_path)
log("integrations.json creato") log("integrations.json creato")
# 5. modules.json # 5. Config da template .example (glob-driven, idempotente).
mods = APP_DIR / "config/modules.json.example" #
if mods.exists(): # Copia OGNI config/<name>.json.example presente nel repo in
shutil.copy(mods, CONFIG_DIR / "modules.json") # config/<name>.json, SOLO se la destinazione non esiste gia'
chown(CONFIG_DIR / "modules.json") # (mai clobber su re-run / re-install).
log("modules.json copiato") #
# Fonte di verita': i .example versionati nel repo argos. Aggiungere
# 5b. File .example aggiuntivi (config sezioni recenti) # un nuovo file config = aggiungere il suo .example, senza toccare
# - automations.json: config feed TI sources + cron daemon TI # questo installer. Allineato a backend/blueprints/backup.py
# - siem_integrations.json: catalogo SIEM Integration Builder # ALLOWED_FILES (provider_*, soar_*, siem_integrations, ...).
# - subnet_registry.json: mapping sede/reparto da subnet #
for stem in ("automations", "siem_integrations", "subnet_registry"): # Skip dei file GENERATI altrove in questo install():
src = APP_DIR / f"config/{stem}.json.example" # argos.json -> step 3 (generate_argos_json)
dst = CONFIG_DIR / f"{stem}.json" # integrations.json -> step 4 (generate_integrations_json + pdf)
if src.exists() and not dst.exists(): # argos_users.json -> step 9 (create_admin_user) — copiarlo qui
shutil.copy(src, dst) # inietterebbe utenti d'esempio prima dell'admin.
os.chmod(dst, 0o640) # File con segreti -> chmod 600 (gli altri 640).
chown(dst) _GENERATED = {"argos.json", "integrations.json", "argos_users.json"}
log(f"{stem}.json copiato da template") _SECRET = {"provider_credentials.json", "soar_credentials.json"}
for src in sorted((APP_DIR / "config").glob("*.json.example")):
name = src.name[:-len(".example")] # foo.json.example -> foo.json
if name in _GENERATED:
continue
dst = CONFIG_DIR / name
if dst.exists():
continue
shutil.copy(src, dst)
os.chmod(dst, 0o600 if name in _SECRET else 0o640)
chown(dst)
log(f"{name} copiato da template")
# 6. Logo cliente # 6. Logo cliente
logo_src = SETUP_DIR / "logo_cliente.png" logo_src = SETUP_DIR / "logo_cliente.png"