Пример #1
0
 def __populate_networks_for_organization(self,
                                          organization=None,
                                          user_string=None,
                                          count=2):
     """
     Populate the given organization with networks.
     :param organization: The organization to add networks to.
     :param user_string: A string representing the user that is being populated.
     :param count: The number of networks to add to the organization.
     :return: The newly-created networks.
     """
     network_ips = set()
     while True:
         network_ips.add(WsFaker.get_ipv4_address())
         if len(network_ips) == count:
             break
     new_networks = []
     for index, network_ip in enumerate(network_ips):
         new_network = organization.networks.create(
             address=network_ip,
             mask_length=24,
             name="Test Network %s" % (index, ),
             scanning_enabled=True,
         )
         self.__populate_ip_addresses_for_network(network=new_network,
                                                  user_string=user_string)
         new_networks.append(new_network)
     return new_networks
Пример #2
0
 def create_dummy(cls):
     from lib import WsFaker
     start_time = WsFaker.get_past_time(minutes=20)
     return LoginAttemptModel(
         ip_address=WsFaker.get_ipv4_address(),
         user_agent=WsFaker.get_user_agent(),
         attempt_date=start_time,
     )
Пример #3
0
 def _populate_dummy(cls, to_populate):
     from lib import WsFaker
     to_populate.network_uuid = WsFaker.create_uuid()
     to_populate.network_address = WsFaker.get_ipv4_address()
     to_populate.network_name = WsFaker.get_network_name()
     to_populate.network_mask_length = WsFaker.get_random_int(minimum=1, maximum=32)
     to_populate.network_cidr_range = "%s/%s" % (to_populate.network_address, to_populate.network_mask_length)
     to_populate.network_added_by = WsFaker.get_word()
     return to_populate
Пример #4
0
 def _populate_dummy(cls, to_populate):
     from lib import WsFaker, RandomHelper
     to_populate.uses_wordpress = RandomHelper.flip_coin()
     to_populate.uses_iss = RandomHelper.flip_coin()
     to_populate.uses_apache = RandomHelper.flip_coin()
     to_populate.uses_nginx = RandomHelper.flip_coin()
     to_populate.total_header_count = WsFaker.get_random_int(minimum=1,
                                                             maximum=500)
     to_populate.unique_header_count = WsFaker.get_random_int(minimum=1,
                                                              maximum=500)
     to_populate.server_headers = WsFaker.get_server_header_values()
     to_populate.transactions_count = WsFaker.get_random_int(minimum=1,
                                                             maximum=500)
     to_populate.ok_count = WsFaker.get_random_int(minimum=1, maximum=500)
     to_populate.has_ok = to_populate.ok_count > 0
     to_populate.redirect_count = WsFaker.get_random_int(minimum=1,
                                                         maximum=500)
     to_populate.has_redirect = to_populate.redirect_count > 0
     to_populate.client_error_count = WsFaker.get_random_int(minimum=1,
                                                             maximum=500)
     to_populate.has_client_error = to_populate.client_error_count > 0
     to_populate.server_error_count = WsFaker.get_random_int(minimum=1,
                                                             maximum=500)
     to_populate.has_server_error = to_populate.server_error_count > 0
     to_populate.total_resource_size = WsFaker.get_random_int(
         minimum=100000, maximum=500000)
     to_populate.uses_tomcat_management_portal = RandomHelper.flip_coin()
     to_populate.has_screenshots = RandomHelper.flip_coin()
     to_populate.screenshots_count = WsFaker.get_random_int(minimum=1,
                                                            maximum=10)
     to_populate.main_screenshot_s3_bucket = WsFaker.get_s3_bucket()
     to_populate.main_screenshot_s3_key = WsFaker.get_s3_key()
     to_populate.response_count = WsFaker.get_random_int(minimum=1,
                                                         maximum=10)
     to_populate.redirect_301_count = WsFaker.get_random_int(minimum=1,
                                                             maximum=10)
     to_populate.redirect_302_count = WsFaker.get_random_int(minimum=1,
                                                             maximum=10)
     to_populate.all_responses_redirects = RandomHelper.flip_coin()
     to_populate.all_responses_server_errors = RandomHelper.flip_coin()
     to_populate.all_responses_client_errors = RandomHelper.flip_coin()
     to_populate.response_statuses = WsFaker.get_http_response_statuses()
     to_populate.hostname_resolves = RandomHelper.flip_coin()
     to_populate.resolved_ip_matches_hostname = RandomHelper.flip_coin()
     to_populate.response_content_types = WsFaker.get_response_content_types(
     )
     to_populate.www_authenticate_headers = WsFaker.get_words()
     to_populate.has_www_authenticate_headers = RandomHelper.flip_coin()
     to_populate.has_basic_auth = RandomHelper.flip_coin()
     to_populate.has_digest_auth = RandomHelper.flip_coin()
     to_populate.has_ntlm_auth = RandomHelper.flip_coin()
     to_populate.basic_auth_realms = WsFaker.get_words()
     to_populate.has_server_headers = RandomHelper.flip_coin()
     to_populate.has_multiple_server_headers = RandomHelper.flip_coin()
     to_populate.all_responses_not_found = RandomHelper.flip_coin()
     to_populate.resolved_ip_address = WsFaker.get_ipv4_address()
     to_populate.ssl_certificate_cname = WsFaker.get_domain_name()
     to_populate.ssl_certificate_expired = RandomHelper.flip_coin()
     to_populate.ssl_certificate_is_valid = RandomHelper.flip_coin()
     to_populate.ssl_certificate_start_time = WsFaker.get_time_in_past()
     to_populate.ssl_certificate_invalid_time = WsFaker.get_time_in_future()
     to_populate.scan_completed_at = DatetimeHelper.now()
     to_populate.hostname_is_ip_address = RandomHelper.flip_coin()
     to_populate.has_ssl_certificate_data = RandomHelper.flip_coin()
     to_populate.ssl_certificate_md5_digest = WsFaker.get_md5_string()
     to_populate.open_ports = WsFaker.get_web_app_open_ports()
     to_populate.landing_header_redirect_location = WsFaker.get_url()
     to_populate.landing_meta_refresh_location = WsFaker.get_url()
     to_populate.landing_response_status = WsFaker.get_http_response_status(
     )
     to_populate.landing_title = " ".join(WsFaker.get_words())
     to_populate.local_login_form_count = WsFaker.get_random_int()
     to_populate.local_login_form_https_count = WsFaker.get_random_int()
     to_populate.remote_login_form_count = WsFaker.get_random_int()
     to_populate.remote_login_form_https_count = WsFaker.get_random_int()
     to_populate.user_agent_fingerprints = WsFaker.get_user_agent_fingerprints(
     )
     return to_populate
Пример #5
0
 def _populate_dummy(cls, to_populate):
     from lib import WsFaker
     to_populate.ip_address_uuid = WsFaker.create_uuid()
     to_populate.ip_address = WsFaker.get_ipv4_address()
     to_populate.ip_address_type = WsFaker.get_ip_address_type()
     return to_populate