Skip to content

fix(security): remediate devsecops findings and consolidate embedding configuration (#154) - #155

Merged
dan-petty merged 2 commits into
release/v0.2.16from
fix/remediate-devsecops-review-findings
Sep 11, 2026
Merged

dan-petty merged 2 commits into
release/v0.2.16from
fix/remediate-devsecops-review-findings

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Summary

Resolves #154.

  • Security Remediations (Session 20260911-060650):

    • Mask authorization_token in MCP/native tool serialization (CWE-200).
    • Enforce RFC 1123 DNS name validation on Kubernetes chaos and LogQL commands to prevent argument injection (CWE-88).
    • Escape Rich markup in console output, panel formatters, links, and table cells (CWE-74).
    • Strip query parameters from telemetry attributes in server middleware (CWE-200).
    • Mask binary tool execution paths in server status (CWE-200).
    • Bound WebSocket stream message sizes to 1MB (CWE-400).
    • Batch keys in Valkey cache flushing (CWE-400).
    • Bound exception details in pipeline execution to <= 256 chars (CWE-209).
    • Add LRU cache eviction in vulnerability lookup client and registry limits in metrics (CWE-400).
    • Stream feedback records line-by-line during export (CWE-400).
  • Embedding Configuration Consolidation:

    • Consolidate all embedding configuration settings under ai.tasks.embedding (model, ollama_urls, timeout).
    • Eliminate redundant embedding_model, embedding_url, and embedding_timeout from ai.rag in config.yaml, config.example.yaml, and AIRAGConfig.
    • Update EmbeddingsEngine, Embedder, and embedding benchmark runner to resolve embedding parameters strictly via ai.tasks.embedding.
  • Network Egress Guard & Offline Suffix Lists:

    • Configure tldextract with suffix_list_urls=(), fallback_to_snapshot=True for complete offline operation.
    • Implement pytest fixture prevent_external_network_calls in tests/conftest.py intercepting non-loopback socket connections across all test runs.
  • Review Prompts & Self-Improvement Loop:

    • Add falsification rules for false CWE-400 claims on local file operations in verify_finding_system.md.
    • Register HALLUCINATION-LOCAL-FILE-OR-COLLECTION-CWE400 in common hallucinations catalog.
    • Update agent instructions in AGENTS.md to protect user runtime config.yaml from automated overwrites.

Verification

  • All 10 CI quality gates pass (uv run devops ci).
  • Targeted embedding and security tests pass without external network egress.
  • Complexity <= 10 and nesting depth <= 5 validated across modified modules.

Copilot AI lite review requested due to automatic review settings September 11, 2026 20:21
… configuration (#154)

- Remediate review session findings for credential leakage, injection, and resource exhaustion
- Consolidate embedding configuration under ai.tasks.embedding and remove duplicate keys from rag
- Add offline fallback to tldextract and test-wide network egress guard
- Protect local user runtime config.yaml from automated sanitization rewrites
- Enhance review falsification rules, feedback export, and common hallucinations catalog
@dan-petty
dan-petty force-pushed the fix/remediate-devsecops-review-findings branch from befe522 to 1b1dfec Compare September 11, 2026 20:22

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, including credential handling and WebSocket size enforcement.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Remediates security/resource-exhaustion findings and consolidates embedding configuration under ai.tasks.embedding.

Changes:

  • Adds input validation, output escaping, credential/path redaction, resource bounds, and offline test isolation.
  • Consolidates embedding model, URL, and timeout settings across consumers and documentation.
  • Updates review guidance, hallucination detection, feedback export, and task tracking.
File summaries
File Change / review note
tests/test_validation.py Tests external socket blocking.
tests/test_resource_schemas.py Uses documentation-safe test IPs.
tests/test_rag_embeddings.py Tests task-level embedding configuration.
tests/test_pydantic_agent.py Tests MCP token redaction.
tests/test_output.py Tests Rich escaping. Review: assertions can pass with interpreted or escaped tags; verify rendered style or ANSI output. [nit; 1 vote]
tests/test_k8s.py Uses safe Kubernetes test IPs.
tests/test_k8s_logs_diff_chaos.py Tests Kubernetes validation.
tests/test_k8s_logql.py Tests LogQL validation.
tests/test_embedding_config_retention.py Tests consolidated embedding configuration retention.
tests/test_consolidation_table_builder.py Tests table escaping.
tests/test_config_env_overrides.py Tests embedding environment overrides.
tests/test_common_hallucinations.py Tests the hallucination catalog entry.
tests/test_ai_agent_capabilities.py Tests MCP token omission.
tests/conftest.py Adds the external-network guard. Review: 0.0.0.0 is unspecified, not loopback; remove it from the allowlist. [moderate; 1 vote]
src/devops_cli/telemetry/metrics.py Bounds metric cardinality.
src/devops_cli/server/routes/stream.py Adds a WebSocket size check. Review: checking after receive_text() does not bound materialized frames and counts code points rather than UTF-8 bytes; enforce the byte limit before buffering. [critical; 1 vote]
src/devops_cli/server/routes/status.py Masks executable paths.
src/devops_cli/server/app.py Removes telemetry query strings.
src/devops_cli/security/vulnerability_lookup.py Adds OSV LRU eviction.
src/devops_cli/security/tflint.py Streams Terraform scanning. Review: same-line checks miss multiline CIDR rules; track block context or parse HCL. [moderate; 3 votes]
src/devops_cli/security/reference_extractor.py Enables offline suffix lookup.
src/devops_cli/security/gitleaks.py Streams file scanning.
src/devops_cli/pipeline/pipeline.py Bounds stage errors. Review: appending an ellipsis after the maximum length produces 259 characters instead of 256. [moderate; 3 votes]
src/devops_cli/output/table_builder.py Escapes table content. Review: the normal renderer still inserts titles, headers, and cells raw; harden the shared renderer or route callers through this helper. [moderate; 1 vote]
src/devops_cli/output/formatters/scalars.py Escapes scalar formatter content.
src/devops_cli/output/formatters/panels.py Escapes panel content.
src/devops_cli/output/console.py Escapes step output. Review: ordinary output paths still interpolate raw messages into Rich markup. [moderate; 3 votes]
src/devops_cli/k8s/logql.py Validates Kubernetes identifiers. Review: the duplicate label-only regex rejects valid dotted names and omits shared length bounds; reuse centralized validation. [moderate; 3 votes]
src/devops_cli/k8s/chaos.py Validates chaos targets. Review: the duplicate label-only regex rejects valid dotted names and omits shared length bounds; reuse centralized validation. [moderate; 3 votes]
src/devops_cli/dry_run/models.py Limits detail keys. Review: key counts do not bound nested or serialized payload size; cap or reject oversized values. [moderate; 1 vote]
src/devops_cli/config/settings.py Consolidates embedding settings.
src/devops_cli/config/options.py Updates embedding options.
src/devops_cli/config/env.py Adds embedding timeout mapping.
src/devops_cli/ai/tasks/verify_finding_system.md Adds CWE-400 verification guidance.
src/devops_cli/ai/tasks/review.md Refines review guidance.
src/devops_cli/ai/tasks/review_output_instruction.md Updates review output guidance.
src/devops_cli/ai/review/exporter.py Streams feedback export. Review: extraction still reads and materializes each session’s complete records list; make extraction incremental or bound input. [moderate; 2 votes]
src/devops_cli/ai/review/common_hallucinations.py Adds hallucination handling. Review: the guard invalidates every existing regular-file finding without checking the target operation, potentially suppressing genuine findings. [moderate; 3 votes]
src/devops_cli/ai/review/common_hallucinations.json Registers the CWE-400 catalog entry.
src/devops_cli/ai/rag/embeddings.py Resolves consolidated embedding settings.
src/devops_cli/ai/personas/devsecops/prompt.md Refines resource-exhaustion guidance.
src/devops_cli/ai/knowledge_base/it_domains/tools/ollama.md Updates Ollama configuration documentation.
src/devops_cli/ai/knowledge_base/devops_cli/tasks/ai_code_review.md Documents feedback-loop behavior.
src/devops_cli/ai/knowledge_base/devops_cli/configuration_and_settings.md Updates configuration documentation.
src/devops_cli/ai/cache/valkey_cache.py Batches cache deletion.
src/devops_cli/ai/benchmark/embedding_runner.py Uses task embedding settings.
src/devops_cli/ai/benchmark/document_chunker.py Adjusts term indexing.
src/devops_cli/ai/agents/embeddings.py Uses task embedding models.
src/devops_cli/ai/agents/capabilities.py Redacts MCP authorization tokens. Review: removing the token from runtime settings breaks authenticated MCP tools; separate secure credentials from redacted diagnostics. [critical; 3 votes]
docs/ENV_VARS.md Documents embedding timeout.
docs/CONFIGURATION.md Updates configuration documentation.
docs/agent/tasks/task-154-remediate-devsecops-review-findings.md Adds remediation task. Review: change lifecycle status from In Progress to In Review and synchronize the index. [nit; 3 votes]
docs/agent/task.md Indexes task 154. Review: change the open-PR row from In Progress to In Review. [nit; 3 votes]
config.example.yaml Updates the embedding configuration template.
AGENTS.md Protects runtime configuration from automated overwrites.
Review details

Suppressed comments (5)

src/devops_cli/dry_run/models.py:30

  • Limiting only the number of top-level keys does not bound the payload: a single value can still be an arbitrarily large string, list, or nested mapping, and this validator runs after that object is already built. The model therefore does not provide the claimed memory bound; truncate or reject nested values, or apply a serialized-size cap.
        if len(v) > _MAX_DRY_RUN_DETAILS_KEYS:
            return dict(list(v.items())[:_MAX_DRY_RUN_DETAILS_KEYS])
        return v

src/devops_cli/output/table_builder.py:50

  • build_structured_table is not the renderer used by the normal console table path (console.py calls formatters.tables.render_table), whose title, headers, and cells are still inserted raw. The new escaping therefore does not protect ordinary print(..., columns=..., rows=...) or dispatcher output; harden the shared renderer or route all callers through this helper.
    src/devops_cli/server/routes/stream.py:84
  • _MAX_WEBSOCKET_MESSAGE_BYTES is a byte limit, but len(data) counts Unicode code points. A payload containing multibyte characters can therefore pass this check while exceeding 1 MiB on the wire and still reach JSON parsing; compare the UTF-8 encoded length instead.
    tests/conftest.py:21
  • 0.0.0.0 is the unspecified address, not a loopback address. Whitelisting it means this autouse guard can permit a non-loopback connection despite its stated invariant; remove it from the allowlist and use an address-aware loopback check if broader loopback ranges are needed.
    tests/test_output.py:846
  • These assertions are satisfied by both escaped and unescaped output: an escaped literal such as \[bold red] still contains the substring [bold red] that is being searched for. The test therefore would pass if Rich markup were still interpreted; assert on the rendered style/ANSI output (or another Rich-level representation) to prove the injected tags remain unstyled.
  • Files reviewed: 55/55 changed files
  • Comments generated: 11
  • 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/server/routes/stream.py Resolved
Comment thread src/devops_cli/ai/review/exporter.py Resolved
Comment thread src/devops_cli/k8s/chaos.py Resolved
Comment thread src/devops_cli/output/console.py Resolved
Comment thread src/devops_cli/pipeline/pipeline.py Resolved
Comment thread src/devops_cli/security/tflint.py Resolved
Comment thread docs/agent/task.md Resolved
@dan-petty
dan-petty merged commit 02bb059 into release/v0.2.16 Sep 11, 2026
4 checks passed
@dan-petty
dan-petty deleted the fix/remediate-devsecops-review-findings branch September 11, 2026 22:55
dan-petty added a commit that referenced this pull request Sep 12, 2026
* docs(changelog): document v0.2.15 release highlights and features (#105)

* docs(changelog): document v0.2.15 release highlights and features

* docs(changelog): clarify k8s logs invocation and list all 11 security scanners

* docs(agents): update agent instructions to honor API rate limits and quotas (#130)

* docs(agents): update agent instructions to honor API rate limits and quotas

- Add API rate limiting, complexity budgeting, and quota guidelines to AGENTS.md across core engineering, GitHub integration, and AI inference.
- Synchronize DEVOPS_CLI_AGENTS_METADATA_TEMPLATE in instruction_generator.py with rate-limiting rules.
- Add regression test assertions to test_instruction_generator.py.
- Track deliverable in task-129-agent-instructions-rate-limits.md.

Closes #129

* docs(agents): include AI inference rate limits and expand generator test assertions

* docs(agents): make semaphore example executable and link PR in task tracking

* feat(ai): render chat persona title in orange styling (#133)

* feat(ai): render chat persona title in orange styling

- Render persona title in bold dark_orange in chat section header rule
- Output persona reply prompt in bold dark_orange using Rich console
- Preserve bold cyan styling for 'You:' user prompt
- Update unit tests in test_ai_cmd.py asserting persona and user prompt colors

Closes #132

* test(ai): assert dark_orange section header styling and update task status to In Review

* fix(k8s): review pod restarts, eliminate cgroup oom kills, and optimize workload resource limits (#136)

* fix(k8s): review pod restarts, eliminate cgroup oom kills, and optimize workload resource limits

- Remove hard memory limits on Ollama DaemonSet (leaving requests at 3000m CPU and 8Gi RAM), allowing dynamic memory bursting into available node RAM without cgroup OOM kills
- Add startupProbe to Ollama DaemonSet with 5-minute failure threshold for cold starts and large model weight loading
- Relax Ollama livenessProbe (10s timeout, 15s period, 6 failure threshold) to prevent premature kubelet SIGKILL terminations during heavy inference
- Raise memory and CPU limits across core workloads (ArgoCD controller, repoServer, server, and Redis; Valkey; Jaeger; Registry; Fluent Bit; and Loki)
- Add comprehensive regression tests in tests/test_k8s.py verifying resource limit invariants and probe resilience
- Create task tracking document docs/agent/tasks/task-135-k8s-pod-restarts-resource-limits.md

Closes #135

* fix(k8s): bound Ollama memory limit, enforce probe contracts, and assert all resource changes

* feat(k8s): deploy squid caching proxy with ssl bump, observability, and failover handling (#134)

* feat(k8s): deploy squid caching proxy with ssl bump, observability, and failover handling

- Deploy high-capacity Squid caching proxy configured for 100GB single objects
- Enable SSL-Bump TLS interception with dynamic cert generation for Ollama 70B layers
- Add Prometheus observability via squid-exporter sidecar on port 9301
- Enable structured JSON access logging to stdout and Cache Manager API
- Implement LFUDA dynamic aging eviction with proactive high/low watermarks (92%/85%)
- Integrate Squid proxy env vars and CA certificate mount in ollama-daemonset
- Document failover architecture across node crash, WAN outage, and storage domains
- Add comprehensive unit test suite in test_k8s_squid.py

Closes #131

* fix(docker): format and sort imports in _client helper

* refactor(k8s): relocate squid docker assets to k8s/squid/docker to prevent SDK namespace shadowing

* feat(k8s): add condor node affinity for high-capacity 1.8TB NVMe storage allocation

* fix(docker): format import order in client builder

* fix(k8s): resolve review feedback on squid probes, egress policy, ca sync, and chown

* feat(docs): implement document compaction engine and enhance review self-improvement loop (#138)

* feat(docs): implement document compaction engine and enhance review self-improvement loop

- Author DocCompactor engine supporting roadmap, release notes, and log compaction
- Integrate devops docs compact subcommand with check, dry-run, and series filtering
- Expose docs_compact tool on FastMCP server and synchronize MCP JSON schemas
- Harden reference extractor to exclude glob patterns, examples, and stdlib prefixes
- Resolve executive summary reporting error handling for skipped and errored files
- Enhance review prompts and system instructions for closed-loop self-improvement
- Constrain Loki logging NetworkPolicy ingress to ingress-nginx controller
- Add comprehensive test suites for compaction engine and MCP tools

Closes #137

* fix(docs): resolve review feedback on error sanitization, path containment, and syntax boundaries

- Sanitize and bound error strings in pipeline errored_files registry to <= 256 chars
- Enforce strict regex validation and archive directory containment for release series
- Use negative lookbehind boundaries for secret tokens to support underscore identifiers
- Restore process dry-run state via try/finally in docs compact CLI command
- Refine log header version extraction and eliminate hardcoded series strings
- Populate roadmap and release notes section counters in DocCompactionResult
- Truncate caller-provided details in DocCompactionError to 256 characters
- Replace hardcoded package prefixes with dynamic importlib package introspection

* feat(ai): format chat responses as rich markdown and failover ollama models

* docs(roadmap): add agentic sandbox iteration architecture tasks

* feat(k8s): enable squid caching forward proxy cluster-wide and resolve root ca (#143)

* feat(k8s): enable squid caching forward proxy cluster-wide and resolve root ca

* feat(ai): support chat model cli overrides and map llm gateway to roadmap

* fix(k8s): address copilot review on squid proxy security and ca rotation

* feat(k8s): enable in-cluster squid proxying, store-id caching, and loopback rewriting

* fix(k8s): resolve pod restarts on gpu-feature-discovery and prometheus stack with burstable qos

* docs(agent): reconcile task lifecycles for v0.2.16 milestone release merge

* docs(devcontainer): align devcontainer usage guide with modern best practices (#145)

* docs(devcontainer): align devcontainer usage guide with modern best practices

* docs(devcontainer): address peer review feedback and improve configuration examples

* docs: remove obsolete development log and redundant pending features docs (#146) (#147)

* docs: remove obsolete development log and redundant pending features docs (#146)

* docs(agent): update task 146 status to in review with PR #147

* docs(routine): distinguish docs compaction from manual task archival

* refactor(core): decouple circular module imports and streamline convoluted import patterns (#148) (#149)

* refactor(core): decouple circular module imports and streamline convoluted import patterns (#148)

* fix(test): resolve child module import edges in invariant check and decouple config settings (#148)

* fix(k8s): route stack lifecycle run_subprocess and forward patches to _stack_lifecycle (#148)

* docs(architecture): document pre-1.0 alpha status, zero legacy remnants, and post-1.0 semver policy (#150) (#151)

* docs(architecture): document pre-1.0 alpha status, zero legacy remnants, and post-1.0 semver policy (#150)

* docs(security): sanitize homelab configurations and align release manuals with pre-1.0 alpha policy

- Fix Copilot review feedback on RELEASE_CYCLE.md: use generic SemVer placeholders X.Y.0 and X.Y.Z
- Fix Copilot review feedback on knowledge base: qualify release_management.md and release_engineering_and_semver_governance.md with pre-1.0 alpha zero backwards compatibility policy vs post-1.0 SemVer 2.0.0 governance
- Sanitize internal hostnames, RFC 1918 IPs, and hardware mount paths across k8s/squid/deployment.yaml, tests/test_k8s_squid.py, docs/ROADMAP.md, docs/squid-failover-and-observability.md, and docs/agent/tasks/
- Update AGENTS.md and instruction_generator.py with comprehensive prohibitions against recording internal infrastructure details
- Ground changes in Issue #152 and docs/agent/tasks/task-152-sanitize-internal-systems-and-strengthen-instructions.md

* docs(security): gate pre-1.0 alpha notice on devops-cli and sanitize cluster network docs (#152) (#153)

* docs(security): gate pre-1.0 alpha notice on devops-cli and sanitize cluster network docs (#152)

- Gate pre-1.0 alpha notice on meta.is_devops_cli across generate_pointer_stub, generate_instruction_content, and generate_agents_md so external scaffolded projects do not receive DevOps CLI-specific alpha notices
- Update test_instruction_generator.py to verify is_devops_cli gating behavior on pointer stubs and AGENTS.md
- Sanitize LAN speed reference in docs/squid-failover-and-observability.md to local cluster network speed
- Update task tracking in docs/agent/tasks/task-152-sanitize-internal-systems-and-strengthen-instructions.md

* docs(agent): update task-152 PR reference to #153

* test(ai): assert absence of pre-1.0 alpha lifecycle block for generic external projects

* fix(security): remediate devsecops findings and consolidate embedding configuration (#154) (#155)

* fix(security): remediate devsecops findings and consolidate embedding configuration (#154)

- Remediate review session findings for credential leakage, injection, and resource exhaustion
- Consolidate embedding configuration under ai.tasks.embedding and remove duplicate keys from rag
- Add offline fallback to tldextract and test-wide network egress guard
- Protect local user runtime config.yaml from automated sanitization rewrites
- Enhance review falsification rules, feedback export, and common hallucinations catalog

* fix(security): remediate pr 155 review comments and exclude documented example network references (#154)

* docs(roadmap): add milestones v0.2.19, v0.2.20, and v0.2.21, and mark task 154 complete

* chore(release): bump version to v0.2.16 and finalize changelog

* feat(sandbox): implement long-running workload sandbox lifecycle engine (#157)

* feat(sandbox): implement long-running workload sandbox lifecycle engine

* docs(agent): update task 106 tracking to In Review with PR 157

* feat(sandbox): remediate pr review findings, update agent instructions, and resolve threads

* fix(sandbox): address bandit b108 tmpfs mount false positive and format

* docs(roadmap): reprioritize roadmap and redistribute features across v0.2.17-v0.2.19

* feat(ci): automatically apply formatting and linting across CLI and CI commands (#159)

* feat(ci): automatically apply formatting and linting across CLI and CI commands (#158)

- Default --fix to True on devops ci, devops ci format, and devops ci lint
- Support --check flag for non-mutating validation
- Introduce top-level devops format and devops lint CLI commands with clean usage
- Move _layouts/ and assets/ to docs/ for Jekyll GitHub Pages compliance
- Prevent event loop deadlock in introspect_mcp_tools and offload check_docs
- Update test suites, architectural invariants, and documentation

* fix(docs): address PR 159 review comments on executor cleanup, alias docs, and jekyll layout

- Introspect leaf command aliases directly so devops format and devops lint generate clean leaf command usage rather than inheriting all ci subcommands
- Implement non-blocking thread pool executor cleanup with wait=False, cancel_futures=True and asyncio.wait_for in introspect_mcp_tools
- Remove /docs/ prefix in docs/_layouts/default.html navigation and footer links to prevent 404s on GitHub Pages
- Configure default layout in docs/github-pages.config.yaml for Jekyll markdown pages
- Synchronize task tracking and regenerate documentation

* chore(tasks): mark task-158 as done upon PR #159 merge

* fix(release): add release notes extraction fallback and enforce changelog version check (#140, #160)

Resolves release orchestration failures where release notes extraction fails due to missing version headers or changelog discrepancies:
- Strictly enforce matching version in CHANGELOG.md during devops release check (fatal Exit 1)
- Implement layered fallback extraction across CHANGELOG.md -> docs/RELEASE_NOTES.md -> git commit log
- Defensive fallback to git commit log in .github/workflows/release.yml
- Decompose release_check to maintain cyclomatic complexity <= 10
- Comprehensive unit tests in tests/test_release.py

* chore(tasks): mark task-140 as done upon PR #160 merge

* docs(release): update v0.2.16 changelog and release notes highlights

* fix(review): address PR 161 comments on sandbox port allocation, secret lookbehind, and gfd image

* fix(sandbox): align requested_ports type annotation in SandboxRegistry with allocate_ports
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