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

fix(builtin): don't allow symlinks to escape or enter bazel managed node_module folders #1800

Merged
merged 1 commit into from
Apr 10, 2020

Conversation

gregmagolan
Copy link
Collaborator

@gregmagolan gregmagolan commented Apr 7, 2020

No description provided.

Copy link
Collaborator

@alexeagle alexeagle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow, I kinda understand. I wish @soldair was available for review but I think it's good.

Would be nice to have that added test coverage but I guess there's integration test coverage coming from some downstream usecase like jest?

# escape and no symlinks may enter
if [ "$(basename ${BAZEL_PATCH_ROOT})" == "execroot" ]; then
# We are in execroot, linker node_modules is in the PWD
export BAZEL_PATCH_GUARDS="${PWD}/node_modules"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like this doesn't work if your node_modules is in a subdirectory, which we support - but I think that's what BAZEL_NODE_MODULES_ROOT is doing below? maybe this needs a comment that we do this in a catch-all case where we don't have a BAZEL_NODE_MODULES_ROOT - but then why does that happen?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BAZEL_NODE_MODULES_ROOT is the path to the external workspace such as npm/node_modules.
This path is actually the path to the linker symlink node_modules under execroot which should work regardless of where node_modules is.

Copy link
Collaborator Author

@gregmagolan gregmagolan Apr 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BAZEL_NODE_MODULES_ROOT is always set in templated_args above:

    env_vars += """if [[ -z "${BAZEL_NODE_MODULES_ROOT:-}" ]]; then
  export BAZEL_NODE_MODULES_ROOT=%s
fi
""" % node_modules_root

so below is just a sanity check

@buildsize
Copy link

buildsize bot commented Apr 9, 2020

File name Previous Size New Size Change
release.tar.gz 956.81 KB 957.8 KB 1021 bytes (0%)

@buildsize
Copy link

buildsize bot commented Apr 9, 2020

File name Previous Size New Size Change
release.tar.gz 968.29 KB 969.24 KB 973 bytes (0%)

@gregmagolan gregmagolan force-pushed the node_symlinks_fixes branch 3 times, most recently from 00a4c20 to 23c1500 Compare April 9, 2020 16:25
filipesilva added a commit to filipesilva/angular-cli that referenced this pull request Apr 9, 2020
Snapshot for bazel-contrib/rules_nodejs#1800, taken from https://github.com/aspect-dev/rules_nodejs-builds/tree/labs.

Contains fixes related to the symlink behaviour inside of bazel. Without it, webpack needs to be configured to be aware of symlinks and preserve the paths.
gregmagolan added a commit to gregmagolan/rules_nodejs that referenced this pull request Apr 9, 2020
Issue bazel-contrib#1803 was fixed by bazel-contrib#1800 which is already landed. bazel-contrib#1805 also fixes via a different mechanism and will also land soon.
gregmagolan added a commit to gregmagolan/rules_nodejs that referenced this pull request Apr 9, 2020
Issue bazel-contrib#1813 was fixed by bazel-contrib#1800 which is already landed. bazel-contrib#1805 also fixes via a different mechanism and will also land soon.
gregmagolan added a commit to gregmagolan/rules_nodejs that referenced this pull request Apr 9, 2020
Issue bazel-contrib#1813 was fixed by bazel-contrib#1800 which is already landed. bazel-contrib#1805 also fixes via a different mechanism and will also land soon.
gregmagolan added a commit to gregmagolan/rules_nodejs that referenced this pull request Apr 9, 2020
Issue bazel-contrib#1813 was fixed by bazel-contrib#1800 which is already landed. bazel-contrib#1805 also fixes via a different mechanism and will also land soon.
gregmagolan added a commit to gregmagolan/rules_nodejs that referenced this pull request Apr 9, 2020
Issue bazel-contrib#1813 was fixed by bazel-contrib#1800 which is already landed. bazel-contrib#1805 also fixes via a different mechanism and will also land soon.
@gregmagolan gregmagolan force-pushed the node_symlinks_fixes branch 2 times, most recently from 46c0343 to a5e6da4 Compare April 9, 2020 20:42
gregmagolan added a commit to gregmagolan/rules_nodejs that referenced this pull request Apr 9, 2020
Issue bazel-contrib#1813 was fixed by bazel-contrib#1800 which is already landed. bazel-contrib#1805 also fixes via a different mechanism and will also land soon.
gregmagolan added a commit to gregmagolan/rules_nodejs that referenced this pull request Apr 9, 2020
Issue bazel-contrib#1813 was fixed by bazel-contrib#1800 which is already landed. bazel-contrib#1805 also fixes via a different mechanism and will also land soon.
gregmagolan added a commit that referenced this pull request Apr 9, 2020
Issue #1813 was fixed by #1800 which is already landed. #1805 also fixes via a different mechanism and will also land soon.
@gregmagolan gregmagolan force-pushed the node_symlinks_fixes branch 6 times, most recently from 9773808 to 0209cff Compare April 10, 2020 00:04
@gregmagolan gregmagolan merged commit 4554ce7 into bazel-contrib:master Apr 10, 2020
filipesilva added a commit to filipesilva/angular-cli that referenced this pull request Apr 10, 2020
Snapshot for bazel-contrib/rules_nodejs#1800, taken from https://github.com/aspect-dev/rules_nodejs-builds/tree/labs.

Contains fixes related to the symlink behaviour inside of bazel. Without it, webpack needs to be configured to be aware of symlinks and preserve the paths.
filipesilva added a commit to filipesilva/angular-cli that referenced this pull request Apr 10, 2020
Snapshot for bazel-contrib/rules_nodejs#1800, taken from https://github.com/aspect-dev/rules_nodejs-builds/tree/labs.

Contains fixes related to the symlink behaviour inside of bazel. Without it, webpack needs to be configured to be aware of symlinks and preserve the paths.
filipesilva added a commit to filipesilva/angular-cli that referenced this pull request Apr 10, 2020
Snapshot for bazel-contrib/rules_nodejs#1800, taken from https://github.com/aspect-dev/rules_nodejs-builds/tree/labs.

Contains fixes related to the symlink behaviour inside of bazel. Without it, webpack needs to be configured to be aware of symlinks and preserve the paths.
gregmagolan pushed a commit to gregmagolan/angular-cli that referenced this pull request Apr 10, 2020
Snapshot for bazel-contrib/rules_nodejs#1800, taken from https://github.com/aspect-dev/rules_nodejs-builds/tree/labs.

Contains fixes related to the symlink behaviour inside of bazel. Without it, webpack needs to be configured to be aware of symlinks and preserve the paths.
@soldair
Copy link
Collaborator

soldair commented Apr 14, 2020

\o sorry for the delay. i somehow missed most of my communication last week

filipesilva added a commit to filipesilva/angular-cli that referenced this pull request Apr 16, 2020
Snapshot for bazel-contrib/rules_nodejs#1800, taken from https://github.com/aspect-dev/rules_nodejs-builds/tree/labs.

Contains fixes related to the symlink behaviour inside of bazel. Without it, webpack needs to be configured to be aware of symlinks and preserve the paths.
gregmagolan pushed a commit to filipesilva/angular-cli that referenced this pull request Apr 16, 2020
Snapshot for bazel-contrib/rules_nodejs#1800, taken from https://github.com/aspect-dev/rules_nodejs-builds/tree/labs.

Contains fixes related to the symlink behaviour inside of bazel. Without it, webpack needs to be configured to be aware of symlinks and preserve the paths.
filipesilva added a commit to filipesilva/angular-cli that referenced this pull request Apr 27, 2020
Snapshot for bazel-contrib/rules_nodejs#1800, taken from https://github.com/aspect-dev/rules_nodejs-builds/tree/labs.

Contains fixes related to the symlink behaviour inside of bazel. Without it, webpack needs to be configured to be aware of symlinks and preserve the paths.
gregmagolan pushed a commit to gregmagolan/angular-cli that referenced this pull request Apr 27, 2020
…mmits)

Squashed commits:
[241a8bc] build: use ts_library macro with common defaults
[12b3f3c] build: use @bazel/bazelisk
[22792f3] ci: update required status checks
[d7dbbab] build: use no-remote-exec tag so test still runs in sandbox

Turns out there is a linker bug with no sandbox.
[3eeab18] build: run tests depending on webdriver-manager locally
[2cf4d32] docs: add bazel jasmine_node_test debug information
[c0d3912] build: update to rules_nodejs 1.6.0
[4f0cb97] build: add webdriver-manager update & ngcc to postinstall

This is required so that yarn_install can add all generated & downloaded files to the generated bazel filegroups
[be1f0ed] ci: use xlarge for bazel tests
[27f94da] test: remove non-bazel test setup
[d085d5e] build: update yarn lock
[3bc6c54] test(@angular/cli): add npm_integration_test
[c83a90f] build: add missing npm_package_archive targets
[8f72222] test(@angular-devkit/build-ng-packagr): build and test with Bazel
[c56b83e] test(@angular-devkit/build-angular): build and test with Bazel
[a7e827c] test(@angular-devkit/build-webpack): build and test with Bazel
[4e7bcd3] build: use rules_nodejs snapshot

Snapshot for bazel-contrib/rules_nodejs#1800, taken from https://github.com/aspect-dev/rules_nodejs-builds/tree/labs.

Contains fixes related to the symlink behaviour inside of bazel. Without it, webpack needs to be configured to be aware of symlinks and preserve the paths.
[4507c05] build: don't copy root package test folders
[8b79f9d] fix(@ngtools/webpack): remove internal markers

With these in, we can't access the properties from other Bazel targets.
[e1bc6e1] fix(@ngtools/webpack): export VirtualFileSystemDecorator type

We shouldn't need to export this, but webpack-rollup-loader uses it.
[ffce320] refactor: rename toplevel BUILD to BUILD.bazel
[90e5429] build: also validade BUILD.bazel files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants