Basementup commited on
Commit
df119a4
·
verified ·
1 Parent(s): 3774398

Upload sexy.py

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