Menu

Parse untrusted files with WebAssembly modules that can't touch your network or disk
📰

Parse untrusted files with WebAssembly modules that can't touch your network or disk

DEV Community: rust·Adan Potyondy·3 days ago
#vRw9p565
#devtorust#devto#dev#module#invoice
Long article (1022 words) — no AI summary yet.
Reading 0:00
15s threshold

A supplier emails an invoice. It's a reply, so the text you need sits above a signature and a quoted thread. The PDF is attached as base64. The IBAN inside has two digits swapped.

You could send all of it to an AI model. But most of this work follows rules, and rules are cheaper, faster and give the same answer every time. We wrote those rules as small WebAssembly modules in Rust, and the whole library is MIT-licensed on GitHub: neblex-wasm-modules .

Each module takes JSON in and returns JSON out. Here is why we chose WebAssembly, and how five modules handled three invoice emails.

Why WebAssembly for parsing untrusted input?

A WebAssembly module runs in a sandbox separated from the host . It can only reach the outside world through its imports: a list of host functions, such as reading a file or opening a connection, that the host passes in when the module starts .

Our modules have no imports at all, and we check that before every release.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.