Skip to content

fix(review): remediate DevSecOps findings and enhance review self-improvement loop (#185) - #186

Merged
dan-petty merged 8 commits into
release/v0.2.17from
fix/review-remediation-self-improvement
Sep 13, 2026
Merged

dan-petty merged 8 commits into
release/v0.2.17from
fix/review-remediation-self-improvement

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Summary

Remediate reportable findings from multi-persona review session 20260913-060209, calibrate anti-hallucination datasets, export review feedback, and strengthen review prompts and documentation for closed-loop self-improvement.

Closes #185

Remediations & Enhancements

  • Sandbox Probe: Block AWS/GCP/Azure link-local metadata endpoints (169.254.169.254, metadata.google.internal), bound regex search window (body[:8192]) and length ($\le 256$ chars) with re.error catching, and validate probe HTTP URLs against SSRF.
  • Telemetry Waterfall: Enforce hex validation on trace_id (^[0-9a-fA-F]{16,32}$) and validate Jaeger endpoints against SSRF via validate_url.
  • Telemetry Context: Add trace_flags: str = "01" validation and support in generate_traceparent.
  • Sandbox Logs & Panic Detector: Mask secrets in panic messages/stacktraces, enforce 0o600 file permissions and 0o700 directory permissions on incident archives.
  • Sandbox Metrics: Reject cgroup path traversal (..) and restrict metrics parsing to valid cgroup v2 hierarchies.
  • Sandbox Models: Truncate EndpointProbeResult.details strings to $\le 1024$ chars and mask embedded credentials.
  • Security Sanitizer: Mask secrets in positional/non-flag arguments within sanitize_command_args_for_display.
  • Valkey Client: Cleanly strip enclosing brackets from IPv6 hostnames.
  • HTTP Client: Validate timeout argument types and reject unsupported types with TypeError.
  • K8s Stack Lifecycle: Mask non-localhost email addresses in Open-WebUI bootstrap summary output.
  • Anti-Hallucination Dataset: Register 4 new catalog entries in src/devops_cli/ai/review/common_hallucinations.json for false positives on Keyring secrets, prompt boundaries, local cache service bindings, and exposition syntax.
  • Review Self-Improvement Loop: Export 795 findings and 23 invalidations via devops review export-feedback to .data/feedback_dataset.jsonl, and update docs/SELF_IMPROVEMENT.md, src/devops_cli/ai/tasks/review.md, and AGENTS.md.

Verification

  • Targeted unit tests passing for all modified submodules.
  • Architectural invariants passing (complexity $\le 10$, nesting $\le 5$, no collection warnings).
  • Full 10/10 devops ci quality gates passing locally.

…eview self-improvement loop (#185)

- sandbox probe: block metadata endpoints, bound regex len and search window, validate target URLs
- telemetry waterfall: enforce hex trace ID validation and validate Jaeger endpoints against SSRF
- telemetry context: add trace_flags parameter to generate_traceparent
- sandbox logs: mask secrets in panic incidents and set 0o600 file / 0o700 dir permissions
- sandbox metrics: reject cgroup path traversal and restrict parsing to valid cgroup hierarchies
- sandbox models: truncate and mask probe result details and incident messages/stacktraces
- sanitizer: mask secrets in non-flag arguments in sanitize_command_args_for_display
- valkey client: correctly strip enclosing brackets from IPv6 hostnames
- http client: validate timeout argument types
- k8s stack lifecycle: mask non-localhost emails in bootstrap summary display
- anti-hallucination dataset: calibrate false positives into common_hallucinations.json
- documentation & prompts: update SELF_IMPROVEMENT.md, review.md, AGENTS.md, and task tracking
@dan-petty
dan-petty marked this pull request as ready for review September 13, 2026 13:12
Copilot AI lite review requested due to automatic review settings September 13, 2026 13:12

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 findings remain across SSRF protection, readiness logic, validation, permissions, sanitization, configuration, and tests.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR remediates security and validation findings while strengthening PR monitoring and review self-improvement workflows.

Changes:

  • Harden sandbox, telemetry, secret masking, permissions, paths, and timeout validation.
  • Improve GitHub merge-readiness and Kubernetes lifecycle handling.
  • Add regression tests, feedback data, documentation, and task metadata.
File summaries
File Description
tests/test_valkey.py Adds bracketed IPv6 coverage.
tests/test_sandbox_traces.py Tests trace flags and Jaeger validation.
tests/test_sandbox_probe.py Tests metadata blocking and regex safety.
tests/test_sandbox_metrics.py Tests cgroup path rejection.
tests/test_sandbox_logs.py Tests masking and file permissions.
tests/test_pr_cmd.py Tests blocked PR handling.
tests/test_k8s.py Tests email masking and Kubernetes behavior.
tests/test_k8s_context.py Isolates configuration fixtures.
tests/test_http.py Tests timeout type validation.
tests/test_github_pr_monitor.py Tests merge-readiness states.
tests/test_consolidation_security_sanitizer.py Tests positional secret masking.
tests/conftest.py Adds workspace configuration protection.
src/devops_cli/valkey/client.py Handles bracketed IPv6 hosts.
src/devops_cli/telemetry/waterfall.py Validates trace IDs and Jaeger URLs.
src/devops_cli/telemetry/context.py Supports trace flags.
src/devops_cli/security/sanitizer.py Masks positional arguments.
src/devops_cli/sandbox/probe.py Blocks metadata targets and bounds regex checks.
src/devops_cli/sandbox/models.py Sanitizes probe and incident details.
src/devops_cli/sandbox/metrics.py Validates cgroup paths.
src/devops_cli/sandbox/logs.py Applies incident archive permissions.
src/devops_cli/http/client.py Validates timeout parameters.
src/devops_cli/github/pr_monitor.py Adds mergeability and review gating.
src/devops_cli/config/settings.py Resolves configured project paths.
src/devops_cli/commands/pr.py Refactors monitor output and validation.
src/devops_cli/commands/k8s/stack_lifecycle.py Masks bootstrap emails and adapts Helm commands.
src/devops_cli/ai/tasks/review.md Expands review falsification guidance.
src/devops_cli/ai/review/common_hallucinations.json Adds false-positive catalog entries.
k8s/namespaces.yaml Adjusts security policy labels.
k8s/logging/fluent-bit-values.yaml Adds Kubernetes log labels.
docs/SELF_IMPROVEMENT.md Updates feedback catalog guidance.
docs/commands/k8s.md Refreshes Kubernetes documentation.
docs/CLI_REFERENCE.md Updates CLI reference text.
docs/agent/tasks/task-185-review-remediation-self-improvement.md Tracks remediation work.
docs/agent/tasks/task-183-pr-merge-readiness-gating.md Adds PR monitoring task documentation.
docs/agent/task.md Indexes task 185.
AGENTS.md Updates self-improvement references.
Review details

Suppressed comments (5)

docs/agent/tasks/task-185-review-remediation-self-improvement.md:7

  • The task is marked In Review, but its taxonomy uses the unregistered priority/high label and the lifecycle-inconsistent status/in-progress. The repository defines priority/p1-high and status/in-review in .github/labels.yml:79-102, so the task metadata will not reconcile with the PR state.
**Taxonomy**: `type/bug`, `scope/security`, `priority/high`, `status/in-progress`

docs/agent/tasks/task-185-review-remediation-self-improvement.md:12

  • This committed task document exposes a hidden .data/reviews/... artifact path. The repository's zero-information-leakage policy forbids publishing .data/ paths in task tracking and documentation; keep the session identifier without the private artifact location.
Address reportable findings from multi-persona review session `20260913-060209` (`.data/reviews/20260913-060209/`):

src/devops_cli/config/settings.py:567

  • Returning every env-supplied path regresses invalid configuration handling: if DEVOPS_CLI_CONFIG points to an existing directory, load_settings() now reaches read_text() and raises IsADirectoryError, whereas the previous is_file() guard failed closed. Keep file validation for reads and handle a separate non-existent target only when saving.
        return Path(env_config).resolve()

src/devops_cli/github/pr_monitor.py:280

  • This substring check also matches negated review text such as No changes requested, causing a completed Copilot review to be treated as a blocking changes request. Match the structured CHANGES_REQUESTED state or the bot's positive recommendation marker rather than an unrestricted substring.
    has_changes = (
        state == "CHANGES_REQUESTED" or "changes recommended" in body or "changes requested" in body

tests/test_sandbox_logs.py:107

  • mask_secrets() (used by PanicIncident.sanitize_stacktrace) replaces password assignments with ****** in src/devops_cli/security/sanitizer.py:18-21, not <masked-password>. This new assertion therefore fails; align it with the existing sanitizer sentinel or change the sanitizer consistently for all callers.
  • Files reviewed: 36/36 changed files
  • Comments generated: 16
  • 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/sandbox/probe.py Resolved
Comment thread src/devops_cli/sandbox/probe.py Resolved
Comment thread src/devops_cli/telemetry/waterfall.py Resolved
Comment thread src/devops_cli/sandbox/models.py Resolved
Comment thread src/devops_cli/telemetry/context.py Resolved
Comment thread tests/conftest.py Resolved
@dan-petty dan-petty changed the title fix(review): remediate session 20260913-060209 findings and enhance review self-improvement loop (#185) fix(review): remediate DevSecOps findings and enhance review self-improvement loop (#185) Sep 13, 2026
…and test fixtures (#185)

- probe: canonicalize trailing dot and resolve host to block link-local/cloud metadata
- waterfall: reject resolved metadata hosts and fix exception tuple in Jaeger trace query
- k8s: mask short and malformed emails in bootstrap display and preserve PII in dry-run
- pr monitor: exclude unknown mergeable_state from readiness and evaluate latest review per user
- http client: raise HTTPTimeoutTypeError derived from ValidationError and TypeError
- sandbox logs: unlink archive and raise SandboxError on incident chmod failure
- sandbox metrics: enforce path-aware containment for cgroup v2 hierarchies
- sandbox models: recursively sanitize nested details and reserve suffix length for truncation cap
- telemetry context: raise TraceValidationError on invalid traceparent flags
- conftest: detect and fail on unauthorized creation or deletion of workspace config.yaml
- tasks: reconcile PR #184 mapping, update taxonomy to status/in-review, and re-sync index

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 security and correctness findings remain in endpoint validation, PR readiness, archive handling, metrics and payload bounds, async authentication, and task indexing.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (6)

Previously missed (3) — in code that hasn't changed since the last review.

src/devops_cli/github/pr_monitor.py:680

  • The --no-require-reviews mode must still report a GitHub-blocked PR as blocked. With this condition, a blocked PR with green checks skips the actionable result when reviews are disabled, is_ready_for_merge remains false, and monitoring waits until timeout (exit 3) instead of returning the blocked exit 2. The option should only bypass the review-settling wait, not branch-protection status.
    src/devops_cli/sandbox/logs.py:107
  • The directory permission failure is still swallowed. If an existing incident directory has permissive permissions and chmod(0o700) fails, this function continues and reports a successful archive, violating the new directory-protection guarantee. Fail before writing (or otherwise abort the archive) on this error, as the final file chmod already does.
    src/devops_cli/sandbox/metrics.py:121
  • This still does not restrict parsing to cgroup v2 hierarchies: after exempting /sys/fs/cgroup, _is_forbidden_cgroup_path only rejects a finite list of system roots, so existing directories such as /tmp, /home, or /opt are accepted by parse_cgroup_v2_directory. Require the resolved path to be the cgroup root or its descendants (or make a dedicated fake root injectable for tests) so arbitrary directories cannot be treated as cgroup data.

docs/agent/task.md:27

  • This row uses a pull-request URL in the Issue column and duplicates issue #183, which is already indexed on the previous row for the merge-readiness task. The referenced task-183-stack-deploy-conflicts.md itself declares issue #183 / PR #182, so the index now has conflicting records and no valid issue link for this task. Reconcile the task identity and keep one authoritative issue/PR entry per task file.
| [#182](https://github.com/dan-petty/devops-cli/pull/182) | [#182](https://github.com/dan-petty/devops-cli/pull/182) | Resolve Helm Stack Deploy SSA Conflicts, Loki Validation, and PodSecurity Failures | `Done` | [`task-183-stack-deploy-conflicts.md`](tasks/task-183-stack-deploy-conflicts.md) |

src/devops_cli/core/process.py:182

  • The GitHub-token exception is added only to synchronous run_subprocess; run_subprocess_async below still passes build_subprocess_env directly and strips GH_TOKEN/GITHUB_TOKEN. Any asynchronous gh invocation in a CI environment will therefore lose the ambient authentication that this change intends to preserve. Share this bin_name == "gh" handling with both subprocess paths.
    if bin_name == "gh":
        for token_var in ("GH_TOKEN", "GITHUB_TOKEN"):
            if token_var in os.environ and token_var not in sub_env:
                sub_env[token_var] = os.environ[token_var]

src/devops_cli/sandbox/models.py:286

  • The new validator masks each stacktrace line but does not bound line length or the number of lines. PanicDetector._continue_panic appends every matching log line and archive_incident serializes the whole list, so a workload can still create an unbounded incident payload despite the message cap. Bound the stacktrace payload before archiving.
    @field_validator("stacktrace", mode="before")
    @classmethod
    def sanitize_stacktrace(cls, v: Any) -> list[str]:
        """Mask secrets in stacktrace lines."""
        if not isinstance(v, list):
            return []
        from devops_cli.security.sanitizer import mask_secrets

        return [mask_secrets(str(line)) for line in v]
  • Files reviewed: 39/39 changed files
  • Comments generated: 4
  • Review effort level: Lite

Comment thread src/devops_cli/sandbox/probe.py Resolved
Comment thread src/devops_cli/sandbox/probe.py Resolved
Comment thread src/devops_cli/telemetry/waterfall.py Resolved
Comment thread src/devops_cli/github/pr_monitor.py Resolved
@dan-petty
dan-petty merged commit 10cc880 into release/v0.2.17 Sep 13, 2026
4 checks passed
@dan-petty
dan-petty deleted the fix/review-remediation-self-improvement branch September 13, 2026 17:55
dan-petty added a commit that referenced this pull request Sep 14, 2026
* feat(release): v0.2.17

* feat(sandbox): protocol-agnostic endpoint readiness and health probing subsystem (#107)

Closes #107

* docs(agent): reconcile task 107 tracking to done (#107)

* feat(telemetry): cgroup v2 metrics collection and prometheus application scraping (#108)

Closes #108

* docs(agent): reconcile task 108 to done following PR #164 merge

* docs(agent): require draft pull requests for in-progress work (#165) (#166)

* docs(agent): require draft pull requests for in-progress work (#165)

* docs(agent): align lifecycle definitions and update task index for PR #166

* fix(sandbox): resolve cpu delta sampling, ssrf boundaries, and cgroup fallback (#168)

* fix(sandbox): remediate pr 164 review findings on sandbox metrics collection (#167)

* test(sandbox): normalize whitespace in help assertion for variable terminal widths

* test(sandbox): assert help option text without border wrapping sensitivity

* fix(sandbox): address pr 168 review comments on url sanitization and telemetry contracts (#167)

* fix(sandbox): resolve pr 168 review comments on cpu delta sampling, ssrf boundaries, and cgroup fallback (#167)

* test(sandbox): remove redundant comment header in metrics tests

* feat(pr): monitor pr checks, copilot reviews, and review threads (#170) (#171)

* feat(github): automated pr monitoring and copilot review verification (#170)

* fix(pr): resolve copilot review findings and enforce 5m/60s monitoring standards (#170)

* feat(k8s): configurable k8s context setting and conditional minikube autostart (#172) (#174)

* feat(k8s): configurable k8s context setting and conditional minikube autostart (#172)

* docs(k8s): document minikube devcontainer lifecycle and external cluster configurations (#172)

* fix(k8s): resolve copilot review findings for context validation and autostart (#172)

* test(k8s): update qdrant secret lifecycle assertion for effective context flag (#172)

* fix(github): project field options sync, complete pagination, generic owner resolution, and mock hostname standardization (#175) (#173)

- Resolve automated GitHub Projects bot resetting status by auto-provisioning missing single-select options (e.g. 'In Review')
- Implement complete pagination across projectsV2 items, issues, and PR endpoints
- Resolve project owner dynamically via gh api user login without hardcoded usernames
- Display draft PR warnings cleanly in monitor exit handler
- Standardize all mock/dummy test values across all tests to example.com with no subdomain
- Enforce complexity <= 10 and nesting <= 5 architectural invariants

* fix(review): remediate devsecops findings and enhance review self-improvement loop (#176) (#177)

* docs(agent): bootstrap task 176 for review findings remediation

* fix(review): remediate DevSecOps findings and enhance review self-improvement loop (#176)

* feat(telemetry): w3c traceparent propagation and distributed trace correlation (#109) (#178)

* feat(telemetry): w3c traceparent propagation and distributed trace correlation (#109)

* docs(agent): link draft PR 178 in task 109 tracking

* fix(k8s): resolve helm ssa conflicts, loki validation, podsecurity, and qdrant permissions (#183) (#182)

* fix(k8s): resolve helm ssa conflicts, loki validation, podsecurity, and qdrant permissions (#183)

* docs(agent): link pull request #182 in task 183 tracking

* feat(sandbox): streaming diagnostic log aggregator and panic detector (#110) (#179)

* feat(sandbox): streaming diagnostic log aggregator and panic detector (#110)

* docs(agent): link draft PR #179 in task-110 tracking

* fix(sandbox): remediate review findings, demux streams, bound follow memory, and sanitize output (#110)

* docs(agent): update task 110 status to In Review and record review thread resolutions

* fix(github): gate pr merge readiness on required approvals, mergeable state, and reviewer feedback (#183) (#184)

* fix(github): gate pr merge readiness on required approvals, mergeable state, and reviewer feedback (#183)

* fix(github): remediate copilot review findings on pr merge readiness (#183)

* fix(github): enforce review approval gate, exclude negative copilot headings, and forward tokens (#183)

* fix(github): restrict copilot heading match, validate approval head sha, and support explicit env (#183)

* fix(review): remediate DevSecOps findings and enhance review self-improvement loop (#185) (#186)

* fix(github): gate pr merge readiness on required approvals, mergeable state, and reviewer feedback (#183)

* fix(review): remediate session 20260913-060209 findings and enhance review self-improvement loop (#185)

- sandbox probe: block metadata endpoints, bound regex len and search window, validate target URLs
- telemetry waterfall: enforce hex trace ID validation and validate Jaeger endpoints against SSRF
- telemetry context: add trace_flags parameter to generate_traceparent
- sandbox logs: mask secrets in panic incidents and set 0o600 file / 0o700 dir permissions
- sandbox metrics: reject cgroup path traversal and restrict parsing to valid cgroup hierarchies
- sandbox models: truncate and mask probe result details and incident messages/stacktraces
- sanitizer: mask secrets in non-flag arguments in sanitize_command_args_for_display
- valkey client: correctly strip enclosing brackets from IPv6 hostnames
- http client: validate timeout argument types
- k8s stack lifecycle: mask non-localhost emails in bootstrap summary display
- anti-hallucination dataset: calibrate false positives into common_hallucinations.json
- documentation & prompts: update SELF_IMPROVEMENT.md, review.md, AGENTS.md, and task tracking

* docs(agent): link pull request #186 in task 185 tracking

* fix(review): address review feedback across sandbox, telemetry, k8s, and test fixtures (#185)

- probe: canonicalize trailing dot and resolve host to block link-local/cloud metadata
- waterfall: reject resolved metadata hosts and fix exception tuple in Jaeger trace query
- k8s: mask short and malformed emails in bootstrap display and preserve PII in dry-run
- pr monitor: exclude unknown mergeable_state from readiness and evaluate latest review per user
- http client: raise HTTPTimeoutTypeError derived from ValidationError and TypeError
- sandbox logs: unlink archive and raise SandboxError on incident chmod failure
- sandbox metrics: enforce path-aware containment for cgroup v2 hierarchies
- sandbox models: recursively sanitize nested details and reserve suffix length for truncation cap
- telemetry context: raise TraceValidationError on invalid traceparent flags
- conftest: detect and fail on unauthorized creation or deletion of workspace config.yaml
- tasks: reconcile PR #184 mapping, update taxonomy to status/in-review, and re-sync index

* fix(process): preserve GH_TOKEN and GITHUB_REPOSITORY for gh binary execution

* fix(repo): prioritize git remote origin before GITHUB_REPOSITORY fallback

* fix(security): pin vetted ip transports against dns rebinding and enforce clean merge state (#185) (#186)

* feat(github): implement native devops cli functionality for gh operations and pr governance (#181) (#187)

* feat(github): implement native devops cli functionality for gh operations and pr governance (#181)

- Implement native devops pr ready, diff, and close subcommands
- Implement native devops gh rate-limit and runs subcommands
- Register FastMCP tools pr_ready, pr_diff, pr_close, gh_rate_limit, gh_runs_list, gh_run_view
- Harden config discovery and add pytest safety barrier against workspace config mutations
- Configure squid k8s deployment to use internal registry alias registry.local:5000
- Add comprehensive test coverage and documentation updates

* feat(github): add REST fallbacks for pr view/checks, issues/pr edit, and resolve loki crashloop (#181)

- Fall back to REST API in devops pr view and devops pr checks when GraphQL rate limits are exceeded
- Add devops pr edit and devops gh issues edit subcommands
- Register FastMCP tools pr_edit and gh_issue_edit
- Disable loki-sc-rules sidecar in dev cluster k8s/logging/loki-values.yaml to eliminate k8s API watch crashloop
- Add unit tests for pr/issue edit and REST fallbacks

* docs(agent): link PR #187 in task 181 tracking

* ci(workflows): gate pull request workflow on unresolved review threads and merge blockers (#188)

- Update .github/workflows/ci.yml pull_request triggers to include ready_for_review
- Add Verify PR Merge Readiness step to CI workflow calling devops pr check-readiness
- Add devops pr check-readiness command and REST fallback for list_prs and list_threads
- Add pr_check_readiness FastMCP tool and harden _run_mcp_cmd with mask_secrets
- Sanitize output and validate formats in gh run view/list and pr view/checks/diff
- Remediate and resolve 11 Copilot review findings across PR #187

* fix(process): preserve GH_TOKEN and GITHUB_REPOSITORY for gh binary execution

* fix(repo): prioritize git remote origin before GITHUB_REPOSITORY fallback

* fix(github): remediate review findings across pr readiness, sanitization, and rest fallbacks (#181) (#188)

* fix(ci): support allow-blocked-state in pr check-readiness for github actions workflow

* docs(agent): update task 181 checklist with passing ci checks and resolved review feedback

* fix(github): add REST API fallback and rate limit handling for pr review threads (#180) (#189) (#191)

* fix(github): add REST API fallback and rate limit handling for pr review threads (#180) (#189)

* docs(agent): record PR #191 in task 180 tracking

* docs(agent): require concise commit messages stating direct effect of change (#169) (#192)

* fix(k8s): harden logging perimeter and scope fluent bit namespaces (#121) (#193)

* chore(ci): align core dependencies and synchronize lockfile (#115) (#194)

* feat(argo): implement automated gitops drift detection and watch command (#111)

* feat(argo): implement automated gitops drift detection and watch command (#111)

* fix(argo): address PR #195 review feedback on gitops webhook, secret masking, and baseline persistence

* feat(github): declarative branch protection auditor and repository secret synchronization (#197)

* feat(github): declarative branch protection auditor and repository secret synchronization

* docs(agent): link PR #197 in task-114 tracking file

* fix(github): lazily fetch public key during secret sync and isolate tests

* chore(release): cut v0.2.17 and finalize release notes (#198)

* feat(test): add deterministic async memory and connection pool profiler (#199)

Implement deterministic async memory and connection pool profiler under devops test profile-memory (#199)

Closes #199
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