-
Notifications
You must be signed in to change notification settings - Fork 564
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update AVA config Add harden for default endowments and test Add some refactoring and fix coverage issues Add endowment registry Add hardening for special endowment cases (snap & ethereum) Refactor nyc config Revert hardening of the ethereum endowment Update ava test runner config Revert default-endowments.ts Additionally harden args and returned values Add script for updating coverage thresholds Refactor tests related to hardening of the endowments (optimization) Update coverage thresholds after refactoring Add tests for endowment modules Add object walker utility Integrate object-walker into the AVA security tests and do some refactoring Revert hardening of a snap endowment in index.ts (for now) Manually resolve coverage threshold confusion after deleting line of code
- Loading branch information
Showing
42 changed files
with
1,321 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"reporter": ["html", "json-summary", "text", "json"], | ||
"reporter": ["html", "json-summary", "json"], | ||
"exclude": ["*.js", "./src/index.ts", "**/*.ava.test.ts"], | ||
"report-dir": "./coverage-ava" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
module.exports = () => { | ||
return { | ||
concurrency: 5, | ||
extensions: ['ts'], | ||
require: ['ts-node/register'], | ||
verbose: true, | ||
files: ['src/**/*.ava.test.ts'], | ||
timeout: '30s', | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* NYC coverage reporter configuration. | ||
*/ | ||
module.exports = { | ||
'check-coverage': true, | ||
branches: 91.02, | ||
lines: 91.36, | ||
functions: 92.85, | ||
statements: 91.36, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/snaps-execution-environments/src/common/endowments/abortController.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Creates AbortController function hardened by SES. | ||
* | ||
* @returns An object with the attenuated `AbortController` function. | ||
*/ | ||
const createAbortController = () => { | ||
return { | ||
AbortController: harden(AbortController), | ||
} as const; | ||
}; | ||
|
||
const endowmentModule = { | ||
names: ['AbortController'] as const, | ||
factory: createAbortController, | ||
}; | ||
export default endowmentModule; |
16 changes: 16 additions & 0 deletions
16
packages/snaps-execution-environments/src/common/endowments/abortSignal.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Creates AbortSignal function hardened by SES. | ||
* | ||
* @returns An object with the attenuated `AbortSignal` function. | ||
*/ | ||
const createAbortSignal = () => { | ||
return { | ||
AbortSignal: harden(AbortSignal), | ||
} as const; | ||
}; | ||
|
||
const endowmentModule = { | ||
names: ['AbortSignal'] as const, | ||
factory: createAbortSignal, | ||
}; | ||
export default endowmentModule; |
16 changes: 16 additions & 0 deletions
16
packages/snaps-execution-environments/src/common/endowments/arrayBuffer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Creates ArrayBuffer function hardened by SES. | ||
* | ||
* @returns An object with the attenuated `ArrayBuffer` function. | ||
*/ | ||
const createArrayBuffer = () => { | ||
return { | ||
ArrayBuffer: harden(ArrayBuffer), | ||
} as const; | ||
}; | ||
|
||
const endowmentModule = { | ||
names: ['ArrayBuffer'] as const, | ||
factory: createArrayBuffer, | ||
}; | ||
export default endowmentModule; |
16 changes: 16 additions & 0 deletions
16
packages/snaps-execution-environments/src/common/endowments/atob.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Creates atob function hardened by SES. | ||
* | ||
* @returns An object with the attenuated `atob` function. | ||
*/ | ||
const createAtob = () => { | ||
return { | ||
atob: harden(atob), | ||
} as const; | ||
}; | ||
|
||
const endowmentModule = { | ||
names: ['atob'] as const, | ||
factory: createAtob, | ||
}; | ||
export default endowmentModule; |
16 changes: 16 additions & 0 deletions
16
packages/snaps-execution-environments/src/common/endowments/bigInt.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Creates BigInt function hardened by SES. | ||
* | ||
* @returns An object with the attenuated `BigInt` function. | ||
*/ | ||
const createBigInt = () => { | ||
return { | ||
BigInt: harden(BigInt), | ||
} as const; | ||
}; | ||
|
||
const endowmentModule = { | ||
names: ['BigInt'] as const, | ||
factory: createBigInt, | ||
}; | ||
export default endowmentModule; |
16 changes: 16 additions & 0 deletions
16
packages/snaps-execution-environments/src/common/endowments/bigInt64Array.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Creates BigInt64Array function hardened by SES. | ||
* | ||
* @returns An object with the attenuated `BigInt64Array` function. | ||
*/ | ||
const createBigInt64Array = () => { | ||
return { | ||
BigInt64Array: harden(BigInt64Array), | ||
} as const; | ||
}; | ||
|
||
const endowmentModule = { | ||
names: ['BigInt64Array'] as const, | ||
factory: createBigInt64Array, | ||
}; | ||
export default endowmentModule; |
16 changes: 16 additions & 0 deletions
16
packages/snaps-execution-environments/src/common/endowments/bigUint64Array.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Creates BigUint64Array function hardened by SES. | ||
* | ||
* @returns An object with the attenuated `BigUint64Array` function. | ||
*/ | ||
const createBigUint64Array = () => { | ||
return { | ||
BigUint64Array: harden(BigUint64Array), | ||
} as const; | ||
}; | ||
|
||
const endowmentModule = { | ||
names: ['BigUint64Array'] as const, | ||
factory: createBigUint64Array, | ||
}; | ||
export default endowmentModule; |
16 changes: 16 additions & 0 deletions
16
packages/snaps-execution-environments/src/common/endowments/btoa.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Creates btoa function hardened by SES. | ||
* | ||
* @returns An object with the attenuated `btoa` function. | ||
*/ | ||
const createBtoa = () => { | ||
return { | ||
btoa: harden(btoa), | ||
} as const; | ||
}; | ||
|
||
const endowmentModule = { | ||
names: ['btoa'] as const, | ||
factory: createBtoa, | ||
}; | ||
export default endowmentModule; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/snaps-execution-environments/src/common/endowments/dataView.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Creates DataView function hardened by SES. | ||
* | ||
* @returns An object with the attenuated `DataView` function. | ||
*/ | ||
const createDataView = () => { | ||
return { | ||
DataView: harden(DataView), | ||
} as const; | ||
}; | ||
|
||
const endowmentModule = { | ||
names: ['DataView'] as const, | ||
factory: createDataView, | ||
}; | ||
export default endowmentModule; |
Oops, something went wrong.