Skip to content

feat(security): qdrant vector database api key secret protection and clusterip default - #48

Merged
dan-petty merged 3 commits into
release/v0.2.12from
feat/qdrant-secret-protection
Sep 7, 2026
Merged

dan-petty merged 3 commits into
release/v0.2.12from
feat/qdrant-secret-protection

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Summary

Enforce mandatory API key secret protection on the local Qdrant vector database Helm deployment in k8s/llm/values-qdrant.yaml, eliminating unauthenticated network exposure and hardening RAG subsystem credential storage via OS Keyring.

Closes #43

Key Changes

  • Kubernetes Helm Manifest (k8s/llm/values-qdrant.yaml):
    • Configured service.type: ClusterIP (previously NodePort) to prevent unauthenticated host exposure.
    • Set apiKey: false and readOnlyApiKey: false to disable plain-text value embedding.
    • Injected QDRANT__SERVICE__API_KEY into Qdrant container environment via extraEnv using secretKeyRef pointing to Kubernetes Secret qdrant-api-key:api-key.
  • Config & Secret Registry (src/devops_cli/config/):
    • Registered qdrant.url, qdrant.api_key, and qdrant.collection_prefix in options.py.
    • Added qdrant.api_key to SECRET_CONFIG_OPTIONS (bringing audited secret count to 7) and KEYRING_KEYS (qdrant_api_key).
    • Added environment variable mapping in env.py (DEVOPS_CLI_QDRANT_API_KEY, DEVOPS_CLI_QDRANT_URL, DEVOPS_CLI_QDRANT_COLLECTION_PREFIX) with is_secret=True.
    • Added api_key: str | None = None to QdrantConfig in settings.py and implemented get_qdrant_api_key(settings).
  • RAG Subsystem & Keyring Resolution (src/devops_cli/ai/rag/):
    • Updated indexer.py (resolve_qdrant_client, WorkspaceIndexer.__init__) to automatically resolve Qdrant credentials from OS Keyring.
    • Updated qdrant.py (QdrantClient.__init__) to default api_key to get_qdrant_api_key(load_settings()).
    • Updated investigator.py, commands/rag.py, and builtin_tools.py to forward OS Keyring API keys.
  • Kubernetes Stack Lifecycle & Secret Sync (src/devops_cli/k8s/, src/devops_cli/commands/k8s/):
    • Implemented fetch_qdrant_api_key() and updated sync_k8s_credentials() to provision and synchronize qdrant-api-key in llm namespace.
    • Added _ensure_qdrant_api_key_secret() in stack_lifecycle.py to create the secret prior to Qdrant Helm installation and synchronize post-deployment.
  • Verification & Testing:
    • Authored comprehensive test suite tests/test_k8s_qdrant_security.py (10/10 green).
    • Updated tests/test_config_audit_keys.py asserting 7 audited secret options (4/4 green).
    • Passed Checkov IaC scan on k8s/ (0 violations) and architectural invariants gates.
    • Verified full CI quality gate (uv run devops ci — 10/10 gates green, coverage >= 90%).

@dan-petty dan-petty added type/security Type security: a vulnerability or a leak scope/k8s Kubernetes commands, Helm charts, pods, services, and policies priority/p1-high Priority P1: high-impact work for the next planned milestone labels Sep 6, 2026
Copilot AI lite review requested due to automatic review settings September 6, 2026 23:33
@dan-petty dan-petty added type/security Type security: a vulnerability or a leak scope/k8s Kubernetes commands, Helm charts, pods, services, and policies priority/p1-high Priority P1: high-impact work for the next planned milestone labels Sep 6, 2026
@dan-petty dan-petty added this to the v0.2.12 milestone Sep 6, 2026

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

The current secret-provisioning path passes the API key on the kubectl command line, which can leak into process listings and traced command-line telemetry, and it also doesn’t fail fast if secret creation fails.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR hardens the local Qdrant (RAG vector DB) deployment by removing unauthenticated exposure, shifting API-key material to Kubernetes Secrets + OS keyring, and wiring the CLI/RAG stack to resolve credentials securely.

Changes:

  • Switch Qdrant Helm values to ClusterIP by default and inject QDRANT__SERVICE__API_KEY via secretKeyRef (no plaintext in values).
  • Add first-class qdrant.* config options + env var mappings, and route qdrant.api_key through the audited secret/keyring registries.
  • Add K8s credential sync + lifecycle provisioning for qdrant-api-key, and add a dedicated test suite + docs updates.
File summaries
File Description
tests/test_k8s_qdrant_security.py Adds end-to-end tests covering Helm values security posture, keyring precedence, RAG client resolution, and K8s secret sync.
tests/test_config_audit_keys.py Updates audited secret count and asserts qdrant.api_key is included.
src/devops_cli/k8s/credentials.py Adds fetch_qdrant_api_key() and sync wiring under sync_k8s_credentials().
src/devops_cli/config/settings.py Extends QdrantConfig and adds get_qdrant_api_key() helper.
src/devops_cli/config/options.py Registers qdrant.url, qdrant.api_key, qdrant.collection_prefix and adds qdrant.api_key to secret/keyring registries.
src/devops_cli/config/env.py Adds DEVOPS_CLI_QDRANT_* env var mappings + secret spec for API key.
src/devops_cli/config/init.py Re-exports get_qdrant_api_key.
src/devops_cli/commands/rag.py Passes resolved Qdrant API key into client creation.
src/devops_cli/commands/k8s/stack_lifecycle.py Ensures qdrant-api-key exists before Helm install and syncs credentials post-deploy; updates dry-run details.
src/devops_cli/commands/k8s/init.py Exposes _ensure_qdrant_api_key_secret via the command package exports.
src/devops_cli/ai/tools/builtin_tools.py Ensures RAG tool path uses authenticated Qdrant client.
src/devops_cli/ai/rag/qdrant.py Adds automatic keyring-based API key resolution when api_key omitted.
src/devops_cli/ai/rag/investigator.py Ensures investigator uses keyring-resolved Qdrant API key.
src/devops_cli/ai/rag/indexer.py Adds resolve_qdrant_client() and makes WorkspaceIndexer auto-resolve/backfill credentials and embedder.
src/devops_cli/ai/rag/init.py Exports resolve_qdrant_client.
k8s/llm/values-qdrant.yaml Enforces ClusterIP default and Secret-based API key injection (no plaintext keys in values).
docs/ROADMAP.md Marks Phase 48 Qdrant secret protection as completed.
docs/PENDING_FEATURES.md Marks related Phase 48 items (incl. Qdrant) as completed.
docs/LOG.md Adds changelog entry for Qdrant secret protection work.
docs/ENV_VARS.md Documents new Qdrant environment variables.
docs/agent/task.md Updates task tracking to include Phase 48.4 Qdrant work in WIP list.
Review details
  • Files reviewed: 21/21 changed files
  • Comments generated: 4
  • 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/rag/indexer.py Resolved
Comment thread src/devops_cli/ai/rag/qdrant.py Resolved
@dan-petty
dan-petty merged commit a76c9cd into release/v0.2.12 Sep 7, 2026
4 checks passed
@dan-petty
dan-petty deleted the feat/qdrant-secret-protection branch September 7, 2026 12:09
@dan-petty dan-petty mentioned this pull request Sep 7, 2026
dan-petty added a commit that referenced this pull request Sep 7, 2026
* feat(devcontainer): automate PR devcontainer cleanup on PR merge in GHCR (#44)

* feat(devcontainer): automate PR devcontainer cleanup on PR merge in GHCR

- Add GitHub Actions workflow .github/workflows/cleanup-devcontainer.yml triggered on pull_request [closed] and workflow_dispatch
- Scope GHCR image pruning to pr-<number> or wildcard tags while preserving release tags (latest, v*, main)
- Reclaim multi-architecture storage via delete-untagged and delete-ghost-images
- Pin dataaxiom/ghcr-cleanup-action to commit SHA for supply chain security
- Enhance devops_cli.commands.gh token resolution (Keyring github.token and gh auth token) and use REST API for milestones
- Update agent instructions in AGENTS.md, ROUTINE_TASKS.md, docs/agent/README.md to leverage GitHub project integrations and issue tracking
- Sync roadmap milestones and track Phase 47.4 deliverables

Closes #39

* docs(task): update Phase 47.4 tracking with PR 44 and commit 21711bd

* fix(gh): support DEVOPS_CLI_GITHUB_TOKEN and add pagination to milestone api

- Address Copilot review comments on PR #44
- Check DEVOPS_CLI_GITHUB_TOKEN in _get_github_client()
- Pass --paginate and per_page=100 in _get_repo_milestones()
- Add regression tests in tests/test_gh_cmd.py

* feat(ci): pin GitHub Actions to immutable commit SHAs (#45)

* feat(ci): pin GitHub Actions to immutable commit SHAs

* docs(task): update Phase 48.1 tracking with PR 45

* docs(roadmap): update action SHA pinning status to completed

* docs(task): record Copilot review resolution on PR 45

* feat(security): isolate subprocess environment and enforce credential boundary (#46)

* feat(security): isolate subprocess environment and enforce credential boundary

* fix(security): normalize env var key case for cross-platform matching and ensure test determinism

* docs(task): update Phase 48.2 tracking with PR #46 and Copilot review resolution

* feat(k8s): cluster default-deny NetworkPolicies for monitoring and argocd namespaces (#47)

* feat(k8s): cluster default-deny NetworkPolicies for monitoring and argocd namespaces

* fix(k8s): address Copilot review on NetworkPolicy ingress comments, API server egress selector, and test assertions

* docs(task): record PR #47 and Copilot review remediation in Phase 48.3 tracking

* feat(security): qdrant vector database api key secret protection and clusterip default (#48)

* feat(security): qdrant vector database api key secret protection and clusterip default

* fix(review): address Copilot findings for stdin secret apply, fail-fast lifecycle, and debug logging

* docs(agent): update task tracking for PR #48 and Copilot review resolutions

* docs(agent): record Phase 48.4 PR #48 squash-merge and issue #43 closure

* feat(review): review finding remediation, github project automation, and runtime duration formatting (#49)

* refactor(review): address session 164259 findings and harden self-improvement loop

* docs(agent): mark Phase 48.5 task completed and PR 49 verified

* feat(github): remote project sync, automated milestone closure, and submodule test grouping

* feat(devcontainer): enhance mcp lifecycle sync and enforce commit message hygiene

* feat(output): format command elapsed duration in human readable units

Upgrade format_duration to support microsecond, millisecond, second, minute, hour, and day formatting across CLI command completion, CI summaries, AI reviews, and benchmarks.

* refactor(github): omit status from milestone description

Ensure milestone descriptions extracted from roadmap use strictly the feature name without appending status strings in parentheses.

* feat(valkey): valkey workstation caching, rate limiting, and v0.2.12 release preparation

- Implement pure-Python RESP2/RESP3 encoder and stream parser without C dependencies
- Add TCP socket client (ValkeyClient) with connection pooling, timeouts, and zero-trust SSRF validation
- Implement atomic token bucket rate limiter with embedded Lua script
- Implement distributed AI cache provider (ValkeyCacheProvider) for embeddings and review findings
- Implement devops valkey CLI command group (ping, info, stats, keys, get, set, flush, backup, cli)
- Register 6 FastMCP Valkey tools and dynamic system resource resource://valkey/status
- Bump package version to 0.2.12 and synchronize release documentation
- Pass all 10 devops ci quality gates with 95% test coverage

* docs(agents): codify strict release PR title convention feat(release): v<version>

* fix(review): remediate pull request review findings across valkey, output, and github subsystems
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/k8s Kubernetes commands, Helm charts, pods, services, and policies 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