code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def retrieve_arn(config): """ See issue #374. SM does not currently store ARNs in a consistent place. :param config: itemrevision config dict :return: ARN, if we can find it """ if config.get('arn'): return config.get('arn') if config.get('Arn'): return config.get('Arn') ...
See issue #374. SM does not currently store ARNs in a consistent place. :param config: itemrevision config dict :return: ARN, if we can find it
retrieve_arn
python
Netflix/security_monkey
migrations/versions/bfb550a500ab_.py
https://github.com/Netflix/security_monkey/blob/master/migrations/versions/bfb550a500ab_.py
Apache-2.0
def hash_item(item, ephemeral_paths): """ Finds the hash of a dict. :param item: dictionary, representing an item tracked in security_monkey :return: hash of the json dump of the item """ complete = hash_config(item) durable = durable_hash(item, ephemeral_paths) return complete, durable
Finds the hash of a dict. :param item: dictionary, representing an item tracked in security_monkey :return: hash of the json dump of the item
hash_item
python
Netflix/security_monkey
migrations/versions/bfb550a500ab_.py
https://github.com/Netflix/security_monkey/blob/master/migrations/versions/bfb550a500ab_.py
Apache-2.0
def durable_hash(item, ephemeral_paths): """ Remove all ephemeral paths from the item and return the hash of the new structure. :param item: dictionary, representing an item tracked in security_monkey :return: hash of the sorted json dump of the item with all ephemeral paths removed. """ durabl...
Remove all ephemeral paths from the item and return the hash of the new structure. :param item: dictionary, representing an item tracked in security_monkey :return: hash of the sorted json dump of the item with all ephemeral paths removed.
durable_hash
python
Netflix/security_monkey
migrations/versions/bfb550a500ab_.py
https://github.com/Netflix/security_monkey/blob/master/migrations/versions/bfb550a500ab_.py
Apache-2.0
def sync(self, account_type, name, active, third_party, notes, identifier, custom_fields): """ Syncs the account with the database. If account does not exist it is created. Other attributes including account name are updated to conform with the third-party data source. """ accoun...
Syncs the account with the database. If account does not exist it is created. Other attributes including account name are updated to conform with the third-party data source.
sync
python
Netflix/security_monkey
security_monkey/account_manager.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/account_manager.py
Apache-2.0
def update(self, account_id, account_type, name, active, third_party, notes, identifier, custom_fields=None): """ Updates an existing account in the database. """ _get_or_create_account_type(account_type) # Query the account by ID if provided: if account_id: ...
Updates an existing account in the database.
update
python
Netflix/security_monkey
security_monkey/account_manager.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/account_manager.py
Apache-2.0
def create(self, account_type, name, active, third_party, notes, identifier, custom_fields=None): """ Creates an account in the database. """ account_type_result = _get_or_create_account_type(account_type) account = Account.query.filter( Account.name ==...
Creates an account in the database.
create
python
Netflix/security_monkey
security_monkey/account_manager.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/account_manager.py
Apache-2.0
def _populate_account(self, account, account_type_id, name, active, third_party, notes, identifier, custom_fields=None): """ Creates account DB object to be stored in the DB by create or update. May be overridden to store additional data """ account.name...
Creates account DB object to be stored in the DB by create or update. May be overridden to store additional data
_populate_account
python
Netflix/security_monkey
security_monkey/account_manager.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/account_manager.py
Apache-2.0
def get_account_by_id(account_id): """ Retrieves an account plus any additional custom fields """ account = Account.query.filter(Account.id == account_id).first() manager_class = account_registry.get(account.account_type.name) account = manager_class()._load(account) db.session.expunge(accou...
Retrieves an account plus any additional custom fields
get_account_by_id
python
Netflix/security_monkey
security_monkey/account_manager.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/account_manager.py
Apache-2.0
def __init__(self, watchers_auditors=None, account=None, debug=False): """ envs are list of environments where we care about changes """ self.account = account self.notifications = "" self.new = [] self.delete = [] self.changed = [] self.watchers_a...
envs are list of environments where we care about changes
__init__
python
Netflix/security_monkey
security_monkey/alerter.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/alerter.py
Apache-2.0
def report(self): """ Collect change summaries from watchers defined and send out an email """ if app.config.get("DISABLE_EMAILS"): app.logger.info("Alerter is not sending emails as they are disabled in the Security Monkey configuration.") return changed_...
Collect change summaries from watchers defined and send out an email
report
python
Netflix/security_monkey
security_monkey/alerter.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/alerter.py
Apache-2.0
def load_policies(self, item, policy_keys): """For a given item, return a list of all resource policies. Most items only have a single resource policy, typically found inside the config with the key, "Policy". Some technologies have multiple resource policies. A lambda function ...
For a given item, return a list of all resource policies. Most items only have a single resource policy, typically found inside the config with the key, "Policy". Some technologies have multiple resource policies. A lambda function is an example of an item with multiple resource polic...
load_policies
python
Netflix/security_monkey
security_monkey/auditor.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditor.py
Apache-2.0
def _issue_matches_listeners(self, item, issue): """ Verify issue is on a port for which the ALB/ELB/RDS contains a listener. Entity: [cidr:::/0] Access: [ingress:tcp:80] """ if not issue.notes: return False protocol_and_ports = self._get_listener_ports_and_p...
Verify issue is on a port for which the ALB/ELB/RDS contains a listener. Entity: [cidr:::/0] Access: [ingress:tcp:80]
_issue_matches_listeners
python
Netflix/security_monkey
security_monkey/auditor.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditor.py
Apache-2.0
def _merge_cidrs(cls): """ We learned about CIDRs from the following functions: - _load_elasticips() - _load_vpcs() - _load_vpces() - _load_natgateways() - _load_network_whitelist() These cidr's are stored in the OBJECT_STORE in a way that is no...
We learned about CIDRs from the following functions: - _load_elasticips() - _load_vpcs() - _load_vpces() - _load_natgateways() - _load_network_whitelist() These cidr's are stored in the OBJECT_STORE in a way that is not optimal: OBJECT_STO...
_merge_cidrs
python
Netflix/security_monkey
security_monkey/auditor.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditor.py
Apache-2.0
def _load_s3_buckets(cls): """Store the S3 bucket ARNs from all our accounts""" results = cls._load_related_items('s3') for item in results: add(cls.OBJECT_STORE['s3'], item.name, item.account.identifier)
Store the S3 bucket ARNs from all our accounts
_load_s3_buckets
python
Netflix/security_monkey
security_monkey/auditor.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditor.py
Apache-2.0
def _load_vpcs(cls): """Store the VPC IDs. Also, extract & store network/NAT ranges.""" results = cls._load_related_items('vpc') for item in results: add(cls.OBJECT_STORE['vpc'], item.latest_config.get('id'), item.account.identifier) add(cls.OBJECT_STORE['cidr'], item.lat...
Store the VPC IDs. Also, extract & store network/NAT ranges.
_load_vpcs
python
Netflix/security_monkey
security_monkey/auditor.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditor.py
Apache-2.0
def _load_userids(cls): """Store the UserIDs from all IAMUsers and IAMRoles.""" user_results = cls._load_related_items('iamuser') role_results = cls._load_related_items('iamrole') for item in user_results: fixed_item = ensure_item_has_latest_revision_id(item) if ...
Store the UserIDs from all IAMUsers and IAMRoles.
_load_userids
python
Netflix/security_monkey
security_monkey/auditor.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditor.py
Apache-2.0
def _load_accounts(cls): """Store the account IDs of all friendly/thirdparty accounts.""" friendly_accounts = Account.query.filter(Account.third_party == False).all() third_party = Account.query.filter(Account.third_party == True).all() cls.OBJECT_STORE['ACCOUNTS']['DESCRIPTIONS'] = lis...
Store the account IDs of all friendly/thirdparty accounts.
_load_accounts
python
Netflix/security_monkey
security_monkey/auditor.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditor.py
Apache-2.0
def inspect_entity(self, entity, item): """A entity can represent an: - ARN - Account Number - UserID - CIDR - VPC - VPCE Determine if the who is in our current account. Add the associated account to the entity. Return: 'SAME...
A entity can represent an: - ARN - Account Number - UserID - CIDR - VPC - VPCE Determine if the who is in our current account. Add the associated account to the entity. Return: 'SAME' - The who is in our same account. 'FR...
inspect_entity
python
Netflix/security_monkey
security_monkey/auditor.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditor.py
Apache-2.0
def add_issue(self, score, issue, item, notes=None, action_instructions=None): """ Adds a new issue to an item, if not already reported. :return: The new issue """ if notes and len(notes) > 1024: notes = notes[0:1024] if not self.override_scores: ...
Adds a new issue to an item, if not already reported. :return: The new issue
add_issue
python
Netflix/security_monkey
security_monkey/auditor.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditor.py
Apache-2.0
def audit_objects(self): """ Inspect all of the auditor's items. """ app.logger.debug("Asked to audit {} Objects".format(len(self.items))) self.prep_for_audit() self.current_support_items = {} query = ItemAuditScore.query.filter(ItemAuditScore.technology == self.i...
Inspect all of the auditor's items.
audit_objects
python
Netflix/security_monkey
security_monkey/auditor.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditor.py
Apache-2.0
def _is_current_method_disabled(self): """ Determines whether this method has been marked as disabled based on Audit Issue Scores settings. """ for override_score in self.override_scores: if override_score.method == self.current_method_name + ' (' + self.__class__.__n...
Determines whether this method has been marked as disabled based on Audit Issue Scores settings.
_is_current_method_disabled
python
Netflix/security_monkey
security_monkey/auditor.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditor.py
Apache-2.0
def read_previous_items(self): """ Pulls the last-recorded configuration from the database. :return: List of all items for the given technology and the given account. """ prev_list = [] for account in self.accounts: prev = self.datastore.get_all_ctype_filtered...
Pulls the last-recorded configuration from the database. :return: List of all items for the given technology and the given account.
read_previous_items
python
Netflix/security_monkey
security_monkey/auditor.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditor.py
Apache-2.0
def save_issues(self): """ Save all new issues. Delete all fixed issues. """ app.logger.debug("\n\nSaving Issues.") # Work around for issue where previous get's may cause commit to fail db.session.rollback() for item in self.items: changes = False ...
Save all new issues. Delete all fixed issues.
save_issues
python
Netflix/security_monkey
security_monkey/auditor.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditor.py
Apache-2.0
def email_report(self, report): """ Given a report, send an email using SES. """ if not report: app.logger.info("No Audit issues. Not sending audit email.") return if app.config.get("DISABLE_EMAILS"): app.logger.info("Emails are disabled in t...
Given a report, send an email using SES.
email_report
python
Netflix/security_monkey
security_monkey/auditor.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditor.py
Apache-2.0
def create_report(self): """ Using a Jinja template (jinja_audit_email.html), create a report that can be emailed. :return: HTML - The output of the rendered template. """ jenv = get_jinja_env() template = jenv.get_template('jinja_audit_email.html') for item in s...
Using a Jinja template (jinja_audit_email.html), create a report that can be emailed. :return: HTML - The output of the rendered template.
create_report
python
Netflix/security_monkey
security_monkey/auditor.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditor.py
Apache-2.0
def _create_auditor_settings(self): """ Checks to see if an AuditorSettings entry exists for each issue. If it does not, one will be created with disabled set to false. """ app.logger.debug("Creating/Assigning Auditor Settings in account {} and tech {}".format(self.accounts, self...
Checks to see if an AuditorSettings entry exists for each issue. If it does not, one will be created with disabled set to false.
_create_auditor_settings
python
Netflix/security_monkey
security_monkey/auditor.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditor.py
Apache-2.0
def link_to_support_item_issues(self, item, sub_item, sub_issue_message=None, issue_message=None, issue=None, score=None): """ Creates a new issue that is linked to an issue in a support auditor """ matching_issues = [] for sub_issue in sub_item.issues: if sub_issue.f...
Creates a new issue that is linked to an issue in a support auditor
link_to_support_item_issues
python
Netflix/security_monkey
security_monkey/auditor.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditor.py
Apache-2.0
def link_to_support_item(self, score, issue_message, item, sub_item, issue=None): """ Creates a new issue that is linked a support watcher item """ if issue is None: issue = self.add_issue(score, issue_message, item) issue.sub_items.append(sub_item) return iss...
Creates a new issue that is linked a support watcher item
link_to_support_item
python
Netflix/security_monkey
security_monkey/auditor.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditor.py
Apache-2.0
def _check_for_override_score(self, score, account): """ Return an override to the hard coded score for an issue being added. This could either be a general override score for this check method or one that is specific to a particular field in the account. :param score: the hard ...
Return an override to the hard coded score for an issue being added. This could either be a general override score for this check method or one that is specific to a particular field in the account. :param score: the hard coded score which will be returned back if there is ...
_check_for_override_score
python
Netflix/security_monkey
security_monkey/auditor.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditor.py
Apache-2.0
def _flatten_iter_response(self, response): """ The cloudaux iter_account_region decorator returns a list of tuples. Each tuple contains two members. 1) The result. 2) The exception map. This method combines that list of tuples into a single result list and a single exception map. ...
The cloudaux iter_account_region decorator returns a list of tuples. Each tuple contains two members. 1) The result. 2) The exception map. This method combines that list of tuples into a single result list and a single exception map.
_flatten_iter_response
python
Netflix/security_monkey
security_monkey/cloudaux_watcher.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/cloudaux_watcher.py
Apache-2.0
def hash_item(config, ephemeral_paths): """ Finds the hash of a dict. :param ephemeral_paths: :param config: :param item: dictionary, typically representing an item tracked in SM such as an IAM role :return: hash of the json dump of the item """ complete = DeepHash(conf...
Finds the hash of a dict. :param ephemeral_paths: :param config: :param item: dictionary, typically representing an item tracked in SM such as an IAM role :return: hash of the json dump of the item
hash_item
python
Netflix/security_monkey
security_monkey/datastore.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/datastore.py
Apache-2.0
def copy_unlinked(self): """ Used to address SQLAlchemy annoyances when the auditor saves issues. For some reason... if we don't make a copy of this object, SQLAlchemy complains that it's already attached to item... """ return ItemAudit(score=self.score, issue=self.issue, notes=s...
Used to address SQLAlchemy annoyances when the auditor saves issues. For some reason... if we don't make a copy of this object, SQLAlchemy complains that it's already attached to item...
copy_unlinked
python
Netflix/security_monkey
security_monkey/datastore.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/datastore.py
Apache-2.0
def get_all_ctype_filtered(self, tech=None, account=None, region=None, name=None, include_inactive=False): """ Returns a list of Items joined with their most recent ItemRevision, potentially filtered by the criteria above. """ item_map = {} query = Item.query if t...
Returns a list of Items joined with their most recent ItemRevision, potentially filtered by the criteria above.
get_all_ctype_filtered
python
Netflix/security_monkey
security_monkey/datastore.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/datastore.py
Apache-2.0
def store(self, ctype, region, account, name, active_flag, config, arn=None, new_issues=None, ephemeral=False, source_watcher=None): """ Saves an itemrevision. Create the item if it does not already exist. """ new_issues = new_issues if new_issues else [] item = se...
Saves an itemrevision. Create the item if it does not already exist.
store
python
Netflix/security_monkey
security_monkey/datastore.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/datastore.py
Apache-2.0
def _delete_duplicate_item(self, items): """ Given a list of identical items (account, name, region, technology), delete the duplicate, and return the most current item back out. :param items: :return: """ last_item = items.pop() for i in items: ...
Given a list of identical items (account, name, region, technology), delete the duplicate, and return the most current item back out. :param items: :return:
_delete_duplicate_item
python
Netflix/security_monkey
security_monkey/datastore.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/datastore.py
Apache-2.0
def _get_item(self, technology, region, account, name): """ Returns the first item with matching parameters. Creates item if it doesn't exist. """ account_result = Account.query.filter(Account.name == account).first() if not account_result: raise Exception("Ac...
Returns the first item with matching parameters. Creates item if it doesn't exist.
_get_item
python
Netflix/security_monkey
security_monkey/datastore.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/datastore.py
Apache-2.0
def store_exception(source, location, exception, ttl=None): """ Method to store exceptions in the database. :param source: :param location: :param exception: :param ttl: :return: """ try: app.logger.debug("Logging exception from {} with location: {} to the database.".format(s...
Method to store exceptions in the database. :param source: :param location: :param exception: :param ttl: :return:
store_exception
python
Netflix/security_monkey
security_monkey/datastore.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/datastore.py
Apache-2.0
def delete_item_revisions_by_date(start_date, end_date): """This will remove all item revisions per the following strategy: 0. Iterate over every item. 1. Get a list of all item revisions within the date range provided. 2. If the revisions on the date selected refers to ALL revisions of a given item, th...
This will remove all item revisions per the following strategy: 0. Iterate over every item. 1. Get a list of all item revisions within the date range provided. 2. If the revisions on the date selected refers to ALL revisions of a given item, then delete the item outright, and skip to the next item. 3. O...
delete_item_revisions_by_date
python
Netflix/security_monkey
security_monkey/datastore.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/datastore.py
Apache-2.0
def detect_change(item, account, technology, complete_hash, durable_hash): """ Checks the database to see if the latest revision of the specified item matches what Security Monkey has pulled from AWS. Note: this method makes no distinction between a changed item, a new item, a deleted item, or one ...
Checks the database to see if the latest revision of the specified item matches what Security Monkey has pulled from AWS. Note: this method makes no distinction between a changed item, a new item, a deleted item, or one that only has changes in the ephemeral section. :param item: dict describing ...
detect_change
python
Netflix/security_monkey
security_monkey/datastore_utils.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/datastore_utils.py
Apache-2.0
def crossdomain(allowed_origins=None, methods=None, headers=None, max_age=21600, attach_to_all=True, automatic_options=True): """ Add the necessary headers for CORS requests. Copied from http://flask.pocoo.org/snippets/56/ with minor modifications. From that URL: ...
Add the necessary headers for CORS requests. Copied from http://flask.pocoo.org/snippets/56/ with minor modifications. From that URL: This snippet by Armin Ronacher can be used freely for anything you like. Consider it public domain.
crossdomain
python
Netflix/security_monkey
security_monkey/decorators.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/decorators.py
Apache-2.0
def add_or_update_issue(self, issue, technology, account, count): """ Searches for existing tickets based on the summary. If one exists, it will update the count and preserve any leading description text. If not, it will create a ticket. """ summary = '{0} - {1} - {2}'.format(issue, technology, ...
Searches for existing tickets based on the summary. If one exists, it will update the count and preserve any leading description text. If not, it will create a ticket.
add_or_update_issue
python
Netflix/security_monkey
security_monkey/jirasync.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/jirasync.py
Apache-2.0
def sync_issues(self, accounts=None, tech_name=None): """ Runs add_or_update_issue for every AuditorSetting, filtered by technology and accounts, if provided. """ query = AuditorSettings.query.join( (Technology, Technology.id == AuditorSettings.tech_id) ).join( (A...
Runs add_or_update_issue for every AuditorSetting, filtered by technology and accounts, if provided.
sync_issues
python
Netflix/security_monkey
security_monkey/jirasync.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/jirasync.py
Apache-2.0
def delete_revisions_by_date(start_date, end_date): """Deletes item revisions within between the dates provided. Dates must be provided in YYYY-MM-DD formats.""" try: start = datetime.strptime(start_date, "%Y-%m-%d") end = datetime.strptime(end_date, "%Y-%m-%d") except Exception: # noqa ...
Deletes item revisions within between the dates provided. Dates must be provided in YYYY-MM-DD formats.
delete_revisions_by_date
python
Netflix/security_monkey
security_monkey/manage.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/manage.py
Apache-2.0
def get_monitors(account_name, monitor_names, debug=False): """ Returns a list of monitors in the correct audit order which apply to one or more of the accounts. """ requested_mons = [] account = get_account_by_name(account_name) account_manager = account_registry.get(account.account_type.na...
Returns a list of monitors in the correct audit order which apply to one or more of the accounts.
get_monitors
python
Netflix/security_monkey
security_monkey/monitors.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/monitors.py
Apache-2.0
def get_monitors_and_dependencies(account, monitor_names, debug=False): """ Returns a list of monitors in the correct audit order which apply to one or more of the accounts plus any monitors with audit results dependent on the ones requested. """ monitors = all_monitors(account, debug) monit...
Returns a list of monitors in the correct audit order which apply to one or more of the accounts plus any monitors with audit results dependent on the ones requested.
get_monitors_and_dependencies
python
Netflix/security_monkey
security_monkey/monitors.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/monitors.py
Apache-2.0
def all_monitors(account_name, debug=False): """ Returns a list of all monitors in the correct audit order which apply to one or more of the accounts. """ monitor_dict = {} account = get_account_by_name(account_name) account_manager = account_registry.get(account.account_type.name)() fo...
Returns a list of all monitors in the correct audit order which apply to one or more of the accounts.
all_monitors
python
Netflix/security_monkey
security_monkey/monitors.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/monitors.py
Apache-2.0
def _find_dependent_monitors(monitors, monitor_names): """ Used to find all the monitors that re dependent on those in the original monitor_names to the list. """ last_iteration_count = 0 while len(monitor_names) != last_iteration_count: # May need to loop through the list mutiple times ...
Used to find all the monitors that re dependent on those in the original monitor_names to the list.
_find_dependent_monitors
python
Netflix/security_monkey
security_monkey/monitors.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/monitors.py
Apache-2.0
def get_monitors_to_run(self, account, interval=None): """ Return a list of (watcher, auditor) enabled for a specific account, optionally filtered by interval time """ mons = [] if interval: for monitor in self.all_monitors: if monitor.watcher ...
Return a list of (watcher, auditor) enabled for a specific account, optionally filtered by interval time
get_monitors_to_run
python
Netflix/security_monkey
security_monkey/reporter.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/reporter.py
Apache-2.0
def get_items_to_audit(self, watcher, auditor, watchers_with_changes): """ Returns the items that have changed if there are no changes in dependencies, otherwise returns all slurped items for reauditing """ watcher.full_audit_list = None if auditor.support_watcher_indexes...
Returns the items that have changed if there are no changes in dependencies, otherwise returns all slurped items for reauditing
get_items_to_audit
python
Netflix/security_monkey
security_monkey/reporter.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/reporter.py
Apache-2.0
def prep_for_slurp(self): """ Should be run before slurp is run to grab the IgnoreList. """ query = IgnoreListEntry.query query = query.join((Technology, Technology.id == IgnoreListEntry.tech_id)) self.ignore_list = query.filter(Technology.name == self.index).all()
Should be run before slurp is run to grab the IgnoreList.
prep_for_slurp
python
Netflix/security_monkey
security_monkey/watcher.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/watcher.py
Apache-2.0
def prep_for_batch_slurp(self): """ Should be run before batching slurps to set the current account (and region). This will load the DB objects for account and technology for where we are currently at in the process. :return: """ self.prep_for_slurp() # Which ac...
Should be run before batching slurps to set the current account (and region). This will load the DB objects for account and technology for where we are currently at in the process. :return:
prep_for_batch_slurp
python
Netflix/security_monkey
security_monkey/watcher.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/watcher.py
Apache-2.0
def check_ignore_list(self, name): """ See if the given item has a name flagging it to be ignored by security_monkey. """ for result in self.ignore_list: # Empty prefix comes back as None instead of an empty string ... prefix = result.prefix or "" if n...
See if the given item has a name flagging it to be ignored by security_monkey.
check_ignore_list
python
Netflix/security_monkey
security_monkey/watcher.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/watcher.py
Apache-2.0
def slurp_exception(self, location=None, exception=None, exception_map={}, source="watcher"): """ Logs any exceptions that happen in slurp and adds them to the exception_map using their location as the key. The location is a tuple in the form: (technology, account, region, item_name) th...
Logs any exceptions that happen in slurp and adds them to the exception_map using their location as the key. The location is a tuple in the form: (technology, account, region, item_name) that describes the object where the exception occurred. Location can also exclude an item_name if t...
slurp_exception
python
Netflix/security_monkey
security_monkey/watcher.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/watcher.py
Apache-2.0
def location_in_exception_map(self, item_location, exception_map={}): """ Determines whether a given location is covered by an exception already in the exception map. Item location: (self.index, self.account, self.region, self.name) exception Maps: (index, account, region,...
Determines whether a given location is covered by an exception already in the exception map. Item location: (self.index, self.account, self.region, self.name) exception Maps: (index, account, region, name) (index, account, region) ...
location_in_exception_map
python
Netflix/security_monkey
security_monkey/watcher.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/watcher.py
Apache-2.0
def find_deleted(self, previous=[], current=[], exception_map={}): """ Find any items that have been deleted since the last run of the watcher. Add these items to the deleted_items list. """ prev_map = {item.location(): item for item in previous} curr_map = {item.location...
Find any items that have been deleted since the last run of the watcher. Add these items to the deleted_items list.
find_deleted
python
Netflix/security_monkey
security_monkey/watcher.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/watcher.py
Apache-2.0
def find_new(self, previous=[], current=[]): """ Find any new objects that have been created since the last run of the watcher. Add these items to the created_items list. """ prev_map = {item.location(): item for item in previous} curr_map = {item.location(): item for ite...
Find any new objects that have been created since the last run of the watcher. Add these items to the created_items list.
find_new
python
Netflix/security_monkey
security_monkey/watcher.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/watcher.py
Apache-2.0
def find_modified(self, previous=[], current=[], exception_map={}): """ Find any objects that have been changed since the last run of the watcher. Add these items to the changed_items list. """ prev_map = {item.location(): item for item in previous} curr_map = {item.locat...
Find any objects that have been changed since the last run of the watcher. Add these items to the changed_items list.
find_modified
python
Netflix/security_monkey
security_monkey/watcher.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/watcher.py
Apache-2.0
def find_changes(self, current=None, exception_map=None): """ Identify changes between the configuration I have and what I had last time the watcher ran. This ignores any account/region which caused an exception during slurp. """ current = current or [] exception_...
Identify changes between the configuration I have and what I had last time the watcher ran. This ignores any account/region which caused an exception during slurp.
find_changes
python
Netflix/security_monkey
security_monkey/watcher.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/watcher.py
Apache-2.0
def issues_found(self): """ Runs through any changed items to see if any have issues. :return: boolean whether any changed items have issues """ has_issues = False has_new_issue = False has_unjustified_issue = False for item in self.created_items + self.ch...
Runs through any changed items to see if any have issues. :return: boolean whether any changed items have issues
issues_found
python
Netflix/security_monkey
security_monkey/watcher.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/watcher.py
Apache-2.0
def from_items(cls, old_item=None, new_item=None, source_watcher=None): """ Create ChangeItem from two separate items. :return: An instance of ChangeItem """ if not old_item and not new_item: return valid_item = new_item if new_item else old_item audit...
Create ChangeItem from two separate items. :return: An instance of ChangeItem
from_items
python
Netflix/security_monkey
security_monkey/watcher.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/watcher.py
Apache-2.0
def description(self): """ Provide an HTML description of the object for change emails and the Jinja templates. :return: string of HTML describing the object. """ jenv = get_jinja_env() template = jenv.get_template('jinja_change_item.html') body = template.render(...
Provide an HTML description of the object for change emails and the Jinja templates. :return: string of HTML describing the object.
description
python
Netflix/security_monkey
security_monkey/watcher.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/watcher.py
Apache-2.0
def ensure_item_has_latest_revision_id(item): """ This is a function that will attempt to correct an item that does not have a latest revision id set. There are two outcomes that result: 1. If there is a revision with the item id, find the latest revision, and update the item such that it point t...
This is a function that will attempt to correct an item that does not have a latest revision id set. There are two outcomes that result: 1. If there is a revision with the item id, find the latest revision, and update the item such that it point to that latest revision. 2. If not -- then we will...
ensure_item_has_latest_revision_id
python
Netflix/security_monkey
security_monkey/watcher.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/watcher.py
Apache-2.0
def doRollover(self): """ Override base class method to make the new log file group writable. """ # Rotate the file first. handlers.RotatingFileHandler.doRollover(self) # Add group write to the current permissions. try: currMode = os.stat(self.baseFil...
Override base class method to make the new log file group writable.
doRollover
python
Netflix/security_monkey
security_monkey/__init__.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/__init__.py
Apache-2.0
def setup_logging(): """ Logging in security_monkey can be configured in two ways. 1) Vintage: Set LOG_FILE and LOG_LEVEL in your config. LOG_FILE will default to stderr if no value is supplied. LOG_LEVEL will default to DEBUG if no value is supplied. LOG_LEVEL = "DEBUG" LOG_FILE =...
Logging in security_monkey can be configured in two ways. 1) Vintage: Set LOG_FILE and LOG_LEVEL in your config. LOG_FILE will default to stderr if no value is supplied. LOG_LEVEL will default to DEBUG if no value is supplied. LOG_LEVEL = "DEBUG" LOG_FILE = "/var/log/security_monkey/s...
setup_logging
python
Netflix/security_monkey
security_monkey/__init__.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/__init__.py
Apache-2.0
def lookup_account_by_identifier(self, identifier): """ Overrides the lookup to also check the number for backwards compatibility """ account = super(GCPAccountManager, self).lookup_account_by_identifier(identifier) return account
Overrides the lookup to also check the number for backwards compatibility
lookup_account_by_identifier
python
Netflix/security_monkey
security_monkey/account_managers/gcp_account.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/account_managers/gcp_account.py
Apache-2.0
def _populate_account(self, account, account_type, name, active, third_party, notes, identifier, custom_fields=None): """ # TODO(supertom): look into this. Overrides create and update to also save the number, s3_name and role_name for backwards compatibility ...
# TODO(supertom): look into this. Overrides create and update to also save the number, s3_name and role_name for backwards compatibility
_populate_account
python
Netflix/security_monkey
security_monkey/account_managers/gcp_account.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/account_managers/gcp_account.py
Apache-2.0
def check_upcoming_expiration(self, cert_item): """ alert when a cert's expiration is within 30 days """ expiration = cert_item.config.get('NotAfter', None) if expiration: expiration = parser.parse(expiration) now = expiration.now(tzutc()) time...
alert when a cert's expiration is within 30 days
check_upcoming_expiration
python
Netflix/security_monkey
security_monkey/auditors/acm.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/acm.py
Apache-2.0
def check_future_expiration(self, cert_item): """ alert when a cert's expiration is within 60 days """ expiration = cert_item.config.get('NotAfter', None) if expiration: expiration = parser.parse(expiration) now = expiration.now(tzutc()) time_t...
alert when a cert's expiration is within 60 days
check_future_expiration
python
Netflix/security_monkey
security_monkey/auditors/acm.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/acm.py
Apache-2.0
def _get_listener_ports_and_protocols(self, item): """ "ListenerDescriptions": [ { "LoadBalancerPort": 80, "Protocol": "HTTP", }, { "Protocol": "HTTPS", "LoadBalancerPort": 443, } """ ...
"ListenerDescriptions": [ { "LoadBalancerPort": 80, "Protocol": "HTTP", }, { "Protocol": "HTTPS", "LoadBalancerPort": 443, }
_get_listener_ports_and_protocols
python
Netflix/security_monkey
security_monkey/auditors/elb.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/elb.py
Apache-2.0
def check_internet_scheme(self, elb_item): """ alert when an ELB has an "internet-facing" scheme and a security group containing ingress issues on a listener port. - Friendly Cross Account - Thirdparty Cross Account - Unknown Access - Internet Accessible ...
alert when an ELB has an "internet-facing" scheme and a security group containing ingress issues on a listener port. - Friendly Cross Account - Thirdparty Cross Account - Unknown Access - Internet Accessible
check_internet_scheme
python
Netflix/security_monkey
security_monkey/auditors/elb.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/elb.py
Apache-2.0
def check_listener_reference_policy(self, elb_item): """ alert when an SSL listener is not using the latest reference policy. """ policy_port_map = defaultdict(list) for listener in elb_item.config.get('ListenerDescriptions', []): if len(listener.get('PolicyNames', []...
alert when an SSL listener is not using the latest reference policy.
check_listener_reference_policy
python
Netflix/security_monkey
security_monkey/auditors/elb.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/elb.py
Apache-2.0
def check_logging(self, elb_item): """ Alert when elb logging is not enabled """ logging = elb_item.config.get('Attributes', {}).get('AccessLog', {}) if not logging: self.add_issue(1, Categories.RECOMMENDATION, elb_item, notes='Enable access logs') return ...
Alert when elb logging is not enabled
check_logging
python
Netflix/security_monkey
security_monkey/auditors/elb.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/elb.py
Apache-2.0
def _process_custom_listener_policy(self, policy_name, policy, ports, elb_item): """ Alerts on: sslv2 sslv3 missing server order preference deprecated ciphers """ if policy.get('protocols', {}).get('sslv2', None): notes = Catego...
Alerts on: sslv2 sslv3 missing server order preference deprecated ciphers
_process_custom_listener_policy
python
Netflix/security_monkey
security_monkey/auditors/elb.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/elb.py
Apache-2.0
def check_ssl_policy(self, alb): """ ALB SSL Policies are much simpler than ELB (classic) policies. - Custom policies are not allowed. - Try to use ELBSecurityPolicy-2016-08 - Alert on unknown policy or if using ELBSecurityPolicy-TLS-1-0-2015-04 - The ELBSecurityPolicy-20...
ALB SSL Policies are much simpler than ELB (classic) policies. - Custom policies are not allowed. - Try to use ELBSecurityPolicy-2016-08 - Alert on unknown policy or if using ELBSecurityPolicy-TLS-1-0-2015-04 - The ELBSecurityPolicy-2016-08 and ELBSecurityPolicy-2015-05 security...
check_ssl_policy
python
Netflix/security_monkey
security_monkey/auditors/elbv2.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/elbv2.py
Apache-2.0
def check_for_kms_key_rotation(self, kms_item): """ Alert when a KMS key is not configured for rotation This is a AWS CIS Foundations Benchmark audit item (2.8) """ rotation_status = kms_item.config.get('KeyRotationEnabled') if not rotation_status: self.add_is...
Alert when a KMS key is not configured for rotation This is a AWS CIS Foundations Benchmark audit item (2.8)
check_for_kms_key_rotation
python
Netflix/security_monkey
security_monkey/auditors/kms.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/kms.py
Apache-2.0
def check_running_in_vpc(self, redshift_cluster): """ alert when not running in a VPC. """ if not redshift_cluster.config.get('VpcId'): message = "POLICY - Redshift cluster not in VPC." self.add_issue(10, message, redshift_cluster)
alert when not running in a VPC.
check_running_in_vpc
python
Netflix/security_monkey
security_monkey/auditors/redshift.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/redshift.py
Apache-2.0
def check_for_public_zone_with_private_records(self, route53_item): """ alert when a public zone has private records. """ if not route53_item.config.get('zoneprivate'): for r in route53_item.config.get('records'): for regex in self.internal_record_regex: ...
alert when a public zone has private records.
check_for_public_zone_with_private_records
python
Netflix/security_monkey
security_monkey/auditors/route53.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/route53.py
Apache-2.0
def _port_for_rule(self, rule): """ Looks at the from_port and to_port and returns a sane representation. """ phrase = '{direction}:{protocol}:{port}' direction = rule.get('rule_type') protocol = rule['ip_protocol'] port_range = '{0}-{1}'.format(rule['from_port'],...
Looks at the from_port and to_port and returns a sane representation.
_port_for_rule
python
Netflix/security_monkey
security_monkey/auditors/security_group.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/security_group.py
Apache-2.0
def check_securitygroup_ec2_rfc1918(self, sg_item): """ alert if EC2 SG contains RFC1918 CIDRS Deprecated as EC2 Classic is gone. """ tag = "Non-VPC Security Group contains private RFC-1918 CIDR" severity = 5 if sg_item.config.get("vpc_id", None): ret...
alert if EC2 SG contains RFC1918 CIDRS Deprecated as EC2 Classic is gone.
check_securitygroup_ec2_rfc1918
python
Netflix/security_monkey
security_monkey/auditors/security_group.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/security_group.py
Apache-2.0
def _check_cross_account(self, item, key, recorder, direction='ingress', severity=10): """ Inspects each rule to look for cross account access. Called by: - check_friendly_cross_account_* - check_thirdparty_cross_account_* - check_unknown_cross_account_* ...
Inspects each rule to look for cross account access. Called by: - check_friendly_cross_account_* - check_thirdparty_cross_account_* - check_unknown_cross_account_* Looks at both CIDR rules and rules referencing other security groups. Args: ...
_check_cross_account
python
Netflix/security_monkey
security_monkey/auditors/security_group.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/security_group.py
Apache-2.0
def _check_internet_accessible(self, item, direction='ingress', severity=10): """ Make sure the SG does not contain any 0.0.0.0/0 or ::/0 rules. Called by: check_internet_accessible_ingress() check_internet_accessible_egress() Returns: `none` ...
Make sure the SG does not contain any 0.0.0.0/0 or ::/0 rules. Called by: check_internet_accessible_ingress() check_internet_accessible_egress() Returns: `none`
_check_internet_accessible
python
Netflix/security_monkey
security_monkey/auditors/security_group.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/security_group.py
Apache-2.0
def check_verified(self, ses_item): """ alert when an SES identity is not verified. """ if not ses_item.config.get('verified'): self.add_issue(1, 'SES Identity Not Verified.', ses_item)
alert when an SES identity is not verified.
check_verified
python
Netflix/security_monkey
security_monkey/auditors/ses.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/ses.py
Apache-2.0
def check_subscriptions_crossaccount(self, item): """ "subscriptions": [ { "Owner": "020202020202", "Endpoint": "someemail@example.com", "Protocol": "email", "TopicArn": ARN_PREFIX + ":sns:" + AWS_DEFAULT_REGION + ":020202020202:somes...
"subscriptions": [ { "Owner": "020202020202", "Endpoint": "someemail@example.com", "Protocol": "email", "TopicArn": ARN_PREFIX + ":sns:" + AWS_DEFAULT_REGION + ":020202020202:somesnstopic", "SubscriptionArn": ARN_PREFIX + ":sn...
check_subscriptions_crossaccount
python
Netflix/security_monkey
security_monkey/auditors/sns.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/sns.py
Apache-2.0
def _port_range_exists(self, allowed_list, error_cat='ALLOWED'): """ Check to see if a port range exists in the allowed field. """ errors = [] if allowed_list: for allowed in allowed_list: ports = allowed.get('ports', None) if ports: ...
Check to see if a port range exists in the allowed field.
_port_range_exists
python
Netflix/security_monkey
security_monkey/auditors/gcp/gce/firewall.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/gcp/gce/firewall.py
Apache-2.0
def _target_tags_valid(self, target_tags, error_cat='TARGET_TAGS'): """ Check to see if target tags are present. """ errors = [] if not target_tags: ae = make_audit_issue( error_cat, 'FOUND', 'NOT') errors.append(ae) return errors
Check to see if target tags are present.
_target_tags_valid
python
Netflix/security_monkey
security_monkey/auditors/gcp/gce/firewall.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/gcp/gce/firewall.py
Apache-2.0
def _source_ranges_open(self, source_ranges, error_cat='SOURCE_RANGES'): """ Check to see if the source range field is set to allow all traffic """ errors = [] open_range = '0.0.0.0/0' for source_range in source_ranges: if source_range == open_range: ...
Check to see if the source range field is set to allow all traffic
_source_ranges_open
python
Netflix/security_monkey
security_monkey/auditors/gcp/gce/firewall.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/gcp/gce/firewall.py
Apache-2.0
def inspect_target_tags(self, item): """ Driver for Target Tags. Calls helpers as needed. return: (bool, [list of AuditIssues]) """ errors = [] target_tags = item.config.get('TargetTags', None) err = self._target_tags_valid(target_tags) errors.extend(err...
Driver for Target Tags. Calls helpers as needed. return: (bool, [list of AuditIssues])
inspect_target_tags
python
Netflix/security_monkey
security_monkey/auditors/gcp/gce/firewall.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/gcp/gce/firewall.py
Apache-2.0
def inspect_source_ranges(self, item): """ Driver for Source Ranges. Calls helpers as needed. return: (bool, [list of AuditIssues]) """ errors = [] source_ranges = item.config.get('SourceRanges', None) if source_ranges: err = self._source_ranges_open...
Driver for Source Ranges. Calls helpers as needed. return: (bool, [list of AuditIssues])
inspect_source_ranges
python
Netflix/security_monkey
security_monkey/auditors/gcp/gce/firewall.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/gcp/gce/firewall.py
Apache-2.0
def inspect_allowed(self, item): """ Driver for Allowed field (protocol/ports list). Calls helpers as needed. return: (bool, [list of AuditIssues]) """ errors = [] err = self._port_range_exists(item.config.get('Allowed')) errors.extend(err) if err else None ...
Driver for Allowed field (protocol/ports list). Calls helpers as needed. return: (bool, [list of AuditIssues])
inspect_allowed
python
Netflix/security_monkey
security_monkey/auditors/gcp/gce/firewall.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/gcp/gce/firewall.py
Apache-2.0
def _legacy_exists(self, network, error_cat='NET'): """ Look for legacy-style (non-subnetwork style) network. return: [list of AuditIssues] """ errors = [] subnetworks = network.get('Subnetworks', None) auto_create_subnetworks = network.get( 'AutoCrea...
Look for legacy-style (non-subnetwork style) network. return: [list of AuditIssues]
_legacy_exists
python
Netflix/security_monkey
security_monkey/auditors/gcp/gce/network.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/gcp/gce/network.py
Apache-2.0
def inspect_network(self, item): """ Driver for Network. Calls helpers as needed. return: (bool, [list of AuditIssues]) """ errors = [] network = item.config err = self._legacy_exists(network) errors.extend(err) if err else None if errors: ...
Driver for Network. Calls helpers as needed. return: (bool, [list of AuditIssues])
inspect_network
python
Netflix/security_monkey
security_monkey/auditors/gcp/gce/network.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/gcp/gce/network.py
Apache-2.0
def _acl_allusers_exists(self, acl_list, error_cat='ACL'): """ Looks for allUsers in acl. return: [list of AuditIssues] """ allusers = 'allUsers' errors = [] for acl in acl_list: entity = acl.get('entity') role = acl.get('role') ...
Looks for allUsers in acl. return: [list of AuditIssues]
_acl_allusers_exists
python
Netflix/security_monkey
security_monkey/auditors/gcp/gcs/bucket.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/gcp/gcs/bucket.py
Apache-2.0
def _acl_max_owners(self, acl_list, error_cat='ACL'): """ Looks for Max OWNERS in acl. return: [list of AuditIssues] """ errors = [] if self.gcp_config.MAX_OWNERS_PER_BUCKET: owner = 'OWNER' count = 0 for acl in acl_list: ...
Looks for Max OWNERS in acl. return: [list of AuditIssues]
_acl_max_owners
python
Netflix/security_monkey
security_monkey/auditors/gcp/gcs/bucket.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/gcp/gcs/bucket.py
Apache-2.0
def _cors_method(self, cors_list, error_cat='CORS'): """ Looks at the CORS method. Anything other than GET is flagged. return: [list of AuditIssues] """ errors = [] for cors in cors_list: methods = cors.get('method') for method in methods: ...
Looks at the CORS method. Anything other than GET is flagged. return: [list of AuditIssues]
_cors_method
python
Netflix/security_monkey
security_monkey/auditors/gcp/gcs/bucket.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/gcp/gcs/bucket.py
Apache-2.0
def inspect_acl(self, item): """ Driver for Bucket ACL. Calls helpers as needed. return: (bool, [list of AuditIssues]) """ acl = item.config.get('Acl') errors_acl = [] if acl: err = self._acl_allusers_exists(acl, 'ACL') errors_acl.extend(e...
Driver for Bucket ACL. Calls helpers as needed. return: (bool, [list of AuditIssues])
inspect_acl
python
Netflix/security_monkey
security_monkey/auditors/gcp/gcs/bucket.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/gcp/gcs/bucket.py
Apache-2.0
def inspect_default_object_acl(self, item): """ Driver for Default Object ACL. Calls helpers as needed. return: (bool, [list of AuditIssues]) """ def_obj_acl = item.config.get('DefaultObjectAcl') errors_acl = [] if def_obj_acl: err = self._acl_alluser...
Driver for Default Object ACL. Calls helpers as needed. return: (bool, [list of AuditIssues])
inspect_default_object_acl
python
Netflix/security_monkey
security_monkey/auditors/gcp/gcs/bucket.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/gcp/gcs/bucket.py
Apache-2.0
def inspect_cors(self, item): """ Driver for CORS field. Calls helpers as needed. return: (bool, [list of AuditIssues]) """ cors = item.config.get('Cors') if cors: errors = [] err = self._cors_method(cors) errors.extend(err) if err els...
Driver for CORS field. Calls helpers as needed. return: (bool, [list of AuditIssues])
inspect_cors
python
Netflix/security_monkey
security_monkey/auditors/gcp/gcs/bucket.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/gcp/gcs/bucket.py
Apache-2.0
def check_cors(self, item): """ Check CORS field. CORS policy is set with: gsutil cors set /tmp/cors.json gs://your-bucket """ (ok, errors) = self.inspect_cors(item) process_issues(self, ok, errors, item)
Check CORS field. CORS policy is set with: gsutil cors set /tmp/cors.json gs://your-bucket
check_cors
python
Netflix/security_monkey
security_monkey/auditors/gcp/gcs/bucket.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/gcp/gcs/bucket.py
Apache-2.0
def _max_keys(self, key_count, error_cat='SA'): """ Alert when a service account has too many keys. return: [list of AuditIssues] """ errors = [] if key_count > self.gcp_config.MAX_SERVICEACCOUNT_KEYS: ae = make_audit_issue( error_cat, 'MAX', ...
Alert when a service account has too many keys. return: [list of AuditIssues]
_max_keys
python
Netflix/security_monkey
security_monkey/auditors/gcp/iam/serviceaccount.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/gcp/iam/serviceaccount.py
Apache-2.0
def _actor_role(self, policies, error_cat='SA'): """ Determine if a serviceaccount actor is specified. return: [list of AuditIssues] """ errors = [] for policy in policies: role = policy.get('Role') if role and role == 'iam.serviceAccountActor': ...
Determine if a serviceaccount actor is specified. return: [list of AuditIssues]
_actor_role
python
Netflix/security_monkey
security_monkey/auditors/gcp/iam/serviceaccount.py
https://github.com/Netflix/security_monkey/blob/master/security_monkey/auditors/gcp/iam/serviceaccount.py
Apache-2.0