Description of issue or feature request:
Related to #957
The Targets.delegate()method fails if one of the file paths or patterns passed via the paths argument is absolute, i.e. starts with a directory separator. At the same time it warns if it the path does not have self._targets_directory as prefix, which very well may be an absolute path.
https://github.com/theupdateframework/tuf/blob/409eef1a4872a88b610e81b375f36b07a8e0f996/tuf/repository_tool.py#L2286-L2294
The Targets.add_paths() methods emits a similar message (with debug level). Note that the method does not check whether the passed paths have a leading directory separator, although it should, in order to be consistent with above function.
https://github.com/theupdateframework/tuf/blob/409eef1a4872a88b610e81b375f36b07a8e0f996/tuf/repository_tool.py#L1868-L1872
Current behavior:
Targets.delegate() and Targets.add_paths() emit warning/debug message if a passed path or path pattern is not prefixed with the targets directory base path, i.e. self._targets_directory.
Targets.add_paths does not check if the passed paths are indeed relative.
Expected behavior:
Either,
Targets.delegate() and Targets.add_paths() should not care about the prefix of the passed paths or path patterns.
Targets.add_paths should probably assert that the passed paths are relative, to be consistent with the sibling the corresponding functionality of delegate().
Description of issue or feature request:
Related to #957
The
Targets.delegate()method fails if one of the file paths or patterns passed via thepathsargument is absolute, i.e. starts with a directory separator. At the same time it warns if it the path does not haveself._targets_directoryas prefix, which very well may be an absolute path.https://github.com/theupdateframework/tuf/blob/409eef1a4872a88b610e81b375f36b07a8e0f996/tuf/repository_tool.py#L2286-L2294
The
Targets.add_paths()methods emits a similar message (with debug level). Note that the method does not check whether the passed paths have a leading directory separator, although it should, in order to be consistent with above function.https://github.com/theupdateframework/tuf/blob/409eef1a4872a88b610e81b375f36b07a8e0f996/tuf/repository_tool.py#L1868-L1872
Current behavior:
Targets.delegate()andTargets.add_paths()emit warning/debug message if a passed path or path pattern is not prefixed with the targets directory base path, i.e.self._targets_directory.Targets.add_pathsdoes not check if the passed paths are indeed relative.Expected behavior:
Either,
Targets.delegate()andTargets.add_paths()should not care about the prefix of the passed paths or path patterns.Targets.add_pathsshould probably assert that the passed paths are relative, to be consistent with the sibling the corresponding functionality ofdelegate().