class AuthDBValidator(object): adjuster_prefix = 'adjust_' data_spec = AuthDBDataSpec() # base adjuster methods adjust_to_lowercase = make_adjuster_applying_callable(to_lowercase) adjust_lowercase_only = make_adjuster_applying_callable(check_if_lowercase) adjust_ascii_only_to_unicode_stripped = make_adjuster_applying_callable( ascii_only_to_unicode_stripped) adjust_stripped = make_adjuster_applying_callable(to_stripped) adjust_ldap_safe = make_adjuster_applying_callable(make_val_ldap_safe) adjust_json_serializable = make_adjuster_applying_callable(make_json_serializable) # adjust_json_bool_vals = make_adjuster_applying_callable(make_json_key_to_bool) adjust_valid_cert_serial_number = make_adjuster_applying_callable(validate_cert_serial_number) # adjuster methods used for specific columns adjust_org_id = chained( adjust_ascii_only_to_unicode_stripped, adjust_ldap_safe, make_adjuster_using_data_spec('org_id')) adjust_asn = make_adjuster_using_data_spec('asn') adjust_cc = chained( adjust_stripped, make_adjuster_using_data_spec('cc')) adjust_email_notifications_language = chained( adjust_stripped, make_adjuster_using_data_spec('cc')) adjust_request_parameters = chained( adjust_json_serializable, adjust_ascii_only_to_unicode_stripped, # adjust_json_bool_vals, ) adjust_inside_request_parameters = adjust_request_parameters adjust_search_request_parameters = adjust_request_parameters adjust_threats_request_parameters = adjust_request_parameters adjust_email = chained( adjust_ascii_only_to_unicode_stripped, make_adjuster_using_data_spec('email')) adjust_notification_time = make_adjuster_using_data_spec('time_simple') adjust_fqdn = chained( adjust_stripped, make_adjuster_using_data_spec('fqdn')) adjust_ip_network = chained( adjust_stripped, make_adjuster_using_data_spec('ip_network')) adjust_url = chained( adjust_stripped, make_adjuster_using_data_spec('url_regexed')) adjust_criteria_name_name = adjust_ascii_only_to_unicode_stripped adjust_criteria_category_category = adjust_ascii_only_to_unicode_stripped adjust_extra_id_value = make_adjuster_using_data_spec('extra_id') adjust_org_group_id = chained( adjust_ascii_only_to_unicode_stripped, adjust_ldap_safe) adjust_user_login = chained( adjust_ascii_only_to_unicode_stripped, adjust_ldap_safe, make_adjuster_using_data_spec('user_login')) adjust_component_login = chained( adjust_ascii_only_to_unicode_stripped, adjust_ldap_safe) adjust_source_id = chained( adjust_ldap_safe, make_adjuster_using_data_spec('source')) adjust_anonymized_source_id = adjust_source_id adjust_label = chained( adjust_ldap_safe, adjust_ascii_only_to_unicode_stripped, ) adjust_system_group_name = chained( adjust_ldap_safe, adjust_ascii_only_to_unicode_stripped, ) adjust_serial_hex = chained( adjust_to_lowercase, adjust_valid_cert_serial_number, ) adjust_creator_details = adjust_json_serializable adjust_revocation_comment = adjust_stripped adjust_ca_label = chained( adjust_lowercase_only, adjust_ascii_only_to_unicode_stripped, adjust_ldap_safe, )
class AuthDBSimplifiedValidators(object): VALIDATOR_METHOD_PREFIX = 'validator_for__' data_spec = _AuthDBValidatorsSimplifiedDataSpec() # The following methods are used to validate values for specific # Auth DB columns, identified by names that are based on one of the # following two patterns: # # (1) *qualified*: `validator_for__<table name>__<column name>`. # (2) *unqualified* (aka *generic*): `validator_for__<column name>`, # # To find the validator appropriate for a particular column in a # particular table, the machinery of AuthDBCustomDeclarativeMeta # first tries to find the validator method by the *qualified* name, # and then, if nothing was found, by the *unqualified* name. # (1) *qualified* validator methods: validator_for__email_notification_time__notification_time = ( make_adjuster_using_data_spec('time_hour_minute')) validator_for__criteria_name__name = _adjust_ascii_only_to_unicode_stripped_or_none validator_for__criteria_category__category = chained( _adjust_to_unicode_stripped, make_adjuster_using_data_spec('category')) validator_for__entity_type__label = ( make_adjuster_using_data_spec('entity_type')) validator_for__location_type__label = ( make_adjuster_using_data_spec('location_type')) validator_for__extra_id_type__label = ( make_adjuster_using_data_spec('extra_id_type')) validator_for__extra_id__value = ( make_adjuster_using_data_spec('extra_id')) validator_for__registration_request__submitted_on = _adjust_time validator_for__registration_request__modified_on = _adjust_time validator_for__registration_request__email = chained( _adjust_ascii_only_ldap_safe_to_unicode_stripped, make_adjuster_using_data_spec('registration_request_email')) validator_for__registration_request_email_notification_address__email = chained( _adjust_ascii_only_to_unicode, make_adjuster_applying_callable(str.strip), make_adjuster_using_data_spec('registration_request_email')) validator_for__user__login = chained( _adjust_ascii_only_ldap_safe_to_unicode_stripped, make_adjuster_using_data_spec('user_login')) validator_for__component__login = chained( _adjust_ascii_only_ldap_safe_to_unicode_stripped, make_adjuster_using_data_spec('component_login')) validator_for__subsource__label = ( _adjust_ascii_only_ldap_safe_to_unicode_stripped_or_none) validator_for__subsource_group__label = ( _adjust_ascii_only_ldap_safe_to_unicode_stripped_or_none) validator_for__criteria_container__label = ( _adjust_ascii_only_ldap_safe_to_unicode_stripped_or_none) validator_for__system_group__name = ( _adjust_ascii_only_ldap_safe_to_unicode_stripped_or_none) validator_for__cert__serial_hex = chained( _adjust_to_unicode_stripped, make_adjuster_applying_callable(str.lower), make_adjuster_applying_callable(_verified_as_valid_cert_serial_number)) validator_for__cert__creator_details = _adjust_to_json_or_none validator_for__cert__created_on = _adjust_time validator_for__cert__valid_from = _adjust_time validator_for__cert__expires_on = _adjust_time validator_for__cert__revoked_on = _adjust_time validator_for__cert__revocation_comment = chained( _adjust_to_unicode_stripped, _adjust_to_none_if_empty_or_whitespace) validator_for__ca_cert__ca_label = chained( _adjust_ascii_only_ldap_safe_to_unicode_stripped, make_adjuster_applying_callable(_verified_as_ca_label_containing_no_uppercase), _adjust_to_none_if_empty_or_whitespace) # (2) *unqualified* (*generic*) validator methods: validator_for__org_id = chained( _adjust_ascii_only_ldap_safe_to_unicode_stripped, make_adjuster_using_data_spec('org_id')) validator_for__org_group_id = _adjust_ascii_only_ldap_safe_to_unicode_stripped_or_none validator_for__email_notification_language = _adjust_country_code validator_for__email = chained( _adjust_ascii_only_to_unicode, make_adjuster_applying_callable(str.strip), make_adjuster_using_data_spec('email')) validator_for__asn = chained( make_adjuster_applying_callable(ascii_str), _adjust_to_unicode_stripped, make_adjuster_using_data_spec('asn')) validator_for__cc = _adjust_country_code validator_for__fqdn = chained( _adjust_to_unicode_stripped, make_adjuster_using_data_spec('fqdn')) validator_for__ip_network = chained( _adjust_to_unicode_stripped, make_adjuster_using_data_spec('ip_network')) validator_for__url = chained( _adjust_to_unicode_stripped, make_adjuster_using_data_spec('url')) validator_for__source_id = _adjust_source_id validator_for__anonymized_source_id = _adjust_source_id validator_for__certificate = chained( _adjust_ascii_only_to_unicode, _adjust_to_none_if_empty_or_whitespace) validator_for__csr = chained( _adjust_ascii_only_to_unicode, _adjust_to_none_if_empty_or_whitespace) validator_for__ssl_config = chained( _adjust_ascii_only_to_unicode, _adjust_to_none_if_empty_or_whitespace)
class AuthDBValidator(object): adjuster_prefix = 'adjust_' data_spec = AuthDBDataSpec() # base adjuster methods adjust_to_lowercase = make_adjuster_applying_callable(to_lowercase) adjust_ascii_only_to_unicode_stripped = make_adjuster_applying_callable( ascii_only_to_unicode_stripped) adjust_stripped = make_adjuster_applying_callable(to_stripped) adjust_ldap_safe = make_adjuster_applying_callable(make_val_ldap_safe) # adjuster methods used for specific columns adjust_org_id = chained( adjust_ascii_only_to_unicode_stripped, adjust_ldap_safe, make_adjuster_using_data_spec('org_id')) adjust_asn = make_adjuster_using_data_spec('asn') adjust_cc = chained( adjust_stripped, make_adjuster_using_data_spec('cc')) adjust_email_notifications_language = chained( adjust_stripped, make_adjuster_using_data_spec('cc')) adjust_email = chained( adjust_ascii_only_to_unicode_stripped, make_adjuster_using_data_spec('email')) adjust_notification_time = make_adjuster_applying_callable(validate_time_hour_minute_only) adjust_fqdn = chained( adjust_stripped, make_adjuster_using_data_spec('fqdn')) adjust_ip_network = chained( adjust_stripped, make_adjuster_using_data_spec('ip_network')) adjust_url = chained( adjust_stripped, make_adjuster_using_data_spec('url_regexed')) adjust_criteria_name_name = adjust_ascii_only_to_unicode_stripped adjust_criteria_category_category = adjust_ascii_only_to_unicode_stripped adjust_org_group_id = chained( adjust_ascii_only_to_unicode_stripped, adjust_ldap_safe) adjust_user_login = chained( adjust_ascii_only_to_unicode_stripped, adjust_ldap_safe, make_adjuster_using_data_spec('user_login')) adjust_component_login = chained( adjust_ascii_only_to_unicode_stripped, adjust_ldap_safe) adjust_source_id = chained( adjust_ldap_safe, make_adjuster_using_data_spec('source')) adjust_anonymized_source_id = adjust_source_id adjust_label = chained( adjust_ldap_safe, adjust_ascii_only_to_unicode_stripped, ) adjust_system_group_name = chained( adjust_ldap_safe, adjust_ascii_only_to_unicode_stripped, ) adjust_serial_hex = make_adjuster_using_data_spec('hex_number') adjust_revocation_comment = adjust_stripped adjust_request_case_id = adjust_serial_hex adjust_status = adjust_stripped adjust_ca_label = chained( adjust_ascii_only_to_unicode_stripped, adjust_ldap_safe, )
_adjust_ascii_only_ldap_safe_to_unicode_stripped = ( make_adjuster_applying_callable(_ascii_only_ldap_safe_str_strip)) _adjust_ascii_only_ldap_safe_to_unicode_stripped_or_none = chained( make_adjuster_applying_callable(_ascii_only_ldap_safe_str_strip), _adjust_to_none_if_empty_or_whitespace) _adjust_to_json_or_none = ( make_adjuster_applying_callable(_to_json_or_none)) _adjust_country_code = chained( _adjust_to_unicode_stripped, make_adjuster_using_data_spec('cc')) _adjust_source_id = chained( _adjust_ascii_only_ldap_safe_to_unicode_stripped, make_adjuster_using_data_spec('source')) _adjust_time = ( make_adjuster_using_data_spec('time')) class _AuthDBValidatorsSimplifiedDataSpec(BaseDataSpec): org_id = UnicodeField() extra_id = UnicodeField()