Search is not available for this dataset
text
stringlengths
75
104k
def is_exclude_file(filename, exclude): """Return True if file matches exclude pattern.""" base_name = os.path.basename(filename) if base_name.startswith('.'): return True for pattern in exclude: if fnmatch.fnmatch(base_name, pattern): return True if fnmatch.fnmatch...
def match_file(filename, exclude): """Return True if file is okay for modifying/recursing.""" if is_exclude_file(filename, exclude): return False if not os.path.isdir(filename) and not is_python_file(filename): return False return True
def find_files(filenames, recursive, exclude): """Yield filenames.""" while filenames: name = filenames.pop(0) if recursive and os.path.isdir(name): for root, directories, children in os.walk(name): filenames += [os.path.join(root, f) for f in children ...
def _main(argv, standard_out, standard_error): """Return exit status. 0 means no error. """ import argparse parser = argparse.ArgumentParser(description=__doc__, prog='autoflake') parser.add_argument('-c', '--check', action='store_true', help='return error code if change...
def read(self, input_stream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Read the data encoding the ObtainLease response payload and decode it into its constituent parts. Args: input_stream (stream): A data stream containing encoded object data, supporting ...
def write(self, output_stream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Write the data encoding the ObtainLease response payload to a stream. Args: output_stream (stream): A data stream in which to encode object data, supporting a write method; usually a Bytearr...
def write(self, output_stream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Write the data encoding the Cancel request payload to a stream. Args: output_stream (stream): A data stream in which to encode object data, supporting a write method; usually a BytearrayStre...
def read(self, input_stream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Read the data encoding the Cancel response payload and decode it into its constituent parts. Args: input_stream (stream): A data stream containing encoded object data, supporting a rea...
def create(cls, name_value, name_type): ''' Returns a Name object, populated with the given value and type ''' if isinstance(name_value, Name.NameValue): value = name_value elif isinstance(name_value, str): value = cls.NameValue(name_value) els...
def read(self, istream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Read the data encoding the Digest object and decode it into its constituent parts. Args: istream (Stream): A data stream containing encoded object data, supporting a read method; usually a ...
def write(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Write the data encoding the Digest object to a stream. Args: ostream (Stream): A data stream in which to encode object data, supporting a write method; usually a BytearrayStream object. ...
def create(cls, hashing_algorithm=HashingAlgorithmEnum.SHA_256, digest_value=b'', key_format_type=KeyFormatTypeEnum.RAW): """ Construct a Digest object from provided digest values. Args: hashing_algorithm (HashingAlgorithm): An enumeratio...
def read(self, istream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Read the data encoding the ApplicationSpecificInformation object and decode it into its constituent parts. Args: istream (Stream): A data stream containing encoded object data, supporting a...
def write(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Write the data encoding the ApplicationSpecificInformation object to a stream. Args: ostream (Stream): A data stream in which to encode object data, supporting a write method; usually a By...
def create(cls, application_namespace, application_data): """ Construct an ApplicationSpecificInformation object from provided data and namespace values. Args: application_namespace (str): The name of the application namespace. application_data (str): Application...
def read(self, input_stream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Read the data encoding the DerivationParameters struct and decode it into its constituent parts. Args: input_stream (stream): A data stream containing encoded object data, supporting a...
def write(self, output_stream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Write the data encoding the DerivationParameters struct to a stream. Args: output_stream (stream): A data stream in which to encode object data, supporting a write method; usually a Bytearra...
def read(self, input_stream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Read the data encoding the Get request payload and decode it into its constituent parts. Args: input_stream (stream): A data stream containing encoded object data, supporting a read me...
def write(self, output_stream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Write the data encoding the Get request payload to a stream. Args: output_stream (stream): A data stream in which to encode object data, supporting a write method; usually a BytearrayStream ...
def read(self, input_stream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Read the data encoding the Get response payload and decode it into its constituent parts. Args: input_stream (stream): A data stream containing encoded object data, supporting a read m...
def write(self, output_stream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Write the data encoding the Get response payload to a stream. Args: output_stream (stream): A data stream in which to encode object data, supporting a write method; usually a BytearrayStream...
def read(self, input_stream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Read the data encoding the SignatureVerify request payload and decode it into its constituent parts. Args: input_stream (stream): A data stream containing encoded object data, supporti...
def write(self, output_stream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Write the data encoding the SignatureVerify request payload to a stream. Args: output_stream (stream): A data stream in which to encode object data, supporting a write method; usuall...
def read(self, input_stream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Read the data encoding the SignatureVerify response payload and decode it into its constituent parts. Args: input_stream (stream): A data stream containing encoded object data, support...
def process_request(self, request, credential=None): """ Process a KMIP request message. This routine is the main driver of the KmipEngine. It breaks apart and processes the request header, handles any message errors that may result, and then passes the set of request batch item...
def build_error_response(self, version, reason, message): """ Build a simple ResponseMessage with a single error result. Args: version (ProtocolVersion): The protocol version the response should be addressed with. reason (ResultReason): An enumeration cla...
def _process_template_attribute(self, template_attribute): """ Given a kmip.core TemplateAttribute object, extract the attribute value data into a usable dictionary format. """ attributes = {} if len(template_attribute.names) > 0: raise exceptions.ItemNotFoun...
def _get_attributes_from_managed_object(self, managed_object, attr_names): """ Given a kmip.pie object and a list of attribute names, attempt to get all of the existing attribute values from the object. """ attr_factory = attribute_factory.AttributeFactory() retrieved_att...
def _get_attribute_from_managed_object(self, managed_object, attr_name): """ Get the attribute value from the kmip.pie managed object. """ if attr_name == 'Unique Identifier': return str(managed_object.unique_identifier) elif attr_name == 'Name': names = l...
def _set_attributes_on_managed_object(self, managed_object, attributes): """ Given a kmip.pie object and a dictionary of attributes, attempt to set the attribute values on the object. """ for attribute_name, attribute_value in six.iteritems(attributes): object_type = ...
def _set_attribute_on_managed_object(self, managed_object, attribute): """ Set the attribute value on the kmip.pie managed object. """ attribute_name = attribute[0] attribute_value = attribute[1] if self._attribute_policy.is_attribute_multivalued(attribute_name): ...
def get_relevant_policy_section(self, policy_name, group=None): """ Look up the policy corresponding to the provided policy name and group (optional). Log any issues found during the look up. """ policy_bundle = self._operation_policies.get(policy_name) if not policy_bun...
def is_allowed( self, policy_name, session_user, session_group, object_owner, object_type, operation ): """ Determine if object access is allowed for the provided policy and session settings. """ ...
def write(self, output_stream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Write the data encoding the Decrypt request payload to a stream. Args: output_stream (stream): A data stream in which to encode object data, supporting a write method; usually a BytearrayStr...
def read(self, istream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Read the data encoding the RevokeRequestPayload object and decode it into its constituent parts. Args: istream (Stream): A data stream containing encoded object data, supporting a read metho...
def write(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Write the data encoding the RevokeRequestPayload object to a stream. Args: ostream (Stream): A data stream in which to encode object data, supporting a write method; usually a BytearrayStream objec...
def validate(self): """ Error check the attributes of the ActivateRequestPayload object. """ if self.unique_identifier is not None: if not isinstance(self.unique_identifier, attributes.UniqueIdentifier): msg = "invalid unique iden...
def read(self, istream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Read the data encoding the RevokeResponsePayload object and decode it into its constituent parts. Args: istream (Stream): A data stream containing encoded object data, supporting a read meth...
def create(self, secret_type, value=None): """ Create a secret object of the specified type with the given value. Args: secret_type (ObjectType): An ObjectType enumeration specifying the type of secret to create. value (dict): A dictionary containing secr...
def set_setting(self, setting, value): """ Set a specific setting value. This will overwrite the current setting value for the specified setting. Args: setting (string): The name of the setting to set (e.g., 'certificate_path', 'hostname'). Required....
def load_settings(self, path): """ Load configuration settings from the file pointed to by path. This will overwrite all current setting values. Args: path (string): The path to the configuration file containing the settings to load. Required. Raises...
def process_bind_param(self, value, dialect): """ Returns the integer value of the usage mask bitmask. This value is stored in the database. Args: value(list<enums.CryptographicUsageMask>): list of enums in the usage mask dialect(string): SQL dialect ...
def process_result_value(self, value, dialect): """ Returns a new list of enums.CryptographicUsageMask Enums. This converts the integer value into the list of enums. Args: value(int): The integer value stored in the database that is used to create the list of...
def read(self, istream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Read the encoding of the LongInteger from the input stream. Args: istream (stream): A buffer containing the encoded bytes of a LongInteger. Usually a BytearrayStream object. Required. k...
def write(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Write the encoding of the LongInteger to the output stream. Args: ostream (stream): A buffer to contain the encoded bytes of a LongInteger. Usually a BytearrayStream object. Required. ...
def validate(self): """ Verify that the value of the LongInteger is valid. Raises: TypeError: if the value is not of type int or long ValueError: if the value cannot be represented by a signed 64-bit integer """ if self.value is not None: ...
def read(self, istream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Read the encoding of the BigInteger from the input stream. Args: istream (stream): A buffer containing the encoded bytes of the value of a BigInteger. Usually a BytearrayStream object. ...
def write(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Write the encoding of the BigInteger to the output stream. Args: ostream (Stream): A buffer to contain the encoded bytes of a BigInteger object. Usually a BytearrayStream object. R...
def validate(self): """ Verify that the value of the BigInteger is valid. Raises: TypeError: if the value is not of type int or long """ if self.value is not None: if not isinstance(self.value, six.integer_types): raise TypeError('expected...
def validate(self): """ Verify that the value of the Enumeration is valid. Raises: TypeError: if the enum is not of type Enum ValueError: if the value is not of the expected Enum subtype or if the value cannot be represented by an unsigned 32-bit integer ...
def read_value(self, istream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Read the value of the Boolean object from the input stream. Args: istream (Stream): A buffer containing the encoded bytes of the value of a Boolean object. Usually a BytearrayStream object. ...
def write_value(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Write the value of the Boolean object to the output stream. Args: ostream (Stream): A buffer to contain the encoded bytes of the value of a Boolean object. Usually a BytearrayStream object. ...
def write(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Write the encoding of the Boolean object to the output stream. Args: ostream (Stream): A buffer to contain the encoded bytes of a Boolean object. Usually a BytearrayStream object. Required. ...
def validate(self): """ Verify that the value of the Boolean object is valid. Raises: TypeError: if the value is not of type bool. """ if self.value: if not isinstance(self.value, bool): raise TypeError("expected: {0}, observed: {1}".forma...
def read(self, istream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Read the encoding of the Interval from the input stream. Args: istream (stream): A buffer containing the encoded bytes of the value of an Interval. Usually a BytearrayStream object. ...
def validate(self): """ Verify that the value of the Interval is valid. Raises: TypeError: if the value is not of type int or long ValueError: if the value cannot be represented by an unsigned 32-bit integer """ if self.value is not None: ...
def key_wrapping_data(self): """ Retrieve all of the relevant key wrapping data fields and return them as a dictionary. """ key_wrapping_data = {} encryption_key_info = { 'unique_identifier': self._kdw_eki_unique_identifier, 'cryptographic_paramete...
def key_wrapping_data(self, value): """ Set the key wrapping data attributes using a dictionary. """ if value is None: value = {} elif not isinstance(value, dict): raise TypeError("Key wrapping data must be a dictionary.") self._kdw_wrapping_metho...
def validate(self): """ Verify that the contents of the PublicKey object are valid. Raises: TypeError: if the types of any PublicKey attributes are invalid. """ if not isinstance(self.value, bytes): raise TypeError("key value must be bytes") elif ...
def validate(self): """ Verify that the contents of the SecretData object are valid. Raises: TypeError: if the types of any SecretData attributes are invalid. """ if not isinstance(self.value, bytes): raise TypeError("secret value must be bytes") ...
def validate(self): """ Verify that the contents of the OpaqueObject are valid. Raises: TypeError: if the types of any OpaqueObject attributes are invalid. """ if not isinstance(self.value, bytes): raise TypeError("opaque value must be bytes") eli...
def convert_attribute_name_to_tag(value): """ A utility function that converts an attribute name string into the corresponding attribute tag. For example: 'State' -> enums.Tags.STATE Args: value (string): The string name of the attribute. Returns: enum: The Tags enumeration va...
def convert_attribute_tag_to_name(value): """ A utility function that converts an attribute tag into the corresponding attribute name string. For example: enums.Tags.STATE -> 'State' Args: value (enum): The Tags enumeration value of the attribute. Returns: string: The attribut...
def get_bit_mask_from_enumerations(enumerations): """ A utility function that computes a bit mask from a collection of enumeration values. Args: enumerations (list): A list of enumeration values to be combined in a composite bit mask. Returns: int: The composite bit mas...
def get_enumerations_from_bit_mask(enumeration, mask): """ A utility function that creates a list of enumeration values from a bit mask for a specific mask enumeration class. Args: enumeration (class): The enumeration class from which to draw enumeration values. mask (int): ...
def is_bit_mask(enumeration, potential_mask): """ A utility function that checks if the provided value is a composite bit mask of enumeration values in the specified enumeration class. Args: enumeration (class): One of the mask enumeration classes found in this file. These include: ...
def is_attribute(tag, kmip_version=None): """ A utility function that checks if the tag is a valid attribute tag. Args: tag (enum): A Tags enumeration that may or may not correspond to a KMIP attribute type. kmip_version (enum): The KMIPVersion enumeration that should be used ...
def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Read the data encoding the CreateKeyPair request payload and decode it into its constituent parts. Args: input_buffer (stream): A data buffer containing encoded object data, supporting...
def write(self, output_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Write the data encoding the CreateKeyPair request payload to a buffer. Args: output_buffer (stream): A data buffer in which to encode object data, supporting a write method. kmip...
def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Read the data encoding the CreateKeyPair response payload and decode it into its constituent parts. Args: input_buffer (stream): A data buffer containing encoded object data, supportin...
def write(self, output_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Write the data encoding the CreateKeyPair response payload to a buffer. Args: output_buffer (stream): A data buffer in which to encode object data, supporting a write method. kmi...
def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Read the data encoding the GetAttributeList request payload and decode it into its constituent parts. Args: input_buffer (stream): A data stream containing encoded object data, support...
def write(self, output_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Write the data encoding the GetAttributeList request payload to a stream. Args: output_buffer (stream): A data stream in which to encode object data, supporting a write method; usual...
def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Read the data encoding the GetAttributeList response payload and decode it into its constituent parts. Args: input_buffer (stream): A data stream containing encoded object data, suppor...
def write(self, output_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Write the data encoding the GetAttributeList response payload to a stream. Args: output_buffer (stream): A data stream in which to encode object data, supporting a write method; usua...
def get_json_files(p): """ Scan the provided policy directory for all JSON policy files. """ f = [os.path.join(p, x) for x in os.listdir(p) if x.endswith(".json")] return sorted(f)
def scan_policies(self): """ Scan the policy directory for policy data. """ policy_files = get_json_files(self.policy_directory) for f in set(policy_files) - set(self.policy_files): self.file_timestamps[f] = 0 for f in set(self.policy_files) - set(policy_files...
def run(self): """ Start monitoring operation policy files. """ self.initialize_tracking_structures() if self.live_monitoring: self.logger.info("Starting up the operation policy file monitor.") while not self.halt_trigger.is_set(): time.sl...
def get_certificate_from_connection(connection): """ Extract an X.509 certificate from a socket connection. """ certificate = connection.getpeercert(binary_form=True) if certificate: return x509.load_der_x509_certificate( certificate, backends.default_backend() ...
def get_extended_key_usage_from_certificate(certificate): """ Given an X.509 certificate, extract and return the extendedKeyUsage extension. """ try: return certificate.extensions.get_extension_for_oid( x509.oid.ExtensionOID.EXTENDED_KEY_USAGE ).value except x509.Exte...
def get_common_names_from_certificate(certificate): """ Given an X.509 certificate, extract and return all common names. """ common_names = certificate.subject.get_attributes_for_oid( x509.oid.NameOID.COMMON_NAME ) return [common_name.value for common_name in common_names]
def get_client_identity_from_certificate(certificate): """ Given an X.509 certificate, extract and return the client identity. """ client_ids = get_common_names_from_certificate(certificate) if len(client_ids) > 0: if len(client_ids) > 1: raise exceptions.PermissionDenied( ...
def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Read the data encoding the Create request payload and decode it into its constituent parts. Args: input_buffer (stream): A data buffer containing encoded object data, supporting a read...
def write(self, output_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Write the data encoding the Create request payload to a buffer. Args: output_buffer (stream): A data buffer in which to encode object data, supporting a write method. kmip_versio...
def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Read the data encoding the Create response payload and decode it into its constituent parts. Args: input_buffer (stream): A data buffer containing encoded object data, supporting a rea...
def write(self, output_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Write the data encoding the Create response payload to a buffer. Args: output_buffer (stream): A data buffer in which to encode object data, supporting a write method. kmip_versi...
def convert(self, obj): """ Convert a Pie object into a core secret object and vice versa. Args: obj (various): A Pie or core secret object to convert into the opposite object space. Required. Raises: TypeError: if the object type is unrecognized...
def read(self, input_stream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Read the data encoding the Encrypt response payload and decode it into its constituent parts. Args: input_stream (stream): A data stream containing encoded object data, supporting a re...
def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Read the data encoding the DeriveKey request payload and decode it into its constituent parts. Args: input_buffer (stream): A data stream containing encoded object data, supporting a r...
def write(self, output_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Write the data encoding the DeriveKey request payload to a stream. Args: output_buffer (stream): A data stream in which to encode object data, supporting a write method; usually a BytearrayS...
def is_attribute_supported(self, attribute): """ Check if the attribute is supported by the current KMIP version. Args: attribute (string): The name of the attribute (e.g., 'Cryptographic Algorithm'). Required. Returns: bool: True if the attribute...
def is_attribute_deprecated(self, attribute): """ Check if the attribute is deprecated by the current KMIP version. Args: attribute (string): The name of the attribute (e.g., 'Unique Identifier'). Required. """ rule_set = self._attribute_rule_sets.get...
def is_attribute_applicable_to_object_type(self, attribute, object_type): """ Check if the attribute is supported by the given object type. Args: attribute (string): The name of the attribute (e.g., 'Name'). Required. object_type (ObjectType): An ObjectTy...
def is_attribute_multivalued(self, attribute): """ Check if the attribute is allowed to have multiple instances. Args: attribute (string): The name of the attribute (e.g., 'State'). Required. """ # TODO (peterhamilton) Handle multivalue swap between c...
def get_valid_value(self, direct_value, config_section, config_option_name, default_value): """Returns a value that can be used as a parameter in client or server. If a direct_value is given, that value will be returned instead of the value from the config file. If the ap...
def read(self, input_stream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Read the data encoding the Check response payload and decode it into its constituent parts. Args: input_stream (stream): A data stream containing encoded object data, supporting a read...
def write(self, output_stream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Write the data encoding the Check response payload to a stream. Args: output_stream (stream): A data stream in which to encode object data, supporting a write method; usually a BytearrayStre...
def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_2_0): """ Read the data stream and decode the AttributeReference structure into its parts. Args: input_buffer (stream): A data stream containing encoded object data, supporting a read method. ...
def write(self, output_buffer, kmip_version=enums.KMIPVersion.KMIP_2_0): """ Write the AttributeReference structure encoding to the data stream. Args: output_buffer (stream): A data stream in which to encode Attributes structure data, supporting a write method. ...
def read(self, input_stream, kmip_version=enums.KMIPVersion.KMIP_2_0): """ Read the data stream and decode the Attributes structure into its parts. Args: input_stream (stream): A data stream containing encoded object data, supporting a read method. ...