Skip to content

Commit

Permalink
Merge pull request #7 from Axonius/bug.user-ip-association-improvment
Browse files Browse the repository at this point in the history
[improvement] user_ip_association sublist iteration
  • Loading branch information
Katz-Tal authored Jun 21, 2023
2 parents ade43d3 + 56047c6 commit dcc93d0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions custom_axonius_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,15 @@ def user_ip_association(ip_address: str, username: str) -> bool:
True of this IP address is related to the user else it returns False.
"""
ax_ip = find_ip(ip_address)
if not ax_ip.get("ERROR") and (
username in (item for sublist in ax_ip.get("users") for item in sublist)
or username in ax_ip.get("users")
):
return True
if not ax_ip.get("ERROR"):
for sublist in ax_ip.get("users"):
if isinstance(sublist, list):
for _sub_item in sublist:
if username in _sub_item:
return True
else:
if username in sublist:
return True
return False


Expand Down

0 comments on commit dcc93d0

Please sign in to comment.