Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanitize repo simulator role names when writing #1702

Merged
merged 1 commit into from
Dec 15, 2021

Conversation

MVrachev
Copy link
Collaborator

@MVrachev MVrachev commented Dec 1, 2021

Description of the changes being introduced by the pull request:

Sanitize the role names in the repo simulator when dumping in a
directory the same way the ngclient does.
That's necessary because when testing fishy role names from test_updater_with_simulator leads to an
error:
PermissionError: [Errno 13] Permission denied: '/.json'

Please verify and check that the pull request fulfills the following
requirements
:

  • The code follows the Code Style Guidelines
  • Tests have been added for the bug fix or new feature
  • Docs have been added for the bug fix or new feature

@coveralls
Copy link

coveralls commented Dec 1, 2021

Pull Request Test Coverage Report for Build 1572851593

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 97.577%

Totals Coverage Status
Change from base Build 1563115608: 0.0%
Covered Lines: 4092
Relevant Lines: 4177

💛 - Coveralls

@jku
Copy link
Member

jku commented Dec 2, 2021

alternatively could sanitize the delegated rolename when writing the file like client does (quoted_role = parse.quote(role, ""))

@sechkova
Copy link
Contributor

sechkova commented Dec 2, 2021

Well it just happened that I did the same thing yesterday: dc908ee
(without the part in test_updater_with_simulator.py)

@MVrachev
Copy link
Collaborator Author

MVrachev commented Dec 2, 2021

Well it just happened that I did the same thing yesterday: dc908ee
(without the part in test_updater_with_simulator.py)

@sechkova I am sorry it happened that way, I haven't read #1689 and didn't notice that.
I will drop this commit and leave only the commit related to the error.

@sechkova
Copy link
Contributor

sechkova commented Dec 2, 2021

Bad timing on both sides 🤷 Can you have a look at my commit before dropping yours? Maybe I've missed something.

@MVrachev
Copy link
Collaborator Author

MVrachev commented Dec 2, 2021

Bad timing on both sides 🤷 Can you have a look at my commit before dropping yours? Maybe I've missed something.

I just had a look and yours seems to cover what I did here, so don't worry.

@MVrachev MVrachev changed the title Tests: add dump dir option and fix an error Sanitize repo simulator role names when writing Dec 2, 2021
@MVrachev
Copy link
Collaborator Author

MVrachev commented Dec 2, 2021

I updated the code by using what @jku suggested.
Additionally, the commit and pr descriptions were changed together with the pr title.

Copy link
Member

@jku jku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit does not do what the message says.

  • It url encodes role names that do not need sanitizing (but does not url encode the delegated role names that could need it)
  • Then it skips dumping metadata for roles that actually would need sanitizing if they were used as filenames?

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 <mvrachev@vmware.com>
@MVrachev
Copy link
Collaborator Author

This commit does not do what the message says.

  • It url encodes role names that do not need sanitizing (but does not url encode the delegated role names that could need it)
  • Then it skips dumping metadata for roles that actually would need sanitizing if they were used as filenames?

I changed the code to dump the delegated roles and removed the code where I skipped dumping.

@jku jku merged commit 551a10c into theupdateframework:develop Dec 15, 2021
@MVrachev MVrachev deleted the dump-dirs branch December 20, 2021 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants