Skip to content

Commit

Permalink
Allow paths to contain *
Browse files Browse the repository at this point in the history
From #377, the [TUF spec] allows for paths to contain `*`. According to
@lukesteensen, this is routinely used in delegations.

Note though this does not attempt to implement delegation path globs.
That will be implemented in #388.

[TUF spec]: https://theupdateframework.github.io/specification/latest/#targetpath
  • Loading branch information
erickt committed Sep 27, 2022
1 parent 7b8af7a commit 3c77917
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tuf/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ static PATH_ILLEGAL_STRINGS: &[&str] = &[
"\"",
"|",
"?",
"*",
// control characters, all illegal in FAT
"\u{000}",
"\u{001}",
Expand Down Expand Up @@ -2314,6 +2313,23 @@ mod test {
}
}

#[test]
fn allow_asterisk_in_target_path() {
let good_paths = &[
"*",
"*/some/path",
"*/some/path/",
"some/*/path",
"some/*/path/*",
];

for path in good_paths.iter() {
assert!(safe_path(path).is_ok());
assert!(TargetPath::new(path.to_string()).is_ok());
assert!(MetadataPath::new(path.to_string()).is_ok());
}
}

#[test]
fn path_matches_chain() {
let test_cases: &[(bool, &str, &[&[&str]])] = &[
Expand Down

0 comments on commit 3c77917

Please sign in to comment.