-
-
Notifications
You must be signed in to change notification settings - Fork 109
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
feat: add execroot & runfiles symlink guards to js_binary #133
Conversation
7b7c6c8
to
4a76052
Compare
4a76052
to
dacb4c5
Compare
3d9e566
to
89eb420
Compare
dd68379
to
c7d9971
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's add the tests too, otherwise it's too tempting to leave it for later...
0faad7c
to
2b133a2
Compare
19bb590
to
2ec930e
Compare
2ec930e
to
7717b25
Compare
Done. Brought unit tests in from rules_nodejs for the patches |
@@ -15,7 +15,7 @@ console.log(c.id()) | |||
const fp = require('@e2e/lib') | |||
console.log('--@e2e/lib--') | |||
console.log(fp.id()) | |||
const rulesFooA = require('../external/rules_foo/foo/node_modules/@aspect-test/a') | |||
const rulesFooA = require('../../rules_foo/foo/node_modules/@aspect-test/a') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting change needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea, the path here is runfiles relative for this test. no legacy external runfiles :)
Fixes #114
The fs patches here have been modified from their original implementation in rules_nodejs https://github.com/bazelbuild/rules_nodejs/blob/173a0252f273de48a6a237518e9cb0d9854cb8e6/packages/node-patches/src/fs.ts.
The have been improved to allow following symlinks within the sandbox, which is required for finding deps in a symlinks node_modules structure. Since the sandbox (on macos) is a tree of symlinks that all point back to their counterparts outside of the sandbox, the old implementation prevented following symlinks entirely (akin to passing `--preserve-symlinks) since every follow was an escape from the guarded sandbox.
In this implementation, if the readlink escape is a symlink to a symlink then we readlink the escaped symlink. For lstat we do the same. For realpath, if we the relative path from the link to the realpath can be remapped into the escaped root then it is.
In rules_js, the guards are setup to protect the execroot (which protects the sandbox when there is one and protects from escaping into the source tree when there isn't) and to protect the runfiles tree for the js_binary in the build, test or run target since that is a symlink tree as well. This is simpler than what was done in rules_nodejs which was to protect all of the dynamically linked node_modules trees.