Skip to content

fix(security): remediate review findings, exclude home in sandbox, and relocate MockProvider (#205) - #206

Merged
dan-petty merged 4 commits into
release/v0.2.18from
fix/205-remediate-review-findings-self-improvement
Sep 14, 2026
Merged

dan-petty merged 4 commits into
release/v0.2.18from
fix/205-remediate-review-findings-self-improvement

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Summary

  • Relocate MockProvider to Tests: Removed MockProvider from production src/devops_cli/ai/providers/mock.py to tests/mock_provider.py and provided clean register_provider registry factory.
  • Eliminate Brittle Pattern Exclusions in Favor of .gitignore: Replaced custom directory exclusion sets across RAG indexer, file watcher, argo, complexity scanner, repomap, drift auditor, ast graph, and harness slots with dynamic .gitignore lookup via is_ignored_by_git.
  • Sandbox Home Directory Exclusion Preference: Added user configuration preference sandbox.exclude_home_dir (default: True) in Settings, config.example.yaml, defaults.py, and options.py to completely exclude the user home directory (/home//*, ~//*) from sandbox mounts.
  • SSRF & Hostname Sanitization: Replaced literal 0.0.0.0 checks with ip.is_unspecified to eliminate Bandit B104 warnings, and standardized mock test hostnames to example.com.
  • Mandatory In-Review PR Transition Sequence: Enshrined rule in AGENTS.md to open draft PRs, update task status to In Review with populated PR field, and push the branch.

Closes #205

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Copilot was unable to run its full agentic suite in this review.

Pull request overview

This PR hardens the CLI against secret leakage and unsafe filesystem/network access while improving GitHub CLI usage via centralized rate limiting and more robust reference extraction.

Changes:

  • Add centralized run_gh() with pacing/backoff/caching and migrate GitHub CLI calls to it (plus new devops gh api).
  • Strengthen sandbox/process/devcontainer path validation and default home-directory exclusion behavior.
  • Improve network reference extraction (RFC exclusions, dedup/sort, .gitignore awareness) and expand test coverage for the new security behavior.

Reviewed changes

Copilot reviewed 77 out of 78 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/test_workload_sandbox.py Adds tests for home-dir exclusion behavior in Docker sandbox runner.
tests/test_subsystem_containment_and_redaction.py Fixes sandbox timeout test to use a workspace dir fixture.
tests/test_sandbox_traces.py Extends SSRF/metadata-blocking tests and adds error-handling cases.
tests/test_sandbox_probe.py Updates DNS spoof test hostnames to non-metadata example host.
tests/test_sandbox_lifecycle.py Adds secret masking tests and expands home-dir workspace validation tests.
tests/test_reference_extractor.py Expands tests for RFC exclusions, dedup/sort, telemetry-key discrimination.
tests/test_pydantic_ai_profiles_and_providers.py Switches MockProvider registration to test helper + register API.
tests/test_providers.py Registers mock provider in tests via new provider registry API.
tests/test_process.py Adds cwd traversal/forbidden-path tests for subprocess runners.
tests/test_pr_cmd.py Adds test ensuring PR thread rendering masks secrets.
tests/test_k8s_context.py Adds tests for secret masking and KUBECONFIG path safety + minikube autostart flag.
tests/test_harness.py Adds SqlitePlanStore forbidden-path test.
tests/test_github_ssh.py Updates tests to patch run_gh instead of run_subprocess.
tests/test_github_rate_limiter.py New unit tests for GitHub rate limiter, caching, and retries.
tests/test_github_milestones.py Updates gh command tests to patch run_gh.
tests/test_gh_cmd.py Updates gh command tests for run_gh and adds devops gh api tests.
tests/test_devcontainer.py Adds mount target traversal/forbidden path tests and secret masking for minikube start msg.
tests/test_config_commands.py Adds DEVOPS_CLI_CONFIG path safety tests and sandbox config dotted set/get tests.
tests/test_common_hallucinations.py Adds tests for new hallucination patterns.
tests/conftest.py Adds session autouse fixture to register test MockProvider.
src/devops_cli/watchers/file_watcher.py Switches ignore logic to gitignore-aware filtering using repo helpers.
src/devops_cli/telemetry/waterfall.py Consolidates unsafe IP checks and blocks private IP ranges for Jaeger.
src/devops_cli/security/reference_extractor.py Major upgrade: constants centralization, gitignore scanning, RFC exclusions, dedup/sort, telemetry discrimination.
src/devops_cli/security/kubeconform.py Uses gitignore-aware filtering during native fallback scanning.
src/devops_cli/security/gitleaks.py Uses gitignore-aware filtering for scan candidate selection.
src/devops_cli/security/complexity.py Uses gitignore-aware filtering for Python complexity scan inputs.
src/devops_cli/security/checkov.py Uses gitignore-aware filtering for fallback IaC scan traversal.
src/devops_cli/security/init.py Exposes new reference extractor helpers (dedup/sort).
src/devops_cli/sandbox/models.py Adds Pydantic validators to mask secrets in outputs/logs/archive fields.
src/devops_cli/sandbox/engine.py Adds home/subpath detection + configurable exclude_home_dir setting.
src/devops_cli/output/formatters/tables.py Filters/dedups/sorts network references before table rendering.
src/devops_cli/models/vulnerability.py Adds multi-location support for NetworkReference and aggregation display.
src/devops_cli/lang/en/help.py Adds help text for new devops gh api command.
src/devops_cli/github/ssh.py Routes gh operations through centralized run_gh.
src/devops_cli/github/rate_limiter.py New module implementing pacing/backoff/caching and run_gh().
src/devops_cli/docker/sandbox.py Adds configurable home exclusion logic and constants-based sensitive paths.
src/devops_cli/core/repo.py Improves gitignore matching for directories (trailing slash handling).
src/devops_cli/core/process_pipeline.py Uses secure env builder and sanitizes telemetry command strings.
src/devops_cli/core/process.py Adds cwd validation (no traversal / forbidden system dirs) for subprocess runners.
src/devops_cli/config/settings.py Adds SandboxConfig, validates DEVOPS_CLI_CONFIG safely, routes gh token to run_gh.
src/devops_cli/config/options.py Adds option key for sandbox.exclude_home_dir.
src/devops_cli/config/defaults.py Adds default for sandbox home exclusion.
src/devops_cli/config/constants.py Centralizes reference-extractor constants + sandbox sensitive subpaths; removes legacy gitignore dirs list.
src/devops_cli/config/init.py Re-exports new constants/config and removes CONST_GITIGNORE_DIRS export.
src/devops_cli/commands/vault.py Expands vault path validation exception handling to include VaultConfigurationError.
src/devops_cli/commands/pr.py Ensures gh-backed PR commands echo stdout and masks secrets in thread summaries.
src/devops_cli/commands/k8s/cluster_runtime.py Validates KUBECONFIG entries against traversal/forbidden system paths.
src/devops_cli/commands/k8s/cluster_context.py Masks exception text in warnings and respects should_autostart_minikube().
src/devops_cli/commands/gh.py Migrates gh calls to run_gh, adds devops gh api command, enables caching for read ops.
src/devops_cli/commands/devcontainer.py Validates mount targets and masks minikube start messages.
src/devops_cli/commands/config.py Uses run_gh for gh auth checks in secret detection.
src/devops_cli/argo/gitops.py Switches manifest scanning ignore logic to gitignore-aware filtering.
src/devops_cli/ai/tools/builtin_tools.py Makes code search gitignore-aware.
src/devops_cli/ai/tasks/review.md Updates review instructions to prevent specific hallucination patterns.
src/devops_cli/ai/review/runner.py Uses gitignore-aware filtering for review candidate file inclusion.
src/devops_cli/ai/review/pipeline.py Filters/dedups/sorts network references in consolidated reporting and tables.
src/devops_cli/ai/review/common_hallucinations.py Improves file pattern matching by also matching on full location path.
src/devops_cli/ai/review/common_hallucinations.json Adds new hallucination patterns for fixer payload & CI allow-blocked-state.
src/devops_cli/ai/review/chunker.py Removes static ignore set and uses gitignore-aware filtering.
src/devops_cli/ai/repomap.py Uses gitignore-aware filtering for repo symbol discovery.
src/devops_cli/ai/rag/indexer.py Updates gitignore parsing and uses gitignore-aware filtering for indexing.
src/devops_cli/ai/providers/init.py Adds provider registration API; removes baked-in MockProvider.
src/devops_cli/ai/library/drift_auditor.py Uses gitignore-aware filtering for drift audit file scanning.
src/devops_cli/ai/instruction_generator.py Adds guidance prohibiting brittle pattern subsets; mandates constants placement.
src/devops_cli/ai/harness/slots.py Uses gitignore-aware filtering instead of hardcoded ignored dirs.
src/devops_cli/ai/harness/planning.py Restricts SqlitePlanStore db_path to approved bases (cwd/home/tmp).
src/devops_cli/ai/harness/filesystem.py Uses gitignore-aware filtering when finding/searching files.
src/devops_cli/ai/ast/graph.py Uses gitignore-aware filtering for AST graph file collection.
docs/commands/gh.md Documents new devops gh api command.
docs/agent/tasks/task-205-remediate-review-findings-self-improvement.md Adds new task doc for session 20260914 remediation work.
docs/agent/tasks/task-204-remediate-devsecops-findings-self-improvement.md Adds new task doc for session 20260913 remediation work.
docs/agent/task.md Removes legacy monolithic task index file.
docs/SELF_IMPROVEMENT.md Adds a remediation case study section for session 20260913-231617.
docs/CLI_REFERENCE.md Adds CLI reference entry for devops gh api.
config.example.yaml Documents sandbox.exclude_home_dir config.
README.md Adds devops gh api to top-level command listing.
AGENTS.md Updates agent instructions to prohibit bare gh calls and reinforce rate-managed tooling.
Suppressed comments (4)

src/devops_cli/security/reference_extractor.py:1

  • is_local_or_reserved_domain() returns False for clean in _SPECIAL_USE_TLDS (e.g. internal, local, lan), which contradicts the function’s purpose and makes bare special-use hostnames appear non-local. This should likely be return True (and keep the separate logic that rejects bare suffixes in extraction paths where desired).
    src/devops_cli/security/reference_extractor.py:1
  • The docstring says this helper returns True for “reserved” IPs, but the implementation explicitly returns False for is_example_or_reserved_ip(ip) (which commonly includes reserved/documentation ranges). Update the docstring to match the new behavior (excluding unspecified and example/reserved ranges), or adjust the logic if reserved IPs are intended to be treated as local/non-public.
    src/devops_cli/security/reference_extractor.py:1
  • Doing DNS resolution inside reference classification can introduce latency, non-determinism, and unexpected network dependency (especially when analyzing arbitrary repo content). Consider removing DNS lookups from the extraction heuristics, or gating them behind an explicit enable_dns_checks flag / environment setting, keeping the default behavior fully offline and deterministic.
    src/devops_cli/security/reference_extractor.py:1
  • _is_metric_or_telemetry_context() accepts text_segment and line_idx but (in the shown implementation) doesn’t use them. This makes the helper’s API larger than necessary and suggests missing intended logic. Either use these context fields (e.g., to detect inline telemetry patterns) or remove them from the signature and update call sites.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/devops_cli/ai/rag/indexer.py Resolved
@dan-petty
dan-petty force-pushed the fix/205-remediate-review-findings-self-improvement branch from b9d0b8e to 8851254 Compare September 14, 2026 20:46
@dan-petty
dan-petty merged commit 6b21070 into release/v0.2.18 Sep 14, 2026
4 checks passed
@dan-petty
dan-petty deleted the fix/205-remediate-review-findings-self-improvement branch September 14, 2026 21:14
@dan-petty dan-petty mentioned this pull request Sep 15, 2026
11 tasks done
dan-petty added a commit that referenced this pull request Sep 16, 2026
* feat(release): v0.2.18

* fix(security): harden secret sanitizer boundaries and safe path exclusions (#116) (#203)

* fix(security): harden secret sanitizer boundaries and safe path exclusions (#116)

* fix(release): default release PRs to draft mode

* fix(security): harden secret boundaries, remove extension lookahead, and update task status (#116)

* fix(security): remediate devsecops findings and add native rate management (#204)

* test

* fix(security): remediate devsecops findings and add native rate management

* docs(task): update task-204 status to in review and link PR #204

* fix(security): permit token masking in filesystem path arguments

* fix(security): remediate review findings, exclude home in sandbox, and relocate MockProvider (#205) (#206)

* fix(security): remediate review findings, exclude home in sandbox, and relocate MockProvider (#205)

* docs(task): update task-205 status to in review and link PR #206

* test(sandbox): provide explicit tmp_path workspace_dir in test_docker_sandbox_wait_timeout

* fix(rag): support both gitignore and gitwildmatch pathspec factories

* feat(sandbox): multi-tier networking options and decommission task.md (#207) (#208)

* feat(sandbox): multi-tier networking options and decommission task.md index (#207)

* docs(agent): transition task 207 to in-review with PR #208

* test(projects): update test fixtures to eliminate task.md references

* fix(security): replace concrete RFC 1918 and internal homelab endpoints with standard documentation values

* fix(sandbox): harden network containment, secret output masking, and rate limiter caching

* fix(sandbox): remediate egress containment, dns resolution, and output masking findings (#207)

* fix(security): stream sandbox container output directly to sys streams avoiding logger sink cleartext alerts (#207)

* docs(agents): mandate working pull requests from oldest to newest (FIFO)

* docs(roadmap): add v0.2.23 reactive workstation command center and interactive TUI

* docs(agents): mandate root-cause remediation, roadmap synthesis, and interaction improvement

* fix(docs): escape placeholder angle brackets and prune completed roadmap matrix items

* fix(security): stream sandbox output via centralized output writers to resolve codeql cleartext alerts

* fix(k8s): uncap ollama memory limits and elevate daemonset/deployment thresholds (#209) (#210)

* fix(k8s): uncap ollama memory limits and elevate daemonset/deployment thresholds (#209)

* fix(k8s): add CoreDNS resource configs and tighten test assertions (#209)

* fix(github): enforce gh request throttling, disk quota persistence, and diff-only project sync (#211) (#212)

* fix(github): enforce window-budgeted rate pacing, disk quota persistence, and diff-only project sync (#211)

* docs(agent): record PR #212 in task 211 tracking

* fix(github): enforce low-quota circuit breakers, preamble-tolerant JSON parsing, and casing-safe project diffing (#211)

* fix(github): replace quota thresholds with logical exponential backoff (#211)

* test(github): patch run_gh instead of run_subprocess in reconcile tests (#211)

* fix(github): derive rate limit pacing from actual response values without hardcoded windows (#211)

* fix(ci): stop running all of the ci tasks every time a pr is marked ready for review.

* fix(ci): decouple project automation into dedicated workflow and add quota safety guards (#211)

* fix(github): align rate limiter baseline velocity and add quota test coverage (#211)

* refactor(ai): eliminate inline function parameter defaults in favor of defaults submodule

* fix(github): enforce strict non-negative rate quotas, 25% threshold, and remediate review findings (#211)

* fix(typecheck): resolve Path None guard and optional quota remaining in mypy (#211)

* docs: refresh CLI and MCP references for updated commands and errors (#211)

* fix(ci): enforce mandatory pre-push devops ci gate, handle unauthenticated acquire, and expand test coverage (#211)

* fix(pr): align checks fallback to run_subprocess and isolate rate limiter sleep test (#211)

* fix(ci): complete pre-push gate, argo drift tests, and coverage expansion (#211)

* docs(agent): update task-211 documentation with linear window pacing and pre-push quality gate (#211)

* fix(pr): guard pr ready against failing checks and fix project automation uv sync (#211)

* docs(pr): update cli and mcp reference for pr ready --force

* fix(github): address pr 212 review comments on workflows, sandbox, defaults, and rate limiter (#211)

* fix(security): derive artifact version from package metadata and validate whitelist tokens (#211)

* feat(security): sigstore cosign container provenance and image signing (#112) (#213)

* fix(ci): prune all merged PR devcontainer images from ghcr and guard in-flight builds

* feat(security): sigstore cosign container provenance and image signing (#112)

* docs(agent): link PR 213 in task 112 tracking doc

* fix(security): resolve review comments for cosign container provenance (#112)

* ci: re-trigger validation after resolving all review threads

* feat(security): falco ebpf runtime security and anomaly streamer (#113) (#214)

* feat(security): falco ebpf runtime security and anomaly streamer (#113)

* fix(security): resolve review comments for falco ebpf runtime security (#113)

* chore: retrigger validation after resolving all review threads

* feat(security): distributed threat intelligence valkey l2 cache and radar batching (#122) (#215)

* feat(security): distributed threat intelligence valkey l2 cache and radar batching (#122)

* fix(security): resolve review comments for threat intel valkey l2 cache and batching (#122)

* chore: retrigger validation after resolving all review threads

* perf(github): adjust rate limit no-delay used threshold to 30%
@dan-petty dan-petty mentioned this pull request Sep 16, 2026
7 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

2 participants