Spaces:
No application file
No application file
File size: 2,737 Bytes
df119a4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | # 1. Data World (The Sandbox)
dataworld = [
{"txid": "A001", "user": "alice", "amount": 100, "country": "UK"},
{"txid": "A002", "user": "bob", "amount": 5000, "country": "USA"},
{"txid": "A003", "user": "alice", "amount": 200, "country": "UK"}
]
# 2. Rulebook (The Brain)
def rule_largetransaction(transaction):
if transaction["amount"] > 10000:
return "VIOLATION: Transaction amount exceeds 10,000."
return None
def rule_sanctionedcountry(transaction):
sanctioned_country = "SanctionedCountry"
if transaction["country"] == sanctioned_country:
return "VIOLATION: Transaction to sanctioned country."
return None
rulebook = [rule_largetransaction, rule_sanctionedcountry]
# 3. Scenario Injector (The Bad Guy)
def inject_sanctionedtransaction():
print("Injector: Firing bad transaction into Data World.")
baddata = {"txid": "X999", "user": "badactor", "amount": 7500, "country": "SanctionedCountry"}
dataworld.append(baddata)
def inject_largetransaction():
print("Injector: Firing large transaction into Data World.")
baddata = {"txid": "X998", "user": "highroller", "amount": 15000, "country": "USA"}
dataworld.append(baddata)
# 4. Escalation Targets (The Phone Booths)
def escalate_to_compliance_officer(violationreport):
print("--- CRITICAL ESCALATION: Compliance Officer ---")
print("REPORT:", violationreport)
print("-------------------------------------------------------")
def escalate_to_it_audit(violationreport):
print("--- INFO ESCALATION: IT Audit ---")
print("REPORT:", violationreport)
print("-------------------------------------------")
# Audit Script
def run_honeybadger_audit():
print("Honey Badger... Starting audit of", len(dataworld), "records.")
violationsfound = 0
for transaction in dataworld:
for rule_function in rulebook:
violationreason = rule_function(transaction)
if violationreason:
violationsfound += 1
print("Honey Badger... VIOLATION FOUND! txid:", transaction["txid"])
if "VIOLATION" in violationreason:
escalate_to_compliance_officer(violationreason + " Data: " + str(transaction))
else:
escalate_to_it_audit(violationreason + " Data: " + str(transaction))
if violationsfound == 0:
print("Honey Badger... Audit complete. All systems clean.")
# Example Runs
print("--- TEST 1: AUDIT CLEAN WORLD ---")
run_honeybadger_audit()
print("--- TEST 2: INJECTING SANCTIONED TRANSACTION ---")
inject_sanctionedtransaction()
run_honeybadger_audit()
print("--- TEST 3: INJECTING LARGE TRANSACTION ---")
inject_largetransaction()
run_honeybadger_audit() |