@zvenigora/ng-eval-core 0.9.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -14,7 +14,83 @@ Versions 0.1.104–0.1.107 are on npm without entries here.
14
14
 
15
15
  ---
16
16
 
17
- ## [0.9.0] - 2026-10-02
17
+ ## [0.10.1] - 2026-10-05
18
+
19
+ **A security fix: an expression no longer resolves a name on the prototype-pollution blocklist
20
+ against its context.** A patch for every version up to 0.10.0, with no exported symbol changed.
21
+ It is a patch although an expression that names such a key of its context now throws where it
22
+ used to read a value: the names are `Object.prototype`'s own, a context key with one of them is
23
+ rare, and the defect is a security one. `eval-signals` 0.3.0 and `eval-forms` 0.3.x admit it in
24
+ their peer ranges.
25
+
26
+ ### Security
27
+ - **An expression no longer resolves a name on the prototype-pollution blocklist against its
28
+ context** (B6 in the repository's backlog). An identifier is resolved against the context, and
29
+ for a context built from a plain object or a class instance the lookup was a bare property
30
+ access, so an identifier resolved the members the context inherits from `Object.prototype`; so
31
+ did `this.k` and `this["k"]`. The blocklist guarded member access to the objects an expression
32
+ holds, not resolution against the context, and through `Object`'s own static functions an
33
+ expression could then modify shared prototypes. Every published version up to 0.10.0 is
34
+ affected.
35
+ - **Now refused before any lookup**, with the error the member visitor throws for any other
36
+ object, `Access to dangerous property "constructor" is blocked for security reasons`:
37
+ `__proto__`, `constructor`, `prototype`, the four `__define…` and `__lookup…` accessors,
38
+ `hasOwnProperty`, `isPrototypeOf`, `propertyIsEnumerable`, `toString`, `valueOf` and
39
+ `toLocaleString`, as an identifier, as `this.k` or `this["k"]`, or as a member of an
40
+ `EvalScope` held in the context. This applies over every kind of context: a plain object, a
41
+ `Registry`, a class instance, an `EvalContext`, a prior scope or a signal context. Under
42
+ `caseInsensitive` the key the lookup matched is checked too, so `CONSTRUCTOR` over a context
43
+ that holds `constructor` is refused.
44
+ - **A context key with one of those names can no longer be read by an expression**, even where
45
+ the context holds it as a key of its own, as a `Registry` or a signal context's source can.
46
+ Rename the key. An arrow parameter or a `let` with one of these names was already refused.
47
+
48
+ ---
49
+
50
+ ## [0.10.0] - 2026-10-03
51
+
52
+ **An opt-in member-write policy on `EvalContext`, and three fixes.** Nothing changes for a context
53
+ that does not opt in, and every change to an exported symbol is an addition: `EvalContext` gains
54
+ an optional method and `EvalMemberWrite` is new. The three fixes change what an expression
55
+ evaluates to, where it was wrong, and one of them adds a behaviour: a member write now runs the
56
+ caller's setter. `eval-signals` 0.3.0 builds on the policy and requires this version.
57
+
58
+ ### Added
59
+ - **`EvalContext.checkMemberWrite?(write: EvalMemberWrite)`**, an optional method, and the
60
+ **`EvalMemberWrite`** interface, `{ target, key, createdByEvaluation }`. A subclass that
61
+ implements the method is asked before every member write — `o.k = v`, `o.k += v`, `o.k++` —
62
+ none of which reach `set`. To refuse one it throws, and nothing is written. `createdByEvaluation`
63
+ says whether the walk created the target: an object, array or regex literal, a rest value, or an
64
+ arrow function. A call's result and a `new` result never count, even when new, because either
65
+ can return an existing object — `[o].find(x => true)` returns `o`. Implementing the method is the
66
+ opt-in: the walk then records, per `EvalState`, the objects it creates. A context that does not
67
+ implement it pays one field read at each recording site and each member write, and nothing else.
68
+
69
+ ### Fixed
70
+ - **A regex literal is a new `RegExp` on each evaluation.** Acorn builds a regex literal's
71
+ `RegExp` once, at parse time, and every evaluation of one parsed expression shared it — a
72
+ string `EvalService` has cached, and each call of a compiled expression — so a global regex
73
+ carried `lastIndex` from one evaluation into the next: `let r = /a/g; r.test("a")` answered
74
+ `true`, then `false`. Each evaluation now pushes a copy with the same source and flags, at
75
+ `lastIndex` 0, and `let f = () => /a/; f() === f()` is `false`, as in JavaScript.
76
+ - **A hole in an array pattern keeps its position.** Holes were dropped before binding by index,
77
+ so every element after one read its neighbour's value: `let [, b] = [1, 2]` bound `b` to `1`,
78
+ `(([, y]) => y)([1, 2])` returned `1`, and `let [, ...r] = [1, 2, 3]` bound `r` to
79
+ `[1, 2, 3]`. They now bind as JavaScript does: `2`, `2` and `[2, 3]`.
80
+ - **A member write assigns, as JavaScript does — [A23](../../docs/backlog-retired.md#a23).**
81
+ `o.k = v`, `o.k += v` and `o.k++` defined the property with `Object.defineProperty` instead, after
82
+ the same prototype-pollution refusals, which are unchanged. So `r.lastIndex = 0` on a regex and
83
+ `a.length = 0` on an array threw `Failed to set property … Cannot redefine property`, as did any
84
+ non-configurable property; a non-enumerable property became enumerable; and a setter on the
85
+ object you passed in was replaced, or an inherited one hidden, without ever running. Now each
86
+ is an assignment. **Setters now run, and that is the only new behaviour**: reads already ran
87
+ your getters, and a write already ran the getter, reading its target first. A write the object
88
+ refuses — frozen, non-writable, an accessor with no setter — throws, prefixed
89
+ `Failed to set property`, where an accessor with no setter used to be silently replaced.
90
+
91
+ ---
92
+
93
+ ## [0.9.0] - 2026-10-03
18
94
 
19
95
  **A primitive receiver no longer skips the prototype-pollution guard —
20
96
  [B1](../../docs/backlog-retired.md#b1).** A breaking minor. No exported symbol changes shape, but an