A comprehensive tool for managing and manipulating audit files with both CLI and web-based interfaces. This tool allows you to view, search, compare, and remove items from audit files efficiently.
- Parse audit files - Extract and analyze custom items and reports from .audit files
- Remove items - Selectively remove items by ID or description
- Automatic backups - Creates timestamped backups before modifications
- Smart parsing - Handles complex audit file structures including conditional blocks (if/then/else)
- File upload and management - Upload and manage multiple audit files through a modern web interface
- Search and filter - Search items by ID or description with real-time filtering
- Bulk operations - Remove multiple items at once using various input formats
- File comparison (diff) - Compare two audit files side-by-side and merge differences
- Statistics dashboard - View detailed statistics about your audit files
- Visual feedback - Interactive UI with real-time updates and notifications
- Full-featured REST API for programmatic access
- Upload, parse, search, and modify audit files
- Compare files and merge differences
- Bulk operations support
- Python 3.8 or higher
- pip (Python package manager)
- Clone the repository:
git clone <repository-url>
cd Audit-Checker- Create a virtual environment (recommended):
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txtfrom main import find_and_remove_items, print_all_items
# List all items in an audit file
print_all_items("your_file.audit")
# Remove items by description
find_and_remove_items(
"your_file.audit",
descriptions_to_remove=["Ensure no duplicate user names exist"],
remove_reports=True
)from audit_manager import AuditManager
# Initialize manager
manager = AuditManager()
# Load an audit file
manager.load_file("your_file.audit")
# Get all items
items = manager.get_all_elements()
# Search for specific items
results = manager.search_elements("ssh")
# Remove items by ID
manager.remove_elements(["1.1.1", "2.3.4"], remove_reports=True)
# Get statistics
stats = manager.get_statistics()
print(f"Total items: {stats['total_items']}")
print(f"Total reports: {stats['total_reports']}")- Start the web server:
python app.py- Open your browser and navigate to:
http://localhost:5333
-
Main Interface - Upload and manage audit files:
- Click "Upload File" to load an audit file
- Use the search bar to find specific items
- Select items to remove using checkboxes
- Use "Bulk Removal" for removing multiple items at once
- Download the modified file when done
-
File Comparison - Compare two audit files:
- Navigate to the "Compare Files" page
- Select two files to compare
- View differences side-by-side
- Merge items between files
- Export comparison reports
POST /api/upload- Upload an audit fileGET /api/files- List available filesPOST /api/load/<filename>- Load a specific fileGET /api/download- Download current file
GET /api/items- Get all items from loaded fileGET /api/search?q=<query>- Search itemsGET /api/item/<item_id>- Get item detailsGET /api/statistics- Get file statistics
POST /api/remove- Remove selected items{ "ids": ["1.1.1", "2.3.4"], "remove_reports": true }POST /api/bulk-search- Search for multiple itemsPOST /api/bulk-remove- Remove multiple items
POST /api/diff/load- Load two files for comparison{ "file_a": "file1.audit", "file_b": "file2.audit" }GET /api/diff/compare- Get comparison resultsPOST /api/diff/merge- Merge element from one file to anotherPOST /api/diff/remove- Remove element during comparisonPOST /api/diff/batch-merge- Merge multiple elements
Audit-Checker/
├── app.py # Flask web application
├── main.py # CLI script with core functionality
├── audit_manager.py # AuditManager class for file operations
├── requirements.txt # Python dependencies
├── templates/
│ ├── index.html # Main web interface
│ └── diff.html # File comparison interface
├── static/
│ ├── css/ # Stylesheets
│ └── js/ # JavaScript files
├── uploads/ # Uploaded audit files
└── backups/ # Automatic backups
The tool parses audit files by:
- Identifying
<custom_item>and<report>blocks - Extracting IDs and descriptions using regex patterns
- Handling conditional blocks (
<if>,<then>,<else>) - Distinguishing between main items and condition items
- Tracking absolute positions for precise removal
Items are identified by:
- ID: Numeric pattern (e.g.,
1.2.3,4.5.6.7) - Description: Text following the ID
- Context: Location within the file structure (main vs condition)
Only items in main contexts (top-level, <then>, <else>) with numeric IDs are considered valid audit items.
- Automatic timestamped backups are created before any modification
- Backups are stored in the
backups/directory - Format:
filename.audit.YYYYMMDD_HHMMSS.backup
The bulk removal feature accepts multiple input formats:
# By ID only
1.1.1
2.3.4
5.6.7.8
# By ID with description
1.1.1 Ensure filesystem is mounted
2.3.4 Ensure permissions are set
# By partial description
Ensure SSH is configured
Configure firewall rules
# Mixed formats with various separators
1.1.1, 2.3.4; 3.4.5
Ensure no duplicate user names exist
Configure password policies
The system will:
- Parse your input list
- Search for matching items
- Display preview with match status
- Allow selective confirmation
- Create backup and remove selected items
The diff feature allows you to:
- Compare two audit files side-by-side
- Identify items unique to each file
- Find modified items with detailed field-level differences
- Merge items from one file to another
- Remove unwanted items
- Export comparison reports
Comparison categories:
- Unique in A: Items only in first file
- Unique in B: Items only in second file
- Modified: Items present in both but with differences
- Identical: Items that are exactly the same
- Review before removing - Always use the preview feature to verify items before removal
- Use backups - Backups are created automatically, but keep original files safe
- Bulk removal efficiency - Use the bulk removal feature for large-scale operations
- File comparison - Use diff to track changes between audit file versions
- Search functionality - Leverage search to quickly locate items in large files
- ID-based operations - Prefer ID-based operations for precision
File not loading:
- Verify the file is a valid .audit file
- Check file permissions
- Ensure file encoding is UTF-8
Items not found during search:
- Check if the item ID matches exactly
- Verify the item is in a main context (not in
<condition>) - Ensure the description contains the numeric ID prefix
Backup not created:
- Check write permissions in the directory
- Verify the
backups/directory exists - Ensure sufficient disk space
Run the Flask app in debug mode for detailed error messages:
app.run(debug=True, host='0.0.0.0', port=5333)Edit app.py to modify:
- Upload folder location (
UPLOAD_FOLDER) - Maximum file size (
MAX_CONTENT_LENGTH) - Allowed extensions (
ALLOWED_EXTENSIONS) - Server host and port
UPLOAD_FOLDER = 'uploads'
MAX_CONTENT_LENGTH = 16 * 1024 * 1024 # 16MB
ALLOWED_EXTENSIONS = {'audit'}
DEFAULT_PORT = 5333- File uploads are restricted to
.auditextensions only - Filenames are sanitized using
secure_filename() - CORS is enabled for API access
- Files are stored in a dedicated upload directory
- Maximum file size is enforced (16MB default)
Contributions are welcome. Please ensure:
- Code follows existing style conventions
- New features include appropriate documentation
- API changes are backward compatible when possible
This project is provided as-is for audit file management purposes.
For issues, questions, or feature requests, please refer to the project repository.
Note: Always maintain backups of your original audit files. While this tool creates automatic backups, it's best practice to keep separate copies of important files.