Skip to content

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

Merged
dan-petty merged 4 commits into
release/v0.2.18from
feat/122-distributed-threat-intel-valkey-l2
Sep 16, 2026
Merged

dan-petty merged 4 commits into
release/v0.2.18from
feat/122-distributed-threat-intel-valkey-l2

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Summary

Resolves #122.

Architectural Changes:

  1. Distributed Valkey L2 Cache Integration:
    • Integrated Valkey L2 caching into CloudflareRadarClient using key format valkey:threat_intel:domain:<target>.
    • Bounded expiration TTL of 86400 seconds (DEFAULT_THREAT_INTEL_CACHE_TTL_SECONDS = 86400).
    • Graceful offline fallback: if Valkey is unreachable or errors, seamlessly falls back to in-memory L1 cache and live queries without raising exceptions.
  2. Batch Domain Lookup Pipeline:
    • Implemented check_domains_batch(domains, batch_size=25) in CloudflareRadarClient.
    • Resolves domains through L1 in-memory cache and Valkey L2 cache before querying remote Cloudflare Radar Intel API.
    • Pipelined execution with telemetry metrics tracking (devops_cli_threat_intel_lookups_total, threat_intel.lookup.cloudflare_batch).
  3. Cache Hit Statistics:
    • Added get_cache_stats() tracking requests, hits, misses, and hit_ratio.
  4. Review Pipeline Integration:
    • Updated _fetch_vulnerabilities_and_reputations in devops_cli.ai.review.pipeline to batch domain targets with _fetch_domains_threat_intel and radar_client.check_domains_batch.
    • Extracted _fetch_domains_threat_intel and _fetch_ip_threat_intel, maintaining strict nesting depth <= 4 and complexity <= 10.

Verification:

  • Added 100% test coverage in tests/test_security_threat_intel.py (7 tests covering L1 cache, L2 cache hits, L2 misses, TTL, offline fallback, batch lookups, and hit ratio metrics).
  • Passed all existing tests in tests/test_vulnerability_lookup.py.
  • Passed all 8 architectural invariants in tests/test_architectural_invariants.py.
  • Certified 10/10 local CI checks passing with uv run devops ci.

@dan-petty
dan-petty marked this pull request as ready for review September 16, 2026 05:40
Copilot AI lite review requested due to automatic review settings September 16, 2026 05:40

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

Critical cache behavior and multiple moderate correctness, configuration, validation, performance, and testing issues remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds distributed Valkey L2 threat-intelligence caching and batched Cloudflare Radar lookups for security reviews.

Changes:

  • Adds caching, TTLs, statistics, and telemetry.
  • Integrates batched domain lookups into the review pipeline.
  • Adds Valkey client support, tests, configuration defaults, and task documentation.
File summaries
File Description
tests/test_vulnerability_lookup.py Updates vulnerability lookup tests.
tests/test_security_threat_intel.py Tests caching, batching, fallback, and metrics.
src/devops_cli/valkey/client.py Adds TTL alias support.
src/devops_cli/security/vulnerability_lookup.py Implements Valkey caching and domain batching.
src/devops_cli/config/defaults.py Adds cache and batch defaults.
src/devops_cli/config/constants.py Adds the cache key prefix.
src/devops_cli/ai/review/pipeline.py Integrates domain and IP threat-intelligence lookups.
docs/agent/tasks/task-122-distributed-threat-intel-valkey-l2.md Documents task objectives and status.
Review details

Suppressed comments (2)

src/devops_cli/ai/review/pipeline.py:1090

  • The new domain/IP partition and review-pipeline integration are not covered by the existing review-pipeline tests (the added tests exercise CloudflareRadarClient directly). A regression in batch result keys, fallback records, or routing domains versus IPs could therefore pass CI. Add a focused pipeline test mocking both clients and asserting domains use check_domains_batch while IPs use Shodan.
                domain_targets = [target for target, rtype in unique_nets if rtype != "ip"]
                ip_targets = [target for target, rtype in unique_nets if rtype == "ip"]
                if domain_targets:
                    net_cache.update(_fetch_domains_threat_intel(radar_client, domain_targets))

src/devops_cli/valkey/client.py:220

  • The new ex alias is only exercised through a MagicMock in test_security_threat_intel.py; the existing socket tests cover ex_seconds, not this path. A regression could omit or misencode EX 86400 while all new tests still pass. Add a protocol-level test for set(..., ex=60) that verifies the emitted SET ... EX 60 command.
        ex: int | None = None,
    ) -> bool:
        """Set key to hold string value with optional expiration seconds."""
        effective_ttl = ex if ex is not None else (ex_seconds if ex_seconds is not None else ttl)
  • Files reviewed: 8/8 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.

@dan-petty dan-petty mentioned this pull request Sep 16, 2026
11 tasks done
@dan-petty
dan-petty force-pushed the feat/122-distributed-threat-intel-valkey-l2 branch from 29a7da3 to 0753d2c Compare September 16, 2026 12:10
@dan-petty
dan-petty merged commit 9fa5277 into release/v0.2.18 Sep 16, 2026
4 checks passed
@dan-petty
dan-petty deleted the feat/122-distributed-threat-intel-valkey-l2 branch September 16, 2026 12:18
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