Skip to content

Commit

Permalink
Sanitize repo simulator role names when writing
Browse files Browse the repository at this point in the history
Sanitize the delegated rolenames in the repo simulator when dumping in
a directory the same way the ngclient does.
That's necessary because when testing fishy role names leads to an
error:
"PermissionError: [Errno 13] Permission denied: '/.json'"

Signed-off-by: Martin Vrachev <[email protected]>
  • Loading branch information
MVrachev committed Dec 13, 2021
1 parent bdf1cbb commit 3a00db0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/repository_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,5 +397,6 @@ def write(self) -> None:
f.write(self.fetch_metadata(role))

for role in self.md_delegates:
with open(os.path.join(dest_dir, f"{role}.json"), "wb") as f:
quoted_role = parse.quote(role, "")
with open(os.path.join(dest_dir, f"{quoted_role}.json"), "wb") as f:
f.write(self.fetch_metadata(role))

0 comments on commit 3a00db0

Please sign in to comment.