Spaces:
No application file
No application file
| # 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() |