|
137 | 137 | from tuf import log
|
138 | 138 | from tuf import mirrors
|
139 | 139 | from tuf import roledb
|
| 140 | +from tuf import settings |
140 | 141 | import tuf.requests_fetcher
|
141 |
| -import tuf.settings |
142 | 142 | import tuf.keydb
|
143 | 143 | import tuf.sig
|
144 | 144 |
|
|
151 | 151 | # The Timestamp role does not have signed metadata about it; otherwise we
|
152 | 152 | # would need an infinite regress of metadata. Therefore, we use some
|
153 | 153 | # default, but sane, upper file length for its metadata.
|
154 |
| -DEFAULT_TIMESTAMP_UPPERLENGTH = tuf.settings.DEFAULT_TIMESTAMP_REQUIRED_LENGTH |
| 154 | +DEFAULT_TIMESTAMP_UPPERLENGTH = settings.DEFAULT_TIMESTAMP_REQUIRED_LENGTH |
155 | 155 |
|
156 | 156 | # The Root role may be updated without knowing its version number if
|
157 | 157 | # top-level metadata cannot be safely downloaded (e.g., keys may have been
|
158 | 158 | # revoked, thus requiring a new Root file that includes the updated keys)
|
159 | 159 | # and 'unsafely_update_root_if_necessary' is True.
|
160 | 160 | # We use some default, but sane, upper file length for its metadata.
|
161 |
| -DEFAULT_ROOT_UPPERLENGTH = tuf.settings.DEFAULT_ROOT_REQUIRED_LENGTH |
| 161 | +DEFAULT_ROOT_UPPERLENGTH = settings.DEFAULT_ROOT_REQUIRED_LENGTH |
162 | 162 |
|
163 | 163 | # See 'log.py' to learn how logging is handled in TUF.
|
164 | 164 | logger = logging.getLogger(__name__)
|
@@ -270,7 +270,7 @@ def get_valid_targetinfo(self, target_filename, match_custom_field=True):
|
270 | 270 | formats.MAPPING_SCHEMA.check_match(self.map_file['mapping'])
|
271 | 271 |
|
272 | 272 | # Set the top-level directory containing the metadata for each repository.
|
273 |
| - repositories_directory = tuf.settings.repositories_directory |
| 273 | + repositories_directory = settings.repositories_directory |
274 | 274 |
|
275 | 275 | # Verify that the required local directories exist for each repository.
|
276 | 276 | self._verify_metadata_directories(repositories_directory)
|
@@ -731,13 +731,13 @@ def __init__(self, repository_name, repository_mirrors, fetcher=None):
|
731 | 731 | self.consistent_snapshot = False
|
732 | 732 |
|
733 | 733 | # Ensure the repository metadata directory has been set.
|
734 |
| - if tuf.settings.repositories_directory is None: |
| 734 | + if settings.repositories_directory is None: |
735 | 735 | raise exceptions.RepositoryError('The TUF update client'
|
736 | 736 | ' module must specify the directory containing the local repository'
|
737 | 737 | ' files. "tuf.settings.repositories_directory" MUST be set.')
|
738 | 738 |
|
739 | 739 | # Set the path for the current set of metadata files.
|
740 |
| - repositories_directory = tuf.settings.repositories_directory |
| 740 | + repositories_directory = settings.repositories_directory |
741 | 741 | repository_directory = os.path.join(repositories_directory, self.repository_name)
|
742 | 742 |
|
743 | 743 | # raise MissingLocalRepository if the repo does not exist at all.
|
@@ -1138,7 +1138,7 @@ def neither_403_nor_404(mirror_error):
|
1138 | 1138 | # Following the spec, try downloading the N+1th root for a certain maximum
|
1139 | 1139 | # number of times.
|
1140 | 1140 | lower_bound = current_root_metadata['version'] + 1
|
1141 |
| - upper_bound = lower_bound + tuf.settings.MAX_NUMBER_ROOT_ROTATIONS |
| 1141 | + upper_bound = lower_bound + settings.MAX_NUMBER_ROOT_ROTATIONS |
1142 | 1142 |
|
1143 | 1143 | # Try downloading the next root.
|
1144 | 1144 | for next_version in range(lower_bound, upper_bound):
|
@@ -1852,11 +1852,11 @@ def _update_metadata_if_changed(self, metadata_role,
|
1852 | 1852 | # expected role. Note: The Timestamp role is not updated via this
|
1853 | 1853 | # function.
|
1854 | 1854 | if metadata_role == 'snapshot':
|
1855 |
| - upperbound_filelength = tuf.settings.DEFAULT_SNAPSHOT_REQUIRED_LENGTH |
| 1855 | + upperbound_filelength = settings.DEFAULT_SNAPSHOT_REQUIRED_LENGTH |
1856 | 1856 |
|
1857 | 1857 | # The metadata is considered Targets (or delegated Targets metadata).
|
1858 | 1858 | else:
|
1859 |
| - upperbound_filelength = tuf.settings.DEFAULT_TARGETS_REQUIRED_LENGTH |
| 1859 | + upperbound_filelength = settings.DEFAULT_TARGETS_REQUIRED_LENGTH |
1860 | 1860 |
|
1861 | 1861 | try:
|
1862 | 1862 | self._update_metadata(metadata_role, upperbound_filelength,
|
@@ -2681,7 +2681,7 @@ def _preorder_depth_first_walk(self, target_filepath):
|
2681 | 2681 | current_metadata = self.metadata['current']
|
2682 | 2682 | role_names = ['targets']
|
2683 | 2683 | visited_role_names = set()
|
2684 |
| - number_of_delegations = tuf.settings.MAX_NUMBER_OF_DELEGATIONS |
| 2684 | + number_of_delegations = settings.MAX_NUMBER_OF_DELEGATIONS |
2685 | 2685 |
|
2686 | 2686 | # Ensure the client has the most up-to-date version of 'targets.json'.
|
2687 | 2687 | # Raise 'tuf.exceptions.NoWorkingMirrorError' if the changed metadata
|
@@ -2755,7 +2755,7 @@ def _preorder_depth_first_walk(self, target_filepath):
|
2755 | 2755 | if target is None and number_of_delegations == 0 and len(role_names) > 0:
|
2756 | 2756 | logger.debug(repr(len(role_names)) + ' roles left to visit, ' +
|
2757 | 2757 | 'but allowed to visit at most ' +
|
2758 |
| - repr(tuf.settings.MAX_NUMBER_OF_DELEGATIONS) + ' delegations.') |
| 2758 | + repr(settings.MAX_NUMBER_OF_DELEGATIONS) + ' delegations.') |
2759 | 2759 |
|
2760 | 2760 | return target
|
2761 | 2761 |
|
|
0 commit comments