@@ -1038,7 +1038,12 @@ 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
1042+ # to determine in which bin to find the target.
1043+ digest_object = sslib_hash .digest (algorithm = "sha256" )
1044+ digest_object .update (target_filepath .encode ("utf-8" ))
1045+ target_filepath_hash = digest_object .hexdigest ()
1046+
10421047 for path_hash_prefix in self .path_hash_prefixes :
10431048 if target_filepath_hash .startswith (path_hash_prefix ):
10441049 return True
@@ -1058,21 +1063,6 @@ def is_in_trusted_paths(self, target_filepath: str) -> bool:
10581063 return False
10591064
10601065
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-
10761066class Delegations :
10771067 """A container object storing information about all delegations.
10781068
0 commit comments