Skip to content

Use CWD for temp files, and fall back to /tmp only for upstream tests. #361

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

Merged
merged 1 commit into from
Jan 6, 2016

Conversation

flimzy
Copy link
Member

@flimzy flimzy commented Dec 19, 2015

This is an alternative to #334 to fix #303. It uses the CWD for temp files, but falls back to using /tmp only for files found in the system GOROOT path, which should not be vulnerable to the security risks of running nodejs code in /tmp.

If there are ever other situations where we need to run tests in read-only directories, this will fail. I don't know if such cases are likely ever to exist, but if they do, then #334 is probably the preferred solution.

@flimzy
Copy link
Member Author

flimzy commented Jan 4, 2016

Bump?
I'm sure this PR got lost in the recent semi-flurry of other bug reports, not to mention the Real Life™ that we all hopefully have.

But are there any outstanding concerns regarding this PR (or #334) that I should try to tackle, @neelance?

@neelance
Copy link
Member

neelance commented Jan 5, 2016

I like this much better than #334.
@shurcooL What do you think?

@dmitshur
Copy link
Member

dmitshur commented Jan 6, 2016

I'm in agreement. LGTM.

However, one comment about the implementation:

strings.HasPrefix(currentDirectory, runtime.GOROOT())

I believe that is brittle, specifically that it may result in false negatives. However, it shouldn't result in false positives, which is why the PR LGTM and can be merged as is.

It may result in false negatives in:

  • Situations where symlinks are involved in the relevant paths (e.g., imagine currentDirectory has value "/home/user/gorootsymlink" but runtime.GOROOT() returns "/usr/local/go").
  • Situations where case-insensitive filesystems are used (e.g., imagine currentDirectory has value "/USR/Local/GO" but runtime.GOROOT() returns "/usr/local/go").

Those situations are possible but should be rare, so if you're okay with it, we can merge as is, and if the false negatives result in visible problems in situations where it matters, then you can work on improving it. Otherwise it'll be fine as is.

@flimzy
Copy link
Member Author

flimzy commented Jan 6, 2016

Thanks for the feedback, @shurcooL.

Since, in the specific case of upstream Go tests, which this code is meant to address, we do a Chdir to runtime.GOROOT(), then read the input file names from disk, one would hope that this would address both the symlink and case normalization issues.

Still, running one of these tests manually, with a symlink or mismatched case, could lead to a failure. But if someone is running these tests manually in such an environment, hopefully they'll have enough clues to work around the shortcoming... and/or fix the problem at that time, as you suggest.

@dmitshur
Copy link
Member

dmitshur commented Jan 6, 2016

Yep, that sounds good to me.

neelance added a commit that referenced this pull request Jan 6, 2016
Use CWD for temp files, and fall back to /tmp only for upstream tests.
@neelance neelance merged commit f15a4ac into gopherjs:master Jan 6, 2016
@neelance
Copy link
Member

neelance commented Jan 6, 2016

@flimzy As always, thanks for contributing!

@flimzy flimzy deleted the tempdir3 branch January 6, 2016 12:04
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.

gopherjs test + nodejs require == broken and possible security issue
3 participants