Skip to content

Commit

Permalink
consolidate geoip calls
Browse files Browse the repository at this point in the history
  • Loading branch information
wleightond committed Aug 16, 2023
1 parent 3370980 commit 945f7f8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion canarytokens/channel_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def render_GET(self, request: Request):
http_general_info, src_data = handler(request)

# TODO we should fail gracefully when third party dependency fails
geo_info = queries.get_geoinfo_from_ip(ip=http_general_info["src_ip"])
geo_info = queries.get_geoinfo(ip=http_general_info["src_ip"])

hit_info = {
"token_type": canarydrop.type,
Expand Down
2 changes: 1 addition & 1 deletion canarytokens/channel_input_smtp.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def eomReceived(self):
time_of_hit=datetime.utcnow().strftime("%s.%f"),
input_channel="SMTP",
src_ip=self.esmtp.src_ip,
geo_info=queries.get_geoinfo_from_ip(ip=self.esmtp.src_ip),
geo_info=queries.get_geoinfo(ip=self.esmtp.src_ip),
is_tor_relay=queries.is_tor_relay(ip=self.esmtp.src_ip),
mail=SMTPMailField(
recipients=[o.decode() for o in self.esmtp.mail["recipients"]],
Expand Down
6 changes: 3 additions & 3 deletions canarytokens/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def _parse_aws_key_trigger(
src_ip = data["ip"][0]
# DESIGN/TODO: this makes a call to third party ensure we happy with fails here
# and have default.
geo_info = queries.get_geoinfo_from_ip(ip=src_ip)
geo_info = queries.get_geoinfo(ip=src_ip)
is_tor_relay = queries.is_tor_relay(src_ip)
user_agent = data["user_agent"][0]
hit_info = {
Expand Down Expand Up @@ -417,7 +417,7 @@ def _parse_slack_api_trigger(request):
data = {k.decode(): [o.decode() for o in v] for k, v in request.args.items()}
hit_time = datetime.utcnow().strftime("%s.%f")
src_ip = data["ip"][0]
geo_info = queries.get_geoinfo_from_ip(ip=src_ip)
geo_info = queries.get_geoinfo(ip=src_ip)
is_tor_relay = queries.is_tor_relay(src_ip)
user_agent = data["user_agent"][0]
hit_info = {
Expand Down Expand Up @@ -732,7 +732,7 @@ def create_token_hit(
is_tor_relay = None
if src_ip and ("safety_net" not in hit_info or not hit_info["safety_net"]):
hit_info["src_ip"] = src_ip
geo_info = queries.get_geoinfo_from_ip(ip=src_ip)
geo_info = queries.get_geoinfo(ip=src_ip)
is_tor_relay = queries.is_tor_relay(src_ip)
hit_info["geo_info"] = geo_info
hit_info["is_tor_relay"] = is_tor_relay
Expand Down

0 comments on commit 945f7f8

Please sign in to comment.