mirror of
https://github.com/theupdateframework/python-tuf
synced 2026-05-24 10:08:28 +00:00
imports: Fix securesystemslib.hash imports
Make them compatible with vendoring, use from securesystemslib import hash as sslib_hash to have the same style as other securesystemslib imports (and to avoid potential conflict with system hash()). Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
This commit is contained in:
parent
4b66c173d8
commit
dd134a43c8
2 changed files with 7 additions and 7 deletions
|
|
@ -133,6 +133,7 @@
|
|||
|
||||
from securesystemslib import exceptions as sslib_exceptions
|
||||
from securesystemslib import formats as sslib_formats
|
||||
from securesystemslib import hash as sslib_hash
|
||||
from securesystemslib import keys as sslib_keys
|
||||
from securesystemslib import util as sslib_util
|
||||
|
||||
|
|
@ -148,7 +149,6 @@
|
|||
import tuf.requests_fetcher
|
||||
import tuf.keydb
|
||||
|
||||
import securesystemslib.hash
|
||||
import six
|
||||
|
||||
# The Timestamp role does not have signed metadata about it; otherwise we
|
||||
|
|
@ -1207,7 +1207,7 @@ def _check_hashes(self, file_object, trusted_hashes):
|
|||
|
||||
# Verify each hash, raise an exception if any hash fails to verify
|
||||
for algorithm, trusted_hash in six.iteritems(trusted_hashes):
|
||||
digest_object = securesystemslib.hash.digest_fileobject(file_object,
|
||||
digest_object = sslib_hash.digest_fileobject(file_object,
|
||||
algorithm)
|
||||
computed_hash = digest_object.hexdigest()
|
||||
|
||||
|
|
@ -2933,7 +2933,7 @@ def _get_target_hash(self, target_filepath, hash_function='sha256'):
|
|||
# Calculate the hash of the filepath to determine which bin to find the
|
||||
# target. The client currently assumes the repository (i.e., repository
|
||||
# tool) uses 'hash_function' to generate hashes and UTF-8.
|
||||
digest_object = securesystemslib.hash.digest(hash_function)
|
||||
digest_object = sslib_hash.digest(hash_function)
|
||||
encoded_target_filepath = target_filepath.encode('utf-8')
|
||||
digest_object.update(encoded_target_filepath)
|
||||
target_filepath_hash = digest_object.hexdigest()
|
||||
|
|
@ -3088,7 +3088,7 @@ def updated_targets(self, targets, destination_directory):
|
|||
for algorithm, digest in six.iteritems(target['fileinfo']['hashes']):
|
||||
digest_object = None
|
||||
try:
|
||||
digest_object = securesystemslib.hash.digest_filename(target_filepath,
|
||||
digest_object = sslib_hash.digest_filename(target_filepath,
|
||||
algorithm=algorithm)
|
||||
|
||||
# This exception would occur if the target does not exist locally.
|
||||
|
|
|
|||
|
|
@ -39,8 +39,10 @@
|
|||
import json
|
||||
import tempfile
|
||||
|
||||
import securesystemslib
|
||||
from securesystemslib import exceptions as sslib_exceptions
|
||||
from securesystemslib import formats as sslib_formats
|
||||
from securesystemslib import hash as sslib_hash
|
||||
from securesystemslib import interface as sslib_interface
|
||||
from securesystemslib import keys as sslib_keys
|
||||
from securesystemslib import util as sslib_util
|
||||
|
|
@ -55,8 +57,6 @@
|
|||
from tuf import sig
|
||||
import tuf.keydb
|
||||
|
||||
import securesystemslib
|
||||
import securesystemslib.hash
|
||||
import six
|
||||
|
||||
|
||||
|
|
@ -1187,7 +1187,7 @@ def get_target_hash(target_filepath):
|
|||
"""
|
||||
formats.RELPATH_SCHEMA.check_match(target_filepath)
|
||||
|
||||
digest_object = securesystemslib.hash.digest(algorithm=HASH_FUNCTION)
|
||||
digest_object = sslib_hash.digest(algorithm=HASH_FUNCTION)
|
||||
digest_object.update(target_filepath.encode('utf-8'))
|
||||
return digest_object.hexdigest()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue