File tree 2 files changed +16
-6
lines changed 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,11 @@ def build_metadata_dir(base_url: str) -> str:
30
30
31
31
def init_tofu (base_url : str ) -> bool :
32
32
"""Initialize local trusted metadata (Trust-On-First-Use) and create a
33
- directory for downloads"""
33
+ directory for downloads
34
+
35
+ NOTE: This is unsafe and for demonstration only: the bootstrap root
36
+ should be deployed alongside your updater application
37
+ """
34
38
35
39
metadata_dir = build_metadata_dir (base_url )
36
40
@@ -81,6 +85,9 @@ def download(base_url: str, target: str) -> bool:
81
85
os .mkdir (DOWNLOAD_DIR )
82
86
83
87
try :
88
+ # NOTE: initial root should be provided with ``bootstrap`` argument:
89
+ # This examples uses unsafe Trust-On-First-Use initialization so it is
90
+ # not possible here.
84
91
updater = Updater (
85
92
metadata_dir = metadata_dir ,
86
93
metadata_base_url = f"{ base_url } /metadata/" ,
@@ -112,7 +119,7 @@ def download(base_url: str, target: str) -> bool:
112
119
return True
113
120
114
121
115
- def main () -> None :
122
+ def main () -> str | None :
116
123
"""Main TUF Client Example function"""
117
124
118
125
client_args = argparse .ArgumentParser (description = "TUF Client Example" )
@@ -177,6 +184,8 @@ def main() -> None:
177
184
else :
178
185
client_args .print_help ()
179
186
187
+ return None
188
+
180
189
181
190
if __name__ == "__main__" :
182
191
sys .exit (main ())
Original file line number Diff line number Diff line change 12
12
High-level description of ``Updater`` functionality:
13
13
* Initializing an ``Updater`` loads and validates the trusted local root
14
14
metadata: This root metadata is used as the source of trust for all other
15
- metadata.
15
+ metadata. Updater should always be initialized with the ``bootstrap``
16
+ argument: if this is not possible, it can be initialized from cache only.
16
17
* ``refresh()`` can optionally be called to update and load all top-level
17
18
metadata as described in the specification, using both locally cached
18
19
metadata and metadata downloaded from the remote repository. If refresh is
@@ -75,9 +76,9 @@ class Updater:
75
76
download both metadata and targets. Default is ``Urllib3Fetcher``
76
77
config: ``Optional``; ``UpdaterConfig`` could be used to setup common
77
78
configuration options.
78
- bootstrap: ``Optional``; initial root metadata. If a boostrap root is
79
- not provided then the root.json in the metadata cache is used as the
80
- initial root.
79
+ bootstrap: ``Optional``; initial root metadata. A boostrap root should
80
+ always be provided. If it is not, the current root.json in the
81
+ metadata cache is used as the initial root.
81
82
82
83
Raises:
83
84
OSError: Local root.json cannot be read
You can’t perform that action at this time.
0 commit comments