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

feat(checksums): add integrity field with sha512 authentication to yarn.lock #5042

Merged
merged 68 commits into from
Aug 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
a8c1fbb
test(fixtures): adjust yarn.lock and snapshots with integrity field a…
imsnif Dec 3, 2017
89e8ee4
test(integrity): adjust existing cases to integrity field authentication
imsnif Dec 3, 2017
640c8cc
test(fixtures): integrity field authentication cases
imsnif Dec 5, 2017
6d7fb8d
test(integrity): integration and unit tests for the lockfile integrit…
imsnif Dec 5, 2017
b8208e6
chore(deps): add ssri module
imsnif Dec 5, 2017
cccf5b3
feat(checksums): add integrity field with sha512 authentication to ya…
imsnif Dec 5, 2017
142fbd1
test(integrity): additional sri string options
imsnif Dec 8, 2017
0f57798
fix(checksums): better error when algorithms are not supported
imsnif Dec 8, 2017
a0ec613
fix(checksums): proper error message for bad hash in node <= 6
imsnif Dec 8, 2017
ab3edf7
chore(integrity): fixed new flow issues
imsnif Feb 26, 2018
9d54937
test(integrity): adjust additional test case
imsnif Feb 26, 2018
5b6052d
test(fixtures): additional integrity field authentication cases
imsnif Feb 26, 2018
a037ec8
fix(integrity): update integrity for offline-mirror cases
imsnif Feb 26, 2018
a9e7ef2
style(integrity): clarify conditional for flow
imsnif Feb 26, 2018
6d168d6
fix(integrity): throw sync error rather than rejecting it
imsnif Mar 3, 2018
3e1aeee
Merge remote-tracking branch 'origin/master' into sha512
BYK Mar 8, 2018
d487b0d
Merge branch 'master' into sha512
BYK Mar 8, 2018
f40b2d1
Update yarn.lock with new integrity field
BYK Mar 8, 2018
529ec6e
Merge branch 'master' into sha512
BYK Mar 9, 2018
67afa9b
Upgrade ssri
BYK Mar 9, 2018
71539c4
Merge branch 'master' into sha512
BYK Mar 14, 2018
6618e36
Merge branch 'master' into sha512
BYK Mar 15, 2018
fc521d9
Use the latest version of the SSRI package
BYK Mar 16, 2018
7e72e80
Optimize integrity matching from lockfile a bit
BYK Mar 19, 2018
eecfedd
Refactor digest support determination
BYK Mar 23, 2018
8d24160
Merge branch 'master' into sha512
BYK Mar 24, 2018
5fcaf26
test(error): fixed expected error wording
imsnif Mar 25, 2018
34b3dbd
fix(checksum): fail validation on malformed hash or integrity
imsnif Mar 25, 2018
6fcf610
Merge remote-tracking branch 'upstream/master'
imsnif Mar 25, 2018
f1f3ec3
fix(test): verify integrity failure on malformed integrity string
imsnif Mar 25, 2018
2f32c2d
test(fixtures): add install auth malformed integrity fixture
imsnif Mar 26, 2018
2189fbe
chore(deps): update dependency eslint-config-fb-strict to ^22.0.0 (#5…
renovate[bot] Mar 26, 2018
e46ddcf
chore(jest): Upgrade Jest flow types (#5573)
BYK Mar 26, 2018
2aa1f9f
ci(appveyor): Fix AppVeyor tests (#5574)
BYK Mar 26, 2018
dd3e65e
Fix tests
BYK Mar 26, 2018
fefc462
Add missing package cache
BYK Mar 26, 2018
38d1ca2
Bring --update-checksums back
BYK Mar 26, 2018
4c8b6dd
Fix tests
BYK Mar 26, 2018
ffd14a7
Bring --update-checksums back
BYK Mar 26, 2018
1cd0f8b
Fix Flow error
BYK Mar 26, 2018
fc3621c
Fix error w/ updateChecksums
BYK Mar 26, 2018
ef22207
Merge branch 'master' into sha512
BYK Mar 26, 2018
5d0d972
Update ssri semver in package.json
BYK Mar 26, 2018
376e17c
Stabilize TarballFetcher.fetch tests
BYK Mar 26, 2018
089013c
Moar test fixes
BYK Mar 26, 2018
f35bd24
test(update-checksums): make sure the flag works when integrity is ma…
imsnif Mar 26, 2018
64bc77b
fix(updateChecksums): minor issues and edge cases
imsnif Mar 26, 2018
9540637
Revert unrelated change
BYK Mar 26, 2018
d8f91a0
Slight refactor in lockfile parser
BYK Mar 28, 2018
15959ad
Merge branch 'master' into sha512
BYK Mar 28, 2018
93c6786
Merge branch 'master' into sha512
BYK Apr 10, 2018
a6ab8e7
Merge branch 'master' into sha512
BYK Apr 10, 2018
821a766
Merge branch 'master' into sha512
BYK Apr 12, 2018
8fb6ae8
Merge branch 'master' into sha512
BYK Apr 13, 2018
da2877a
Merge branch 'master' into sha512
BYK Apr 13, 2018
18d138c
Merge branch 'master' into sha512
BYK Apr 13, 2018
5e8b680
Merge branch 'master' into sha512
BYK Apr 19, 2018
8a9e756
Merge branch 'master' into sha512
BYK Apr 26, 2018
c52f3fd
Merge branch 'master' into sha512
BYK Apr 29, 2018
028b5ef
Merge branch 'master' into sha512
BYK May 23, 2018
a833726
test(fixtures): update integrity and dep versions
imsnif May 25, 2018
e88aa54
fix(checksums): create integrity when importing from node_modules
imsnif May 25, 2018
cb4a812
Merge branch 'master' into sha512
BYK Jun 12, 2018
6646e32
test(fixtures): add integrity field to expected yarn.lock
imsnif Jun 13, 2018
7da27ab
Fixes error reporting
Jul 25, 2018
d38712d
Fixes error reporting
Jul 25, 2018
8ca0f87
Fixes tests
Jul 30, 2018
5b70d73
Merge branch 'master' into pr-5042
Jul 30, 2018
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
3 changes: 0 additions & 3 deletions __tests__/__snapshots__/fetchers.js.snap

This file was deleted.

50 changes: 36 additions & 14 deletions __tests__/commands/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ test.concurrent('adding to the workspace root should preserve workspace packages
expect(pkg.dependencies).toEqual({'left-pad': '1.1.3', 'max-safe-integer': '1.0.0'});

const lockfile = explodeLockfile(await fs.readFile(path.join(config.cwd, 'yarn.lock')));
expect(lockfile).toHaveLength(15);
expect(lockfile).toHaveLength(20);
expect(lockfile.indexOf('[email protected]:')).toEqual(0);
expect(lockfile.indexOf('[email protected]:')).toEqual(3);
expect(lockfile.indexOf('[email protected]:')).toEqual(6);
expect(lockfile.indexOf('[email protected]:')).toEqual(4);
expect(lockfile.indexOf('[email protected]:')).toEqual(8);
});
});

Expand Down Expand Up @@ -107,6 +107,28 @@ test.concurrent('adds any new package to the current workspace, but install from
});
});

test.concurrent('add creates an entry with a sha512 integrity field', () => {
return runAdd(['[email protected]'], {}, 'add-integrity-sha512', async config => {
const lockfile = explodeLockfile(await fs.readFile(path.join(config.cwd, 'yarn.lock')));
expect(
lockfile[3].indexOf(
'integrity sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==',
),
).toEqual(2);
expect(lockfile[2].indexOf('#893312af69b2123def71f57889001671eeb2c853"')).toBeGreaterThan(0);
// backwards compatibility
});
});

test.concurrent('add creates an entry with a sha1 integrity field when sha512 is unavailable', () => {
return runAdd(['[email protected]'], {}, 'add-integrity-sha1', async config => {
const lockfile = explodeLockfile(await fs.readFile(path.join(config.cwd, 'yarn.lock')));
expect(lockfile[3].indexOf('integrity sha1-R6La9YHt5FQzTe5sYDbK4A2RLk0=')).toEqual(2);
expect(lockfile[2].indexOf('#47a2daf581ede454334dee6c6036cae00d912e4d')).toBeGreaterThan(0);
// backwards compatibility
});
});

test.concurrent('install with arg', async () => {
await runAdd(['is-online'], {}, 'install-with-arg');
});
Expand Down Expand Up @@ -288,7 +310,7 @@ test.concurrent('add should ignore cache', async () => {

const lockFileWritten = await fs.readFile(path.join(config.cwd, 'yarn.lock'));
const lockFileLines = explodeLockfile(lockFileWritten);
expect(lockFileLines).toHaveLength(3);
expect(lockFileLines).toHaveLength(4);
expect(lockFileLines[0]).toEqual('[email protected]:');
expect(lockFileLines[2]).toMatch(
/resolved "https:\/\/registry\.yarnpkg\.com\/left-pad\/-\/left-pad-1\.1\.0\.tgz#[a-f0-9]+"/,
Expand Down Expand Up @@ -378,9 +400,9 @@ test.concurrent('install --initMirror should add init mirror deps from package.j

const lockFileContent = await fs.readFile(path.join(config.cwd, 'yarn.lock'));
const lockFileLines = explodeLockfile(lockFileContent);
expect(lockFileLines).toHaveLength(8);
expect(lockFileLines).toHaveLength(10);
expect(lockFileLines[0].indexOf('mime-db@')).toEqual(0);
expect(lockFileLines[3].indexOf('[email protected]')).toEqual(0);
expect(lockFileLines[4].indexOf('[email protected]')).toEqual(0);
});
});

Expand Down Expand Up @@ -410,7 +432,7 @@ test.concurrent('add with new dependency should be deterministic', async () => {
const lockFileWritten = await fs.readFile(path.join(config.cwd, 'yarn.lock'));
const lockFileLines = explodeLockfile(lockFileWritten);

expect(lockFileLines).toHaveLength(11);
expect(lockFileLines).toHaveLength(14);
expect(lockFileLines.indexOf('mime-db@~1.0.1:')).toBeGreaterThanOrEqual(0);
expect(lockFileLines.indexOf('[email protected]:')).toBeGreaterThanOrEqual(0);
expect(lockFileLines.indexOf('[email protected]:')).toBeGreaterThanOrEqual(0);
Expand Down Expand Up @@ -449,7 +471,7 @@ test.concurrent('add with new dependency should be deterministic 2', async () =>
const lockFileWritten = await fs.readFile(path.join(config.cwd, 'yarn.lock'));
const lockFileLines = explodeLockfile(lockFileWritten);
// see why we don't cleanup lockfile https://github.com/yarnpkg/yarn/issues/79
expect(lockFileLines).toHaveLength(11);
expect(lockFileLines).toHaveLength(14);

const mirror = await fs.walk(path.join(config.cwd, mirrorPath));
expect(mirror).toHaveLength(3);
Expand Down Expand Up @@ -556,7 +578,7 @@ test.concurrent('upgrade scenario', async () => {

const lockFileWritten = await fs.readFile(path.join(config.cwd, 'yarn.lock'));
const lockFileLines = explodeLockfile(lockFileWritten);
expect(lockFileLines).toHaveLength(3);
expect(lockFileLines).toHaveLength(4);
expect(lockFileLines[0]).toEqual('[email protected]:');
expect(lockFileLines[2]).toMatch(
/resolved "https:\/\/registry\.yarnpkg\.com\/left-pad\/-\/left-pad-0\.0\.9\.tgz#[a-f0-9]+"/,
Expand All @@ -578,7 +600,7 @@ test.concurrent('upgrade scenario', async () => {

const lockFileWritten2 = await fs.readFile(path.join(config.cwd, 'yarn.lock'));
const lockFileLines2 = explodeLockfile(lockFileWritten2);
expect(lockFileLines2).toHaveLength(3);
expect(lockFileLines2).toHaveLength(4);
expect(lockFileLines2[0]).toEqual('[email protected]:');
expect(lockFileLines2[2]).toMatch(
/resolved "https:\/\/registry\.yarnpkg\.com\/left-pad\/-\/left-pad-1.1.0.tgz#[a-f0-9]+"/,
Expand Down Expand Up @@ -613,8 +635,8 @@ test.concurrent('upgrade scenario 2 (with sub dependencies)', async () => {
expect(lockFileLines[0]).toEqual('mime-db@~1.23.0:');
expect(lockFileLines[2]).toMatch(/resolved "https:\/\/registry\.yarnpkg\.com\/mime-db\/-\/mime-db-/);

expect(lockFileLines[3]).toEqual('[email protected]:');
expect(lockFileLines[5]).toMatch(
expect(lockFileLines[4]).toEqual('[email protected]:');
expect(lockFileLines[6]).toMatch(
/resolved "https:\/\/registry\.yarnpkg\.com\/mime-types\/-\/mime-types-2\.1\.11\.tgz#[a-f0-9]+"/,
);

Expand Down Expand Up @@ -665,7 +687,7 @@ test.concurrent('downgrade scenario', async () => {
const mirrorPath = 'mirror-for-offline';
const lockFileWritten = await fs.readFile(path.join(config.cwd, 'yarn.lock'));
const lockFileLines = explodeLockfile(lockFileWritten);
expect(lockFileLines).toHaveLength(3);
expect(lockFileLines).toHaveLength(4);
expect(lockFileLines[0]).toEqual('[email protected]:');
expect(lockFileLines[2]).toMatch(
/resolved "https:\/\/registry\.yarnpkg\.com\/left-pad\/-\/left-pad-1\.1\.0\.tgz#[a-f0-9]+"/,
Expand All @@ -686,7 +708,7 @@ test.concurrent('downgrade scenario', async () => {

const lockFileWritten2 = await fs.readFile(path.join(config.cwd, 'yarn.lock'));
const lockFileLines2 = explodeLockfile(lockFileWritten2);
expect(lockFileLines2).toHaveLength(3);
expect(lockFileLines2).toHaveLength(4);
expect(lockFileLines2[0]).toEqual('[email protected]:');
expect(lockFileLines2[2]).toMatch(
/resolved "https:\/\/registry\.yarnpkg\.com\/left-pad\/-\/left-pad-0\.0\.9\.tgz#[a-f0-9]+"/,
Expand Down
17 changes: 1 addition & 16 deletions __tests__/commands/install/__snapshots__/integration.js.snap
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`don't install with file: protocol as default if target is valid semver: install-file-as-default-no-semver 1`] = `
"{
\\"author\\": \\"AJ ONeal <[email protected]> (http://coolaj86.info)\\",
\\"name\\": \\"foo\\",
\\"description\\": \\"A test module with no \`main\`, \`lib\`, or \`dependencies\` specified\\",
\\"version\\": \\"1.0.0\\",
\\"repository\\": {
\\"type\\": \\"git\\",
\\"url\\": \\"git://github.com/coolaj86/node-pakman.git\\"
},
\\"engines\\": {
\\"node\\": \\">= v0.2\\"
}
}
"
`;
exports[`install should authenticate integrity field with combined sha1 and sha512 checksums: integrity stable 1`] = `" integrity \\"sha1-iTMSr2myEj3vcfV4iQAWce6yyFM= sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==\\""`;
Loading