REPL history file should not be world-readableΒ #3392
Copy link
Copy link
Closed
Labels
good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.replIssues and PRs related to the REPL subsystem.Issues and PRs related to the REPL subsystem.securityIssues and PRs related to security.Issues and PRs related to security.
Description
This is what we normally do for privacy.
~ $ ll .*history
-rw------- 1 xecycle xecycle 1.1K Sep 23 12:02 .bash_history
-rw------- 1 xecycle xecycle 326 Jun 23 16:30 .gnuplot_history
-rw------- 1 xecycle xecycle 67K Sep 18 14:32 .mysql_history
-rw-r--r-- 1 xecycle xecycle 0 Oct 16 13:17 .node_repl_history
-rw------- 1 xecycle xecycle 20K Oct 12 17:18 .psql_history
-rw------- 1 xecycle xecycle 15 Mar 11 2015 .zcalc_history
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.replIssues and PRs related to the REPL subsystem.Issues and PRs related to the REPL subsystem.securityIssues and PRs related to security.Issues and PRs related to security.
Activity
Trott commentedon Oct 16, 2015
FWIW,
irbalso does not enforce a restrictive umask.I agree, though, that it ought to default to umask 077.
XeCycle commentedon Oct 16, 2015
This is trivial to fix, and I am working on it. Do we want to
chmodexisting files?rvagg commentedon Oct 16, 2015
probably only do it on file creation
anyone know what the .bash_history policy is here? that might be worth copying.
XeCycle commentedon Oct 16, 2015
Bash does not chmod. So I am going that way.
targos commentedon Oct 16, 2015
zsh creates it like that:
-rw------- 1 mzasso mzasso 37 16 oct. 09:07 .zsh_historyTrott commentedon Oct 16, 2015
@XeCycle The fix is trivial (a one-line change in
lib/internal/repl.js) but the test is a little tricky. Here's what I came up with for a test (to be put in a file with a name along the lines oftest/parallel/test-repl-history.js)Trott commentedon Oct 16, 2015
While writing the above test, I noticed that I do not need to pass
--expose-internalsto requireinternal/repl. Is that a bug?XeCycle commentedon Oct 16, 2015
@Trott I am attempting to test for it on process
beforeExit. Not very sure about everything, but I think it better to avoid testing on internal interface.Trott commentedon Oct 16, 2015
I ran into issues going that route. I think it was because of the way a history file is not created if there is no tty. There may very well be a way around that issue (or whatever weirdness I was running into). So, yes, all things being equal, if you can make it work, testing against the public interface would probably be better.
XeCycle commentedon Oct 16, 2015
I see, the problem is not about terminals. Only
internal/replcreates a history file, the publicrepldoes not.Trott commentedon Oct 16, 2015
Right, so you'd need to use
spawn()or similar to fire up anothernodeinstance and have it enter the REPL the same way a user would. And that's where the terminal stuff (or something like it) comes up. I gave up on that route and came up with the above test instead. (It's yours to use or ignore as you see fit!)XeCycle commentedon Oct 16, 2015
The way looks to me like adding it in
test/addonsa directory for this and callopenptyfrom C++... Isttygoing to have anopenpty?XeCycle commentedon Oct 16, 2015
Oh,
openptyis not available on Windows. I give up, will use your test code, adding a dumb stream so that stdout is also silent.repl: create history file with mode 0600
repl: create history file with mode 0600
repl: create history file with mode 0600
repl: create history file with mode 0600
repl: create history file with mode 0600
repl: create history file with mode 0600
repl: create history file with mode 0600