diff --git a/go.mod b/go.mod index a69b44b73e..ba92f9666b 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/blang/semver/v4 v4.0.0 github.com/cilium/charts v0.0.0-20230127134207-b66f8b685c0c github.com/cilium/cilium v1.13.0-rc5 - github.com/cilium/hubble v0.10.0 + github.com/cilium/hubble v0.11.1 github.com/cilium/proxy v0.0.0-20221007150350-ea56f41688f9 github.com/cilium/workerpool v1.1.3 github.com/cloudflare/cfssl v1.6.3 diff --git a/go.sum b/go.sum index 4d10fe7efd..55a0d9ee4d 100644 --- a/go.sum +++ b/go.sum @@ -186,8 +186,8 @@ github.com/cilium/charts v0.0.0-20230127134207-b66f8b685c0c/go.mod h1:M3C9VOlFvR github.com/cilium/cilium v1.13.0-rc5 h1:ZcO2twwdXBZS3wS09aBnNwT9LcGhXm2UUbF3pHifcfo= github.com/cilium/cilium v1.13.0-rc5/go.mod h1:F1Fyf/X2BIwljlsMIB+0NXd90juH+JJz3Z7ofO5rqpE= github.com/cilium/dns v1.1.4-0.20190417235132-8e25ec9a0ff3/go.mod h1:cXN7jgo+gsGlNvQ7Vqu2ELdc3f7i7PPgupHqSkLzzBo= -github.com/cilium/hubble v0.10.0 h1:xfpd0pvs8Fx6aPiCWCDfMPmYiK7if6lBRLdV3IJ6aHI= -github.com/cilium/hubble v0.10.0/go.mod h1:pDbTf1h/Pw8kZ7PR8qbPyT3nDiSAqmVz9rL0TmfmQ38= +github.com/cilium/hubble v0.11.1 h1:hg6Mwd7rTltU08iXYwQjZ8ucb8qOsK/UW1PPw1JFlUg= +github.com/cilium/hubble v0.11.1/go.mod h1:NOG6duY4Ztz1/pf7VB7l1qOZ3kETIKGKH//2QB/fRec= github.com/cilium/proxy v0.0.0-20221007150350-ea56f41688f9 h1:wBQh5SLM94SdqJN6CtE1jEJOXDNIiFX4gPy7HapeEvc= github.com/cilium/proxy v0.0.0-20221007150350-ea56f41688f9/go.mod h1:ontBl/RX7G0GwcR38YQVp6d75MjIsL1FbBidVpn+F8I= github.com/cilium/workerpool v1.1.3 h1:GB5H495r6AXg8kYklLAOn7N4PDR/djeE4WYPbq8U+yY= diff --git a/vendor/github.com/cilium/hubble/pkg/printer/color.go b/vendor/github.com/cilium/hubble/pkg/printer/color.go index b8770c098e..32ded15829 100644 --- a/vendor/github.com/cilium/hubble/pkg/printer/color.go +++ b/vendor/github.com/cilium/hubble/pkg/printer/color.go @@ -1,16 +1,5 @@ -// Copyright 2021 Authors of Hubble -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-License-Identifier: Apache-2.0 +// Copyright Authors of Hubble package printer @@ -111,3 +100,11 @@ func (c colorer) verdictDropped(a interface{}) string { func (c colorer) verdictAudit(a interface{}) string { return c.yellow.Sprint(a) } + +func (c colorer) verdictTraced(a interface{}) string { + return c.yellow.Sprint(a) +} + +func (c colorer) verdictTranslated(a interface{}) string { + return c.yellow.Sprint(a) +} diff --git a/vendor/github.com/cilium/hubble/pkg/printer/formatter.go b/vendor/github.com/cilium/hubble/pkg/printer/formatter.go index edf0510ec0..1f09f639aa 100644 --- a/vendor/github.com/cilium/hubble/pkg/printer/formatter.go +++ b/vendor/github.com/cilium/hubble/pkg/printer/formatter.go @@ -1,16 +1,5 @@ -// Copyright 2021 Authors of Hubble -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-License-Identifier: Apache-2.0 +// Copyright Authors of Hubble package printer diff --git a/vendor/github.com/cilium/hubble/pkg/printer/options.go b/vendor/github.com/cilium/hubble/pkg/printer/options.go index aaf1bcc48a..2d8dac70c4 100644 --- a/vendor/github.com/cilium/hubble/pkg/printer/options.go +++ b/vendor/github.com/cilium/hubble/pkg/printer/options.go @@ -1,23 +1,10 @@ -// Copyright 2019-2021 Authors of Hubble -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-License-Identifier: Apache-2.0 +// Copyright Authors of Hubble package printer import ( - "fmt" "io" - "os" ) // Output enum of the printer. @@ -26,8 +13,8 @@ type Output int const ( // TabOutput prints flows in even tab-aligned columns. TabOutput Output = iota - // JSONOutput prints flows as json. - JSONOutput + // JSONLegacyOutput prints flows as json in the legacy format + JSONLegacyOutput // CompactOutput prints flows as compact as possible (similar to monitor). CompactOutput // DictOutput presents the same information as TabOutput, but each flow is @@ -52,11 +39,10 @@ type Options struct { // Option ... type Option func(*Options) -// JSON encoded output from the printer. -func JSON() Option { - fmt.Fprintln(os.Stderr, "WARNING: The --output=json option has been deprecated. Use --output=jsonpb instead") +// JSONLegacy encoded output from the printer. +func JSONLegacy() Option { return func(opts *Options) { - opts.output = JSONOutput + opts.output = JSONLegacyOutput } } @@ -103,10 +89,11 @@ func IgnoreStderr() Option { } // WithColor set the color mode. The when argument is one of: -// - "auto": color mode is enabled when the standard output is connected to a -// terminal. -// - "always": color mode is enabled no matter to standard output. -// - "never": color mode is always disabled. +// - "auto": color mode is enabled when the standard output is connected to a +// terminal. +// - "always": color mode is enabled no matter to standard output. +// - "never": color mode is always disabled. +// // Any other value of when means "auto", which is the default. // The color mode is only applied with in Dict or Compact mode. For any other // mode, color is always disabled. @@ -138,7 +125,7 @@ func WithNodeName() Option { } // WithTimeFormat specifies the time format layout to use when printing out -// timestamps. This option has no effect if JSON or JSONPB option is used. +// timestamps. This option has no effect if JSONLegacy or JSONPB option is used. // The layout must be a time format layout as specified in the standard // library's time package. func WithTimeFormat(layout string) Option { diff --git a/vendor/github.com/cilium/hubble/pkg/printer/printer.go b/vendor/github.com/cilium/hubble/pkg/printer/printer.go index 24e1a809b4..534a1573b4 100644 --- a/vendor/github.com/cilium/hubble/pkg/printer/printer.go +++ b/vendor/github.com/cilium/hubble/pkg/printer/printer.go @@ -1,16 +1,5 @@ -// Copyright 2019-2021 Authors of Hubble -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-License-Identifier: Apache-2.0 +// Copyright Authors of Hubble package printer @@ -90,7 +79,7 @@ func New(fopts ...Option) *Printer { // initialize tabwriter since it's going to be needed p.tw = tabwriter.NewWriter(opts.w, 2, 0, 3, ' ', 0) p.color.disable() // the tabwriter is not compatible with colors, thus disable coloring - case JSONOutput, JSONPBOutput: + case JSONLegacyOutput, JSONPBOutput: p.jsonEncoder = json.NewEncoder(p.opts.w) } @@ -213,6 +202,7 @@ func GetFlowType(f *pb.Flow) string { l7Protocol = "http" case *pb.Layer7_Dns: l7Protocol = "dns" + l7Type += " " + l7.GetDns().ObservationSource case *pb.Layer7_Kafka: l7Protocol = "kafka" } @@ -225,9 +215,25 @@ func GetFlowType(f *pb.Flow) string { case api.MessageTypeDrop: return api.DropReason(uint8(f.GetEventType().GetSubType())) case api.MessageTypePolicyVerdict: - return api.MessageTypeNamePolicyVerdict + ":" + api.PolicyMatchType(f.GetPolicyMatchType()).String() + return fmt.Sprintf("%s:%s %s", + api.MessageTypeNamePolicyVerdict, + api.PolicyMatchType(f.GetPolicyMatchType()).String(), + f.GetTrafficDirection().String()) + case api.MessageTypeCapture: return f.GetDebugCapturePoint().String() + case api.MessageTypeTraceSock: + switch f.GetSockXlatePoint() { + case pb.SocketTranslationPoint_SOCK_XLATE_POINT_POST_DIRECTION_FWD: + return "post-xlate-fwd" + case pb.SocketTranslationPoint_SOCK_XLATE_POINT_POST_DIRECTION_REV: + return "post-xlate-rev" + case pb.SocketTranslationPoint_SOCK_XLATE_POINT_PRE_DIRECTION_FWD: + return "pre-xlate-fwd" + case pb.SocketTranslationPoint_SOCK_XLATE_POINT_PRE_DIRECTION_REV: + return "pre-xlate-rev" + } + return f.GetSockXlatePoint().String() } return "UNKNOWN" @@ -252,6 +258,10 @@ func (p Printer) getVerdict(f *pb.Flow) string { msg = "AUDITED" } return p.color.verdictAudit(msg) + case pb.Verdict_TRACED: + return p.color.verdictTraced(msg) + case pb.Verdict_TRANSLATED: + return p.color.verdictTranslated(msg) default: return msg } @@ -351,7 +361,7 @@ func (p *Printer) WriteProtoFlow(res *observerpb.GetFlowsResponse) error { if err != nil { return fmt.Errorf("failed to write out packet: %v", err) } - case JSONOutput: + case JSONLegacyOutput: return p.jsonEncoder.Encode(f) case JSONPBOutput: return p.jsonEncoder.Encode(res) @@ -403,7 +413,7 @@ func (p *Printer) WriteProtoNodeStatusEvent(r *observerpb.GetFlowsResponse) erro } switch p.opts.output { - case JSONOutput, JSONPBOutput: + case JSONPBOutput: return json.NewEncoder(p.opts.werr).Encode(r) case DictOutput: // this is a bit crude, but in case stdout and stderr are interleaved, @@ -553,7 +563,7 @@ func (p *Printer) WriteProtoAgentEvent(r *observerpb.GetAgentEventsResponse) err } switch p.opts.output { - case JSONOutput: + case JSONLegacyOutput: return p.jsonEncoder.Encode(e) case JSONPBOutput: return p.jsonEncoder.Encode(r) @@ -640,7 +650,7 @@ func fmtEndpointShort(ep *pb.Endpoint) string { str := fmt.Sprintf("ID: %d", ep.GetID()) if ns, pod := ep.GetNamespace(), ep.GetPodName(); ns != "" && pod != "" { str = fmt.Sprintf("%s/%s (%s)", ns, pod, str) - } else if lbls := ep.GetLabels(); len(lbls) == 1 && strings.HasPrefix("reserved:", lbls[0]) { + } else if lbls := ep.GetLabels(); len(lbls) == 1 && strings.HasPrefix(lbls[0], "reserved:") { str = fmt.Sprintf("%s (%s)", lbls[0], str) } @@ -655,7 +665,7 @@ func (p *Printer) WriteProtoDebugEvent(r *observerpb.GetDebugEventsResponse) err } switch p.opts.output { - case JSONOutput: + case JSONLegacyOutput: return p.jsonEncoder.Encode(e) case JSONPBOutput: return p.jsonEncoder.Encode(r) @@ -739,12 +749,13 @@ func (p *Printer) WriteProtoDebugEvent(r *observerpb.GetDebugEventsResponse) err func (p *Printer) Hostname(ip, port string, ns, pod, svc string, names []string) (host string) { host = ip if p.opts.enableIPTranslation { - if pod != "" { + switch { + case pod != "": // path.Join omits the slash if ns is empty host = path.Join(ns, pod) - } else if svc != "" { + case svc != "": host = path.Join(ns, svc) - } else if len(names) != 0 { + case len(names) != 0: host = strings.Join(names, ",") } } @@ -866,7 +877,7 @@ func (p *Printer) WriteServerStatusResponse(res *observerpb.ServerStatusResponse if ew.err != nil { return fmt.Errorf("failed to write out server status: %v", ew.err) } - case JSONOutput, JSONPBOutput: + case JSONPBOutput: return p.jsonEncoder.Encode(res) } return nil diff --git a/vendor/modules.txt b/vendor/modules.txt index c8cb3cb7a9..494553d7e2 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -138,8 +138,8 @@ github.com/cilium/cilium/pkg/safetime github.com/cilium/cilium/pkg/spanstat github.com/cilium/cilium/pkg/version github.com/cilium/cilium/pkg/versioncheck -# github.com/cilium/hubble v0.10.0 -## explicit; go 1.18 +# github.com/cilium/hubble v0.11.1 +## explicit; go 1.19 github.com/cilium/hubble/pkg/printer # github.com/cilium/proxy v0.0.0-20221007150350-ea56f41688f9 ## explicit; go 1.13