Commit 1c98ce0
authored
feat(errors): self censoring stack frames (#2928)
Closes: #XXXX
Refs: #XXXX
## Description
Introduces `hideAndHardenFunction` for functions to opt out of having
their frames be visible in abbreviated stacks. See changes to
`lockdown.md` for more.
```js
import { hideAndHardenFunction } from '@endo/errors';
export const foo() = {...stuff...};
hideAndHardenFunction(foo);
console.log(foo.name); // '__HIDE_foo'
```
If a function `foo` is first frozen with `hideAndHardenFunction(foo)`
rather than `freeze(foo)` or `harden(foo)`, then `foo.name` is changed
from `'foo'` to `'__HIDE_foo'`.
When `stackFiltering: 'concise'` or `stackFiltering: 'omit-frames'`,
then (currently only on v8), the stack frames for function whose `name`
begins with `'__HIDE_'` are omitted from the stacks reported by our
causal console. See
### Security Considerations
By allowing functions to opt into this themselves, a sneaky programmer
could use this to hide their attack functions from appearing in frames
of abbreviated stacks. However, more security conscious scenarios should
consider `stackFiltering: 'verbose'` or `stackFiltering:
'shorten-paths'` anyway, which do not drop frames. Nevertheless, this
security hazard is real.
### Scaling Considerations
none
### Documentation Considerations
`hideAndHardenFunction` has a good doc-comment, so presumably that will
appear in docs generated from doc-comments.
### Testing Considerations
As always, test that are about what should appear in stacks are hard to
write regression tests for, since their details depend on, for example,
platform and precise line and column numbers. This would make for
goldens that are *far* to fragile. Instead, I manually tested these, and
I captured the results of manual tests of `deep-send.test.js` in
`lockdown.md`.
### Compatibility Considerations
Production code should never depend on the contents of error messages or
error stacks. However, tests can. We know of goldens for error messages,
but none of error stacks. This PR only affects error stacks, so we do
not expect any compat problems even with golden tests.
### Upgrade Considerations
none1 parent 87530c5 commit 1c98ce0
File tree
19 files changed
+332
-154
lines changed- packages
- common
- errors
- test
- eventual-send/test
- pass-style/test
- patterns
- src/patterns
- test
- ses
- docs
- src/error
19 files changed
+332
-154
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
60 | | - | |
| 61 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
2 | 7 | | |
3 | 8 | | |
4 | 9 | | |
| |||
28 | 33 | | |
29 | 34 | | |
30 | 35 | | |
31 | | - | |
| 36 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
3 | 7 | | |
4 | 8 | | |
5 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| |||
87 | 89 | | |
88 | 90 | | |
89 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
0 commit comments