Skip to content

Commit fcdae97

Browse files
author
Jussi Kukkonen
committed
Updater: clean up _check_hashes() comments
Remove duplicate/obvious comments, tighten other comments and a logline Signed-off-by: Jussi Kukkonen <[email protected]>
1 parent e86520a commit fcdae97

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

tuf/client/updater.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,11 +1167,7 @@ def neither_403_nor_404(mirror_error):
11671167
def _check_hashes(self, file_object, trusted_hashes):
11681168
"""
11691169
<Purpose>
1170-
Non-public method that verifies multiple secure hashes of the downloaded
1171-
file 'file_object'. If any of these fail it raises an exception. This is
1172-
to conform with the TUF spec, which support clients with different hashing
1173-
algorithms. The 'hash.py' module is used to compute the hashes of
1174-
'file_object'.
1170+
Non-public method that verifies multiple secure hashes of 'file_object'.
11751171
11761172
<Arguments>
11771173
file_object:
@@ -1193,21 +1189,18 @@ def _check_hashes(self, file_object, trusted_hashes):
11931189
None.
11941190
"""
11951191

1196-
# Verify each trusted hash of 'trusted_hashes'. If all are valid, simply
1197-
# return.
1192+
# Verify each hash, raise an exception if any hash fails to verify
11981193
for algorithm, trusted_hash in six.iteritems(trusted_hashes):
11991194
digest_object = securesystemslib.hash.digest_fileobject(file_object,
12001195
algorithm)
12011196
computed_hash = digest_object.hexdigest()
12021197

1203-
# Raise an exception if any of the hashes are incorrect.
12041198
if trusted_hash != computed_hash:
12051199
raise securesystemslib.exceptions.BadHashError(trusted_hash,
12061200
computed_hash)
12071201

12081202
else:
1209-
logger.info('The file\'s ' + algorithm + ' hash is'
1210-
' correct: ' + trusted_hash)
1203+
logger.info('Verified ' + algorithm + ' hash: ' + trusted_hash)
12111204

12121205

12131206

0 commit comments

Comments
 (0)