Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* [email protected]

* Update LavaMoat policies

* Bump execution environment and fix a breaking change

* Fix caveat and permissions

* Fix test

* Exclude keyring endowment for now

* Fix test

* Fix snap_confirm missing title
  • Loading branch information
FrederikBolding authored Oct 7, 2022
1 parent db59186 commit 7ba0f78
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 120 deletions.
9 changes: 7 additions & 2 deletions app/scripts/controllers/permissions/flask/snap-permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import {
restrictedMethodPermissionBuilders,
selectHooks,
} from '@metamask/rpc-methods';
import { ExcludedSnapPermissions } from '../../../../../shared/constants/permissions';
import {
ExcludedSnapEndowments,
ExcludedSnapPermissions,
} from '../../../../../shared/constants/permissions';

/**
* @returns {Record<string, Record<string, unknown>>} All endowment permission
Expand All @@ -12,7 +15,9 @@ import { ExcludedSnapPermissions } from '../../../../../shared/constants/permiss
export const buildSnapEndowmentSpecifications = () =>
Object.values(endowmentPermissionBuilders).reduce(
(allSpecifications, { targetKey, specificationBuilder }) => {
allSpecifications[targetKey] = specificationBuilder();
if (!ExcludedSnapEndowments.has(targetKey)) {
allSpecifications[targetKey] = specificationBuilder();
}
return allSpecifications;
},
{},
Expand Down
2 changes: 2 additions & 0 deletions app/scripts/controllers/permissions/specifications.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { constructPermission, PermissionType } from '@metamask/controllers';
///: BEGIN:ONLY_INCLUDE_IN(flask)
import { endowmentCaveatSpecifications as snapsEndowmentCaveatSpecifications } from '@metamask/snap-controllers';
import { caveatSpecifications as snapsCaveatsSpecifications } from '@metamask/rpc-methods';
///: END:ONLY_INCLUDE_IN
import {
Expand Down Expand Up @@ -69,6 +70,7 @@ export const getCaveatSpecifications = ({ getIdentities }) => {

///: BEGIN:ONLY_INCLUDE_IN(flask)
...snapsCaveatsSpecifications,
...snapsEndowmentCaveatSpecifications,
///: END:ONLY_INCLUDE_IN
};
};
Expand Down
5 changes: 4 additions & 1 deletion app/scripts/controllers/permissions/specifications.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('PermissionController specifications', () => {
describe('caveat specifications', () => {
it('getCaveatSpecifications returns the expected specifications object', () => {
const caveatSpecifications = getCaveatSpecifications({});
expect(Object.keys(caveatSpecifications)).toHaveLength(3);
expect(Object.keys(caveatSpecifications)).toHaveLength(4);
expect(
caveatSpecifications[CaveatTypes.restrictReturnedAccounts].type,
).toStrictEqual(CaveatTypes.restrictReturnedAccounts);
Expand All @@ -27,6 +27,9 @@ describe('PermissionController specifications', () => {
expect(caveatSpecifications.permittedCoinTypes.type).toStrictEqual(
SnapCaveatType.PermittedCoinTypes,
);
expect(caveatSpecifications.snapKeyring.type).toStrictEqual(
SnapCaveatType.SnapKeyring,
);
});

describe('restrictReturnedAccounts', () => {
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ export default class MetamaskController extends EventEmitter {
///: BEGIN:ONLY_INCLUDE_IN(flask)
this.snapExecutionService = new IframeExecutionService({
iframeUrl: new URL(
'https://metamask.github.io/iframe-execution-environment/0.8.0',
'https://metamask.github.io/iframe-execution-environment/0.9.0',
),
messenger: this.controllerMessenger.getRestricted({
name: 'ExecutionService',
Expand Down Expand Up @@ -3744,7 +3744,7 @@ export default class MetamaskController extends EventEmitter {
),
getSnaps: this.controllerMessenger.call.bind(
this.controllerMessenger,
'SnapController:getSnaps',
'SnapController:getPermittedSnaps',
origin,
),
requestPermissions: async (requestedPermissions) => {
Expand Down
28 changes: 9 additions & 19 deletions lavamoat/browserify/beta/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,11 +682,11 @@
"3box>ipfs>ipfs-unixfs-importer>async-iterator-batch": true,
"3box>ipfs>ipfs-unixfs-importer>async-iterator-first": true,
"3box>ipfs>ipfs-unixfs-importer>rabin-wasm": true,
"3box>ipfs>ipfs-unixfs-importer>superstruct": true,
"3box>ipfs>ipld-dag-pb": true,
"3box>ipfs>ipld-raw>multihashing-async": true,
"3box>ipfs>multicodec": true,
"3box>ipfs>multihashes": true,
"3box>ipfs>superstruct": true,
"browserify>buffer": true,
"madge>rc>deep-extend": true
}
Expand Down Expand Up @@ -841,11 +841,11 @@
"3box>ipfs>libp2p>libp2p-floodsub": true,
"3box>ipfs>libp2p>libp2p-ping": true,
"3box>ipfs>libp2p>libp2p-switch": true,
"3box>ipfs>libp2p>superstruct": true,
"3box>ipfs>multiaddr": true,
"3box>ipfs>peer-book": true,
"3box>ipfs>peer-id": true,
"3box>ipfs>peer-info": true,
"3box>ipfs>superstruct": true,
"browserify>events": true,
"browserify>insert-module-globals>is-buffer": true,
"browserify>process": true,
Expand Down Expand Up @@ -3068,20 +3068,13 @@
"setTimeout": true
},
"packages": {
"@metamask/eth-json-rpc-infura>@metamask/utils": true,
"@metamask/eth-json-rpc-infura>eth-json-rpc-middleware": true,
"eth-block-tracker>@metamask/utils": true,
"eth-rpc-errors": true,
"json-rpc-engine": true,
"node-fetch": true
}
},
"@metamask/eth-json-rpc-infura>@metamask/utils": {
"packages": {
"@metamask/eth-json-rpc-infura>@metamask/utils>superstruct": true,
"eslint>fast-deep-equal": true,
"nock>debug": true
}
},
"@metamask/eth-json-rpc-infura>eth-json-rpc-middleware": {
"globals": {
"URL": true,
Expand Down Expand Up @@ -4494,9 +4487,13 @@
}
},
"eth-block-tracker>@metamask/utils": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
},
"packages": {
"@metamask/snap-utils>superstruct": true,
"eslint>fast-deep-equal": true,
"eth-block-tracker>@metamask/utils>superstruct": true,
"nock>debug": true
}
},
Expand Down Expand Up @@ -4553,7 +4550,7 @@
},
"packages": {
"browserify>browser-resolve": true,
"eth-json-rpc-middleware>@metamask/utils": true,
"eth-block-tracker>@metamask/utils": true,
"eth-json-rpc-middleware>eth-sig-util": true,
"eth-json-rpc-middleware>pify": true,
"eth-rpc-errors": true,
Expand All @@ -4563,13 +4560,6 @@
"vinyl>clone": true
}
},
"eth-json-rpc-middleware>@metamask/utils": {
"packages": {
"eslint>fast-deep-equal": true,
"eth-json-rpc-middleware>@metamask/utils>superstruct": true,
"nock>debug": true
}
},
"eth-json-rpc-middleware>eth-sig-util": {
"packages": {
"eth-json-rpc-middleware>eth-sig-util>ethereumjs-abi": true,
Expand Down
52 changes: 24 additions & 28 deletions lavamoat/browserify/flask/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,11 +682,11 @@
"3box>ipfs>ipfs-unixfs-importer>async-iterator-batch": true,
"3box>ipfs>ipfs-unixfs-importer>async-iterator-first": true,
"3box>ipfs>ipfs-unixfs-importer>rabin-wasm": true,
"3box>ipfs>ipfs-unixfs-importer>superstruct": true,
"3box>ipfs>ipld-dag-pb": true,
"3box>ipfs>ipld-raw>multihashing-async": true,
"3box>ipfs>multicodec": true,
"3box>ipfs>multihashes": true,
"3box>ipfs>superstruct": true,
"browserify>buffer": true,
"madge>rc>deep-extend": true
}
Expand Down Expand Up @@ -841,11 +841,11 @@
"3box>ipfs>libp2p>libp2p-floodsub": true,
"3box>ipfs>libp2p>libp2p-ping": true,
"3box>ipfs>libp2p>libp2p-switch": true,
"3box>ipfs>libp2p>superstruct": true,
"3box>ipfs>multiaddr": true,
"3box>ipfs>peer-book": true,
"3box>ipfs>peer-id": true,
"3box>ipfs>peer-info": true,
"3box>ipfs>superstruct": true,
"browserify>events": true,
"browserify>insert-module-globals>is-buffer": true,
"browserify>process": true,
Expand Down Expand Up @@ -3229,20 +3229,13 @@
"setTimeout": true
},
"packages": {
"@metamask/eth-json-rpc-infura>@metamask/utils": true,
"@metamask/eth-json-rpc-infura>eth-json-rpc-middleware": true,
"eth-block-tracker>@metamask/utils": true,
"eth-rpc-errors": true,
"json-rpc-engine": true,
"node-fetch": true
}
},
"@metamask/eth-json-rpc-infura>@metamask/utils": {
"packages": {
"@metamask/eth-json-rpc-infura>@metamask/utils>superstruct": true,
"eslint>fast-deep-equal": true,
"nock>debug": true
}
},
"@metamask/eth-json-rpc-infura>eth-json-rpc-middleware": {
"globals": {
"URL": true,
Expand Down Expand Up @@ -3552,11 +3545,15 @@
}
},
"@metamask/rpc-methods": {
"globals": {
"console.warn": true
},
"packages": {
"@metamask/rpc-methods>@metamask/controllers": true,
"@metamask/rpc-methods>@metamask/key-tree": true,
"@metamask/snap-utils": true,
"@metamask/snap-utils>@metamask/utils": true,
"@metamask/snap-utils>superstruct": true,
"eth-block-tracker>@metamask/utils": true,
"eth-rpc-errors": true
}
},
Expand Down Expand Up @@ -3869,7 +3866,7 @@
"@metamask/snap-controllers>readable-web-to-node-stream": true,
"@metamask/snap-controllers>tar-stream": true,
"@metamask/snap-utils": true,
"@metamask/snap-utils>@metamask/utils": true,
"eth-block-tracker>@metamask/utils": true,
"eth-rpc-errors": true,
"json-rpc-engine": true,
"pump": true
Expand Down Expand Up @@ -4034,8 +4031,13 @@
"removeEventListener": true
},
"packages": {
"@metamask/snap-controllers>@metamask/post-message-stream>readable-stream": true,
"@metamask/snap-utils>@metamask/utils": true
"@metamask/snap-controllers>@metamask/post-message-stream>@metamask/utils": true,
"@metamask/snap-controllers>@metamask/post-message-stream>readable-stream": true
}
},
"@metamask/snap-controllers>@metamask/post-message-stream>@metamask/utils": {
"packages": {
"eslint>fast-deep-equal": true
}
},
"@metamask/snap-controllers>@metamask/post-message-stream>readable-stream": {
Expand Down Expand Up @@ -4259,20 +4261,17 @@
"@babel/core>@babel/types": true,
"@metamask/snap-utils>ajv": true,
"@metamask/snap-utils>rfdc": true,
"@metamask/snap-utils>superstruct": true,
"browserify": true,
"browserify>buffer": true,
"browserify>crypto-browserify": true,
"browserify>events": true,
"browserify>path-browserify": true,
"eslint>fast-deep-equal": true,
"eth-block-tracker>@metamask/utils": true,
"semver": true
}
},
"@metamask/snap-utils>@metamask/utils": {
"packages": {
"eslint>fast-deep-equal": true
}
},
"@metamask/snap-utils>rfdc": {
"packages": {
"browserify>buffer": true
Expand Down Expand Up @@ -5314,9 +5313,13 @@
}
},
"eth-block-tracker>@metamask/utils": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
},
"packages": {
"@metamask/snap-utils>superstruct": true,
"eslint>fast-deep-equal": true,
"eth-block-tracker>@metamask/utils>superstruct": true,
"nock>debug": true
}
},
Expand Down Expand Up @@ -5373,7 +5376,7 @@
},
"packages": {
"browserify>browser-resolve": true,
"eth-json-rpc-middleware>@metamask/utils": true,
"eth-block-tracker>@metamask/utils": true,
"eth-json-rpc-middleware>eth-sig-util": true,
"eth-json-rpc-middleware>pify": true,
"eth-rpc-errors": true,
Expand All @@ -5383,13 +5386,6 @@
"vinyl>clone": true
}
},
"eth-json-rpc-middleware>@metamask/utils": {
"packages": {
"eslint>fast-deep-equal": true,
"eth-json-rpc-middleware>@metamask/utils>superstruct": true,
"nock>debug": true
}
},
"eth-json-rpc-middleware>eth-sig-util": {
"packages": {
"eth-json-rpc-middleware>eth-sig-util>ethereumjs-abi": true,
Expand Down
28 changes: 9 additions & 19 deletions lavamoat/browserify/main/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,11 +682,11 @@
"3box>ipfs>ipfs-unixfs-importer>async-iterator-batch": true,
"3box>ipfs>ipfs-unixfs-importer>async-iterator-first": true,
"3box>ipfs>ipfs-unixfs-importer>rabin-wasm": true,
"3box>ipfs>ipfs-unixfs-importer>superstruct": true,
"3box>ipfs>ipld-dag-pb": true,
"3box>ipfs>ipld-raw>multihashing-async": true,
"3box>ipfs>multicodec": true,
"3box>ipfs>multihashes": true,
"3box>ipfs>superstruct": true,
"browserify>buffer": true,
"madge>rc>deep-extend": true
}
Expand Down Expand Up @@ -841,11 +841,11 @@
"3box>ipfs>libp2p>libp2p-floodsub": true,
"3box>ipfs>libp2p>libp2p-ping": true,
"3box>ipfs>libp2p>libp2p-switch": true,
"3box>ipfs>libp2p>superstruct": true,
"3box>ipfs>multiaddr": true,
"3box>ipfs>peer-book": true,
"3box>ipfs>peer-id": true,
"3box>ipfs>peer-info": true,
"3box>ipfs>superstruct": true,
"browserify>events": true,
"browserify>insert-module-globals>is-buffer": true,
"browserify>process": true,
Expand Down Expand Up @@ -3068,20 +3068,13 @@
"setTimeout": true
},
"packages": {
"@metamask/eth-json-rpc-infura>@metamask/utils": true,
"@metamask/eth-json-rpc-infura>eth-json-rpc-middleware": true,
"eth-block-tracker>@metamask/utils": true,
"eth-rpc-errors": true,
"json-rpc-engine": true,
"node-fetch": true
}
},
"@metamask/eth-json-rpc-infura>@metamask/utils": {
"packages": {
"@metamask/eth-json-rpc-infura>@metamask/utils>superstruct": true,
"eslint>fast-deep-equal": true,
"nock>debug": true
}
},
"@metamask/eth-json-rpc-infura>eth-json-rpc-middleware": {
"globals": {
"URL": true,
Expand Down Expand Up @@ -4494,9 +4487,13 @@
}
},
"eth-block-tracker>@metamask/utils": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
},
"packages": {
"@metamask/snap-utils>superstruct": true,
"eslint>fast-deep-equal": true,
"eth-block-tracker>@metamask/utils>superstruct": true,
"nock>debug": true
}
},
Expand Down Expand Up @@ -4553,7 +4550,7 @@
},
"packages": {
"browserify>browser-resolve": true,
"eth-json-rpc-middleware>@metamask/utils": true,
"eth-block-tracker>@metamask/utils": true,
"eth-json-rpc-middleware>eth-sig-util": true,
"eth-json-rpc-middleware>pify": true,
"eth-rpc-errors": true,
Expand All @@ -4563,13 +4560,6 @@
"vinyl>clone": true
}
},
"eth-json-rpc-middleware>@metamask/utils": {
"packages": {
"eslint>fast-deep-equal": true,
"eth-json-rpc-middleware>@metamask/utils>superstruct": true,
"nock>debug": true
}
},
"eth-json-rpc-middleware>eth-sig-util": {
"packages": {
"eth-json-rpc-middleware>eth-sig-util>ethereumjs-abi": true,
Expand Down
Loading

0 comments on commit 7ba0f78

Please sign in to comment.