Skip to content

Commit

Permalink
Use CSPRNG in WASM modules (#110)
Browse files Browse the repository at this point in the history
* Remove unused process.Error type.

* Move process implementation to package csp.

* Use crypto/rand in WASM modules.
  • Loading branch information
lthibault authored Apr 16, 2023
1 parent 64ba4e2 commit 0fd1498
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ require (
golang.org/x/sync v0.1.0
gopkg.in/alexcesaro/statsd.v2 v2.0.0
lukechampine.com/blake3 v1.1.7
pgregory.net/rand v1.0.2
)

require (
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,6 @@ github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtX
github.com/urfave/cli v1.22.10/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/urfave/cli/v2 v2.25.1 h1:zw8dSP7ghX0Gmm8vugrs6q9Ku0wzweqPyshy+syu9Gw=
github.com/urfave/cli/v2 v2.25.1/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
github.com/valyala/fastrand v1.1.0 h1:f+5HkLW4rsgzdNoleUOB69hyT9IlD2ZQh9GyDMfb5G8=
github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU=
github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM=
github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0 h1:GDDkbFiaK8jsSDJfjId/PEGEShv6ugrt4kYsC5UIDaQ=
Expand Down Expand Up @@ -735,9 +734,6 @@ lukechampine.com/blake3 v1.1.7 h1:GgRMhmdsuK8+ii6UZFDL8Nb+VyMwadAgcJyfYHxG6n0=
lukechampine.com/blake3 v1.1.7/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA=
nhooyr.io/websocket v1.8.7 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g=
nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0=
pgregory.net/rand v1.0.2 h1:ASEbkvwOmY/UPF2evJPBJ8XZg71xdKWYdByqKapI7Vw=
pgregory.net/rand v1.0.2/go.mod h1:EyNx8APnDE3Svi8sWgUZ5lOiz60cNZUPPBTyzOUpPl4=
pgregory.net/rapid v0.4.8 h1:d+5SGZWUbJPbl3ss6tmPFqnNeQR6VDOFly+eTjwPiEw=
sourcegraph.com/sourcegraph/go-diff v0.5.0/go.mod h1:kuch7UrkMzY0X+p9CRK03kfuPQ2zzQcaEFbx8wA8rck=
sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3QxT9HOBeFhu6RdvsftgpsbFHBF5Cas6cDKZ0=
zenhack.net/go/util v0.0.0-20230407221818-ef608d25cf61 h1:yFruEx97FKOfapC6xduBhaL2KlMn8IUD7IP56g1vNxo=
Expand Down
5 changes: 3 additions & 2 deletions pkg/csp/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package csp

import (
"context"
"crypto/rand"
"encoding/hex"
"fmt"

capnp "capnproto.org/go/capnp/v3"
"github.com/tetratelabs/wazero"
"lukechampine.com/blake3"
"pgregory.net/rand"

wasm "github.com/tetratelabs/wazero/api"
api "github.com/wetware/ww/internal/api/process"
Expand Down Expand Up @@ -102,7 +102,8 @@ func (wx Server) loadModule(ctx context.Context, args api.Executor_spawn_Params)
config := wazero.
NewModuleConfig().
WithName(name).
WithRandSource(rand.New())
WithRandSource(rand.Reader)


if mod := wx.Runtime.Module(name); mod != nil {
return mod, nil
Expand Down

0 comments on commit 0fd1498

Please sign in to comment.