Take control over your live stream video by running it yourself. Streaming + chat out of the box.
HTML activitypubbroadcastingchatdecentralizedfederationfediversegolanghacktoberfesthlslivelivestreamowncastrtmpself-hostedstreaming-videovideo
fix(plugins): provide secure random source
Gabe Kangasc94152c32f3e
diff --git a/services/plugins/manager.go b/services/plugins/manager.goindex afbb246070..1a93586cc7 100644--- a/services/plugins/manager.go+++ b/services/plugins/manager.go@@ -4,6 +4,7 @@ import ("archive/zip""bytes""context"+ "crypto/rand""encoding/json""fmt""io"@@ -1692,7 +1693,10 @@ func instantiate(ctx context.Context, env *HostEnv, manifest *Manifest, manifest// Give the guest the real host wall and monotonic clocks (wazero's default// is a frozen 2022 clock). Nanosleep is deliberately NOT wired so a plugin// can't block inside a call and burn its timeout budget.- moduleConfig := wazero.NewModuleConfig().WithSysWalltime().WithSysNanotime()+ moduleConfig := wazero.NewModuleConfig().+ WithSysWalltime().+ WithSysNanotime().+ WithRandSource(rand.Reader)if manifest.usesSharedEngine() {engine, release, err := compiledEngines.acquire(ctx, env, manifest.Type)diff --git a/services/plugins/shared_engine_test.go b/services/plugins/shared_engine_test.goindex 047a75b333..60ee9bb4fc 100644--- a/services/plugins/shared_engine_test.go+++ b/services/plugins/shared_engine_test.go@@ -93,6 +93,44 @@ module.exports = definePlugin({}}+func TestSharedEngineJSRandomUUIDUsesHostEntropy(t *testing.T) {+ ctx := context.Background()+ compiledEngines.resetForTest(ctx)+ t.Cleanup(func() { compiledEngines.resetForTest(ctx) })++ env, sends, mu := captureEnv()+ script := `+const { definePlugin, owncast } = require("@owncast/plugin-sdk");+module.exports = definePlugin({+ onChatMessage() { owncast.chat.send(crypto.randomUUID()); }+});`++ const instanceCount = 3+ values := make([]string, 0, instanceCount)+ for range instanceCount {+ loaded := loadShared(t, ctx, env, RuntimeJavaScript, "uuid-test", script, []string{PermChatSend})+ dispatcher := NewLiveDispatcher(func() []*Loaded { return []*Loaded{loaded} })+ dispatcher.Dispatch(ctx, EventChatMessageReceived, chatPayload("alice", "hi"))+ loaded.Close(ctx)++ mu.Lock()+ if len(*sends) != len(values)+1 {+ mu.Unlock()+ t.Fatalf("expected one UUID from plugin instance, got %d sends", len(*sends))+ }+ values = append(values, (*sends)[len(values)].Text)+ mu.Unlock()+ }++ unique := make(map[string]struct{}, len(values))+ for _, value := range values {+ unique[value] = struct{}{}+ }+ if len(unique) != len(values) {+ t.Fatalf("fresh plugin instances returned duplicate UUIDs: %v", values)+ }+}+func TestSharedEngineActionValidationErrorReachesJavaScript(t *testing.T) {ctx := context.Background()compiledEngines.resetForTest(ctx)