Update FreeSWitch Parser for Version Compatibility
Summary
Updates the FreeSWitch parser to handle log format changes across versions and removes unreliable filename dependency.
Changes Made
Parser Updates (parsers/s01-parse/crowdsecurity/freeswitch.yaml)
- Removed filename dependency: Changed from
sofia_reg.cspecific matching tosofia(?:_reg)?\.cpattern - Added version support: Handles 3 log formats across FreeSWitch versions:
- v1.8.x: Basic timestamp format
- v1.9.x: Added CPU percentage
- v1.10.12: Added UUID prefix +
sofia.cmigration
- Enhanced ACL parsing: Updated regex to handle ACL messages with/without domain names
- Improved maintainability: Used YAML anchors to reduce code duplication
Test Updates
- Expanded log coverage: Updated
.tests/freeswitch/freeswitch.logwith 10 examples covering all 3 versions - Realistic test data: Uses sanitized IPs and usernames reflecting real-world usage patterns
- Streamlined assertions: Reduced from 155 to essential assertions focusing on core functionality
Problem Solved
- Filename brittleness: FreeSWitch team moved logging from
sofia_reg.ctosofia.cin recent versions - Version compatibility: Parser only handled old log format with CPU percentage
- Test maintainability: 156 assertions for 5 log entries created maintenance burden
- Limited coverage: Original tests didn't reflect modern FreeSWitch deployments with important security fixes
Testing
All tests pass with the updated parser handling:
- User enumeration attempts
- SIP authentication failures
- ACL rejections
- Multiple IP formats and log structures
Rationale
FreeSWitch's evolution across versions makes filename-based parsing fragile. This update ensures the parser works across deployments regardless of version while maintaining detection accuracy. The streamlined tests focus on essential parsing functionality rather than exhaustive field validation.
This is intended to bring better balance between comprehensive coverage (multiple log formats) and maintainability (targeted assertions).
/kind enhancement
/area agent
Thanks for your PR, please avoid the use of YAML anchors .