From 79890d8393b7335409a710ee4e865e7a3c10d9e7 Mon Sep 17 00:00:00 2001 From: Tess Rinearson Date: Thu, 3 Dec 2020 23:12:08 +0100 Subject: [PATCH] reactors: omit incoming message bytes from reactor logs (#5743) After a reactor has failed to parse an incoming message, it shouldn't output the "bad" data into the logs, as that data is unfiltered and could have anything in it. (We also don't think this information is helpful to have in the logs anyways.) --- blockchain/v0/reactor.go | 2 +- blockchain/v2/reactor.go | 2 +- consensus/reactor.go | 2 +- mempool/reactor.go | 2 +- p2p/pex/pex_reactor.go | 2 +- statesync/reactor.go | 2 +- test/maverick/consensus/reactor.go | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/blockchain/v0/reactor.go b/blockchain/v0/reactor.go index dd3878669..0ffd14194 100644 --- a/blockchain/v0/reactor.go +++ b/blockchain/v0/reactor.go @@ -209,7 +209,7 @@ func (bcR *BlockchainReactor) respondToPeer(msg *bcproto.BlockRequest, func (bcR *BlockchainReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) { msg, err := bc.DecodeMsg(msgBytes) if err != nil { - bcR.Logger.Error("Error decoding message", "src", src, "chId", chID, "msg", msg, "err", err, "bytes", msgBytes) + bcR.Logger.Error("Error decoding message", "src", src, "chId", chID, "err", err) bcR.Switch.StopPeerForError(src, err) return } diff --git a/blockchain/v2/reactor.go b/blockchain/v2/reactor.go index 5da117c94..ecba2c39f 100644 --- a/blockchain/v2/reactor.go +++ b/blockchain/v2/reactor.go @@ -461,7 +461,7 @@ func (r *BlockchainReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) { msg, err := bc.DecodeMsg(msgBytes) if err != nil { r.logger.Error("error decoding message", - "src", src.ID(), "chId", chID, "msg", msg, "err", err, "bytes", msgBytes) + "src", src.ID(), "chId", chID, "msg", msg, "err", err) _ = r.reporter.Report(behaviour.BadMessage(src.ID(), err.Error())) return } diff --git a/consensus/reactor.go b/consensus/reactor.go index 9fb41c37c..22ec379f4 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -230,7 +230,7 @@ func (conR *Reactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) { msg, err := decodeMsg(msgBytes) if err != nil { - conR.Logger.Error("Error decoding message", "src", src, "chId", chID, "msg", msg, "err", err, "bytes", msgBytes) + conR.Logger.Error("Error decoding message", "src", src, "chId", chID, "err", err) conR.Switch.StopPeerForError(src, err) return } diff --git a/mempool/reactor.go b/mempool/reactor.go index 6bf0ce7d7..6b2b56f83 100644 --- a/mempool/reactor.go +++ b/mempool/reactor.go @@ -165,7 +165,7 @@ func (memR *Reactor) RemovePeer(peer p2p.Peer, reason interface{}) { func (memR *Reactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) { msg, err := memR.decodeMsg(msgBytes) if err != nil { - memR.Logger.Error("Error decoding message", "src", src, "chId", chID, "msg", msg, "err", err, "bytes", msgBytes) + memR.Logger.Error("Error decoding message", "src", src, "chId", chID, "err", err) memR.Switch.StopPeerForError(src, err) return } diff --git a/p2p/pex/pex_reactor.go b/p2p/pex/pex_reactor.go index fc701bfdd..64e3f9ec8 100644 --- a/p2p/pex/pex_reactor.go +++ b/p2p/pex/pex_reactor.go @@ -241,7 +241,7 @@ func (r *Reactor) logErrAddrBook(err error) { func (r *Reactor) Receive(chID byte, src Peer, msgBytes []byte) { msg, err := decodeMsg(msgBytes) if err != nil { - r.Logger.Error("Error decoding message", "src", src, "chId", chID, "msg", msg, "err", err, "bytes", msgBytes) + r.Logger.Error("Error decoding message", "src", src, "chId", chID, "err", err) r.Switch.StopPeerForError(src, err) return } diff --git a/statesync/reactor.go b/statesync/reactor.go index 2764698fd..8d6f97018 100644 --- a/statesync/reactor.go +++ b/statesync/reactor.go @@ -100,7 +100,7 @@ func (r *Reactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) { msg, err := decodeMsg(msgBytes) if err != nil { - r.Logger.Error("Error decoding message", "src", src, "chId", chID, "msg", msg, "err", err, "bytes", msgBytes) + r.Logger.Error("Error decoding message", "src", src, "chId", chID, "err", err) r.Switch.StopPeerForError(src, err) return } diff --git a/test/maverick/consensus/reactor.go b/test/maverick/consensus/reactor.go index c82656115..f4cf12c97 100644 --- a/test/maverick/consensus/reactor.go +++ b/test/maverick/consensus/reactor.go @@ -230,7 +230,7 @@ func (conR *Reactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) { msg, err := decodeMsg(msgBytes) if err != nil { - conR.Logger.Error("Error decoding message", "src", src, "chId", chID, "msg", msg, "err", err, "bytes", msgBytes) + conR.Logger.Error("Error decoding message", "src", src, "chId", chID, "err", err) conR.Switch.StopPeerForError(src, err) return }