Skip to content
This repository

Set initial config perms 0600, it holds secrets #120

Merged
merged 2 commits into from about 2 years ago

3 participants

Brendon Murphy Nobuhiro IMAI jugyo
Brendon Murphy

Since the config file holds secret keys for oauth, I figured it was best written default the first time with 0600 perms.

Nobuhiro IMAI
Collaborator
no6v commented

Thank you for noticing this. I agree with this patch even though I prefer using mode: "w", perm: 0600 style :).

I think this File instance could be closed immediately by giving (empty) block or close explicitly.
How do you feel? Is that GC job?

Brendon Murphy

Hmm, I wasn't aware File.open could be passed the perm in a hash. If so, that's probably more explicit.

As for closing it, I'd favor explicit .close over an empty block; it would confuse a reader less. I will drop both in an additional commit.

Nobuhiro IMAI
Collaborator
no6v commented

Does "w" leave alone? or {mode: "w"} ? But that is not essential.
Now, everything is reasonable for me, thanks.
@jugyo, can I merge this?

Nobuhiro IMAI
Collaborator
no6v commented

Sorry for my misreading. mode: is there exactly!

jugyo jugyo merged commit 42f70ba into from
jugyo jugyo closed this
jugyo
Owner
jugyo commented

It was merged.
I think 0600 is best.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 1 addition and 1 deletion. Show diff stats Hide diff stats

  1. +1 1  lib/earthquake/core.rb
2  lib/earthquake/core.rb
@@ -85,7 +85,7 @@ def load_config
85 85 if File.exists?(config[:file])
86 86 load config[:file]
87 87 else
88   - File.open(config[:file], 'w')
  88 + File.open(config[:file], mode: 'w', perm: 0600).close
89 89 end
90 90
91 91 config.update(preferred_config) do |key, cur, new|

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.