Commit Graph

22 Commits

Author SHA1 Message Date
a0e9ba8beb test(metablog): Smoke test for 3-site Gitea ingest (ref #94)
fix(metablog-ingest-site): Handle .git repos with unborn branch (no commits):
- Use git rev-parse --verify HEAD (exits non-zero on unborn branch) instead of
  rev-parse HEAD (which returns "HEAD" string even with no commits)
- Add fall-through path: .git exists + no commits → git symbolic-ref HEAD
  refs/heads/main + commit + push (same as fresh-init path)

test: Add tests/scripts/test-metablog-ingest.sh smoke test:
- Step 1: dry-run --limit 3 verifies report total=3
- Step 2: live --limit 3 accepts any ok+skip combo >= 3
- Step 3: idempotent re-run asserts all 3 skip-already-current
- Step 4: git ls-remote via MOCHAbin SSH verifies remote HEAD exists
- Step 5: clone+diff via MOCHAbin SSH (diff --exclude=.git) verifies
  clone == source

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 15:10:06 +02:00
CyberMind
122cd6cebc
WebUI Obfuscation - admin.HOSTNAME.secubox.in Only (#96)
* docs(spec+plan): WebUI obfuscation design and implementation plan (ref #44)

Spec: docs/superpowers/specs/2026-05-12-webui-obfuscation-design.md
Plan: docs/superpowers/plans/2026-05-12-webui-obfuscation.md

The design locks the SecuBox WebUI to admin.<HOSTNAME>.<DOMAIN_SUFFIX>
via strict-regex ACLs in HAProxy AND nginx, both driven by
/etc/default/secubox as the single source of truth. New package
secubox-defaults ships the env file; secubox-haproxy API exposes
/webui/admin-domain (info), /webui/nginx-config (JWT, rendered vhost),
/webui/refresh (JWT, cache invalidate). A safe renderer script writes
the nginx vhost atomically; haproxyctl + Python /generate both inject
the strict ACL at the top of http-in and https-in frontends.

Plan has 15 tasks with TDD steps, exact file paths, and complete code
in every step (no TBD/TODO). Acceptance criteria + integration test
script included.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(secubox-defaults): scaffold package skeleton (ref #44)

* feat(secubox-defaults): ship /etc/default/secubox env file (ref #44)

* feat(secubox-defaults): postinst autodetect + dpkg-trigger (ref #44)

* feat(secubox-haproxy): webui_identity helper + tests (ref #44)

Implement webui_identity module that parses /etc/default/secubox
and exposes canonical admin URL + regex pattern for HAProxy acl.

New module:
- api/webui_identity.py: Parses SECUBOX_HOSTNAME and SECUBOX_DOMAIN_SUFFIX
  with LRU cache and invalidation support.

Tests (TDD):
- tests/test_webui_identity.py: 5 test cases covering basic parsing,
  missing hostname validation, custom suffix handling, comment handling,
  and cache invalidation.
- tests/conftest.py: sys.path bootstrap for api/ imports.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(webui_identity): catch OSError on defaults read + test (ref #44)

* feat(secubox-haproxy): GET /webui/admin-domain endpoint (ref #44)

* feat(secubox-haproxy): GET /webui/nginx-config rendered vhost (ref #44)

* feat(secubox-haproxy): POST /webui/refresh cache invalidation (ref #44)

* feat(secubox-haproxy): secubox-render-nginx-webui safe renderer (ref #44)

* feat(haproxyctl): inject strict-regex WebUI ACL at frontend top (ref #44)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(secubox-haproxy): /generate symmetry with strict WebUI ACL (ref #44)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(secubox-haproxy): dpkg-trigger refresh on secubox-defaults-changed (ref #44)

* build(secubox-haproxy): depend on secubox-defaults (ref #44)

* test(infra): integration test for WebUI obfuscation (ref #44)

* docs: HISTORY Session 159 — WebUI obfuscation (ref #44)

Records the complete WebUI obfuscation work: new secubox-defaults
package, three /webui/* endpoints, nginx renderer script, haproxyctl
+ Python generator symmetry, dpkg trigger plumbing, integration test.
Includes notes on the brainstorming → spec → plan → subagent-driven
execution flow and the 6 fix iterations caught by reviewers.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: CyberMind-FR <gandalf@Gk2.net>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 14:07:11 +02:00
CyberMind
b0b6e78cab
Merge pull request #84 from CyberMind-FR/feature/license-headers-phase-a
feat(license): CMSD-1.0 header tool, CI, and conventions (Phase A)
2026-05-12 11:41:43 +02:00
b88b8ada95 fix(license): tighten detect_existing + missing-file = repo-wide (ref #81)
Two bug fixes to the CMSD-1.0 license-header tool:

1. detect_existing() previously matched the SPDX token anywhere in the
   first 10 lines, including inside docstrings and prose comments.
   Tightened the matcher to require comment markers (#, //, *, <!--)
   and whitespace before the SPDX token.

   Regression tests:
   - test_detect_existing_no_false_match_in_docstring
   - test_detect_existing_no_false_match_inline_comment_prose

2. _read_enrollment() now returns ["**"] when the allowlist file is
   absent, per spec §5.2 "missing file → repo-wide enforcement".
   Previously it returned [] (nothing enforced), making Phase C closure
   impossible without an additional file.

   Empty allowlist file still returns [] (Phase A initial), so
   test_main_empty_allowlist_passes_check is unaffected.

   New tests:
   - test_read_enrollment_missing_file_means_repo_wide
   - test_main_check_missing_allowlist_enforces_repo_wide

Suite: 49 → 53 passing. --check still exits 0 repo-wide.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 11:39:57 +02:00
2763009fad fix(license): walk() accepts repo_root for subdir invocations (ref #81)
Discovered during Phase B pilot: running `--fix packages/secubox-hub`
yielded zero files because walk() computed `rel` relative to the walk
root (the subdir) while allowlist patterns are repo-relative.

Add optional `repo_root` parameter to walk(); when present, allowlist
matching uses paths relative to it instead of the walk root.
Backwards-compatible (defaults to None, preserving existing tests).
main() passes the discovered repo_root through.

Regression test added: test_walk_subdir_with_repo_root_arg.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 11:03:32 +02:00
6bd4fb3e11 feat(metrics): Add get_ssl_status() for certificate health
- Reads cert from /etc/letsencrypt/live/{domain}/cert.pem
- Thresholds: >7j ok, 3-7j warn, <3j error, ≤0 expired
- 5 unit tests with mocked certificates

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-12 10:57:31 +02:00
e90a07a578 chore(license): self-host header on tool and tests + initial allowlist (ref #81)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 10:00:09 +02:00
c93cfdb639 feat(license): CLI dispatch with --check/--fix/--list/--diff (ref #81)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 09:57:19 +02:00
72733385eb feat(license): walk() with skip-list and enrollment allowlist (ref #81)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 09:54:35 +02:00
2bd965f481 feat(license): apply() for HTML (doctype) and Markdown (frontmatter), plus TOML/YAML/conf (ref #81)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 09:50:48 +02:00
ada5040693 feat(license): apply() for JS/TS/CSS/C/H with idempotence (ref #81)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 09:49:28 +02:00
6474728dc4 feat(license): apply() for Bash with shebang-aware placement (ref #81)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 09:48:43 +02:00
9b0fce3fac test(license): cover Python shebang and encoding-declaration placement (ref #81)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 09:47:43 +02:00
63e62c1d54 feat(license): apply() for plain Python, with idempotence and foreign-skip (ref #81)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 09:45:34 +02:00
5b4d3e25fb feat(license): detect_existing distinguishes CMSD/foreign/none (ref #81)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 09:41:04 +02:00
70ac535e68 feat(license): render_header for slash/block/html comment styles (ref #81)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 09:38:20 +02:00
f08eb38073 feat(license): render_header for hash-comment languages (ref #81)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 09:34:43 +02:00
c7166597f5 chore(license): scaffold license-headers tool and test module (ref #81)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 09:29:28 +02:00
6f59de25c7 feat(scripts): Add tier-manifest helper for APT staging (ref #80)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 09:16:32 +02:00
0daed3c8d9 fix(opad): use model_json_schema() for Pydantic v2
Replace deprecated .schema() with .model_json_schema()

Refs: CM-WALL-OPAD-2026-05
2026-05-12 09:15:09 +02:00
4529b5c11a docs(spec): CMSD-1.0 license headers across the codebase
Brainstormed design for adding the SPDX-CMSD-1.0 header to every
first-party source file (~2,170 across 6 languages), backed by a
reusable Python tool (scripts/license-headers.py), a CI check, and
a phased per-package rollout. Spec covers scope, header rendering
per language, placement rules, tool architecture, CI integration
with an enrollment allowlist, and verification steps.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 09:10:37 +02:00
7b93160478 feat(opad): add Pydantic models and validation tests
Pydantic v1 models equivalent to JSON Schema:
- OPADProfile: Complete 3-prong configuration
- Enums: OPADMode, PolicyAction, LogLevel, Protocol
- Observation, Injection, Policy configs
- OPADEvent and OPADInjectResult for logging

Tests verify JSON Schema and Pydantic equivalence.
All 18 tests passing.

Refs: CM-WALL-OPAD-2026-05

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-12 09:05:22 +02:00