@@ -1038,7 +1038,13 @@ def is_in_trusted_paths(self, target_filepath: str) -> bool:
10381038 is in one of the trusted paths of DelegatedRole"""
10391039
10401040 if self .path_hash_prefixes is not None :
1041- target_filepath_hash = _get_filepath_hash (target_filepath )
1041+ # Calculate the hash of the filepath to determine which bin
1042+ # to find the target. The client currently assumes the repository
1043+ # uses sslib's default algorithm to generate hashes.
1044+ digest_object = sslib_hash .digest ()
1045+ digest_object .update (target_filepath .encode ("utf-8" ))
1046+ target_filepath_hash = digest_object .hexdigest ()
1047+
10421048 for path_hash_prefix in self .path_hash_prefixes :
10431049 if target_filepath_hash .startswith (path_hash_prefix ):
10441050 return True
@@ -1058,21 +1064,6 @@ def is_in_trusted_paths(self, target_filepath: str) -> bool:
10581064 return False
10591065
10601066
1061- def _get_filepath_hash (target_filepath , hash_function = "sha256" ):
1062- """
1063- Calculate the hash of the filepath to determine which bin to find the
1064- target.
1065- """
1066- # The client currently assumes the repository (i.e., repository
1067- # tool) uses 'hash_function' to generate hashes and UTF-8.
1068- digest_object = sslib_hash .digest (hash_function )
1069- encoded_target_filepath = target_filepath .encode ("utf-8" )
1070- digest_object .update (encoded_target_filepath )
1071- target_filepath_hash = digest_object .hexdigest ()
1072-
1073- return target_filepath_hash
1074-
1075-
10761067class Delegations :
10771068 """A container object storing information about all delegations.
10781069
0 commit comments