This directory contains example policies, device configurations, and scripts to help you get started with AuditAgent.
web-server-policy.yaml
- Purpose: Basic web server firewall policy
- Features: HTTP/HTTPS ingress, egress for updates, SSH management
- Use Case: Protecting a public-facing web server
- Devices: Single Linux server with iptables
simple-linux-policy.yaml
- Purpose: Minimal policy for testing
- Features: Basic HTTP/SSH rules, simple structure
- Use Case: Learning policy syntax, quick tests
- Devices: Single Linux device
devices.yaml
- Purpose: Full-featured device configuration
- Features: SSH key authentication, multiple devices
- Use Case: Production multi-device deployments
- Devices: Multiple Linux servers with iptables
example-devices.yaml
- Purpose: Simple device configuration for testing
- Features: Single device, basic SSH settings
- Use Case: Quick testing, learning device configuration
- Devices: Single Linux device
example.py
- Purpose: Basic programmatic usage
- Features: Audit, enforcement, and remediation via Python API
- Use Case: Integrating AuditAgent into Python applications
- Prerequisites: AuditAgent installed via pip
linux_example.py
- Purpose: Linux-specific automation example
- Features: iptables-specific operations, advanced filtering
- Use Case: Linux-focused deployments, iptables management
- Prerequisites: Linux device with iptables
# Audit a web server policy
audit-agent audit examples/web-server-policy.yaml examples/devices.yaml
# View detailed violations
audit-agent audit examples/web-server-policy.yaml examples/devices.yaml --verbose# See what changes would be made (safe, no actual changes)
audit-agent enforce examples/web-server-policy.yaml examples/devices.yaml
# With detailed output
audit-agent enforce examples/web-server-policy.yaml examples/devices.yaml --verbose# Generate AI-corrected policy (requires GOOGLE_AI_API_KEY)
export GOOGLE_AI_API_KEY="your-key-here"
audit-agent ai-remediate examples/web-server-policy.yaml examples/devices.yaml
# Review the generated policy
cat examples/web-server-policy-ai-remediation.yamlFile: web-server-policy.yaml + devices.yaml
# Audit compliance
audit-agent audit examples/web-server-policy.yaml examples/devices.yaml
# Apply the policy
audit-agent enforce examples/web-server-policy.yaml examples/devices.yaml --no-dry-run
# Verify enforcement
audit-agent audit examples/web-server-policy.yaml examples/devices.yamlExpected Result: 100% compliance with HTTP/HTTPS open, all other inbound traffic blocked.
File: simple-linux-policy.yaml
# Simple policy structure:
name: simple-linux
description: "Minimal policy for learning"
default_ingress_action: drop
default_egress_action: accept
rules:
- name: "Allow SSH"
direction: ingress
protocol: tcp
port: 22
source: any
destination: any
action: acceptTry:
- Copy this policy and modify it
- Add your own rules
- Test with
audit-agent audit
File: example.py
# Import AuditAgent modules
from audit_agent.core.policy import NetworkPolicy
from audit_agent.devices.linux_iptables import LinuxIptables
from audit_agent.audit.engine import AuditEngine
import asyncio
# Run audit programmatically
async def run_audit():
policy = NetworkPolicy.from_yaml_file("examples/simple-linux-policy.yaml")
device = LinuxIptables(host="192.168.1.10", username="admin")
engine = AuditEngine()
result = await engine.audit_policy(policy, [device])
print(f"Compliance: {result.overall_compliance_percentage:.1f}%")
asyncio.run(run_audit())# Start with a simple policy
cp examples/simple-linux-policy.yaml my-policy.yaml
# Edit the policy
vim my-policy.yaml
# Test with audit (dry run, safe)
audit-agent audit my-policy.yaml examples/devices.yaml
# If issues found, use AI to fix
audit-agent ai-remediate my-policy.yaml examples/devices.yaml
# Apply when satisfied
audit-agent enforce my-policy.yaml examples/devices.yaml --no-dry-run# Create device list
cp examples/devices.yaml production-devices.yaml
# Edit to add your devices
vim production-devices.yaml
# Audit all devices
audit-agent audit examples/web-server-policy.yaml production-devices.yaml
# Apply to all devices
audit-agent enforce examples/web-server-policy.yaml production-devices.yaml --no-dry-run# Schedule regular audits (crontab)
0 */6 * * * audit-agent audit /path/to/policy.yaml /path/to/devices.yaml --output report.json
# Alert on compliance drops
audit-agent audit policy.yaml devices.yaml --min-compliance 95.0All policy files follow this structure:
name: policy-name
description: "Policy description"
default_ingress_action: drop # or accept
default_egress_action: accept # or drop
rules:
- name: "Rule description"
direction: ingress # or egress
protocol: tcp # tcp, udp, icmp, any
port: 80 # or port range "80-443"
source: any # or CIDR "10.0.0.0/8"
destination: any
action: accept # or dropSee Configuration Guide for complete reference.
Device files specify connection details:
devices:
- name: "web-server-1"
type: "linux_iptables"
host: "192.168.1.10"
username: "admin"
# SSH key authentication (recommended)
private_key: "~/.ssh/id_rsa"
# Or password (not recommended for production)
# password: "secret"
# Optional: SSH port
port: 22
# Optional: Connection timeout
timeout: 30See Secure Authentication Guide for best practices.
# Install AuditAgent
pip install audit-agent
# For AI features
export GOOGLE_AI_API_KEY="your-key"
# For SSH (if using key auth)
ssh-add ~/.ssh/id_rsa# Run a test Linux container with iptables
docker run -d --name test-firewall --cap-add=NET_ADMIN ubuntu:22.04 sleep infinity
# Get container IP
CONTAINER_IP=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' test-firewall)
# Update devices.yaml with container IP
# Then run audit/enforcement against the container✓ Audit completed successfully
Overall Compliance: 100.0%
Compliant Devices: 1/1
Total Issues: 0
Device Compliance:
• web-server-1: 100.0% compliant
✗ Audit found compliance issues
Overall Compliance: 60.0%
Compliant Devices: 0/1
Total Issues: 4
Device Compliance:
• web-server-1: 60.0% compliant (4 issues)
Issues by Severity:
• HIGH: 2
• MEDIUM: 2
✓ Enforcement completed successfully
Actions Executed: 4
Successful: 4
Failed: 0
Changes Applied:
• Added rule: Allow HTTP (port 80)
• Added rule: Allow HTTPS (port 443)
• Modified default ingress action: drop
• Modified default egress action: accept
- Documentation: See docs/ directory
- Issues: https://github.com/xoity/AuditAgent/issues
- Examples: This directory contains working examples
- Community: Discussions and contributions welcome!
- ✅ Review the example files in this directory
- ✅ Copy an example policy and customize it for your needs
- ✅ Test with
audit-agent audit(safe, no changes) - ✅ Apply with
audit-agent enforcewhen satisfied - ✅ Set up continuous compliance monitoring
Ready to get started? See the Getting Started Guide!