Skip to content

feat: add context-aware conditional blocking#10

Open
matanryngler wants to merge 1 commit intomainfrom
feat/context-aware-blocking
Open

feat: add context-aware conditional blocking#10
matanryngler wants to merge 1 commit intomainfrom
feat/context-aware-blocking

Conversation

@matanryngler
Copy link
Owner

Summary

  • Add optional .deployshield.json config file that lets users block write operations only in specific contexts (e.g. prod kube context, production AWS profile) instead of blocking everything unconditionally
  • Support context detection for kubectl/helm (kube context), AWS (profile), Terraform (workspace), GCloud (project), Azure (subscription), and Pulumi (stack) via command flags, env vars, and config file parsing
  • Config uses fnmatch glob patterns (case-sensitive), with secure defaults: no config = block everything, undetectable context = blocked
  • CLI aliases resolved automatically (podman→docker, mongo→mongosh, sls→serverless)

Test plan

  • 97 new tests in tests/test_context_blocking.py covering config loading, flag/env extraction, per-provider context detection, pattern matching, and end-to-end subprocess integration
  • All 385 tests pass (existing + new), backward compatibility verified
  • Ruff lint and format clean

Allow users to block write operations only in specific contexts (e.g.
prod kube context, production AWS profile) via a .deployshield.json
config file. Without config, behavior is unchanged (block everything).

Config supports fnmatch glob patterns for kubectl contexts, AWS
profiles, terraform workspaces, GCP projects, Azure subscriptions,
and Pulumi stacks. Undetectable context defaults to blocked.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant