Skip to content

Add CIS audit, HTML scorecard, and headless agent; fix CI lint - #16

Merged
star7js merged 1 commit into
mainfrom
feat/cis-audit-and-agent
Jul 6, 2026
Merged

Add CIS audit, HTML scorecard, and headless agent; fix CI lint#16
star7js merged 1 commit into
mainfrom
feat/cis-audit-and-agent

Conversation

@star7js

@star7js star7js commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

Consolidates the two fingerprint repos by porting three features from macbook_fingerprint into this repo's packaged layout, and fixes the CI failures that were already on main.

New: audit subpackage

  • audit/cis.py — scored CIS macOS benchmark (23 Level-1 controls), each failing control carries its exact remediation. Indeterminate checks (no privileges / not macOS) are excluded from the score rather than counted as passes.
  • audit/html_report.py — self-contained, shareable HTML scorecard (inline CSS, light/dark).
  • audit/agent.py — launchd monitoring agent with a hash-chained, tamper-evident history log (a silently edited/deleted record breaks the chain).

New CLI subcommands

  • macos-fingerprint audit [--level 1|2] [--format text|json|html] [-o FILE] — exits non-zero if any determinable check fails (CI-friendly).
  • macos-fingerprint agent {run,history,verify,install,uninstall} — headless scheduled monitoring.

CI fixes (main was red)

  • ruff E402 / unused-import errors
  • mypy assignment error in cli.py
  • black formatting across 11 files
  • a test that hardcoded /tmp instead of its realpath (/private/tmp on macOS)

Adaptations vs source repo

  • run_command returns None (not a "<unavailable>" sentinel) on failure.
  • compare_fingerprints() returns {"summary","changes"}, so drift reads ["changes"].keys().
  • The agent invokes python -m macos_fingerprint agent run.

Testing

  • +23 ported tests (test_cis_audit, test_html_report, test_agent).
  • Full suite: 207 passed (incl. slow), coverage 77.2% (gate 75%).
  • ruff / black / mypy all clean.
  • Verified end-to-end on macOS: audit scored the machine, HTML export, and agent run recorded a real cycle with drift detection against a baseline.

Follow-up

Archive the old repo once merged: gh repo archive star7js/macbook_fingerprint

🤖 Generated with Claude Code

Port three features from the macbook_fingerprint repo into the packaged
macos_fingerprint layout as a new `audit` subpackage:

- audit/cis.py: scored CIS macOS benchmark (23 Level-1 controls) with
  per-control remediation; indeterminate checks are excluded from the score.
- audit/html_report.py: self-contained, shareable HTML scorecard.
- audit/agent.py: launchd monitoring agent with a hash-chained,
  tamper-evident history log.

Wire `audit` and `agent` subcommands into the CLI and add tests for all
three modules (+23 tests).

Adaptations vs the source repo: run_command returns None (not an
"<unavailable>" sentinel) on failure, and compare_fingerprints() returns
{"summary","changes"} so drift reads ["changes"].keys(). The agent invokes
`python -m macos_fingerprint agent run`.

Also fix pre-existing CI failures on main: ruff E402/unused-import errors,
a mypy assignment error in cli.py, black formatting across 11 files, and a
test that hardcoded /tmp instead of its realpath (/private/tmp on macOS).

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

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 59.39850% with 108 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/macos_fingerprint/cli.py 7.05% 79 Missing ⚠️
src/macos_fingerprint/audit/agent.py 64.86% 26 Missing ⚠️
src/macos_fingerprint/audit/cis.py 96.25% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@star7js
star7js merged commit 795dfce into main Jul 6, 2026
10 checks passed
@star7js
star7js deleted the feat/cis-audit-and-agent branch July 6, 2026 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants