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 bug in symlink traversal with indirect targets #1084

Closed
wants to merge 1 commit into from

Conversation

robhogan
Copy link
Contributor

Summary:
Fixes a bug where symlinks beginning with indirections (../) may fail to traverse in some projectRoot / watchFolders configurations.

This occurs due to incomplete "normalisation" of a symlink target in metro-file-map, relative to the project root. Given a project root of /project and a symlink /project/src/link-to-foo -> ../../project/foo.js, we would normalise the target to ../project/foo.js rather than simply foo.js - we were not taking into account that further normalisation could be possible after joining with projectRoot.

"Normal" paths are defined as being fully normalised relative to the project root. The unnecessary indirection out and back into the project root fails because TreeFS is a DAG, and internally there is no entry for rootNode.get('..').get('project') - this would be a cycle back to rootNode.

Changelog:

 * **[Fix]:** Symlinks with indirections may not be resolvable

Differential Revision: D49323614

Summary:
Fixes a bug where symlinks beginning with indirections (`../`) may fail to traverse in some `projectRoot` / `watchFolders` configurations.

This occurs due to incomplete "normalisation" of a symlink target in `metro-file-map`, relative to the project root. Given a project root of `/project` and a symlink `/project/src/link-to-foo  -> ../../project/foo.js`, we would normalise the target to `../project/foo.js` rather than simply `foo.js` - we were not taking into account that further normalisation could be possible after joining with `projectRoot`.

"Normal" paths are defined as being *fully* normalised relative to the project root. The unnecessary indirection out and back into the project root fails because `TreeFS` is a DAG, and internally there is no entry for `rootNode.get('..').get('project')` - this would be a cycle back to `rootNode`.

Changelog:
```
 * **[Fix]:** Symlinks with indirections may not be resolvable
```

Differential Revision: D49323614
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 15, 2023
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49323614

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 6f3f7e6.

@robhogan robhogan deleted the export-D49323614 branch September 20, 2023 11:15
robhogan added a commit that referenced this pull request Jan 9, 2024
Summary:
Pull Request resolved: #1084

Fixes a bug where symlinks beginning with indirections (`../`) may fail to traverse in some `projectRoot` / `watchFolders` configurations.

This occurs due to incomplete "normalisation" of a symlink target in `metro-file-map`, relative to the project root. Given a project root of `/project` and a symlink `/project/src/link-to-foo  -> ../../project/foo.js`, we would normalise the target to `../project/foo.js` rather than simply `foo.js` - we were not taking into account that further normalisation could be possible after joining with `projectRoot`.

"Normal" paths are defined as being *fully* normalised relative to the project root. The unnecessary indirection out and back into the project root fails because `TreeFS` is a DAG, and internally there is no entry for `rootNode.get('..').get('project')` - this would be a cycle back to `rootNode`.

Changelog:
```
 * **[Fix]:** Symlinks with indirections may not be resolvable
```

Reviewed By: yungsters

Differential Revision: D49323614

fbshipit-source-id: e01a10a0455b0af22ebc3cdd7c34ca8fd888d0f4
@robhogan robhogan mentioned this pull request Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants