Policies Overview
Policies let you define custom rules to allow or block egress traffic, overriding auto-baseline.What Are Policies?
Policies are YAML configurations that specify:- Allow rules: Domains/IPs that should never trigger Issues (even if not in baseline)
- Block rules: Domains/IPs that should always be blocked (even if in baseline)
- Scope: Which micro-contexts the policy applies to
Use Cases
Corporate Allowlist
Whitelist internal domains that should always be accessible.
Supply Chain Hardening
Block known-bad registries or malicious domains.
Compliance
Enforce egress restrictions (e.g., only allow approved SaaS vendors).
Zero Trust Egress
Define “known-good” list and block everything else.
Policy Types
Allow Policies
Domains/IPs that will never trigger Issues, even if not in baseline. Example:Block Policies
Domains/IPs that will always be blocked, even if in baseline. Example:Policy Scope
Policies can apply to:- All Agents
- GitHub Actions Only
- Specific Workflows
- Kubernetes Only
Pattern Matching
Policies support flexible pattern matching:| Pattern | Matches | Example |
|---|---|---|
example.com | Exact domain | example.com only |
*.example.com | Subdomain wildcard | api.example.com, cdn.example.com |
**.example.com | All subdomains (recursive) | deep.nested.example.com |
192.0.2.0/24 | CIDR range | 192.0.2.1 - 192.0.2.254 |
192.0.2.* | IP wildcard | 192.0.2.1 - 192.0.2.255 |
Creating Policies
Via Dashboard
1
Navigate to Policies
Dashboard → Policies → Create Policy
2
Configure Policy
- Name: e.g., “Corporate Allowlist”
- Type: Allow or Block
- Scope: Global, GitHub Actions, or Kubernetes
- Rules: Add domain/IP patterns
3
Test Policy
Use Test Mode to validate without applying.
4
Apply Policy
Click Save & Apply. Changes take effect within 60 seconds.
Via YAML
Createpolicy.yaml:
Policy Precedence
When multiple policies overlap, Garnet applies them in this order:- Block policies (highest priority)
- Allow policies
- Auto-baseline
malicious.npmjs.org is blocked (block takes precedence).
Testing Policies
Before applying to production, test policies in Test Mode:1
Enable Test Mode
Dashboard → Policy → Test Mode toggle
2
Simulate Traffic
Trigger your workload (GitHub Actions workflow or K8s pod).
3
Review Results
Dashboard shows what would have been allowed/blocked (without actually blocking).
4
Apply Policy
Once validated, disable Test Mode and apply the policy.
Example: Zero Trust Egress
Goal: Only allow known-good domains; block everything else.Policy Metrics
Dashboard → Policies shows:| Metric | Description |
|---|---|
| Rules | Number of allow/block patterns |
| Matches (24h) | Connections affected by this policy |
| Blocks (24h) | Connections blocked by this policy |
| Last Updated | When policy was last modified |