Python Examples
Practical scripts demonstrating rekit integration into defensive security pipelines and CI/CD gates.
Example 1: Automated Pre-commit Static Gate
import subprocess
import json
import sys
def audit_binary(filepath):
# Run rekit triage with --json
cmd = ["python3", "rekit.py", "triage", filepath, "--json"]
proc = subprocess.run(cmd, capture_output=True, text=True)
if proc.returncode != 0:
print(f"Audit failed: {proc.stderr}")
return False
data = json.loads(proc.stdout)
if data.get("packer"):
print(f"ALERT: Binary is packed with {data['packer']}")
return False
print(f"Passed: {filepath} ({data.get('kind')})")
return True
if __name__ == "__main__":
if not audit_binary(sys.argv[1]):
sys.exit(1)