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(tests): avoid installing package from untrusted registry in integration tests [SECURITY] #8776

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions __tests__/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,16 +233,12 @@ describe('--registry option', () => {
expect(lockfile[2]).toContain(registry);
});

test('--registry option with non-exiting registry and show an error', async () => {
test('--registry option with nonexistent registry and show an error', async () => {
const cwd = await makeTemp();
const registry = 'https://example-registry-doesnt-exist.com';
const registry = 'https://example-registry-doesnt-exist.invalid'; // RFC 6761

try {
await runYarn(['add', 'is-array', '--registry', registry], {cwd});
} catch (err) {
const stdoutOutput = err.message;
expect(stdoutOutput.toString()).toMatch(/getaddrinfo ENOTFOUND example-registry-doesnt-exist\.com/g);
}
const yarnAdd = runYarn(['add', 'is-array', '--registry', registry, '--ignore-scripts'], {cwd});
await expect(yarnAdd).rejects.toThrow('getaddrinfo ENOTFOUND example-registry-doesnt-exist.invalid');

Choose a reason for hiding this comment

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

Note some DNSs time out on .invalid domains throwing EAI_AGAIN.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks @ylemkimon - I wasn't aware of that. Updated the test to expect either ENOTFOUND or EAI_AGAIN from getaddrinfo.

Let me know what you think.

});

test('registry option from yarnrc', async () => {
Expand Down