1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
# Copyright 2021, New York University and the TUF contributors
# SPDX-License-Identifier: MIT OR Apache-2.0
"""Configuration options for ``Updater`` class."""
from __future__ import annotations
from dataclasses import dataclass
from enum import Flag, unique
@unique
class EnvelopeType(Flag):
"""Configures deserialization and verification mode of TUF metadata.
Args:
METADATA: Traditional canonical JSON -based TUF Metadata.
SIMPLE: Dead Simple Signing Envelope. (experimental)
"""
METADATA = 1
SIMPLE = 2
@dataclass
class UpdaterConfig:
"""Used to store ``Updater`` configuration.
Args:
max_root_rotations: Maximum number of root rotations.
max_delegations: Maximum number of delegations.
root_max_length: Maximum length of a root metadata file.
timestamp_max_length: Maximum length of a timestamp metadata file.
snapshot_max_length: Maximum length of a snapshot metadata file.
targets_max_length: Maximum length of a targets metadata file.
prefix_targets_with_hash: When `consistent snapshots
<https://theupdateframework.github.io/specification/latest/#consistent-snapshots>`_
are used, target download URLs are formed by prefixing the filename
with a hash digest of file content by default. This can be
overridden by setting ``prefix_targets_with_hash`` to ``False``.
envelope_type: Configures deserialization and verification mode of TUF
metadata. Per default, it is treated as traditional canonical JSON
-based TUF Metadata.
app_user_agent: Application user agent, e.g. "MyApp/1.0.0". This will be
prefixed to ngclient user agent when the default fetcher is used.
"""
max_root_rotations: int = 256
max_delegations: int = 32
root_max_length: int = 512000 # bytes
timestamp_max_length: int = 16384 # bytes
snapshot_max_length: int = 2000000 # bytes
targets_max_length: int = 5000000 # bytes
prefix_targets_with_hash: bool = True
envelope_type: EnvelopeType = EnvelopeType.METADATA
app_user_agent: str | None = None
|