Skip to content

Commit

Permalink
hubble: Use GetType() helper in v1.FlowProtocol() to avoid possible p…
Browse files Browse the repository at this point in the history
…anic

If the event type is unset, or the flow is nil, it's possible that
FlowProtocol could panic. To avoid this, use the GetType() helper method
which is nil safe.

Signed-off-by: Chance Zibolski <chance.zibolski@gmail.com>
  • Loading branch information
chancez committed Sep 5, 2023
1 parent 6557bf1 commit 06d94b9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/hubble/api/v1/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
// FlowProtocol returns the protocol best describing the flow. If available,
// this is the L7 protocol name, then the L4 protocol name.
func FlowProtocol(flow *pb.Flow) string {
switch flow.GetEventType().Type {
switch flow.GetEventType().GetType() {
case monitorAPI.MessageTypeAccessLog:
if l7 := flow.GetL7(); l7 != nil {
switch {
Expand Down

0 comments on commit 06d94b9

Please sign in to comment.