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

Fix directory being empty in ensure_parent_dir #260

Merged
merged 1 commit into from
Aug 4, 2020

Conversation

MVrachev
Copy link
Collaborator

@MVrachev MVrachev commented Jul 17, 2020

Fixes issue #: None

Description of the changes being introduced by the pull request:
If you pass filename like "a.txt" to
securesyslib.util.ensure_parent_dir function, then the directory
of the file will be '' and when calling
securesyslib.storage.create_folder() with '' argument
an exception will be thrown because of the latest changes
in securesyslib.

Please verify and check that the pull request fulfils 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 Jul 17, 2020

Coverage Status

Coverage increased (+0.0005%) to 98.944% when pulling 48d2106 on MVrachev:fix-empty-directory into 6f88f63 on secure-systems-lab:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.0005%) to 98.944% when pulling 48d2106 on MVrachev:fix-empty-directory into 6f88f63 on secure-systems-lab:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0005%) to 98.944% when pulling 48d2106 on MVrachev:fix-empty-directory into 6f88f63 on secure-systems-lab:master.

@coveralls
Copy link

coveralls commented Jul 17, 2020

Coverage Status

Coverage increased (+0.0005%) to 98.944% when pulling 247cf9b on MVrachev:fix-empty-directory into 6f88f63 on secure-systems-lab:master.

@MVrachev MVrachev force-pushed the fix-empty-directory branch from 48d2106 to 495346f Compare July 17, 2020 11:53
Copy link
Collaborator

@joshuagl joshuagl left a comment

Choose a reason for hiding this comment

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

Thanks for finding and fixing this Martin. Looks like I removed similar logic to the change you implemented when I ported the util methods to the abstract storage backend in 8deb29f, only it wasn't a problem at the time because create_folder would silently handle an empty string.

I have added a comment to the test you've added for this inline, otherwise this looks good to me 👍

# then the directory of that filepath will be an empty string.
# We want to make sure that securesyslib.storage.create_folder()
# won't be called with an empty string and thus raise an exception.
securesystemslib.util.ensure_parent_dir('a.txt')
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be simpler if we just moved this test out of the for loop, rather than adding extra handling and a large comment to the for loop. What do you think?

@MVrachev MVrachev force-pushed the fix-empty-directory branch from 495346f to c7a4339 Compare July 24, 2020 11:36
If you pass filename like "a.txt" to
securesyslib.util.ensure_parent_dir function, then the directory
of the file will be '' and when calling
securesyslib.storage.create_folder() with '' argument
an exception will be thrown because of the latest changes
in securesyslib.

Signed-off-by: Martin Vrachev <[email protected]>
@MVrachev MVrachev force-pushed the fix-empty-directory branch from c7a4339 to 247cf9b Compare July 24, 2020 11:37
@MVrachev
Copy link
Collaborator Author

I agree with your comment and I updated the pr with those changes.

Copy link
Collaborator

@joshuagl joshuagl left a comment

Choose a reason for hiding this comment

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

Excellent, thanks for resolving this.

@joshuagl joshuagl merged commit a7308f0 into secure-systems-lab:master Aug 4, 2020
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.

3 participants