immesys / wave

Wide Area Verified Exchange - version 3
MIT License
34 stars 15 forks source link

panic when using an invalid namespace in EncryptMessageParams #7

Closed ddreyer closed 5 years ago

ddreyer commented 5 years ago

Seems like trying to encrypt a message with a garbage namespace value causes waved to panic and quit. I ran this:

import grpc
import wave3 as wv

channel = grpc.insecure_channel("localhost:410")
agent = wv.WAVEStub(channel)

encrypted = agent.EncryptMessage(
            wv.EncryptMessageParams(
                namespace=b"garbage",
                resource="obj1",
                content=b"hello"))

if encrypted.error.code != 0:
    raise Exception(encrypted.error.message)

and got

panic: Value() on unsupported hash scheme instance

goroutine 148 [running]:
github.com/immesys/wave/iapi.(*UnsupportedHashSchemeInstance).Value(0x11c6b90, 0x9ae644, 0xabe860, 0xc42027a500)
    /home/immesys/w/go/src/github.com/immesys/wave/iapi/hashschemes.go:125 +0x39
github.com/immesys/wave/engine.getCachedEntity(0xc013c0, 0x11c6b90, 0x9b3348)
    /home/immesys/w/go/src/github.com/immesys/wave/engine/cache.go:38 +0x56
github.com/immesys/wave/engine.(*Engine).LookupEntity(0xc42017a000, 0xbff060, 0xc420381b60, 0xc013c0, 0x11c6b90, 0xbff260, 0xc42027a500, 0x0, 0x0, 0x0, ...)
    /home/immesys/w/go/src/github.com/immesys/wave/engine/external.go:453 +0x3f
github.com/immesys/wave/eapi.(*EAPI).EncryptMessage(0xc4200b4100, 0xbff060, 0xc420381b60, 0xc420708be0, 0xc4200b4100, 0xc420381ad0, 0xa8e820)
    /home/immesys/w/go/src/github.com/immesys/wave/eapi/eapi.go:1016 +0x3a9
github.com/immesys/wave/eapi/pb._WAVE_EncryptMessage_Handler(0xb5d020, 0xc4200b4100, 0xbff060, 0xc420381b60, 0xc420790930, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/immesys/w/go/src/github.com/immesys/wave/eapi/pb/eapi.pb.go:4346 +0x241
github.com/immesys/wave/vendor/google.golang.org/grpc.(*Server).processUnaryRPC(0xc42008d500, 0xc02bc0, 0xc420666180, 0xc420bd2a00, 0xc42019e990, 0x115bb98, 0x0, 0x0, 0x0)
    /home/immesys/w/go/src/github.com/immesys/wave/vendor/google.golang.org/grpc/server.go:982 +0x4f9
github.com/immesys/wave/vendor/google.golang.org/grpc.(*Server).handleStream(0xc42008d500, 0xc02bc0, 0xc420666180, 0xc420bd2a00, 0x0)
    /home/immesys/w/go/src/github.com/immesys/wave/vendor/google.golang.org/grpc/server.go:1208 +0x1318
github.com/immesys/wave/vendor/google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc4202c6a90, 0xc42008d500, 0xc02bc0, 0xc420666180, 0xc420bd2a00)
    /home/immesys/w/go/src/github.com/immesys/wave/vendor/google.golang.org/grpc/server.go:686 +0x9f
created by github.com/immesys/wave/vendor/google.golang.org/grpc.(*Server).serveStreams.func1
    /home/immesys/w/go/src/github.com/immesys/wave/vendor/google.golang.org/grpc/server.go:684 +0xa1
Traceback (most recent call last):
  File "example.py", line 58, in <module>
    content=b"hello"))
  File "/home/sgx/.local/lib/python3.6/site-packages/grpc/_channel.py", line 533, in __call__
    return _end_unary_response_blocking(state, call, False, None)
  File "/home/sgx/.local/lib/python3.6/site-packages/grpc/_channel.py", line 467, in _end_unary_response_blocking
    raise _Rendezvous(state, None, None, deadline)
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with:
    status = StatusCode.UNAVAILABLE
    details = "Socket closed"
    debug_error_string = "{"created":"@1542327954.004754854","description":"Error received from peer","file":"src/core/lib/surface/call.cc","file_line":1017,"grpc_message":"Socket closed","grpc_status":14}"
>
[1]+  Exit 2                  sudo waved
immesys commented 5 years ago

Fixed, thanks!