How jopohl/sigma-rust works
• Parser & Lexer:
• Modules such as src/detection/lexer.rs and src/detection/ast.rs indicate the use of a lexer (tokenizer) and an abstract syntax tree builder. This is the entry point for parsing the rule syntax.
• Rule Evaluation Engine:
• Core modules such as src/rule.rs, src/detection.rs, and src/lib.rs orchestrate the rule evaluation logic using Pratt parsing and strong type checking.
• Field Management:
• Components under src/field (including modifier.rs, transformation.rs, value.rs) encapsulate how fields and their modifications are processed.
• Error Handling:
• src/error.rs manages error output during parsing and rule matching.
• Event Representation:
• Files like src/event.rs model how input events (e.g., JSON events) are represented and accessed for rule matching.
• Utility Components:
• Base value support (src/basevalue.rs) and selection logic (src/selection.rs) enhance the robustness of matching and type integrity.
• Wildcard Support:
• src/wildcard.rs encapsulates functionality to handle string wildcards in σ‑rules.
Understand the Relationships and Interactions
• The Lexer feeds tokens into an AST builder found under the detection subdirectory.
• The parsed AST is used by the rule evaluation engine to construct rule objects and then interact with events.
• Event data flows into the evaluation routines where field access (and modifiers) come into play for an accurate match.
• Error handling is interleaved throughout these processes to ensure that misformatted inputs or incompatible types are caught.
• The library’s API (exposed via lib.rs) allows external consumers (see examples/ and benches/) to feed in rules and event data.
Architectural Patterns and Design Principles
• Modular design: the separation of concerns is clear, with dedicated modules for parsing, rule definition, field handling, and error management.
• Extensibility: the design anticipates adding more modifiers or field types in future enhancements.
• Testability: the inclusion of tests and benchmarks indicates a commitment to correctness and performance.
Relevant Technologies & Tools
• Written in Rust: note that all components adhere to Rust’s safety and concurrency principles.
• CI/CD: highlight the integration with GitHub Workflows (in .github/workflows) for continuous integration and security audits.
Final Advice
• That any external interactions (APIs exposed to the user, integration with test cases) are clearly noted.
Happy diagramming!