tessl install tessl/pypi-yara-python@3.11.0Python interface for YARA, a powerful malware identification and classification tool
Agent Success
Agent success rate when using this tile
85%
Improvement
Agent success rate improvement when using this tile compared to baseline
0.94x
Baseline
Agent success rate without this tile
90%
Build a utility that scans files with YARA rules and generates detailed match reports. The tool should process scan results and extract comprehensive information about pattern matches.
Execute YARA scans and extract match information from results.
Process string pattern matches within matched rules.
Extract detailed information from individual match instances.
Format match information into a structured report.
@generates
def scan_and_report(rules, data):
"""
Scan data with YARA rules and generate a detailed match report.
Parameters:
- rules: Compiled YARA Rules object
- data: Bytes or string data to scan
Returns:
A dictionary containing:
{
"total_matches": int, # Number of rules that matched
"matches": [
{
"rule": str, # Rule name
"namespace": str, # Rule namespace
"tags": [str], # Rule tags
"meta": dict, # Rule metadata
"strings": [
{
"identifier": str, # String identifier (e.g., "$a")
"instances": [
{
"offset": int, # Byte offset in data
"matched_data": bytes, # Actual matched bytes
"length": int # Length of match
}
]
}
]
}
]
}
"""
pass
def format_report(report_data):
"""
Format a match report into human-readable text.
Parameters:
- report_data: Dictionary returned from scan_and_report()
Returns:
A formatted string report showing:
- Total number of matches
- Each matched rule with its metadata
- String matches with identifiers
- Instance details with offsets and data
"""
passProvides YARA pattern matching and result processing capabilities.
@satisfied-by