@@ -1854,7 +1854,8 @@ def add_paths(self, paths, child_rolename):
1854
1854
securesystemslib.exceptions.Error, if 'child_rolename' has not been
1855
1855
delegated yet.
1856
1856
1857
- tuf.exceptions.InvalidNameError, if 'pathname' does not match pattern.
1857
+ tuf.exceptions.InvalidNameError, if any path in 'paths' does not match
1858
+ pattern.
1858
1859
1859
1860
<Side Effects>
1860
1861
Modifies this Targets' delegations field.
@@ -1870,10 +1871,6 @@ def add_paths(self, paths, child_rolename):
1870
1871
securesystemslib .formats .PATHS_SCHEMA .check_match (paths )
1871
1872
tuf .formats .ROLENAME_SCHEMA .check_match (child_rolename )
1872
1873
1873
- # A list of relative and verified paths or glob patterns to be added to the
1874
- # child role's entry in the parent's delegations field.
1875
- relative_paths = []
1876
-
1877
1874
# Ensure that 'child_rolename' exists, otherwise it will not have an entry
1878
1875
# in the parent role's delegations field.
1879
1876
if not tuf .roledb .role_exists (child_rolename , self ._repository_name ):
@@ -1886,7 +1883,6 @@ def add_paths(self, paths, child_rolename):
1886
1883
# on the file system is not verified. If the path is incorrect,
1887
1884
# the targetfile won't be matched successfully during a client update.
1888
1885
self ._check_path (path )
1889
- relative_paths .append (path )
1890
1886
1891
1887
# Get the current role's roleinfo, so that its delegations field can be
1892
1888
# updated.
@@ -1895,7 +1891,7 @@ def add_paths(self, paths, child_rolename):
1895
1891
# Update the delegated paths of 'child_rolename' to add relative paths.
1896
1892
for role in roleinfo ['delegations' ]['roles' ]:
1897
1893
if role ['name' ] == child_rolename :
1898
- for relative_path in relative_paths :
1894
+ for relative_path in paths :
1899
1895
if relative_path not in role ['paths' ]:
1900
1896
role ['paths' ].append (relative_path )
1901
1897
@@ -1944,7 +1940,7 @@ def add_target(self, filepath, custom=None, fileinfo=None):
1944
1940
securesystemslib.exceptions.FormatError, if 'filepath' is improperly
1945
1941
formatted.
1946
1942
1947
- tuf.exceptions.InvalidNameError, if 'pathname ' does not match pattern.
1943
+ tuf.exceptions.InvalidNameError, if 'filepath ' does not match pattern.
1948
1944
1949
1945
<Side Effects>
1950
1946
Adds 'filepath' to this role's list of targets. This role's
@@ -2024,7 +2020,8 @@ def add_targets(self, list_of_targets):
2024
2020
securesystemslib.exceptions.FormatError, if the arguments are improperly
2025
2021
formatted.
2026
2022
2027
- tuf.exceptions.InvalidNameError, if 'pathname' does not match pattern.
2023
+ tuf.exceptions.InvalidNameError, if any target in 'list_of_targets'
2024
+ does not match pattern.
2028
2025
2029
2026
<Side Effects>
2030
2027
This Targets' roleinfo is updated with the paths in 'list_of_targets'.
@@ -2039,9 +2036,6 @@ def add_targets(self, list_of_targets):
2039
2036
# Raise 'securesystemslib.exceptions.FormatError' if there is a mismatch.
2040
2037
tuf .formats .RELPATHS_SCHEMA .check_match (list_of_targets )
2041
2038
2042
- # Update the tuf.roledb entry.
2043
- relative_list_of_targets = []
2044
-
2045
2039
# Ensure the paths in 'list_of_targets' are relative and use forward slash
2046
2040
# as a separator or raise an exception. The paths of 'list_of_targets'
2047
2041
# will be verified as existing and allowed paths according to this Targets
@@ -2050,14 +2044,12 @@ def add_targets(self, list_of_targets):
2050
2044
# in any order and minimize the number of times these checks are performed.
2051
2045
for target in list_of_targets :
2052
2046
self ._check_path (target )
2053
- relative_list_of_targets .append (target )
2054
2047
2055
2048
# Update this Targets 'tuf.roledb.py' entry.
2056
2049
roleinfo = tuf .roledb .get_roleinfo (self ._rolename , self ._repository_name )
2057
- for relative_target in relative_list_of_targets :
2050
+ for relative_target in list_of_targets :
2058
2051
if relative_target not in roleinfo ['paths' ]:
2059
2052
logger .debug ('Adding new target: ' + repr (relative_target ))
2060
-
2061
2053
else :
2062
2054
logger .debug ('Replacing target: ' + repr (relative_target ))
2063
2055
roleinfo ['paths' ].update ({relative_target : {}})
@@ -2285,7 +2277,8 @@ def delegate(self, rolename, public_keys, paths, threshold=1,
2285
2277
2286
2278
securesystemslib.exceptions.Error, if the delegated role already exists.
2287
2279
2288
- tuf.exceptions.InvalidNameError, if 'pathname' does not match pattern.
2280
+ tuf.exceptions.InvalidNameError, if any path in 'paths' or target in
2281
+ 'list_of_targets' does not match pattern.
2289
2282
2290
2283
<Side Effects>
2291
2284
A new Target object is created for 'rolename' that is accessible to the
@@ -2490,7 +2483,8 @@ def delegate_hashed_bins(self, list_of_targets, keys_of_hashed_bins,
2490
2483
2, or one of the targets in 'list_of_targets' is not relative to the
2491
2484
repository's targets directory.
2492
2485
2493
- tuf.exceptions.InvalidNameError, if 'pathname' does not match pattern.
2486
+ tuf.exceptions.InvalidNameError, if any target in 'list_of_targets'
2487
+ does not match pattern.
2494
2488
2495
2489
<Side Effects>
2496
2490
Delegates multiple target roles from the current parent role.
0 commit comments