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

wrap atomic_write preserving permissions of mets.xml #625

Merged
merged 4 commits into from
Oct 23, 2020

Conversation

kba
Copy link
Member

@kba kba commented Oct 15, 2020

No description provided.

ws = self.resolver.workspace_from_nothing(tempdir)
ws.save_mets()
mets_path = join(ws.directory, 'mets.xml')
assert filemode(stat(mets_path).st_mode) == '-rw-rw-r--'
Copy link
Contributor

Choose a reason for hiding this comment

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

This test fails for me:

 FAILED tests/test_workspace.py::TestWorkspace::test_mets_permissions - AssertionError: assert '-rw-r--r--' == '-rw-rw-r--'

I am afraid that it won't work without using umask.

Copy link
Member Author

Choose a reason for hiding this comment

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

@stweil Can you test again with f92c5a3? This incorporates your umask approach from #608 with a workaround by @pabs3 from untitaker/python-atomicwrites#42

@codecov-io
Copy link

codecov-io commented Oct 20, 2020

Codecov Report

Merging #625 into master will increase coverage by 0.28%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #625      +/-   ##
==========================================
+ Coverage   84.72%   85.00%   +0.28%     
==========================================
  Files          52       52              
  Lines        2952     2975      +23     
  Branches      575      577       +2     
==========================================
+ Hits         2501     2529      +28     
+ Misses        336      332       -4     
+ Partials      115      114       -1     
Impacted Files Coverage Δ
ocrd_utils/ocrd_utils/__init__.py 100.00% <ø> (ø)
ocrd/ocrd/workspace.py 68.88% <100.00%> (-0.10%) ⬇️
ocrd/ocrd/workspace_backup.py 100.00% <100.00%> (ø)
ocrd_utils/ocrd_utils/os.py 95.74% <100.00%> (+2.19%) ⬆️
ocrd_utils/ocrd_utils/logging.py 92.77% <0.00%> (+7.63%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 56c4aa6...898dfd4. Read the comment docs.

@pabs3
Copy link

pabs3 commented Oct 21, 2020 via email

@kba
Copy link
Member Author

kba commented Oct 21, 2020

Please note the security and other issues mentioned in the python- tomicwrites issue.

Noted. We're using atomicwrites to avoid SIGINT in the middle of writing, permission escalation is not an issue here. Thanks for the workaround.

tests/test_workspace.py Outdated Show resolved Hide resolved
@kba kba merged commit e541437 into master Oct 23, 2020
@kba kba deleted the reset-mets-permissions branch October 23, 2020 15:36
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.

5 participants