Skip to content

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

Merged
dan-petty merged 5 commits into
release/v0.2.18from
fix/204-remediate-devsecops-findings-self-improvement
Sep 14, 2026
Merged

dan-petty merged 5 commits into
release/v0.2.18from
fix/204-remediate-devsecops-findings-self-improvement

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Summary

Remediates 11 verified DevSecOps security, path containment, and secret masking findings from review session 20260913-231617, implements native DevOps CLI GitHub rate management with client-side token-bucket pacing, backoff, and caching, and calibrates the self-improvement feedback memory.

Key Changes

  • Native Rate Management: Implemented GitHubRateLimiter and run_gh runner with token-bucket pacing, quota threshold guards, and backoff with jitter. Added native devops gh api command.
  • Path Traversal Hardening: Enforced path containment in SqlitePlanStore, DEVOPS_CLI_CONFIG, subprocess cwd, and devcontainer volume mounts.
  • SSRF Hardening: Blocked private RFC 1918 IPs in Jaeger waterfall trace queries while preserving local loopback.
  • Secret Masking: Masked secrets in sandbox models (SandboxLogLine, SandboxExecResult, PanicIncident), PR review thread summaries, K8s context exceptions, and Minikube status messages.
  • Anti-Hallucination Memory: Disarmed HALLUCINATION-NONEXISTENT-FIXER-PAYLOAD and HALLUCINATION-CI-ALLOW-BLOCKED-STATE.
  • Review Protocol & Docs: Updated review.md, AGENTS.md (strictly prohibiting bare gh commands), and added historical case study in SELF_IMPROVEMENT.md.

Closes #204

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.

🟡 Changes recommended

Unresolved critical and moderate security and rate-management issues remain.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR remediates DevSecOps findings, adds native GitHub CLI rate management, and updates security guidance, tests, and documentation.

Changes:

  • Added GitHubRateLimiter, run_gh, pacing, retries, caching, and devops gh api.
  • Hardened path containment, SSRF protection, Kubernetes handling, and secret masking.
  • Updated tests, hallucination safeguards, documentation, and task metadata.
File summaries
File Summary
uv.lock Updates package version.
tests/test_sandbox_traces.py Tests SSRF protections.
tests/test_sandbox_lifecycle.py Tests secret masking.
tests/test_process.py Tests subprocess CWD validation.
tests/test_pr_cmd.py Tests masked review output.
tests/test_k8s_context.py Tests Kubernetes security behavior.
tests/test_harness.py Tests SQLite path restrictions.
tests/test_github_rate_limiter.py Tests rate management and caching.
tests/test_github_milestones.py Updates runner mocks.
tests/test_gh_cmd.py Tests gh api.
tests/test_devcontainer.py Tests mount and output security.
tests/test_config_commands.py Tests config path validation.
tests/test_common_hallucinations.py Tests catalog additions.
src/devops_cli/telemetry/waterfall.py Blocks private Jaeger targets.
src/devops_cli/sandbox/models.py Masks sandbox secrets.
src/devops_cli/lang/en/help.py Adds API help text.
src/devops_cli/github/rate_limiter.py Implements GitHub request management.
src/devops_cli/core/process.py Validates subprocess CWD.
src/devops_cli/config/settings.py Validates config paths.
src/devops_cli/commands/pr.py Masks thread summaries.
src/devops_cli/commands/k8s/cluster_runtime.py Validates kubeconfig paths.
src/devops_cli/commands/k8s/cluster_context.py Masks warnings and controls autostart.
src/devops_cli/commands/gh.py Adds the API command and runner usage.
src/devops_cli/commands/devcontainer.py Hardens mount handling.
src/devops_cli/ai/tasks/review.md Updates review safeguards.
src/devops_cli/ai/review/common_hallucinations.py Improves path matching.
src/devops_cli/ai/review/common_hallucinations.json Adds hallucination entries.
src/devops_cli/ai/harness/planning.py Restricts plan database paths.
README.md Documents devops gh api.
docs/SELF_IMPROVEMENT.md Adds a remediation case study.
docs/commands/gh.md Documents GitHub API usage.
docs/CLI_REFERENCE.md Updates the CLI reference.
docs/agent/tasks/task-204-remediate-devsecops-findings-self-improvement.md Adds task tracking.
docs/agent/task.md Updates the task index.
AGENTS.md Strengthens GitHub rate-limit guidance.
Review details

Suppressed comments (5)

docs/agent/task.md:65

  • The active-task index repeats the stale lifecycle state for this ready PR: issue #204 is still marked In Progress and has no PR link. Keep the index synchronized with the task file and the repository lifecycle convention by linking PR #204 and marking it In Review.
| [#204](https://github.com/dan-petty/devops-cli/issues/204) | TBD | Remediate DevSecOps review findings & enhance self-improvement loop | `In Progress` | [`task-204-remediate-devsecops-findings-self-improvement.md`](tasks/task-204-remediate-devsecops-findings-self-improvement.md) |

src/devops_cli/ai/harness/planning.py:209

  • The containment check is performed on resolved_path, but the store then keeps the original relative raw_path. If the process changes cwd after construction, later sqlite3.connect(self.db_path) calls can target a different location than the one validated here. Persist the canonical resolved path for file-backed stores.
            if not any(
                resolved_path == b or resolved_path.is_relative_to(b) for b in allowed_bases
            ):

src/devops_cli/ai/review/common_hallucinations.json:464

  • Both new entries use category general, but verify_ground_truth_hallucination() falls through to False for that category (common_hallucinations.py:691), and the review pipeline invalidates a finding only when that check succeeds (verification.py:845-848). These records can match the direct unit tests but will never disarm findings in an actual review. Add a ground-truth branch for these IDs/categories or use a supported verification path.
    "category": "general",
    "description": "Claiming that src/devops_cli/ai/fixer.py exists or that repair_json_string lacks payload size bounds when the function is located in response_repair.py with a 5 MiB cap.",

src/devops_cli/github/rate_limiter.py:133

  • The cache key contains only args, although run_gh also accepts cwd and input. A cacheable gh pr list without --repo can therefore return one repository's result when the same process later runs from another repository; include the execution context in the key or restrict caching to explicit repository-qualified reads.
def _build_cache_key(args: list[str]) -> str:
    """Construct deterministic cache key from command arguments."""
    return "gh:" + " ".join(args)

src/devops_cli/github/rate_limiter.py:127

  • DEVOPS_GH_RATE_INTERVAL is accepted as any float: -1 and nan disable the elapsed < min_interval branch, while inf reaches time.sleep() and can raise instead of pacing. Validate the override as finite and non-negative before constructing the limiter.
            raw_interval = os.environ.get("DEVOPS_GH_RATE_INTERVAL", "")
            try:
                interval = (
                    float(raw_interval) if raw_interval.strip() else _DEFAULT_MIN_INTERVAL_SECONDS
                )
            except ValueError:
                interval = _DEFAULT_MIN_INTERVAL_SECONDS
            _GLOBAL_RATE_LIMITER = GitHubRateLimiter(min_interval=interval)
  • Files reviewed: 34/35 changed files
  • Comments generated: 8
  • Review effort level: Lite

💡 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/harness/planning.py Resolved
Comment thread src/devops_cli/config/settings.py Resolved
Comment thread src/devops_cli/github/rate_limiter.py Resolved
Comment thread src/devops_cli/sandbox/models.py Resolved
Comment thread AGENTS.md Resolved
Comment thread src/devops_cli/github/rate_limiter.py Resolved
Comment thread src/devops_cli/github/rate_limiter.py Resolved
@dan-petty dan-petty added this to the v0.2.18 milestone Sep 14, 2026
@dan-petty dan-petty added type/security Type security: a vulnerability or a leak scope/security Security linters (trivy, bandit, gitleaks, kubeconform) and Vault priority/p1-high Priority P1: high-impact work for the next planned milestone status/in-review Status In Review: the pull request of the item is open labels Sep 14, 2026
@dan-petty dan-petty mentioned this pull request Sep 14, 2026
11 tasks done
@dan-petty
dan-petty merged commit 2eadadb into release/v0.2.18 Sep 14, 2026
4 checks passed
@dan-petty
dan-petty deleted the fix/204-remediate-devsecops-findings-self-improvement branch September 14, 2026 17:06
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

priority/p1-high Priority P1: high-impact work for the next planned milestone scope/security Security linters (trivy, bandit, gitleaks, kubeconform) and Vault status/in-review Status In Review: the pull request of the item is open type/security Type security: a vulnerability or a leak

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

2 participants