Skip to content
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

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from

Conversation

vigneswararaomacharla
Copy link
Contributor

Updated with known source ips related code changes.

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.
@vigneswararaomacharla vigneswararaomacharla changed the base branch from master to dev August 9, 2019 11:18


class RestrictionStatus(Enum):
Restricted = "restricted"
OpenCompletely = "open_completely"
OpenPartly = "open_partly"
SafeIP = "safe_ips"
Copy link
Contributor

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?

Copy link
Contributor Author

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:
Copy link
Contributor

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.

Copy link
Contributor Author

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):
Copy link
Contributor

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?

Copy link
Contributor Author

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants