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

Make the master.key readable only by the owner #32627

Merged
merged 1 commit into from Apr 19, 2018
Merged

Make the master.key readable only by the owner #32627

merged 1 commit into from Apr 19, 2018

Conversation

jlduran
Copy link
Contributor

@jlduran jlduran commented Apr 18, 2018

This change may only apply to POSIX-compliant systems.

Previously:

$ ls -l config/master.key
-rw-r--r--   1 owner  group      32 Jan 1 00:00 master.key

Now:

$ ls -l config/master.key
-rw-------   1 owner  group      32 Jan 1 00:00 master.key

Fixes #32604.

@rails-bot
Copy link

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @schneems (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review.

Please see the contribution instructions for more information.

@pixeltrix
Copy link
Contributor

@jlduran thanks for the PR - does the chmod command silently fail on Windows or does it raise an error? if the latter we need a check before running the command. Also a test added to app_generator_test.rb would be good too. 👍

@jlduran
Copy link
Contributor Author

jlduran commented Apr 19, 2018

@pixeltrix

does the chmod command silently fail on Windows or does it raise an error?

According to this SO answer, chmod is a noop on Windows. I do not have a machine to test it at the moment.

Also a test added to app_generator_test.rb would be good too.

What is the recommended way to skip testing on Windows?

unless Gem.win_platform?
  # test here
end

@pixeltrix
Copy link
Contributor

@jlduran yes, looks like Gem.win_platform? is the check we've used elsewhere.

def test_master_key_is_only_readable_by_the_owner
run_generator

assert_nil File.world_readable?("config/master.key")
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we're setting the group read bit as well we should make this more explicit like:

stat = File.stat("config/master.key")
assert_equal "100600", sprintf("%o, stat.mode)

@pixeltrix
Copy link
Contributor

Once you've made the test change can you squash your commits and then we're good to go - thanks 👍

This change may only apply to POSIX-compliant systems.

Previously:

    $ ls -l config/master.key
    -rw-r--r--   1 owner  group      32 Jan 1 00:00 master.key

Now:

    $ ls -l config/master.key
    -rw-------   1 owner  group      32 Jan 1 00:00 master.key
@pixeltrix pixeltrix merged commit 1a32e05 into rails:master Apr 19, 2018
@pixeltrix
Copy link
Contributor

@jlduran thanks! 👍

@jlduran jlduran deleted the make-master-key-readable-only-by-owner branch April 19, 2018 13:11
pixeltrix added a commit that referenced this pull request Apr 19, 2018
…by-owner

Make the master.key readable only by the owner
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.

None yet

4 participants