Skip to content

Commit

Permalink
Prevent --check-files from crossing symlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
Maël Nison committed Jul 14, 2017
1 parent 1de6ccc commit 581113c
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 2 deletions.
10 changes: 10 additions & 0 deletions __tests__/commands/install/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ async function mockConstants(base: Config, mocks: Object, cb: (config: Config) =
beforeEach(request.__resetAuthedRequests);
afterEach(request.__resetAuthedRequests);

test.concurrent('packages installed through the link protocol should validate all peer dependencies', async () => {
await runInstall({checkFiles: true}, 'check-files-should-not-cross-symlinks', async (config): Promise<void> => {
expect(JSON.parse(await fs.readFile(`${config.cwd}/node_modules/.yarn-integrity`)).files).toEqual([
'some-missing-pkg',
'some-other-pkg',
'some-pkg/package.json',
]);
});
});

test.concurrent('installing a package with a renamed file should not delete it', async () => {
await runInstall({}, 'case-sensitivity', async (config, reporter): Promise<void> => {
const pkgJson = await fs.readJson(`${config.cwd}/package.json`);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"some-pkg": "file:./some-pkg/",
"some-other-pkg": "link:./some-other-pkg",
"some-missing-pkg": "link:./some-missing-pkg"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "some-other-pkg",
"version": "1.0.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "some-pkg",
"version": "1.0.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


"some-missing-pkg@link:./some-missing-pkg":
version "0.0.0"
uid ""

"some-other-pkg@link:./some-other-pkg":
version "0.0.0"
uid ""

"some-pkg@file:./some-pkg/":
version "1.0.0"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"build-win-installer": "scripts\\build-windows-installer.bat",
"check-lockfile": "./scripts/check-lockfile.sh",
"lint": "eslint . && flow check",
"prettier": "eslint . --fix",
"prettier": "eslint src __tests__ --fix",
"release-branch": "./scripts/release-branch.sh",
"test": "yarn lint && yarn test-only",
"test-ci": "yarn build && yarn test-only",
Expand Down
2 changes: 1 addition & 1 deletion src/integrity-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export default class InstallationIntegrityChecker {
async function getFilePaths(rootDir: string, files: Array<string>, currentDir: string = rootDir): Promise<void> {
for (const file of await fs.readdir(currentDir)) {
const entry = path.join(currentDir, file);
const stat = await fs.stat(entry);
const stat = await fs.lstat(entry);
if (stat.isDirectory()) {
await getFilePaths(rootDir, files, entry);
} else {
Expand Down

0 comments on commit 581113c

Please sign in to comment.