Skip to content

Commit 454d4b7

Browse files
committed
Recommend against leading path separators
In theupdateframework/python-tuf#679, the python tuf project forbade leading path separators due to surprising behavior joining target and delegated paths, since Python in particular has the following surprising behavior: ``` >>> os.path.join("/foo", "/bar") '/bar' ``` This PR updates the spec to recommend against using leading path separators in targets.json, and removes their use from the examples. Does this change look acceptable, and is "should not" be the correct phrase, or can this be the more strict "must not"?
1 parent 215c569 commit 454d4b7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tuf-spec.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,9 @@ repo](https://github.com/theupdateframework/specification/issues).
766766
}
767767

768768
Each key of the TARGETS object is a TARGETPATH. A TARGETPATH is a path to
769-
a file that is relative to a mirror's base URL of targets.
769+
a file that is relative to a mirror's base URL of targets. It should not
770+
have a leading path separator to avoid surprising behavior when constructing
771+
paths on disk.
770772

771773
It is allowed to have a TARGETS object with no TARGETPATH elements. This
772774
can be used to indicate that no target files are available.
@@ -831,6 +833,8 @@ repo](https://github.com/theupdateframework/specification/issues).
831833
match file paths "targets/foo.tgz" and "targets/bar.tgz", but not
832834
"targets/foo.txt". Likewise, path pattern "foo-version-?.tgz" matches
833835
"foo-version-2.tgz" and "foo-version-a.tgz", but not "foo-version-alpha.tgz".
836+
It should not have a leading path separator to avoid surprising behavior when
837+
constructing paths on disk.
834838

835839
Prioritized delegations allow clients to resolve conflicts between delegated
836840
roles that share responsibility for overlapping target paths. To resolve
@@ -876,21 +880,21 @@ repo](https://github.com/theupdateframework/specification/issues).
876880
],
877881
"name": "project",
878882
"paths": [
879-
"/project/file3.txt"
883+
"project/file3.txt"
880884
],
881885
"threshold": 1
882886
}
883887
]
884888
},
885889
"expires": "2030-01-01T00:00:00Z",
886890
"targets": {
887-
"/file1.txt": {
891+
"file1.txt": {
888892
"hashes": {
889893
"sha256": "65b8c67f51c993d898250f40aa57a317d854900b3a04895464313e48785440da"
890894
},
891895
"length": 31
892896
},
893-
"/file2.txt": {
897+
"dir/file2.txt": {
894898
"hashes": {
895899
"sha256": "452ce8308500d83ef44248d8e6062359211992fd837ea9e370e561efb1a4ca99"
896900
},

0 commit comments

Comments
 (0)