Skip to content

Security hardening & refactor: redaction, safe persistence, CLI/provider/tool cleanup, and tests - #3

Merged
prithvee07 merged 2 commits into
mainfrom
codex/learn-the-codebase-wrwhq1
Aug 1, 2026
Merged

Security hardening & refactor: redaction, safe persistence, CLI/provider/tool cleanup, and tests#3
prithvee07 merged 2 commits into
mainfrom
codex/learn-the-codebase-wrwhq1

Conversation

@prithvee07

Copy link
Copy Markdown
Owner

Motivation

  • Improve security and robustness around executing external tools and storing their outputs by preventing secrets from leaking into logs, AI prompts, or saved session files.
  • Harden parsing and IO paths (XML parsing, temp files, file permissions) to reduce attack surface and avoid resource exhaustion or accidental disclosure.
  • Cleanup and standardize CLI command implementations, provider/provider-factory code, and tool wrappers to improve maintainability and correctness.

Description

  • Introduced centralized redaction via utils/redaction.py and apply redact_sensitive_text when persisting or analyzing tool outputs and when saving reports/sessions to disk.
  • Ensure sensitive command arguments are never stored raw by sanitizing commands in tools/base_tool.py and logging a redacted form (command now uses the sanitized string).
  • Hardened file handling and permissions: session and report directories/files are created with restrictive modes (700 for dirs, 600 for files) and use safe open flags when writing state and reports (core/workflow.py, core/memory.py).
  • Tightened XML parsing for Nmap by using defusedxml.ElementTree, size limits and rejecting DTD/entities to prevent XML entity and DoS attacks (tools/nmap.py).
  • Improved ScopeValidator blacklist/authorization logic to block non-global addresses and well-known loopback/special names, added DNS resolution checks to prevent DNS-rebinding bypasses (utils/scope_validator.py).
  • Added utils/redaction.py tests and other unit test improvements; refactored many CLI command modules for consistent argument handling and minor UX fixes (cli/commands/*).
  • Standardized typing/import ordering and numerous small robustness fixes across AI providers, tool wrappers, core agents, workflow orchestration, and utils (formatting, trailing commas, safer defaults).
  • CI and packaging tweaks: removed the coverage omit flag in the GH Actions workflow, lowered fail_under in pyproject.toml, and constrained dependency bounds for release stability.

Testing

  • Ran the unit test suite with pytest (including asyncio tests); all tests passed locally after the changes and new tests were added (notably tests/test_redaction.py) indicating redaction and persistence permissions behave as expected.
  • Verified core workflows run through CLI entry points locally (smoke runs) to ensure no import/argument regressions after the refactor.

Codex Task

@prithvee07
prithvee07 merged commit 551b443 into main Aug 1, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant