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

Don't compute integrity when network restricted #6248

Merged
merged 3 commits into from
Aug 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions __tests__/commands/_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export function makeConfigFromDirectory(cwd: string, reporter: Reporter, flags:
prefix: flags.prefix,
production: flags.production,
updateChecksums: !!flags.updateChecksums,
offline: !!flags.offline,
focus: !!flags.focus,
enableDefaultRc: !flags.noDefaultRc,
extraneousYarnrcFiles: flags.useYarnrc,
Expand Down
5 changes: 5 additions & 0 deletions __tests__/commands/install/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,11 @@ test('install should create integrity field if not present', () =>
// backwards-compatibility
}));

test('install should not create integrity field if not present and in offline mode', () =>
runInstall({offline: true}, 'install-update-auth-no-offline-integrity', async config => {
expect(await fs.exists(path.join(config.cwd, 'node_modules', 'abab'))).toEqual(true);
}));

test('install should ignore existing hash if integrity is present even if it fails to authenticate it', () =>
expect(runInstall({}, 'install-update-auth-bad-sha512-good-hash')).rejects.toMatchObject({
message: expect.stringContaining("computed integrity doesn't match our records"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn-offline-mirror "./offline-mirror"
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "install-update-auth-no-offline-integrity",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"abab": "^2.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


abab@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.0.tgz#aba0ab4c5eee2d4c79d3487d85450fb2376ebb0f"
4 changes: 2 additions & 2 deletions src/resolvers/registries/npm-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ export default class NpmResolver extends RegistryResolver {
}
}
}
if (shrunk && shrunk._remote && shrunk._remote.integrity) {
// if the integrity field does not exist, it needs to be created
if (shrunk && shrunk._remote && (shrunk._remote.integrity || this.config.offline)) {
// if the integrity field does not exist and we're not network-restricted, it needs to be created
return shrunk;
}

Expand Down