Skip to content

Commit 9d6970b

Browse files
SecAI-Hubclaude
andcommitted
Implement M44: Auditability and documentation hardening
1. Fix documentation count drift: single source-of-truth test-counts.json (Go 399, Python 718, total 1117), CI test-count-check job that fails if documented counts drift below actual, updated test-matrix.md and README with exact counts. 2. CI evidence easier to verify: Verification & Audit section in README with direct links to CI/build/release workflows, M5 control matrix, supply-chain provenance doc; GitHub Actions CI and Build badges. 3. M4/M5 terminology disambiguation: renamed all roadmap entries from "M0..M43" to "Milestone 0..Milestone 43", created glossary.md distinguishing project milestones vs M5 security assurance level vs acceptance criteria. 4. M5 evidence chain explicit: added "Operator Verification" column to all 26 controls in m5-control-matrix.md, created audit-quick-path.md (run tests, inspect logs, verify artifacts, confirm system states). 5. Recovery path proven: created recovery-runbook.md with degradation triggers, containment latch behavior, acknowledgment/re-attestation procedures, return-to-trusted ceremony, forensic export, severity escalation reference (all with concrete curl commands). 6. Supply-chain verification tightened: created verify-release.sh auditor script (cosign verify, SBOM attestation, SLSA provenance, checksums), created sample-release-bundle.md documenting release artifact structure. 7. Status page restructured: split security-status.md into "Security Assurance Controls (M5 Complete)" and "Product Feature Roadmap", clarified Agent Mode Phase 2/3 are not M5 blockers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5169822 commit 9d6970b

12 files changed

Lines changed: 1653 additions & 111 deletions
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
###############################################################################
5+
# check-test-counts.sh — Detect test-count drift against docs/test-counts.json
6+
#
7+
# Exits non-zero if any per-service count is LOWER than the documented count.
8+
# Counts that EXCEED the documented value are fine (docs just need updating).
9+
###############################################################################
10+
11+
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
12+
COUNTS_FILE="${REPO_ROOT}/docs/test-counts.json"
13+
14+
if [[ ! -f "${COUNTS_FILE}" ]]; then
15+
echo "FATAL: ${COUNTS_FILE} not found."
16+
exit 1
17+
fi
18+
19+
# JSON helper — Python is already set up in CI.
20+
read_json() {
21+
python3 -c "import json,sys; d=json.load(open('${COUNTS_FILE}')); print(d$1)"
22+
}
23+
24+
###############################################################################
25+
# 1. Count Go tests per service
26+
###############################################################################
27+
28+
GO_SERVICES="airlock registry tool-firewall gpu-integrity-watch mcp-firewall policy-engine runtime-attestor integrity-monitor incident-recorder"
29+
30+
go_total_actual=0
31+
drift_found=0
32+
33+
echo "=============================================="
34+
echo " Test-Count Drift Check"
35+
echo "=============================================="
36+
echo ""
37+
echo "--- Go services ---"
38+
39+
# Store results in temp files (bash 3 compatible, no associative arrays)
40+
results_dir=$(mktemp -d)
41+
trap 'rm -rf "${results_dir}"' EXIT
42+
43+
for svc in ${GO_SERVICES}; do
44+
svc_dir="${REPO_ROOT}/services/${svc}"
45+
if [[ ! -d "${svc_dir}" ]]; then
46+
echo "WARNING: services/${svc} directory not found, skipping."
47+
echo "0" > "${results_dir}/${svc}.actual"
48+
else
49+
count=$(cd "${svc_dir}" && go test -v -count=1 ./... 2>&1 | grep -c "^--- PASS" || true)
50+
echo "${count}" > "${results_dir}/${svc}.actual"
51+
go_total_actual=$((go_total_actual + count))
52+
fi
53+
54+
expected=$(read_json "['go']['${svc}']" 2>/dev/null || echo 0)
55+
echo "${expected}" > "${results_dir}/${svc}.expected"
56+
done
57+
58+
###############################################################################
59+
# 2. Count Python tests
60+
###############################################################################
61+
62+
echo "--- Python tests ---"
63+
64+
python_actual=$(cd "${REPO_ROOT}" && \
65+
PYTHONPATH=services python3 -m pytest tests/ --co -q 2>&1 | tail -1 | \
66+
grep -oE '^[0-9]+' || echo 0)
67+
68+
python_expected=$(read_json "['python_total']" 2>/dev/null || echo 0)
69+
70+
###############################################################################
71+
# 3. Compute totals
72+
###############################################################################
73+
74+
go_total_expected=$(read_json "['go_total']" 2>/dev/null || echo 0)
75+
grand_expected=$(read_json "['grand_total']" 2>/dev/null || echo 0)
76+
grand_actual=$((go_total_actual + python_actual))
77+
78+
###############################################################################
79+
# 4. Print summary table
80+
###############################################################################
81+
82+
echo ""
83+
echo "=============================================="
84+
printf " %-22s %8s %8s %8s\n" "Component" "Expected" "Actual" "Status"
85+
echo "----------------------------------------------"
86+
87+
for svc in ${GO_SERVICES}; do
88+
exp=$(cat "${results_dir}/${svc}.expected")
89+
act=$(cat "${results_dir}/${svc}.actual")
90+
if [ "${act}" -lt "${exp}" ]; then
91+
status="DRIFT!"
92+
drift_found=1
93+
elif [ "${act}" -gt "${exp}" ]; then
94+
status="ABOVE (update docs)"
95+
else
96+
status="OK"
97+
fi
98+
printf " %-22s %8d %8d %s\n" "go/${svc}" "${exp}" "${act}" "${status}"
99+
done
100+
101+
# Python row
102+
if [ "${python_actual}" -lt "${python_expected}" ]; then
103+
py_status="DRIFT!"
104+
drift_found=1
105+
elif [ "${python_actual}" -gt "${python_expected}" ]; then
106+
py_status="ABOVE (update docs)"
107+
else
108+
py_status="OK"
109+
fi
110+
printf " %-22s %8d %8d %s\n" "python" "${python_expected}" "${python_actual}" "${py_status}"
111+
112+
echo "----------------------------------------------"
113+
printf " %-22s %8d %8d\n" "Go subtotal" "${go_total_expected}" "${go_total_actual}"
114+
printf " %-22s %8d %8d\n" "Python subtotal" "${python_expected}" "${python_actual}"
115+
printf " %-22s %8d %8d\n" "Grand total" "${grand_expected}" "${grand_actual}"
116+
echo "=============================================="
117+
echo ""
118+
119+
###############################################################################
120+
# 5. Exit with appropriate code
121+
###############################################################################
122+
123+
if [ "${drift_found}" -eq 1 ]; then
124+
echo "FAIL: One or more test counts drifted DOWN from documented values."
125+
echo " This means tests were removed or broken without updating docs/test-counts.json."
126+
exit 1
127+
else
128+
echo "PASS: All test counts meet or exceed documented values."
129+
if [ "${grand_actual}" -gt "${grand_expected}" ]; then
130+
echo "NOTE: Grand total exceeds documented count (${grand_actual} > ${grand_expected})."
131+
echo " Consider updating docs/test-counts.json to reflect the new counts."
132+
fi
133+
exit 0
134+
fi

.github/workflows/ci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,3 +236,25 @@ jobs:
236236
- name: Run incident-recorder recovery tests
237237
working-directory: services/incident-recorder
238238
run: go test -v -race -run "TestRecovery|TestEscalation|TestForensic|TestLatched" ./...
239+
240+
test-count-check:
241+
name: Test Count Drift Check
242+
runs-on: ubuntu-latest
243+
permissions:
244+
contents: read
245+
steps:
246+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
247+
248+
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
249+
with:
250+
go-version: "1.23"
251+
252+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
253+
with:
254+
python-version: "3.12"
255+
256+
- name: Install Python dependencies
257+
run: pip install pyyaml flask requests pytest
258+
259+
- name: Check test counts for drift
260+
run: bash .github/scripts/check-test-counts.sh

README.md

Lines changed: 85 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SecAI OS
22

33
[![CI](https://github.com/SecAI-Hub/SecAI_OS/actions/workflows/ci.yml/badge.svg)](https://github.com/SecAI-Hub/SecAI_OS/actions/workflows/ci.yml)
4+
[![Build](https://github.com/SecAI-Hub/SecAI_OS/actions/workflows/build.yml/badge.svg)](https://github.com/SecAI-Hub/SecAI_OS/actions/workflows/build.yml)
45
[![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
56
[![Fedora 42](https://img.shields.io/badge/Fedora-42-blue)](https://fedoraproject.org/)
67
[![uBlue](https://img.shields.io/badge/Built_on-uBlue-purple)](https://universal-blue.org/)
@@ -150,7 +151,7 @@ Every model passes through the same fully automatic pipeline:
150151
| **Updates** | Cosign-verified rpm-ostree, staged workflow, greenboot auto-rollback |
151152
| **Supply Chain** | Per-service CycloneDX SBOMs, SLSA3 provenance attestation, cosign-signed checksums |
152153

153-
See [docs/threat-model.md](docs/threat-model.md) for threat classes, residual risks, and security invariants. See [docs/security-status.md](docs/security-status.md) for implementation status of all 43 milestones.
154+
See [docs/threat-model.md](docs/threat-model.md) for threat classes, residual risks, and security invariants. See [docs/security-status.md](docs/security-status.md) for implementation status of all 44 milestones.
154155

155156
### Verify Image Signatures
156157

@@ -192,6 +193,34 @@ See [docs/policy-schema.md](docs/policy-schema.md) for full schema reference. Se
192193

193194
---
194195

196+
## Verification & Audit
197+
198+
### Workflow Files
199+
200+
- [CI Workflow](.github/workflows/ci.yml)
201+
- [Build Workflow](.github/workflows/build.yml)
202+
- [Release Workflow](.github/workflows/release.yml)
203+
204+
### Security Documentation
205+
206+
- [M5 Control Matrix](docs/m5-control-matrix.md)
207+
- [Supply Chain Provenance](docs/supply-chain-provenance.md)
208+
- [Security Status](docs/security-status.md)
209+
210+
### CI Verification Evidence
211+
212+
Each CI job produces specific security evidence:
213+
214+
| Job | What It Proves |
215+
|-----|---------------|
216+
| `security-regression` | Adversarial test suite: prompt injection, policy bypass, containment |
217+
| `supply-chain-verify` | SBOM generation via Syft, cosign availability, provenance keywords |
218+
| `go-build-and-test` | 399 Go tests across 9 services with `-race` |
219+
| `python-test` | 718 Python tests (agent, adversarial, M5 acceptance, UI, pipeline) |
220+
| `test-count-check` | Prevents documented test counts from drifting below actual |
221+
222+
---
223+
195224
## Documentation
196225

197226
| Document | Description |
@@ -200,8 +229,8 @@ See [docs/policy-schema.md](docs/policy-schema.md) for full schema reference. Se
200229
| [Threat Model](docs/threat-model.md) | Threat classes, invariants, residual risks |
201230
| [API Reference](docs/api.md) | HTTP API for all services |
202231
| [Policy Schema](docs/policy-schema.md) | Full policy.yaml schema reference |
203-
| [Security Status](docs/security-status.md) | Implementation status of all 43 milestones |
204-
| [Test Matrix](docs/test-matrix.md) | Test coverage: 1000+ tests across Go, Python, shell |
232+
| [Security Status](docs/security-status.md) | Implementation status of all 44 milestones |
233+
| [Test Matrix](docs/test-matrix.md) | Test coverage: 1,117 tests across Go and Python (see [test-counts.json](docs/test-counts.json)) |
205234
| [Compatibility Matrix](docs/compatibility-matrix.md) | GPU, VM, and hardware support |
206235
| [Security Test Matrix](docs/security-test-matrix.md) | Security feature test coverage |
207236
| [FAQ](docs/faq.md) | Common questions |
@@ -226,6 +255,9 @@ See [docs/policy-schema.md](docs/policy-schema.md) for full schema reference. Se
226255
| [Incident Recorder](docs/components/incident-recorder.md) | Security event capture and auto-containment |
227256
| [M5 Control Matrix](docs/m5-control-matrix.md) | M5 acceptance criteria, enforcement paths, operator verification |
228257
| [Supply Chain Provenance](docs/supply-chain-provenance.md) | Provenance pipeline, SBOM coverage, key material |
258+
| [Audit Quick Path](docs/audit-quick-path.md) | External auditor step-by-step verification guide |
259+
| [Recovery Runbook](docs/recovery-runbook.md) | Operator procedures for degradation, containment, and recovery |
260+
| [Sample Release Bundle](docs/sample-release-bundle.md) | Release artifact structure and verification commands |
229261

230262
### Install Guides
231263

@@ -308,13 +340,13 @@ Privacy: Tor-routed, PII stripped, injection detection, privacy-preserving query
308340
## Running Tests
309341

310342
```bash
311-
# Go tests (348 total across 9 services)
343+
# Go tests (399 total across 9 services)
312344
for svc in airlock registry tool-firewall gpu-integrity-watch mcp-firewall \
313345
policy-engine runtime-attestor integrity-monitor incident-recorder; do
314346
(cd services/$svc && go test -v -race ./...)
315347
done
316348

317-
# Python tests (658 total)
349+
# Python tests (718 total)
318350
pip install pytest flask requests pyyaml
319351
python -m pytest tests/ -v
320352

@@ -329,52 +361,53 @@ See [docs/test-matrix.md](docs/test-matrix.md) for full breakdown.
329361
## Roadmap
330362

331363
<details>
332-
<summary>All 43 milestones (click to expand)</summary>
333-
334-
- [x] **M0** -- Threat model, dataflow, invariants, policy files
335-
- [x] **M1** -- Bootable OS, encrypted vault, GPU drivers
336-
- [x] **M2** -- Trusted Registry, hash pinning, cosign verification
337-
- [x] **M3** -- 7-stage quarantine pipeline
338-
- [x] **M4** -- Tool Firewall, default-deny policy
339-
- [x] **M5** -- Online Airlock, sanitization
340-
- [x] **M6** -- Systemd sandboxing, kernel hardening, nftables
341-
- [x] **M7** -- CI/CD, Go/Python tests, shellcheck
342-
- [x] **M8** -- Image/video generation, diffusion worker
343-
- [x] **M9** -- Multi-GPU support (NVIDIA/AMD/Intel/Apple)
344-
- [x] **M10** -- Tor-routed search, SearXNG, PII stripping
345-
- [x] **M11** -- VM support, OVA/QCOW2 builds
346-
- [x] **M12** -- Model integrity monitoring
347-
- [x] **M13** -- Tamper-evident audit logs
348-
- [x] **M14** -- Local passphrase auth
349-
- [x] **M15** -- Vault auto-lock
350-
- [x] **M16** -- Seccomp-BPF + Landlock process isolation
351-
- [x] **M17** -- Secure Boot + TPM2 measured boot
352-
- [x] **M18** -- Memory protection (swap/zswap/core dumps/mlock/TEE)
353-
- [x] **M19** -- Traffic analysis protection
354-
- [x] **M20** -- Privacy-preserving query obfuscation for search
355-
- [x] **M21** -- Clipboard isolation
356-
- [x] **M22** -- Canary/tripwire system
357-
- [x] **M23** -- Emergency wipe (3-level panic)
358-
- [x] **M24** -- Update verification + auto-rollback
359-
- [x] **M25** -- UI polish + security hardening
360-
- [x] **M26** -- Fail-closed pipeline, service auth, CSRF, supply chain pinning
361-
- [x] **M27** -- Enhanced scanners, provenance manifests, fs-verity
362-
- [x] **M28** -- Weight distribution fingerprinting
363-
- [x] **M29** -- Garak LLM vulnerability scanner
364-
- [x] **M30** -- gguf-guard deep GGUF integrity scanner
365-
- [x] **M31** -- Agent Mode (Phase 1: safe local autopilot)
366-
- [x] **M32** -- GPU Integrity Watch (continuous GPU runtime verification)
367-
- [x] **M33** -- MCP Firewall (Model Context Protocol policy gateway)
368-
- [x] **M34** -- Release provenance + per-service SBOMs (SLSA3, CycloneDX, cosign)
369-
- [x] **M35** -- Unified policy decision engine (6 domains, OPA/Rego-upgradeable)
370-
- [x] **M36** -- Runtime attestation + startup gating (TPM2, HMAC state bundles)
371-
- [x] **M37** -- Continuous integrity monitor (baseline-verified file watcher)
372-
- [x] **M38** -- Incident recorder + containment automation (9 classes, 4-state lifecycle)
373-
- [x] **M39** -- GPU integrity deep integration (driver fingerprinting, attestor/incident wiring)
374-
- [x] **M40** -- Agent verified supervisor hardening (signed tokens, replay protection, two-phase approval)
375-
- [x] **M41** -- HSM-backed key handling (pluggable keystore: software/TPM2/PKCS#11)
376-
- [x] **M42** -- Enforcement wiring + CI supply chain verification
377-
- [x] **M43** -- Stronger isolation: sandbox tightening, adversarial tests, CI security regression, MCP isolation, recovery ceremonies, M5 acceptance suite
364+
<summary>All 44 project milestones (click to expand)</summary>
365+
366+
- [x] **Milestone 0** -- Threat model, dataflow, invariants, policy files
367+
- [x] **Milestone 1** -- Bootable OS, encrypted vault, GPU drivers
368+
- [x] **Milestone 2** -- Trusted Registry, hash pinning, cosign verification
369+
- [x] **Milestone 3** -- 7-stage quarantine pipeline
370+
- [x] **Milestone 4** -- Tool Firewall, default-deny policy
371+
- [x] **Milestone 5** -- Online Airlock, sanitization
372+
- [x] **Milestone 6** -- Systemd sandboxing, kernel hardening, nftables
373+
- [x] **Milestone 7** -- CI/CD, Go/Python tests, shellcheck
374+
- [x] **Milestone 8** -- Image/video generation, diffusion worker
375+
- [x] **Milestone 9** -- Multi-GPU support (NVIDIA/AMD/Intel/Apple)
376+
- [x] **Milestone 10** -- Tor-routed search, SearXNG, PII stripping
377+
- [x] **Milestone 11** -- VM support, OVA/QCOW2 builds
378+
- [x] **Milestone 12** -- Model integrity monitoring
379+
- [x] **Milestone 13** -- Tamper-evident audit logs
380+
- [x] **Milestone 14** -- Local passphrase auth
381+
- [x] **Milestone 15** -- Vault auto-lock
382+
- [x] **Milestone 16** -- Seccomp-BPF + Landlock process isolation
383+
- [x] **Milestone 17** -- Secure Boot + TPM2 measured boot
384+
- [x] **Milestone 18** -- Memory protection (swap/zswap/core dumps/mlock/TEE)
385+
- [x] **Milestone 19** -- Traffic analysis protection
386+
- [x] **Milestone 20** -- Privacy-preserving query obfuscation for search
387+
- [x] **Milestone 21** -- Clipboard isolation
388+
- [x] **Milestone 22** -- Canary/tripwire system
389+
- [x] **Milestone 23** -- Emergency wipe (3-level panic)
390+
- [x] **Milestone 24** -- Update verification + auto-rollback
391+
- [x] **Milestone 25** -- UI polish + security hardening
392+
- [x] **Milestone 26** -- Fail-closed pipeline, service auth, CSRF, supply chain pinning
393+
- [x] **Milestone 27** -- Enhanced scanners, provenance manifests, fs-verity
394+
- [x] **Milestone 28** -- Weight distribution fingerprinting
395+
- [x] **Milestone 29** -- Garak LLM vulnerability scanner
396+
- [x] **Milestone 30** -- gguf-guard deep GGUF integrity scanner
397+
- [x] **Milestone 31** -- Agent Mode (Phase 1: safe local autopilot)
398+
- [x] **Milestone 32** -- GPU Integrity Watch (continuous GPU runtime verification)
399+
- [x] **Milestone 33** -- MCP Firewall (Model Context Protocol policy gateway)
400+
- [x] **Milestone 34** -- Release provenance + per-service SBOMs (SLSA3, CycloneDX, cosign)
401+
- [x] **Milestone 35** -- Unified policy decision engine (6 domains, OPA/Rego-upgradeable)
402+
- [x] **Milestone 36** -- Runtime attestation + startup gating (TPM2, HMAC state bundles)
403+
- [x] **Milestone 37** -- Continuous integrity monitor (baseline-verified file watcher)
404+
- [x] **Milestone 38** -- Incident recorder + containment automation (9 classes, 4-state lifecycle)
405+
- [x] **Milestone 39** -- GPU integrity deep integration (driver fingerprinting, attestor/incident wiring)
406+
- [x] **Milestone 40** -- Agent verified supervisor hardening (signed tokens, replay protection, two-phase approval)
407+
- [x] **Milestone 41** -- HSM-backed key handling (pluggable keystore: software/TPM2/PKCS#11)
408+
- [x] **Milestone 42** -- Enforcement wiring + CI supply chain verification
409+
- [x] **Milestone 43** -- Stronger isolation: sandbox tightening, adversarial tests, CI security regression, MCP isolation, recovery ceremonies, M5 acceptance suite
410+
- [x] **Milestone 44** -- Auditability and documentation hardening: test-count drift CI check, CI evidence links and badges, M4/M5 terminology disambiguation, audit quick-path doc, recovery runbook, verify-release script, security/product roadmap split
378411

379412
</details>
380413

@@ -406,7 +439,7 @@ services/
406439
search-mediator/ Python -- Tor-routed web search (:8485)
407440
ui/ Python/Flask -- Web UI (:8480)
408441
common/ Python -- Shared utilities (audit, auth, mlock)
409-
tests/ 658 Python tests, 348 Go tests (~1006 total)
442+
tests/ 718 Python tests, 399 Go tests (1,117 total)
410443
docs/ Architecture, API, threat model, install guides
411444
schemas/ OpenAPI spec, JSON Schema for config files
412445
examples/ Task-oriented walkthroughs

0 commit comments

Comments
 (0)