-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/sg known ip sources #97
base: dev
Are you sure you want to change the base?
Conversation
Updated with Insecure SG known ip sources
Updated with SG known IP sources.
Updated with InsecureSG known ips.
Updated with Insecure SG known CIDR range changes.
Updated with InsecureSG known source ips.
|
||
|
||
class RestrictionStatus(Enum): | ||
Restricted = "restricted" | ||
OpenCompletely = "open_completely" | ||
OpenPartly = "open_partly" | ||
SafeIP = "safe_ips" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just safe
to be consistent in naming?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated and tested.
if known_ip_cidr == source_cidr: | ||
return True | ||
elif source_ip.endswith("/32"): | ||
for ip in known_ip_cidr: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems ipaddress
module allows to check if ip belongs to network. We can do the check if we know source_cidr is /32
:
if source_cidr[-1] in known_ip_cidr: return True
to avoid the loop over all addresses in subnet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated and tested.
"""elif source_cidr.subnet_of(known_ip_cidr): | ||
return True""" | ||
return False | ||
|
||
def restriction_status(self, cidr): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm looking on this code https://github.com/dowjones/hammer/blob/dev/hammer/identification/lambdas/sg-issues-identification/describe_sec_grps_unrestricted_access.py#L57, it checks if the group is restricted and doesn't push it to db if it is. Should we do the same for safe groups? Any reason to save them to DB?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per testing it is not storing Safe groups in DDB. For Safe groups it is returning with Restricted status.
Updated with SG source ip review comments.
Updated with Review comments.
Upated with review comments.
Updated with known source ips related code changes.