Skip to content

Commit 2de103b

Browse files
hyperpolymathclaude
andcommitted
Add P6: rescript-dom-mounter integration as critical dogfooding lesson
panic-attack flagged innerHTML usage as HIGH severity. The correct fix is to use rescript-dom-mounter (SafeDOM.mountStringParsed) which provides 4-layer defence-in-depth with formal verification — not just swapping innerHTML for createElement. Document this as the priority fix. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 426d190 commit 2de103b

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

sinople-theme/DOGFOODING-LESSONS.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,31 @@ Rocket Loader, aggressive caching, respect origin cache headers.
159159
**Action:** Create `scripts/cloudflare-baseline.sh` that applies these settings
160160
to any zone via the Cloudflare API.
161161

162+
### P6: Replace innerHTML with rescript-dom-mounter (CRITICAL)
163+
panic-attack flagged innerHTML usage in graph-viewer.js and navigation.js as
164+
HIGH severity. The correct fix is NOT to replace innerHTML with createElement
165+
(that's just a different unsafe API). The correct fix is to use
166+
**rescript-dom-mounter** (`hyperpolymath/rescript-dom-mounter`) which provides:
167+
168+
- 4-layer defence-in-depth (validation, DOMPurify, Trusted Types, CSP nonce)
169+
- `mountStringParsed` — DOMParser-based mounting with NO innerHTML sink
170+
- Compile-time guarantees via opaque `validSelector` and `validHtml` types
171+
- Formal verification of mount correctness via Idris2 ABI proofs
172+
173+
**Action:** Add rescript-dom-mounter as a dependency. Rewrite graph-viewer.js
174+
and navigation.js in ReScript using SafeDOM.mountStringParsed. Remove all raw
175+
innerHTML/document.write calls from the theme's JS. This is the whole point of
176+
the library — eat your own dogfood.
177+
178+
```rescript
179+
// Before (UNSAFE):
180+
// element.innerHTML = graphHtml
181+
182+
// After (PROVEN SAFE):
183+
open SafeDOM
184+
let _ = mountStringParsed("#graph-container", graphHtml)
185+
```
186+
162187
## Performance Benchmarks (2026-03-16)
163188

164189
| Site | TTFB | Total | Size | Notes |

0 commit comments

Comments
 (0)