How y1z2g3/yara-java works
Core Components
a) Interface Layer (Top):
• Callback interfaces: YaraCompilationCallback, YaraScanCallback
• Model classes: YaraRule, YaraMatch, YaraMeta, YaraString
b) Implementation Layer (Middle) - Split into two parallel paths:
Left Side - Embedded Mode:
• YaraImpl (embedded)
• YaraCompilerImpl (embedded)
• YaraScannerImpl (embedded)
• YaraLibrary (JNI bridge)
Right Side - External Mode:
• YaraImpl (external)
• YaraCompilerImpl (external)
• YaraScannerImpl (external)
• YaraExecutable and YaracExecutable
c) Native Layer (Bottom):
• YARA Native Library (embedded mode)
• YARA External Process (external mode)
Specific details
a) Factory Pattern:
• YaraFactory as the central point for creating instances
• Demonstrate how it creates either embedded or external implementations
b) Component Relationships:
• How YaraCompiler creates rules that feed into YaraScanner
• Callback mechanisms for compilation and scanning
• File/archive handling for rules
Important Notes
a) Annotations for:
• Shared YR_RULES structure in embedded mode
• Process boundaries in external mode
• Native resource management
• Threading considerations
Technical Details
Technical notes for:
• JNI bridge implementation
• Native library requirements
• External process communication
• Resource lifecycle management
Remember to emphasize the factory pattern's role in abstracting the implementation details and how the system manages native resources in both modes of operation.