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 malware scanning service that efficiently scans files using pre-compiled YARA rules.
Your service must support the following operations:
Load pre-compiled rules: The service should load YARA rules from a pre-compiled binary file (not from source).
Scan files: Accept a file path and scan it against the loaded rules, returning all matches.
Return match information: For each matched rule, return:
The scanner should be initialized with the path to a pre-compiled YARA rules file.
"rule": The name of the matched rule (string)"namespace": The namespace of the rule (string, or empty string if none)"tags": A list of tags associated with the rule (list of strings, empty list if no tags)If no rules match, return an empty list.
Given a pre-compiled rules file, loading it successfully initializes the scanner without errors. @test
Scanning a file that matches a rule returns the correct rule name, namespace, and tags. @test
Scanning a file that doesn't match any rules returns an empty list. @test
@generates
class MalwareScanner:
"""Scanner that uses pre-compiled YARA rules to detect malware."""
def __init__(self, compiled_rules_path: str):
"""
Initialize the scanner with pre-compiled YARA rules.
Args:
compiled_rules_path: Path to the pre-compiled YARA rules file
"""
pass
def scan_file(self, file_path: str) -> list[dict]:
"""
Scan a file against the loaded rules.
Args:
file_path: Path to the file to scan
Returns:
A list of dictionaries with keys: 'rule', 'namespace', 'tags'
Each dictionary represents a matched rule.
Returns empty list if no matches.
"""
passProvides YARA pattern matching capabilities for malware detection.