Skip to content

fix: wire up or remove orphaned modules (Fixes #19) - #187

Merged
OkiriGabriel merged 1 commit into
mainfrom
fix/orphaned-modules-19
Nov 24, 2026
Merged

OkiriGabriel merged 1 commit into
mainfrom
fix/orphaned-modules-19

Conversation

@OkiriGabriel

Copy link
Copy Markdown
Collaborator

Fixes #19. Three modules were never imported by the running agent. Each is now either wired in or removed.

collectors/server_enhanced.py → merged into ServerCollector, file removed

The old module used platform.system(), so it detected the agent's own OS and never ran over SSH. Its OS-specific checks are now in collectors/server.py, which detects the target host's OS over the same SSH or local path it already uses:

Target Detection Extra checks
RHEL family (RHEL, CentOS, Rocky, Alma, Amazon Linux, Fedora, OL) uname -s + /etc/os-release ID/ID_LIKE SELinux, firewalld, dnf/yum security updates
Debian/Ubuntu same upgradable packages, reboot-required, AppArmor
Windows Server ver CIM OS/CPU/disk, top processes, stopped auto-start services, System/Application errors (Get-WinEvent), listening ports, firewall, IIS

The PowerShell commands are sent with -EncodedCommand, so SSH and cmd.exe quoting can't mangle them. They use Get-CimInstance instead of the deprecated wmic. The result gains an os_family key. Linux keys are unchanged, and the existing SSH hardening tests still pass.

tools/safe_executor_enhanced.py → removed

It was never imported. Its never-delete blocklist and email alert are implemented properly in tools/executor.py by #186, which also fixes two broken SQL regexes the old file had. Merge #186 first, since docs/FEATURES_SUMMARY.md now points to tools/executor.py for this.

tools/documentation_generator.py → rewritten and wired in

  • render_incident_docs(incident_id, context, result) renders postmortem.md, runbook.md and kb.md in memory from the real run: the diagnosis, threat findings, tools used, commands that actually executed (blocked ones are excluded), suggested fixes, verification result and a rollback hint. It no longer writes to ./documentation or creates directories on import.
  • After a completed incident, api/server.py stores the three files with the incident's logs (<org>/logs/<year>/<month>/<incident_id>/) through the new IncidentStore.save_document: PII-scrubbed, text/markdown, and subject to the same AUDIT_RETENTION_DAYS.
  • AUTO_DOCUMENTATION=true by default (documented in .env.example). Code-review runs are skipped, and a storage failure only logs incident_docs_failed.
  • The documents are not written into org knowledge docs. A diagnosis can quote attacker-controlled log text, and the agent reads those docs back.

Docs

README, PLATFORM_SUPPORT, FEATURES_SUMMARY, ORGANIZATIONAL_GUIDE, START_HERE, QUESTIONS_ANSWERED, the status docs and SUMMARY_OF_CHANGES are updated to match.

Tests

  • tests/test_server_collector_os.py: OS detection for each family runs on the target host, plus a round-trip check of the encoded PowerShell.
  • tests/test_incident_docs.py: rendering, the security section, scrubbed storage, the flag, the code-review skip, and storage failures not breaking the incident.
  • Full suite: 1218 passed, 4 skipped. Flake8 (CI selection) and bandit -ll are clean.

🤖 Generated with Claude Code

- ServerCollector detects the TARGET host's OS over the existing SSH/local
  path (uname + /etc/os-release, ver for Windows) and adds RHEL (SELinux,
  firewalld, security updates), Debian (upgrades, reboot-required, AppArmor)
  and Windows Server (CIM, Get-WinEvent, services, firewall, IIS) checks.
  Result gains an os_family key. Replaces collectors/server_enhanced.py,
  which detected the agent's own OS and never used SSH.
- Remove tools/safe_executor_enhanced.py: never imported; the never-delete
  blocklist and email alert live in tools/executor.py (#186).
- documentation_generator renders postmortem/runbook/KB markdown in memory
  from the real run; the API stores them with the incident's logs
  (PII-scrubbed, same retention) behind AUTO_DOCUMENTATION (default true).
  Code-review runs are skipped; documents are never written to org docs.
- Update README and docs that referenced the removed files.

Fixes #19

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

Integrate or remove orphaned modules (*_enhanced, documentation_generator, docker parser)

1 participant