Open weslambert opened 3 years ago
python3-yara
Maybe something like the following as a standalone script, or added to so-yara-update:
#!/usr/bin/python3
import argparse
import yara
from pathlib import Path
parser = argparse.ArgumentParser()
parser.add_argument('--path', '-p', help='Path to YARA rules')
args = parser.parse_args()
rules_dir = args.path
def validate_yar(rules_dir):
# Check all subdirs for YARA rules
paths = Path(rules_dir).glob('**/*.yar*')
for path in paths:
path_str = str(path)
if path_str.endswith(".yar"):
rule = path_str
print("Validating " + rule + "...")
# Script will exit upon failed compilation
yara.compile(filepath=rule)
else:
continue
validate_yar(rules_dir)
Consider using something like plyara: https://github.com/plyara/plyara