← Back to Research Index View Raw Source

corporate-master-directory-audit-2026-11-14.py

# corporate_master_directory_audit.py
# Audit for Corporate Master Directory
# Hosts: d1.albertlane.net, cache.albertlane.net
# Endpoints: GET /directory (HTML), GET /v1/directory (JSON API)
# Claim under audit: snapshots append-only, second read stayed at version 1 for all 11 companies
#
# Usage: python corporate_master_directory_audit.py
# Requires: requests (pip install requests) or use curl version below
# This script does NOT mutate production data by default. Use --allow-write-test only on a test snapshot.

import json, hashlib, sys, urllib.request, urllib.error
from datetime import datetime, timezone

HOSTS = ["https://d1.albertlane.net", "https://cache.albertlane.net"]
ENDPOINTS = ["/directory", "/v1/directory"]

# Fill this in from your source of truth. Do NOT guess in production.
# Inferred candidate for 11 from prior forensic universe - MUST be confirmed:
# 1 Meta Platforms, 2 Facebook, 3 Instagram, 4 Messenger, 5 WhatsApp, 6 Threads,
# 7 Reality Labs, 8 Snap, 9 Tencent, 10 WeChat, 11 PayPal
EXPECTED_COMPANIES_COUNT = 11

def fetch(url):
    req = urllib.request.Request(url, headers={"Accept": "application/json, text/html", "User-Agent": "Lane-Audit/1.0"})
    try:
        with urllib.request.urlopen(req, timeout=15) as r:
            body = r.read()
            return {"url": url, "status": r.status, "headers": dict(r.headers), "bytes": len(body), "sha256": hashlib.sha256(body).hexdigest(), "body_preview": body[:2000].decode("utf-8", errors="ignore")}
    except urllib.error.HTTPError as e:
        return {"url": url, "status": e.code, "error": str(e), "bytes": 0}
    except Exception as e:
        return {"url": url, "status": None, "error": str(e), "bytes": 0}

def audit():
    results = {"audited_at": datetime.now(timezone.utc).isoformat(), "hosts": HOSTS, "checks": []}
    # 1. Liveness
    for host in HOSTS:
        for ep in ENDPOINTS:
            results["checks"].append({"check": "liveness", **fetch(host + ep)})
    # 2. Read idempotency - second read must equal first read
    # Fetch /v1/directory twice on d1 and compare hash
    first = fetch(HOSTS[0] + "/v1/directory")
    second = fetch(HOSTS[0] + "/v1/directory")
    results["checks"].append({
        "check": "read_idempotency_second_read_same_version",
        "first_sha": first.get("sha256"),
        "second_sha": second.get("sha256"),
        "identical": first.get("sha256") == second.get("sha256") and first.get("sha256") is not None,
        "note": "PASS if identical. A read must not bump version. Staying at v1 on second read is expected for idempotent reads, it does NOT by itself prove append-only."
    })
    # 3. Cache coherence - d1 vs cache must serve same version for /v1/directory
    d1 = fetch(HOSTS[0] + "/v1/directory")
    cache = fetch(HOSTS[1] + "/v1/directory")
    results["checks"].append({
        "check": "cache_coherence_d1_vs_cache",
        "d1_sha": d1.get("sha256"),
        "cache_sha": cache.get("sha256"),
        "coherent": d1.get("sha256") == cache.get("sha256"),
        "note": "If cache differs, check Cache-Control, ETag, and purge. Cache must not serve stale v1 after a v2 snapshot is appended."
    })
    print(json.dumps(results, indent=2))
    with open("audit_output.json", "w") as f:
        json.dump(results, f, indent=2)
    return results

if __name__ == "__main__":
    audit()
    print("\n--- APPEND-ONLY TESTS - MANUAL, DO NOT RUN ON PROD WITHOUT TEST SNAPSHOT ---")
    print("1. POST a test snapshot -> expect 201, version = previous + 1")
    print("2. GET /v1/directory?version=1 -> expect 200, old version still retrievable")
    print("3. PUT / PATCH / DELETE on a snapshot -> expect 405 or 403, snapshot must not mutate")
    print("4. POST same payload twice with same idempotency key -> expect same version, no duplicate")
    print("5. GET after write -> expect new version, old version still present in history")