@@ -139,11 +139,8 @@ def __init__(self, path_to_tuf_config_file):
139
139
os .environ .get ('TUF_ENABLE_LOGGING' , False )
140
140
141
141
if enable_logging :
142
- # https://github.com/theupdateframework/tuf/pull/749
143
- log_filename = os .path .join (tuf .settings .repositories_directory ,
144
- tuf_config ['repository_dir' ],
145
- 'tuf.log' )
146
- tuf .log .enable_file_logging (log_filename )
142
+ # NOTE: Also set TUF output to DEBUG and above.
143
+ logging .getLogger ("tuf" ).setLevel (logging .DEBUG )
147
144
148
145
# Also set verbose, non-quiet in-toto logging.
149
146
# https://github.com/in-toto/in-toto/blob/8eb8eab8c94f47e67a24b5e7d56f4519092dd9d2/in_toto/in_toto_verify.py#L205
@@ -290,7 +287,7 @@ def __verify_in_toto_metadata(self, target_relpath,
290
287
params = self .__substitute_parameters (target_relpath )
291
288
verifylib .in_toto_verify (layout , layout_key_dict ,
292
289
substitution_parameters = params )
293
- logging .info ('E2E verified {}' .format (target_relpath ))
290
+ logger .info ('in-toto verified {}' .format (target_relpath ))
294
291
except :
295
292
logger .exception ('in-toto failed to verify {}' \
296
293
.format (target_relpath ))
@@ -326,9 +323,7 @@ def _get_target(self, target_relpath, download_in_toto_metadata=True):
326
323
327
324
# Either the target has not been updated...
328
325
if not len (updated_targets ):
329
- logger .info ('{} has not been updated' \
330
- .format (target_relpath ))
331
-
326
+ logger .debug ('{} has not been updated' .format (target_relpath ))
332
327
# or, it has been updated, in which case...
333
328
else :
334
329
# First, we use TUF to download and verify the target.
@@ -337,6 +332,8 @@ def _get_target(self, target_relpath, download_in_toto_metadata=True):
337
332
assert updated_target == target
338
333
self .__updater .download_target (updated_target , self .__targets_dir )
339
334
335
+ logger .info ('TUF verified {}' .format (target_relpath ))
336
+
340
337
# Next, we use in-toto to verify the supply chain of the target.
341
338
# NOTE: We use a flag to avoid recursively downloading in-toto
342
339
# metadata for in-toto metadata themselves, and so on ad infinitum.
@@ -355,8 +352,8 @@ def _get_target(self, target_relpath, download_in_toto_metadata=True):
355
352
not target_relpath .endswith ('.html' ):
356
353
self .__download_and_verify_in_toto_metadata (target , target_relpath )
357
354
else :
358
- logging .warning ('Switched off in-toto verification for {}' \
359
- .format (target_relpath ))
355
+ logger .warning ('Switched off in-toto verification for {}' \
356
+ .format (target_relpath ))
360
357
361
358
target_path = os .path .join (self .__targets_dir , target_relpath )
362
359
return target_path
@@ -382,14 +379,22 @@ def download(self, target_relpath, dest_dir, dest_filename):
382
379
if 'TUF_CONFIG_FILE' in os .environ :
383
380
import glob
384
381
import tempfile
385
- import tuf .settings
386
382
387
- # NOTE: By default, we turn off TUF logging, and use the pip log instead.
388
- # You may turn toggle this behaviour using the "enable_logging" flag in the
389
- # TUF configuration file.
383
+ # We always turn off TUF logging.
384
+ import tuf .settings
390
385
tuf .settings .ENABLE_FILE_LOGGING = False
386
+ # By default, set the TUF console logging level to >= CRITICAL.
387
+ import tuf .log
388
+ logging .getLogger ("tuf" ).setLevel (logging .CRITICAL )
389
+
390
+ # Import what we need from TUF.
391
391
from tuf .client .updater import Updater
392
392
393
+ # Also set non-verbose, quiet in-toto logging.
394
+ import in_toto .log
395
+ logging .getLogger ("in_toto" ).setLevelVerboseOrQuiet (False , True )
396
+
397
+ # Import what we need from in-toto.
393
398
from in_toto import verifylib
394
399
from in_toto .models .metadata import Metablock
395
400
from in_toto .util import import_public_keys_from_files_as_dict
0 commit comments