Map all 12 The Char Coal Times audit channels and add full test suite

This commit is contained in:
FlexiCraft Admin 2026-11-27 01:44:31 +00:00
parent 1e003c2f50
commit 645cc91496
2 changed files with 64 additions and 14 deletions

View file

@ -1,17 +1,17 @@
{
"description": "ID du salon Discord Charcoal associe a chaque ministere (0 = desactive tant que non renseigne)",
"description": "ID du salon Discord Charcoal associe a chaque ministere",
"channels": {
"diamond": 0,
"emerald": 0,
"netherite": 0,
"coal": 0,
"iron": 0,
"copper": 0,
"lapis": 0,
"redstone": 0,
"gold": 0,
"quartz": 0,
"resin": 0,
"amethyst": 0
"diamond": 1574858560750493697,
"emerald": 1574858562835058769,
"netherite": 1574858564940337172,
"coal": 1574858566769057792,
"iron": 1574858573106909264,
"copper": 1574858575493341365,
"lapis": 1574858577892483172,
"redstone": 1574858589087080460,
"gold": 1574858591775498382,
"quartz": 1574858593667387402,
"resin": 1574858596355674253,
"amethyst": 1574858598528581832
}
}

View file

@ -0,0 +1,50 @@
import os, sys, json, sqlite3, subprocess
sys.path.insert(0, "/var/www/flexicraft-site")
from core.audit_core import AUDIT_DB, AUDIT_SOCK, GENESIS_HASH, _compute_hash, emit_audit
from core.permissions_bus import evaluate_web_access, resolve_forgejo_team, update_role_domain_guarded
from core.package_updater import load_registry
print("=================================================================")
print(" BANC DE TEST & DIAGNOSTIC GLOBAL — INFRASTRUCTURE FLEXICRAFT")
print("=================================================================")
for svc in ("flexicraft-status", "flexicraft-web", "forgejo"):
st = subprocess.run(["systemctl", "is-active", svc], capture_output=True, text=True).stdout.strip()
print(f" {'✅' if st == 'active' else '❌'} Service {svc:<20} : {st}")
sock_ok = os.path.exists(AUDIT_SOCK)
print(f" {'✅' if sock_ok else '❌'} Socket Unix Audit Bus : {'actif (' + AUDIT_SOCK + ')' if sock_ok else 'ABSENT'}")
web_adm = evaluate_web_access(["683346841265373195"])
fg_team = resolve_forgejo_team(["683346841265373195"])
guard_test = update_role_domain_guarded("TestBot", False, "web", "683346841265373195", {"web_tier": "visitor"})
guard_ok = (not guard_test.get("ok")) and ("Verrou constitutionnel" in guard_test.get("error", ""))
print(f" {'✅' if web_adm.get('admin') and fg_team == 'guardian' else '❌'} Bus Permissions (3 dom.) : web={web_adm.get('tier')} | forgejo={fg_team}")
print(f" {'✅' if guard_ok else '❌'} Garde-fou Anti-Coup d'Etat: {'bloque correctement' if guard_ok else 'ECHEC'}")
reg = load_registry().get("packages", [])
print(f" {'✅' if len(reg) > 0 else '❌'} Registre Paquets : {len(reg)} paquets indexes")
eid = emit_audit("quartz", "self_test", "SystemCheck", "Diagnostic d'intégrité SQLite WAL & SHA-256", "audit.db", {"sphere": "Test Système"})
conn = sqlite3.connect(AUDIT_DB)
wal_mode = next(iter(conn.execute("PRAGMA journal_mode;").fetchone()))
rows = conn.execute("SELECT id, ts, ministry, source, actor_name, action, target, details_json, prev_hash, row_hash FROM audit_events ORDER BY id ASC").fetchall()
conn.close()
expected_prev = GENESIS_HASH
chain_valid = True
for r in rows:
_, ts, m, s, act, ac, tgt, det, ph, rh = r
if ph != expected_prev or rh != _compute_hash(expected_prev, ts, m, s, act, ac, tgt or "", det or "{}"):
chain_valid = False
break
expected_prev = rh
print(f" {'✅' if wal_mode == 'wal' else '❌'} Base SQLite mode WAL : journal_mode={wal_mode} ({len(rows)} evenements)")
print(f" {'✅' if chain_valid else '❌'} Integrite Chaine SHA-256 : {'VALIDE (0 alteration)' if chain_valid else 'CORROMPUE'}")
with open("/var/www/flexicraft-site/config/audit_channels.json", "r") as f:
ch_map = json.load(f).get("channels", {})
linked = sum(1 for v in ch_map.values() if int(v or 0) > 0)
print(f" {'✅' if linked == 12 else '⚠️'} Salons Charcoal mappes : {linked}/12 ministeres relies")