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

Allow read-only node_modules folder with more sophisticated type check #40

Open
cdauth opened this issue Nov 16, 2023 · 1 comment
Open

Comments

@cdauth
Copy link

cdauth commented Nov 16, 2023

I'm hardening the Docker image of my Node.js app by making the whole app owned by root but run it as another user so that it cannot modify itself. To make the cache work, only the node_modules/.cache/myapp folder is owned by the app user.

Currently, with the changes introduced by #10, find-cache-dir returns null if node_modules is not writable.

Here is how I think the permission check should work instead if node_modules is found:

  • If node_modules/.cache/${name} exists: If it is writeable, return node_modules/.cache/${name}, otherwise return null
  • Otherwise, if node_modules/.cache exists: If it is writeable, return node_modules/.cache/${name}, otherwise return null
  • Otherwise: If node_modules is writeable, return node_modules/.cache/${name}, otherwise return null

As a workaround for now, I can specify the cache dir using the CACHE_DIR environment variable.

@sindresorhus
Copy link
Owner

This is an extreme edge-case, but a good pull request with tests would be accepted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants