Skip to content

Commit

Permalink
fix(picky-wasm): [SECURITY] remove wee_alloc dependency
Browse files Browse the repository at this point in the history
`wee_alloc` crate is currently unmaintained and has a few open issues.
In particular, one of these issue is an unbounded memeroy leak. As such,
we stop considering this crate as production-ready and switch to the
default Rust standard allocator in newer NPM packages.

- rustwasm/wee_alloc#106
- rustwasm/wee_alloc#107
- https://rustsec.org/advisories/RUSTSEC-2022-0054.html

Issue: ARC-98
  • Loading branch information
CBenoit committed Sep 19, 2022
1 parent ba2753e commit 64c9a82
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 74 deletions.
67 changes: 10 additions & 57 deletions ffi/wasm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 1 addition & 8 deletions ffi/wasm/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "picky"
version = "0.4.0"
version = "0.4.1"
authors = ["Benoît CORTIER <bcortier@proton.me>"]
edition = "2021"
publish = false
Expand Down Expand Up @@ -35,13 +35,6 @@ serde_json = "1.0.82"
# code size when deploying.
console_error_panic_hook = { version = "0.1.7", optional = true }

# `wee_alloc` is a tiny allocator for wasm that is only ~1K in code size
# compared to the default allocator's ~10K. It is slower than the default
# allocator, however.
#
# Unfortunately, `wee_alloc` requires nightly Rust when targeting wasm for now.
wee_alloc = { version = "0.4.5", optional = true }

getrandom = { version = "0.2.7", features = ["js"] }

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions ffi/wasm/README.md
Expand Up @@ -11,7 +11,7 @@ This should be run in the CI.
2. Build the package:

```
$ wasm-pack build --target web --scope devolutions --out-name picky --features wee_alloc
$ wasm-pack build --target web --scope devolutions --out-name picky
```

3. Rename `@devolutions/picky-wasm` to `@devolutions/picky` in `pkg/package.json`.
Expand All @@ -34,7 +34,7 @@ Other tests are run using `nodejs` and the `ava` testing framework.
For these, you need to build the npm package targeting `nodejs`:

```
$ wasm-pack build --target nodejs --scope @devolutions --out-name picky --features wee_alloc
$ wasm-pack build --target nodejs --scope @devolutions --out-name picky
```

Rename `@devolutions/picky-wasm` to `@devolutions/picky` in `pkg/package.json`.
Expand Down
2 changes: 1 addition & 1 deletion ffi/wasm/publish.ps1
Expand Up @@ -2,7 +2,7 @@

$ErrorActionPreference = "Stop"

wasm-pack build --target bundler --scope devolutions --out-name picky --features wee_alloc
wasm-pack build --target bundler --scope devolutions --out-name picky

if ($LastExitCode -ne 0)
{
Expand Down
6 changes: 0 additions & 6 deletions ffi/wasm/src/lib.rs
Expand Up @@ -7,12 +7,6 @@ pub mod pem;

use wasm_bindgen::prelude::*;

// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
// allocator.
#[cfg(festure = "wee_alloc")]
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;

#[wasm_bindgen(start)]
pub fn init_picky() -> Result<(), JsValue> {
// When the `console_error_panic_hook` feature is enabled, we can call the
Expand Down

0 comments on commit 64c9a82

Please sign in to comment.