Skip to content

Commit f3f94a4

Browse files
committed
add some correct checks on data coming from new command
1 parent d0b96fa commit f3f94a4

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

aikido_zen/background_process/commands/check_firewall_lists.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ def process_check_firewall_lists(
3535
if user_agent is not None and isinstance(user_agent, str):
3636
# User agent blocking (e.g. blocking AI scrapers)
3737
if connection_manager.firewall_lists.is_user_agent_blocked(user_agent):
38-
reason = "You"
3938
return {
4039
"blocked": True,
4140
"type": "bot-blocking",
4241
}
42+
43+
return {
44+
"blocked": False,
45+
}

aikido_zen/sources/functions/request_handler.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,21 @@ def pre_response():
5959
},
6060
receive=True,
6161
)
62-
if not check_fw_lists_res["success"] or not check_fw_lists_res["blocked"]:
62+
if not check_fw_lists_res["success"] or not check_fw_lists_res["data"]["blocked"]:
6363
return
6464

65-
if check_fw_lists_res["type"] == "allowlist":
65+
block_type = check_fw_lists_res["data"]["type"]
66+
67+
if block_type == "allowlist":
6668
message = "Your IP address is not allowed."
6769
message += " (Your IP: " + context.remote_address + ")"
6870
return message, 403
69-
70-
if check_fw_lists_res["data"]["type"] == "blocklist":
71+
if block_type == "blocklist":
7172
message = "Your IP address is blocked due to "
7273
message += check_fw_lists_res["data"]["reason"]
7374
message += " (Your IP: " + context.remote_address + ")"
7475
return message, 403
75-
76-
# User agent blocking (e.g. blocking AI scrapers)
77-
if check_fw_lists_res["data"]["type"] == "bot-blocking":
76+
if block_type == "bot-blocking":
7877
msg = "You are not allowed to access this resource because you have been identified as a bot."
7978
return msg, 403
8079

0 commit comments

Comments
 (0)