Skip to content

Commit

Permalink
Merge pull request #377 from theupdateframework/more-root-rotations
Browse files Browse the repository at this point in the history
Increase the number of root rotations allowed during TUF refresh.
  • Loading branch information
kommendorkapten authored Jul 15, 2024
2 parents 65e5cf9 + b3498cf commit b60c2a6
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions repo/tuf_on_ci/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import click
from tuf.api.exceptions import ExpiredMetadataError
from tuf.api.metadata import Metadata
from tuf.ngclient import Updater
from tuf.ngclient import Updater, UpdaterConfig


def expiry_check(dir: str, role: str, timestamp: int):
Expand Down Expand Up @@ -61,6 +61,10 @@ def client(
os.makedirs(metadata_dir, exist_ok=True)
os.mkdir(artifact_dir)

# Allow for a large number of root rotations, as metadata is
# not cached during testing
config = UpdaterConfig(max_root_rotations=256)

# initialize client with --initial-root or from metadata_url
if initial_root is not None:
shutil.copy(initial_root, os.path.join(metadata_dir, "root.json"))
Expand All @@ -73,15 +77,19 @@ def client(

if update_base_url is not None:
# Update client to update_base_url before doing the actual update
updater = Updater(metadata_dir, update_base_url, artifact_dir, artifact_url)
updater = Updater(
metadata_dir, update_base_url, artifact_dir, artifact_url, config=config
)
try:
updater.refresh()
print(f"Client metadata update from base url {update_base_url}: OK")
except ExpiredMetadataError as e:
print(f"WARNING: update base url has expired metadata: {e}")

# Update client to metadata_url
updater = Updater(metadata_dir, metadata_url, artifact_dir, artifact_url)
updater = Updater(
metadata_dir, metadata_url, artifact_dir, artifact_url, config=config
)
ref_time_string = ""
if time is not None:
# HACK: replace reference time with ours: initial root has been loaded
Expand Down

0 comments on commit b60c2a6

Please sign in to comment.