How pranlawate/avc-parser works
Project Type and Purpose
• This is an open-source, standalone CLI tool written in Python for post-incident forensic analysis of SELinux AVC denial logs.
• It implements a modular pipeline: input validation → parsing/anomaly detection → semantic enrichment → output formatting (rich terminal, reports, JSON).
• Key use cases: security analysis, compliance reporting, SIEM integration.
High-Level Components
• CLI Controller (parse_avc.py)
• Entry point: parses command-line arguments, dispatches workflow.
• Configuration Module (config/constants.py)
• Centralizes audit patterns, size limits, analysis settings.
• Validators (validators/file_validator.py)
• Validates file type, existence, permissions; auto-detects format.
• Parsers & Context Model (selinux/context.py)
• Builds AvcContext objects, interprets raw AVC log records.
• Detectors (detectors/anomaly_detector.py)
• Implements semantic rules: deduplication, dontaudit detection, correlation.
• Utility Libraries (utils/*.py)
• Shared helpers: file format detection, time parsing, pattern matching, sorting, SELinux command generation, legacy logic.
• Formatters
• json_formatter.py → outputs normalized JSON for machines/SIEM.
• report_formatter.py → renders rich terminal panels or text reports.
• Examples & Scripts
• examples/ → sample integration code using the core library.
• scripts/ → developer utilities (test data generation, profiling, log validation).
• Tests
• tests/ → unit and integration tests covering all modules.
External Dependencies & Integrations
• Python 3.6+
• Third-party: Rich library (terminal styling), audit/ausearch package (optional).
• External commands: sesearch for policy investigation commands.
• Input sources: raw audit.log, ausearch output, piped/pasted blocks.
• Outputs: console, JSON files, piped data to SIEM or other tools.
Details to Capture
• CLI invocation options and how they alter the workflow (flags → branching).
• The two-tier output system (rich panels vs. report vs. JSON).
• The auto-detection path in validators.
• Test coverage spanning all modules.
• Configuration constants driving analyzer behavior.