rustwasm / wasm-bindgen

Facilitating high-level interactions between Wasm modules and JavaScript
https://rustwasm.github.io/docs/wasm-bindgen/
Apache License 2.0
7.74k stars 1.07k forks source link

The generated wasm file should no include users' file path #3422

Closed axetroy closed 1 year ago

axetroy commented 1 year ago

Running the command to compile

wasm-pack build --release --target bundler --out-dir out/bundler

and preview in Chrome

截屏2023-05-11 23 40 44

And we can see the path in the output file.

Usually, it has the risk of leaking user information.

I'm not sure which package(rust/wasm-pack/or other crate) generated this

  (func $func184 (param $var0 i32)
    nop
  )
  (data (i32.const 1048576) "/Users/axetroy/.cargo/registry/src/github.com-1ecc6299db9ec823/generic-array-0.14.7/src/hex.rs\00\00\00\00\10\00^\00\00\00.\00\00\00<\00\00\00\00\00\10\00^\00\00\00*\00\00\00\1e\00\00\00`unwrap_throw` failed/Users/axetroy/.cargo/registry/src/github.com-1ecc6299db9ec823/block-buffer-0.10.4/src/lib.rs\00\00\95\00\10\00]\00\00\00\ae\00\00\00\09\00\00\00\07\00\00\00\10\02\00\00\08\00\00\00\08\00\00\00\09\00\00\00\f0\03\00\00\08\00\00\00\0a\00\00\00\0b\00\00\00\e0\02\00\00\08\00\00\00\0c\00\00\00\0d\00\00\00p\03\00\00\08\00\00\00\0e\00\00\00\0b\00\00\00\e0\02\00\00\08\00\00\00\0f\00\00\00\10\00\00\00\00\02\00\00\08\00\00\00\11\00\00\00\12\00\00\00\b0\03\00\00\08\00\00\00\13\00\00\00\14\00\00\00\00\04\00\00\08\00\00\00\15\00\00\00\07\00\00\00\10\02\00\00\08\00\00\00\16\00\00\00\07\00\00\00\10\02\00\00\08\00\00\00\17\00\00\00\18\00\00\00\f0\01\00\00\08\00\00\00\19\00\00\00\1a\00\00\00\04\00\00\00\04\00\00\00\1b\00\00\00\1c\00\00\00\1a\00\00\00\04\00\00\00\04\00\00\00\1d\00\00\00\1e\00\00\00\1a\00\00\00\04\00\00\00\04\00\00\00\1f\00\00\00 \00\00\00\1a\00\00\00\04\00\00\00\04\00\00\00!\00\00\00\22\00\00\00\1a\00\00\00\04\00\00\00\04\00\00\00#\00\00\00$\00\00\00\1a\00\00\00\04\00\00\00\04\00\00\00%\00\00\00&\00\00\00\1a\00\00\00\04\00\00\00\04\00\00\00'\00\00\00(\00\00\00\1a\00\00\00\04\00\00\00\04\00\00\00)\00\00\00*\00\00\00\1a\00\00\00\04\00\00\00\04\00\00\00+\00\00\00,\00\00\00\1a\00\00\00\04\00\00\00\04\00\00\00-\00\00\00.\00\00\00\1a\00\00\00\04\00\00\00\04\00\00\00/\00\00\000\00\00\00/Users/axetroy/.cargo/registry/src/github.com-1ecc6299db9ec823/wasm-bindgen-futures-0.4.35/src/lib.rs\00\00\00\90\02\10\00e\00\00\00\da\00\00\00\15")
  (data (i32.const 1049360) "`async fn` resumed after completion\001\00\00\00\04\00\00\00\04\00\00\002\00\00\00\00\00\00\00g\e6\09j\85\aeg\bbr\f3n<:\f5O\a5\7fR\0eQ\8ch\05\9b\ab\d9\83\1f\19\cd\e0[\d8\9e\05\c1\07\d5|6\17\ddp09Y\0e\f71\0b\c0\ff\11\15Xh\a7\8f\f9d\a4O\fa\be\08\c9\bc\f3g\e6\09j;\a7\ca\84\85\aeg\bb+\f8\94\fer\f3n<\f16\1d_:\f5O\a5\d1\82\e6\ad\7fR\0eQ\1fl>+\8ch\05\9bk\bdA\fb\ab\d9\83\1fy!~\13\19\cd\e0[\d8\9e\05\c1]\9d\bb\cb\07\d5|6*)\9ab\17\ddp0Z\01Y\919Y\0e\f7\d8\ec/\151\0b\c0\ffg&3g\11\15Xh\87J\b4\8e\a7\8f\f9d\0d.\0c\db\a4O\fa\be\1dH\b5Gsrc/lib.rs\00\00\08\04\10\00\0a\00\00\00\b4\00\00\00\1a\00\00\00Signal has been abort!slice blob failed!\08\04\10\00\0a\00\00\00\c2\00\00\00\0e\00\00\00get arrayBuffer failed!\00\08\04\10\00\0a\00\00\00\c5\00\00\00\0e\00\00\00\08\04\10\00\0a\00\00\00\1a\00\00\00\1e\00\00\004\03\10\00\00\00\00\00\08\04\10\00\0a\00\00\00\14\00\00\00\01\00\00\00\08\04\10\00\0a\00\00\00(\00\00\00\1e\00\00\00\08\04\10\00\0a\00\00\00\22\00\00\00\01\00\00\00\08\04\10\00\0a\00\00\006\00\00\00\1e\00\00\00\08\04\10\00\0a\00\00\000\00\00\00\01\00\00\00\08\04\10\00\0a\00\00\00D\00\00\00\1e\00\00\00\08\04\10\00\0a\00\00\00>\00\00\00\01\00\00\00\08\04\10\00\0a\00\00\00R\00\00\00\1e\00\00\00\08\04\10\00\0a\00\00\00L\00\00\00\01\00\00\00\08\04\10\00\0a\00\00\00`\00\00\00\1e\00\00\00\08\04\10\00\0a\00\00\00Z\00\00\00\01\00\00\00\08\04\10\00\0a\00\00\00n\00\00\00\1e\00\00\00\08\04\10\00\0a\00\00\00h\00\00\00\01\00\00\00\08\04\10\00\0a\00\00\00|\00\00\00\1e\00\00\00\08\04\10\00\0a\00\00\00v\00\00\00\01\00\00\00\08\04\10\00\0a\00\00\00\8a\00\00\00\1e\00\00\00\08\04\10\00\0a\00\00\00\84\00\00\00\01\00\00\00\08\04\10\00\0a\00\00\00\98\00\00\00\1e\00\00\00\08\04\10\00\0a\00\00\00\92\00\00\00\01\00\00\00\08\04\10\00\0a\00\00\00\a6\00\00\00\1e\00\00\00\08\04\10\00\0a\00\00\00\a0\00\00\00\01\00\00\00`unwrap_throw` failed\00\00\003\00\00\00\00\00\00\00\01\00\00\004\00\00\005\00\00\006\00\00\003\00\00\00\04\00\00\00\04\00\00\007\00\00\008\00\00\009\00\00\00:\00\00\00\00\00\00\00\01\00\00\004\00\00\005\00\00\006\00\00\00;\00\00\00\04\00\00\00\04\00\00\00<\00\00\00=\00\00\00;\00\00\00\04\00\00\00\04\00\00\00>\00\00\00?\00\00\00FnOnce called more than oncealready borrowed@\00\00\00\00\00\00\00\01\00\00\00A\00\00\00/Users/axetroy/.cargo/registry/src/github.com-1ecc6299db9ec823/wasm-bindgen-futures-0.4.35/src/lib.rs\00\00\00\b0\06\10\00e\00\00\00\a5\00\00\00\0f\00\00\00\b0\06\10\00e\00\00\00\85\00\00\00'\00\00\00\b0\06\10\00e\00\00\00\af\00\00\00$\00\00\00already borrowedB\00\00\00\00\00\00\00\01\00\00\00A\00\00\00/Users/axetroy/.cargo/registry/src/github.com-1ecc6299db9ec823/wasm-bindgen-futures-0.4.35/src/task/singlethread.rs\00C\00\00\00D\00\00\00E\00\00\00F\00\00\00h\07\10\00s\00\00\00U\00\00\00%\00\00\00G\00\00\00\04\00\00\00\04\00\00\00H\00\00\00I\00\00\00already mutably borrowedJ\00\00\00\00\00\00\00\01\00\00\00K\00\00\00/Users/axetroy/.cargo/registry/src/github.com-1ecc6299db9ec823/wasm-bindgen-futures-0.4.35/src/queue.rs\008\08\10\00g\00\00\00\1a\00\00\00.\00\00\00already borrowedJ\00\00\00\00\00\00\00\01\00\00\00A\00\00\008\08\10\00g\00\00\00\1d\00\00\00)\00\00\008\08\10\00g\00\00\002\00\00\00\1a\00\00\00closure invoked recursively or after being droppedclosure invoked recursively or after being droppedo\16\80s\b9\b2\14I\d7B$\17\00\06\8a\da\bc0o\a9\aa81\16M\ee\8d\e3N\0e\fb\b0A round_count greater than KECCAK_F_ROUND_COUNT is not supported!/Users/axetroy/.cargo/registry/src/github.com-1ecc6299db9ec823/keccak-0.1.4/src/lib.rs\00\b5\09\10\00V\00\00\00\eb\00\00\00\09\00\00\00\00\00\00\00\01\00\00\00\00\00\00\00\82\80\00\00\00\00\00\00\8a\80\00\00\00\00\00\80\00\80\00\80\00\00\00\80\8b\80\00\00\00\00\00\00\01\00\00\80\00\00\00\00\81\80\00\80\00\00\00\80\09\80\00\00\00\00\00\80\8a\00\00\00\00\00\00\00\88\00\00\00\00\00\00\00\09\80\00\80\00\00\00\00\0a\00\00\80\00\00\00\00\8b\80\00\80\00\00\00\00\8b\00\00\00\00\00\00\80\89\80\00\00\00\00\00\80\03\80\00\00\00\00\00\80\02\80\00\00\00\00\00\80\80\00\00\00\00\00\00\80\0a\80\00\00\00\00\00\00\0a\00\00\80\00\00\00\80\81\80\00\80\00\00\00\80\80\80\00\00\00\00\00\80\01\00\00\80\00\00\00\00\08\80\00\80\00\00\00\80closure invoked recursively or after being droppedJsValue()\00\12\0b\10\00\08\00\00\00\1a\0b\10\00\01\00\00\000123456789abcdef,\0b\10\00\10\00\00\00_\00\00\00\04\00\00\00\04\00\00\00`\00\00\00a\00\00\00b\00\00\00called `Option::unwrap()` on a `None` valuememory allocation of  bytes failed\00\00\00\87\0b\10\00\15\00\00\00\9c\0b\10\00\0d\00\00\00library/std/src/alloc.rs\bc\0b\10\00\18\00\00\00U\01\00\00\09\00\00\00library/std/src/panicking.rs\e4\0b\10\00\1c\00\00\00B\02\00\00\1e\00\00\00\e4\0b\10\00\1c\00\00\00A\02\00\00\1f\00\00\00c\00\00\00\0c\00\00\00\04\00\00\00d\00\00\00_\00\00\00\08\00\00\00\04\00\00\00e\00\00\00f\00\00\00\10\00\00\00\04\00\00\00g\00\00\00h\00\00\00_\00\00\00\08\00\00\00\04\00\00\00i\00\00\00j\00\00\00_\00\00\00\00\00\00\00\01\00\00\00k\00\00\00l\00\00\00\04\00\00\00\04\00\00\00m\00\00\00n\00\00\00o\00\00\00library/alloc/src/raw_vec.rscapacity overflow\00\00\00\ac\0c\10\00\11\00\00\00\90\0c\10\00\1c\00\00\00\0d\02\00\00\05\00\00\00a formatting trait implementation returned an error\00l\00\00\00\00\00\00\00\01\00\00\00p\00\00\00library/alloc/src/fmt.rs\1c\0d\10\00\18\00\00\00d\02\00\00 \00\00\00BorrowErrorBorrowMutErrorindex out of bounds: the len is  but the index is \00]\0d\10\00 \00\00\00}\0d\10\00\12\00\00\00t\00\00\00\00\00\00\00\01\00\00\00u\00\00\00: \00\00D\0d\10\00\00\00\00\00\b0\0d\10\00\02\00\00\0000010203040506070809101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 out of range for slice of length range end index \00\00\ae\0e\10\00\10\00\00\00\8c\0e\10\00\22\00\00\00Error")
)
daxpedda commented 1 year ago

This isn't a problem with wasm-bindgen or wasm-pack, but with Rust in general.

See https://doc.rust-lang.org/rustc/command-line-arguments.html#--remap-path-prefix-remap-source-names-in-output for how to avoid this.

Hopefully this can be more easily configured in the future: https://github.com/rust-lang/rfcs/pull/3127.