Skip to content

Commit

Permalink
Merge pull request #196 from rmhowe425/dev/filter-private-ips
Browse files Browse the repository at this point in the history
Adding domain alert missing parity from web app
  • Loading branch information
achillean authored Jul 14, 2023
2 parents 2d55abf + 3036d83 commit 9ed7496
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions shodan/cli/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import json
import shodan
from tldextract import extract
from ipaddress import ip_address

from collections import defaultdict
from operator import itemgetter
Expand Down Expand Up @@ -132,9 +133,15 @@ def alert_domain(domain, triggers):

if domain_parse.subdomain:
domain_ips = set([record['value'] for record in info['data']
if record['subdomain'] == domain_parse.subdomain])
if record['subdomain'] == domain_parse.subdomain and
not ip_address(record['value']).is_private])
else:
domain_ips = set([record['value'] for record in info['data']])
domain_ips = set([record['value'] for record in info['data']
if not ip_address(record['value']).is_private])

if not domain_ips:
raise click.ClickException('No external IPs were found to be associated with this domain. '
'No alert was created.')

# Create the actual alert
click.secho('Creating alert...', dim=True)
Expand Down

0 comments on commit 9ed7496

Please sign in to comment.