Python interface for YARA, a powerful malware identification and classification tool
Overall
score
85%
Evaluation — 85%
↓ 0.94xAgent success when using this tile
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.
Install with Tessl CLI
npx tessl i tessl/pypi-yara-pythonevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10