Skip to main content

Linux iptables Policy Enforcer & Auditor

Project description

AuditAgent - Linux iptables Policy Enforcer & Auditor PyPI version License Build Status

  • A Python framework for declaratively defining and enforcing iptables firewall policies across Linux servers without requiring agents on the servers themselves.

Table of Contents

Features

  • Declarative Policy Definition: Define iptables policies using Python DSL
  • Linux iptables Support: Complete support for iptables firewall rules
  • Policy Audit & Drift Detection: Compare live iptables rules against declared policies
  • 🤖 AI-Powered Remediation: Automatically generate remediation policies using Google AI or OpenAI
  • Automated Remediation: Intelligent automated fixing of detected policy violations
  • Risk-Based Strategies: Conservative, balanced, and aggressive remediation approaches
  • Rollback Capabilities: Automatic rollback on validation failures
  • Idempotent Enforcement: Apply changes only when needed
  • Pre-flight Validation: Simulate changes before applying them
  • Secure Authentication: Dynamic credential prompting and SSH agent integration
  • SSH Authentication: Support for password and key-based authentication

Getting Started

Refer to the Getting Started guide for installation steps, example code, and CLI usage.

AI-Powered Remediation 🤖

AuditAgent now includes AI-powered automatic remediation that uses advanced language models to analyze compliance issues and generate corrected policies:

# Set your Google AI Studio API key (free tier available)
export GOOGLE_AI_API_KEY="your-key-here"

# Generate and apply AI-powered remediation
audit-agent ai-remediate policy.yaml devices.yaml --apply

Features:

  • 🎯 Achieves 100% compliance automatically
  • 🔄 Iterative refinement for optimal results
  • 📊 Detailed analysis and summary reports
  • 🌐 Supports Google AI Studio (Gemini), OpenAI, Azure OpenAI
  • 🔒 Secure local API key management
  • 🚀 Designed for future web-based management

For complete documentation, see AI Remediation Guide.

Automated Remediation

AuditAgent now supports intelligent automated remediation that can fix detected policy violations without manual intervention. This feature provides:

  • Smart Decision Making: Risk-based analysis of whether violations should be automatically fixed
  • Multiple Strategies: Choose from conservative, balanced, or aggressive remediation approaches
  • Safety First: Dry-run by default with explicit confirmation for risky changes
  • Rollback Protection: Automatic rollback if validation fails after remediation
  • Comprehensive Reporting: Detailed logs of all remediation actions taken

Quick Start

# Dry-run automated remediation (safe, shows what would be done)
audit-agent auto-remediate --devices devices.yaml --policy policy.yaml

# Execute remediation with conservative strategy
audit-agent auto-remediate --devices devices.yaml --policy policy.yaml --execute --strategy conservative

# View detailed help
audit-agent auto-remediate --help

For complete documentation, see Automated Remediation Guide.

Configuration Guide

For detailed YAML schema and reference, see the Configuration Guide.

Secure Authentication

AuditAgent supports secure authentication without hardcoded credentials. See the Secure Authentication Guide for:

  • SSH Agent Integration: Use SSH agent for key management
  • Dynamic Credential Prompting: Prompt for passwords at runtime
  • Migration from Hardcoded Credentials: Remove security risks from config files

Quick example:

devices:
  - type: "linux_iptables"
    name: "web-server-01"
    host: "192.168.0.111"
    username: "vagrant"
    private_key: "~/.ssh/id_rsa"
    # No hardcoded passwords - prompts when needed

Examples

The examples/ directory contains sample policy and device configurations:

  • simple-linux-policy.yaml: Minimal policy example
  • devices.yaml: Sample device inventory configuration
  • devices-secure.yaml: Secure device configuration without hardcoded credentials
  • web-server-policy.yaml: End-to-end web server policy
  • automated_remediation_demo.py: Demonstrates automated remediation features
  • See additional configurations in the examples/ folder.

Installation

Standard Installation

pip install audit-agent

With AI Support

pip install audit-agent[ai]

Or install from source:

git clone https://github.com/xoity/AuditAgent
cd AuditAgent
pip install -e ".[ai]"

Project Structure

audit_agent/
├── core/           # Core policy and rule definitions
├── devices/        # Linux iptables implementation
├── audit/          # Audit and compliance checking
├── enforcement/    # Policy enforcement engine
├── validation/     # Pre-flight checks and validation
└── utils/          # Utilities and helpers

Supported Devices

  • Linux servers with iptables firewall

Contributing

Contributions, issues, and feature requests are welcome. Please open an issue or pull request on the GitHub repository.

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

audit_agent-1.0.0.tar.gz (82.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

audit_agent-1.0.0-py3-none-any.whl (70.5 kB view details)

Uploaded Python 3

File details

Details for the file audit_agent-1.0.0.tar.gz.

File metadata

  • Download URL: audit_agent-1.0.0.tar.gz
  • Upload date:
  • Size: 82.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for audit_agent-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a216d5e481e219416f1f8f5f68c1e61da6b14448e57d48116787c98f17b56835
MD5 849cceac575d339062f5e087b1b44d42
BLAKE2b-256 f144017f217712dd7300f3c5bf0cf30c38ffeb8c0618b8b15bb198b789e37b63

See more details on using hashes here.

File details

Details for the file audit_agent-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: audit_agent-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 70.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for audit_agent-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bed3e8430edf779899806e5016d9e659217e6e5b5235d62a10afa6fcad9711ae
MD5 301bb87645b072014e608bf05ac24269
BLAKE2b-256 4bc04921270e8e75eb8cdeeb1ed609072585260301400c836a681d23920932b0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page