From 50c0062db47cc72949b61dc87c8fa36431530a5c Mon Sep 17 00:00:00 2001 From: RamiBerm <54766858+RamiBerm@users.noreply.github.com> Date: Tue, 1 Mar 2022 14:41:23 +0200 Subject: [PATCH 01/17] Support stopping oas/servicemesh/telemetry in flight (#867) * Update oas_generator.go and servicemap.go * Update oas_generator.go * Update esClient.go * Update servicemap.go --- agent/pkg/elastic/esClient.go | 14 +++++++++----- agent/pkg/oas/oas_generator.go | 17 +++++++++++++++-- agent/pkg/servicemap/servicemap.go | 6 ++++++ 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/agent/pkg/elastic/esClient.go b/agent/pkg/elastic/esClient.go index acedb8579..9ccc30ebb 100644 --- a/agent/pkg/elastic/esClient.go +++ b/agent/pkg/elastic/esClient.go @@ -4,13 +4,14 @@ import ( "bytes" "crypto/tls" "encoding/json" + "net/http" + "sync" + "time" + "github.com/elastic/go-elasticsearch/v7" "github.com/up9inc/mizu/shared" "github.com/up9inc/mizu/shared/logger" "github.com/up9inc/mizu/tap/api" - "net/http" - "sync" - "time" ) type client struct { @@ -31,6 +32,9 @@ func GetInstance() *client { func (client *client) Configure(config shared.ElasticConfig) { if config.Url == "" || config.User == "" || config.Password == "" { + if client.es != nil { + client.es = nil + } logger.Log.Infof("No elastic configuration was supplied, elastic exporter disabled") return } @@ -46,13 +50,13 @@ func (client *client) Configure(config shared.ElasticConfig) { es, err := elasticsearch.NewClient(cfg) if err != nil { - logger.Log.Fatalf("Failed to initialize elastic client %v", err) + logger.Log.Errorf("Failed to initialize elastic client %v", err) } // Have the client instance return a response res, err := es.Info() if err != nil { - logger.Log.Fatalf("Elastic client.Info() ERROR: %v", err) + logger.Log.Errorf("Elastic client.Info() ERROR: %v", err) } else { client.es = es client.index = "mizu_traffic_http_" + time.Now().Format("2006_01_02_15_04") diff --git a/agent/pkg/oas/oas_generator.go b/agent/pkg/oas/oas_generator.go index df7278325..76d9a550b 100644 --- a/agent/pkg/oas/oas_generator.go +++ b/agent/pkg/oas/oas_generator.go @@ -33,10 +33,23 @@ func (g *oasGenerator) Start() { g.entriesChan = make(chan EntryWithSource, 100) // buffer up to 100 entries for OAS processing g.ServiceSpecs = &sync.Map{} g.started = true - go instance.runGeneretor() + go instance.runGenerator() } -func (g *oasGenerator) runGeneretor() { +func (g *oasGenerator) Stop() { + if !g.started { + return + } + g.cancel() + g.Reset() + g.started = false +} + +func (g *oasGenerator) IsStarted() bool { + return g.started +} + +func (g *oasGenerator) runGenerator() { for { select { case <-g.ctx.Done(): diff --git a/agent/pkg/servicemap/servicemap.go b/agent/pkg/servicemap/servicemap.go index 3f7359feb..e27585d3a 100644 --- a/agent/pkg/servicemap/servicemap.go +++ b/agent/pkg/servicemap/servicemap.go @@ -32,6 +32,7 @@ type serviceMap struct { type ServiceMap interface { Enable() + Disable() IsEnabled() bool NewTCPEntry(source *tapApi.TCP, destination *tapApi.TCP, protocol *tapApi.Protocol) GetStatus() ServiceMapStatus @@ -159,6 +160,11 @@ func (s *serviceMap) Enable() { s.enabled = true } +func (s *serviceMap) Disable() { + s.Reset() + s.enabled = false +} + func (s *serviceMap) IsEnabled() bool { return s.enabled } From 94dfa6885897b137137fdfc6501b50fe05d907b7 Mon Sep 17 00:00:00 2001 From: RamiBerm <54766858+RamiBerm@users.noreply.github.com> Date: Wed, 2 Mar 2022 09:48:42 +0200 Subject: [PATCH 02/17] Revert "Support stopping oas/servicemesh/telemetry in flight (#867)" (#868) This reverts commit 50c0062db47cc72949b61dc87c8fa36431530a5c. --- agent/pkg/elastic/esClient.go | 14 +++++--------- agent/pkg/oas/oas_generator.go | 17 ++--------------- agent/pkg/servicemap/servicemap.go | 6 ------ 3 files changed, 7 insertions(+), 30 deletions(-) diff --git a/agent/pkg/elastic/esClient.go b/agent/pkg/elastic/esClient.go index 9ccc30ebb..acedb8579 100644 --- a/agent/pkg/elastic/esClient.go +++ b/agent/pkg/elastic/esClient.go @@ -4,14 +4,13 @@ import ( "bytes" "crypto/tls" "encoding/json" - "net/http" - "sync" - "time" - "github.com/elastic/go-elasticsearch/v7" "github.com/up9inc/mizu/shared" "github.com/up9inc/mizu/shared/logger" "github.com/up9inc/mizu/tap/api" + "net/http" + "sync" + "time" ) type client struct { @@ -32,9 +31,6 @@ func GetInstance() *client { func (client *client) Configure(config shared.ElasticConfig) { if config.Url == "" || config.User == "" || config.Password == "" { - if client.es != nil { - client.es = nil - } logger.Log.Infof("No elastic configuration was supplied, elastic exporter disabled") return } @@ -50,13 +46,13 @@ func (client *client) Configure(config shared.ElasticConfig) { es, err := elasticsearch.NewClient(cfg) if err != nil { - logger.Log.Errorf("Failed to initialize elastic client %v", err) + logger.Log.Fatalf("Failed to initialize elastic client %v", err) } // Have the client instance return a response res, err := es.Info() if err != nil { - logger.Log.Errorf("Elastic client.Info() ERROR: %v", err) + logger.Log.Fatalf("Elastic client.Info() ERROR: %v", err) } else { client.es = es client.index = "mizu_traffic_http_" + time.Now().Format("2006_01_02_15_04") diff --git a/agent/pkg/oas/oas_generator.go b/agent/pkg/oas/oas_generator.go index 76d9a550b..df7278325 100644 --- a/agent/pkg/oas/oas_generator.go +++ b/agent/pkg/oas/oas_generator.go @@ -33,23 +33,10 @@ func (g *oasGenerator) Start() { g.entriesChan = make(chan EntryWithSource, 100) // buffer up to 100 entries for OAS processing g.ServiceSpecs = &sync.Map{} g.started = true - go instance.runGenerator() + go instance.runGeneretor() } -func (g *oasGenerator) Stop() { - if !g.started { - return - } - g.cancel() - g.Reset() - g.started = false -} - -func (g *oasGenerator) IsStarted() bool { - return g.started -} - -func (g *oasGenerator) runGenerator() { +func (g *oasGenerator) runGeneretor() { for { select { case <-g.ctx.Done(): diff --git a/agent/pkg/servicemap/servicemap.go b/agent/pkg/servicemap/servicemap.go index e27585d3a..3f7359feb 100644 --- a/agent/pkg/servicemap/servicemap.go +++ b/agent/pkg/servicemap/servicemap.go @@ -32,7 +32,6 @@ type serviceMap struct { type ServiceMap interface { Enable() - Disable() IsEnabled() bool NewTCPEntry(source *tapApi.TCP, destination *tapApi.TCP, protocol *tapApi.Protocol) GetStatus() ServiceMapStatus @@ -160,11 +159,6 @@ func (s *serviceMap) Enable() { s.enabled = true } -func (s *serviceMap) Disable() { - s.Reset() - s.enabled = false -} - func (s *serviceMap) IsEnabled() bool { return s.enabled } From 9053c58146e677390beaf2965c055e4a1dc24240 Mon Sep 17 00:00:00 2001 From: Liraz Yehezkel Date: Tue, 29 Mar 2022 10:25:25 +0300 Subject: [PATCH 03/17] Remove token from mizu community --- .../Pages/TrafficPage/TrafficPage.tsx | 4 ++-- ui/src/helpers/api.js | 24 ------------------- 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/ui/src/components/Pages/TrafficPage/TrafficPage.tsx b/ui/src/components/Pages/TrafficPage/TrafficPage.tsx index 3b0419acf..4089ed578 100644 --- a/ui/src/components/Pages/TrafficPage/TrafficPage.tsx +++ b/ui/src/components/Pages/TrafficPage/TrafficPage.tsx @@ -1,6 +1,6 @@ import React, {useEffect, useState} from "react"; import { Button } from "@material-ui/core"; -import Api,{getWebsocketUrl} from "../../../helpers/api"; +import Api, { MizuWebsocketURL } from "../../../helpers/api"; import debounce from 'lodash/debounce'; import {useSetRecoilState, useRecoilState} from "recoil"; import {useCommonStyles} from "../../../helpers/commonStyle" @@ -65,7 +65,7 @@ const trafficViewerApi = {...api} return ( <> - ); diff --git a/ui/src/helpers/api.js b/ui/src/helpers/api.js index 229d8109b..1db29859f 100644 --- a/ui/src/helpers/api.js +++ b/ui/src/helpers/api.js @@ -3,13 +3,10 @@ import * as axios from "axios"; export const MizuWebsocketURL = process.env.REACT_APP_OVERRIDE_WS_URL ? process.env.REACT_APP_OVERRIDE_WS_URL : window.location.protocol === 'https:' ? `wss://${window.location.host}/ws` : `ws://${window.location.host}/ws`; -export const FormValidationErrorType = "formError"; - const CancelToken = axios.CancelToken; const apiURL = process.env.REACT_APP_OVERRIDE_API_URL ? process.env.REACT_APP_OVERRIDE_API_URL : `${window.location.origin}/`; -let token = "" let client = null let source = null @@ -24,8 +21,6 @@ export default class Api { } constructor() { - token = localStorage.getItem("token"); - client = this.getAxiosClient(); source = null; } @@ -125,20 +120,10 @@ export default class Api { return response.data; } - persistToken = (tk) => { - token = tk; - client = this.getAxiosClient(); - localStorage.setItem('token', token); - } - getAxiosClient = () => { const headers = { Accept: "application/json" } - - if (token) { - headers['x-session-token'] = `${token}`; // we use `x-session-token` instead of `Authorization` because the latter is reserved by kubectl proxy, making mizu view not work - } return axios.create({ baseURL: apiURL, timeout: 31000, @@ -146,12 +131,3 @@ export default class Api { }); } } - -export function getWebsocketUrl() { - let websocketUrl = MizuWebsocketURL; - if (token) { - websocketUrl += `/${token}`; - } - - return websocketUrl; -} \ No newline at end of file From 2253737625df0157b9c60304c94ea47076588814 Mon Sep 17 00:00:00 2001 From: Liraz Yehezkel Date: Wed, 30 Mar 2022 13:09:10 +0300 Subject: [PATCH 04/17] Try to avoid overlap only for maps including under 10 services --- .../ServiceMapModal/ServiceMapModal.tsx | 29 ++++++++++++------- .../ServiceMapModal/ServiceMapOptions.ts | 4 +-- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/ui/src/components/ServiceMapModal/ServiceMapModal.tsx b/ui/src/components/ServiceMapModal/ServiceMapModal.tsx index ca1406fe7..f120ce5b5 100644 --- a/ui/src/components/ServiceMapModal/ServiceMapModal.tsx +++ b/ui/src/components/ServiceMapModal/ServiceMapModal.tsx @@ -100,6 +100,7 @@ export const ServiceMapModal: React.FC = ({ isOpen, onOpen const commonClasses = useCommonStyles(); const [isLoading, setIsLoading] = useState(true); const [graphData, setGraphData] = useState({ nodes: [], edges: [] }); + const [graphOptions, setGraphOptions] = useState(ServiceMapOptions); const getServiceMapData = useCallback(async () => { try { @@ -149,6 +150,14 @@ export const ServiceMapModal: React.FC = ({ isOpen, onOpen // eslint-disable-next-line }, [isOpen]) + useEffect(() => { + if(graphData?.nodes?.length === 0) return; + let options = {...graphOptions}; + options.physics.barnesHut.avoidOverlap = graphData?.nodes?.length > 10 ? 0 : 1; + setGraphOptions(options); + // eslint-disable-next-line + },[graphData?.nodes?.length]) + useEffect(() => { getServiceMapData(); return () => setGraphData({ nodes: [], edges: [] }) @@ -180,7 +189,7 @@ export const ServiceMapModal: React.FC = ({ isOpen, onOpen
- close onClose()} style={{ cursor: "pointer" }}> + close onClose()} style={{ cursor: "pointer" }}/>
    -
  • HTTP
  • -
  • HTTP/2
  • -
  • gRPC
  • -
  • AMQP
  • -
  • KAFKA
  • -
  • REDIS
  • +
  • HTTP
  • +
  • HTTP/2
  • +
  • gRPC
  • +
  • AMQP
  • +
  • KAFKA
  • +
  • REDIS
} @@ -211,4 +220,4 @@ export const ServiceMapModal: React.FC = ({ isOpen, onOpen ); -} \ No newline at end of file +} diff --git a/ui/src/components/ServiceMapModal/ServiceMapOptions.ts b/ui/src/components/ServiceMapModal/ServiceMapOptions.ts index 057ed7101..b525f66dc 100644 --- a/ui/src/components/ServiceMapModal/ServiceMapOptions.ts +++ b/ui/src/components/ServiceMapModal/ServiceMapOptions.ts @@ -148,7 +148,7 @@ const ServiceMapOptions = { springLength: 180, springConstant: 0.04, damping: 0.2, - avoidOverlap: 1 + avoidOverlap: 0 }, }, layout: { @@ -171,4 +171,4 @@ const ServiceMapOptions = { }, }; -export default ServiceMapOptions \ No newline at end of file +export default ServiceMapOptions From 697bfef8612a2bcdc40d52b42c2387081f10862c Mon Sep 17 00:00:00 2001 From: Liraz Yehezkel Date: Wed, 30 Mar 2022 17:03:21 +0300 Subject: [PATCH 05/17] TLS icon position --- .../TrafficViewer/EntryListItem/EntryListItem.module.sass | 4 +++- .../components/TrafficViewer/EntryListItem/EntryListItem.tsx | 4 +--- ui-common/src/components/UI/Protocol.tsx | 2 +- ui-common/src/components/UI/style/StatusCode.module.sass | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ui-common/src/components/TrafficViewer/EntryListItem/EntryListItem.module.sass b/ui-common/src/components/TrafficViewer/EntryListItem/EntryListItem.module.sass index 334fa0033..b137bb415 100644 --- a/ui-common/src/components/TrafficViewer/EntryListItem/EntryListItem.module.sass +++ b/ui-common/src/components/TrafficViewer/EntryListItem/EntryListItem.module.sass @@ -66,8 +66,10 @@ margin-top: -60px .capture img - height: 20px + height: 14px z-index: 1000 + margin-top: 12px + margin-left: -2px .endpointServiceContainer display: flex diff --git a/ui-common/src/components/TrafficViewer/EntryListItem/EntryListItem.tsx b/ui-common/src/components/TrafficViewer/EntryListItem/EntryListItem.tsx index e55b90fe0..8bc7f0b10 100644 --- a/ui-common/src/components/TrafficViewer/EntryListItem/EntryListItem.tsx +++ b/ui-common/src/components/TrafficViewer/EntryListItem/EntryListItem.tsx @@ -140,8 +140,6 @@ export const EntryItem: React.FC = ({entry, style, headingMode}) => const isStatusCodeEnabled = ((entry.proto.name === "http" && "status" in entry) || entry.status !== 0); - let endpointServiceContainer = "10px"; - if (!isStatusCodeEnabled) endpointServiceContainer = "20px"; return
= ({entry, style, headingMode}) => {isStatusCodeEnabled &&
} -
+
= ({protocol, horizontal}) => { backgroundColor: protocol.backgroundColor, color: protocol.foregroundColor, fontSize: protocol.fontSize, - marginRight: "-20px", + marginRight: "-6px", }} title={protocol.longName} > diff --git a/ui-common/src/components/UI/style/StatusCode.module.sass b/ui-common/src/components/UI/style/StatusCode.module.sass index c9af8a775..4faa4344c 100644 --- a/ui-common/src/components/UI/style/StatusCode.module.sass +++ b/ui-common/src/components/UI/style/StatusCode.module.sass @@ -9,7 +9,7 @@ text-align: center line-height: 22px font-weight: 600 - margin-left: 8px + margin-left: 3px .neutral background: gray From 2ef6afa39583ac6f3bfee4d322a3d201209c66ab Mon Sep 17 00:00:00 2001 From: Nimrod Gilboa Markevich <59927337+nimrod-up9@users.noreply.github.com> Date: Wed, 30 Mar 2022 17:13:56 +0300 Subject: [PATCH 06/17] Hotfix tap issues - restart service mesh tapping when tap targets change, fallback to source namespace (#953) * Read from service mesh network namespaces upon update (#944) #patch * Set the entry namespace to the source namespace if the destination is not resolved (#950) --- agent/pkg/api/main.go | 7 ++++++- tap/passive_tapper.go | 10 +++------- tap/source/packet_source_manager.go | 17 ++++++----------- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/agent/pkg/api/main.go b/agent/pkg/api/main.go index d37fbe0da..f4f83b5be 100644 --- a/agent/pkg/api/main.go +++ b/agent/pkg/api/main.go @@ -183,6 +183,7 @@ func resolveIP(connectionInfo *tapApi.ConnectionInfo) (resolvedSource string, re } } else { resolvedSource = resolvedSourceObject.FullAddress + namespace = resolvedSourceObject.Namespace } unresolvedDestination := fmt.Sprintf("%s:%s", connectionInfo.ServerIP, connectionInfo.ServerPort) @@ -194,7 +195,11 @@ func resolveIP(connectionInfo *tapApi.ConnectionInfo) (resolvedSource string, re } } else { resolvedDestination = resolvedDestinationObject.FullAddress - namespace = resolvedDestinationObject.Namespace + // Overwrite namespace (if it was set according to the source) + // Only overwrite if non-empty + if resolvedDestinationObject.Namespace != "" { + namespace = resolvedDestinationObject.Namespace + } } } return resolvedSource, resolvedDestination, namespace diff --git a/tap/passive_tapper.go b/tap/passive_tapper.go index e9ecf5216..57fd2a075 100644 --- a/tap/passive_tapper.go +++ b/tap/passive_tapper.go @@ -112,7 +112,7 @@ func UpdateTapTargets(newTapTargets []v1.Pod) { tapTargets = newTapTargets - packetSourceManager.UpdatePods(tapTargets) + packetSourceManager.UpdatePods(tapTargets, !*nodefrag, mainPacketInputChan) if tlsTapperInstance != nil { if err := tlstapper.UpdateTapTargets(tlsTapperInstance, &tapTargets, *procfs); err != nil { @@ -198,12 +198,8 @@ func initializePacketSources() error { } var err error - if packetSourceManager, err = source.NewPacketSourceManager(*procfs, *fname, *iface, *servicemesh, tapTargets, behaviour); err != nil { - return err - } else { - packetSourceManager.ReadPackets(!*nodefrag, mainPacketInputChan) - return nil - } + packetSourceManager, err = source.NewPacketSourceManager(*procfs, *fname, *iface, *servicemesh, tapTargets, behaviour, !*nodefrag, mainPacketInputChan) + return err } func initializePassiveTapper(opts *TapOpts, outputItems chan *api.OutputChannelItem) (*tcpStreamMap, *tcpAssembler) { diff --git a/tap/source/packet_source_manager.go b/tap/source/packet_source_manager.go index 3fc0ee0b9..bf527ef2e 100644 --- a/tap/source/packet_source_manager.go +++ b/tap/source/packet_source_manager.go @@ -24,7 +24,7 @@ type PacketSourceManager struct { } func NewPacketSourceManager(procfs string, filename string, interfaceName string, - mtls bool, pods []v1.Pod, behaviour TcpPacketSourceBehaviour) (*PacketSourceManager, error) { + mtls bool, pods []v1.Pod, behaviour TcpPacketSourceBehaviour, ipdefrag bool, packets chan<- TcpPacketInfo) (*PacketSourceManager, error) { hostSource, err := newHostPacketSource(filename, interfaceName, behaviour) if err != nil { return nil, err @@ -43,7 +43,7 @@ func NewPacketSourceManager(procfs string, filename string, interfaceName string behaviour: behaviour, } - sourceManager.UpdatePods(pods) + go hostSource.readPackets(ipdefrag, packets) return sourceManager, nil } @@ -64,16 +64,16 @@ func newHostPacketSource(filename string, interfaceName string, return source, nil } -func (m *PacketSourceManager) UpdatePods(pods []v1.Pod) { +func (m *PacketSourceManager) UpdatePods(pods []v1.Pod, ipdefrag bool, packets chan<- TcpPacketInfo) { if m.config.mtls { - m.updateMtlsPods(m.config.procfs, pods, m.config.interfaceName, m.config.behaviour) + m.updateMtlsPods(m.config.procfs, pods, m.config.interfaceName, m.config.behaviour, ipdefrag, packets) } m.setBPFFilter(pods) } func (m *PacketSourceManager) updateMtlsPods(procfs string, pods []v1.Pod, - interfaceName string, behaviour TcpPacketSourceBehaviour) { + interfaceName string, behaviour TcpPacketSourceBehaviour, ipdefrag bool, packets chan<- TcpPacketInfo) { relevantPids := m.getRelevantPids(procfs, pods) logger.Log.Infof("Updating mtls pods (new: %v) (current: %v)", relevantPids, m.sources) @@ -90,6 +90,7 @@ func (m *PacketSourceManager) updateMtlsPods(procfs string, pods []v1.Pod, source, err := newNetnsPacketSource(procfs, pid, interfaceName, behaviour) if err == nil { + go source.readPackets(ipdefrag, packets) m.sources[pid] = source } } @@ -153,12 +154,6 @@ func (m *PacketSourceManager) setBPFFilter(pods []v1.Pod) { } } -func (m *PacketSourceManager) ReadPackets(ipdefrag bool, packets chan<- TcpPacketInfo) { - for _, src := range m.sources { - go src.readPackets(ipdefrag, packets) - } -} - func (m *PacketSourceManager) Close() { for _, src := range m.sources { src.close() From ac94554d2fcf400ec5c1752f65f61dac74557829 Mon Sep 17 00:00:00 2001 From: Liraz Yehezkel Date: Wed, 30 Mar 2022 17:14:56 +0300 Subject: [PATCH 07/17] common versions --- ui-common/package.json | 4 ++-- ui/package.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ui-common/package.json b/ui-common/package.json index 4ca4729f7..b0eedc50f 100644 --- a/ui-common/package.json +++ b/ui-common/package.json @@ -1,6 +1,6 @@ { "name": "@up9/mizu-common", - "version": "1.0.144", + "version": "1.0.147", "description": "Made with create-react-library", "author": "", "license": "MIT", @@ -90,4 +90,4 @@ "files": [ "dist" ] -} \ No newline at end of file +} diff --git a/ui/package.json b/ui/package.json index 9a23aedc6..4d997bc0f 100644 --- a/ui/package.json +++ b/ui/package.json @@ -13,7 +13,7 @@ "@types/jest": "^26.0.22", "@types/node": "^12.20.10", "@uiw/react-textarea-code-editor": "^1.4.12", - "@up9/mizu-common": "1.0.144", + "@up9/mizu-common": "1.0.147", "axios": "^0.25.0", "core-js": "^3.20.2", "craco-babel-loader": "^1.0.3", @@ -75,4 +75,4 @@ "last 1 safari version" ] } -} \ No newline at end of file +} From e03db7b09b392a0023c113aafed27fbc419564bb Mon Sep 17 00:00:00 2001 From: AmitUp9 <96980485+AmitUp9@users.noreply.github.com> Date: Wed, 20 Apr 2022 11:20:14 +0300 Subject: [PATCH 08/17] Bug/UI/tra 4473 grpc decoding error (#1025) * note added and formatting added * showing message on ui instead of console error --- ui-common/package.json | 2 +- .../EntryDetailed/EntrySections.tsx | 149 +++++++++--------- ui/package.json | 1 - 3 files changed, 79 insertions(+), 73 deletions(-) diff --git a/ui-common/package.json b/ui-common/package.json index 511f081d1..e8f00e77c 100644 --- a/ui-common/package.json +++ b/ui-common/package.json @@ -49,7 +49,7 @@ "moment": "^2.29.1", "node-fetch": "^3.1.1", "numeral": "^2.0.6", - "protobuf-decoder": "^0.1.0", + "protobuf-decoder": "^0.1.2", "react-graph-vis": "^1.0.7", "react-lowlight": "^3.0.0", "react-router-dom": "^6.2.1", diff --git a/ui-common/src/components/TrafficViewer/EntryDetailed/EntrySections.tsx b/ui-common/src/components/TrafficViewer/EntryDetailed/EntrySections.tsx index ac582dc88..02321c5e1 100644 --- a/ui-common/src/components/TrafficViewer/EntryDetailed/EntrySections.tsx +++ b/ui-common/src/components/TrafficViewer/EntryDetailed/EntrySections.tsx @@ -1,13 +1,13 @@ import styles from "./EntrySections.module.sass"; -import React, {useState} from "react"; -import {SyntaxHighlighter} from "../../UI/SyntaxHighlighter/index"; +import React, { useState } from "react"; +import { SyntaxHighlighter } from "../../UI/SyntaxHighlighter/index"; import CollapsibleContainer from "../../UI/CollapsibleContainer"; import FancyTextDisplay from "../../UI/FancyTextDisplay"; import Queryable from "../../UI/Queryable"; import Checkbox from "../../UI/Checkbox"; import ProtobufDecoder from "protobuf-decoder"; -import {default as jsonBeautify} from "json-beautify"; -import {default as xmlBeautify} from "xml-formatter"; +import { default as jsonBeautify } from "json-beautify"; +import { default as xmlBeautify } from "xml-formatter"; interface EntryViewLineProps { label: string; @@ -18,40 +18,40 @@ interface EntryViewLineProps { useTooltip?: boolean; } -const EntryViewLine: React.FC = ({label, value, selector = "", overrideQueryValue = "", displayIconOnMouseOver = true, useTooltip = true}) => { +const EntryViewLine: React.FC = ({ label, value, selector = "", overrideQueryValue = "", displayIconOnMouseOver = true, useTooltip = true }) => { let query: string; if (!selector) { query = ""; } else if (overrideQueryValue) { query = `${selector} == ${overrideQueryValue}`; - } else if (typeof(value) == "string") { + } else if (typeof (value) == "string") { query = `${selector} == "${JSON.stringify(value).slice(1, -1)}"`; } else { query = `${selector} == ${value}`; } return (label && - - - {label} - - - - - - ) || null; + + + {label} + + + + + + ) || null; } @@ -63,11 +63,11 @@ interface EntrySectionCollapsibleTitleProps { query?: string, } -const EntrySectionCollapsibleTitle: React.FC = ({title, color, expanded, setExpanded, query = ""}) => { +const EntrySectionCollapsibleTitle: React.FC = ({ title, color, expanded, setExpanded, query = "" }) => { return
{ setExpanded(!expanded) }} @@ -90,12 +90,12 @@ interface EntrySectionContainerProps { query?: string, } -export const EntrySectionContainer: React.FC = ({title, color, children, query = ""}) => { +export const EntrySectionContainer: React.FC = ({ title, color, children, query = "" }) => { const [expanded, setExpanded] = useState(true); return } + title={} > {children} @@ -130,6 +130,7 @@ export const EntryBodySection: React.FC = ({ const isBase64Encoding = encoding === 'base64'; const supportsPrettying = supportedFormats.some(format => contentType?.indexOf(format) > -1); + const [isDecodeGrpc, setIsDecodeGrpc] = useState(true); const formatTextBody = (body: any): string => { if (!decodeBase64) return body; @@ -141,7 +142,7 @@ export const EntryBodySection: React.FC = ({ if (jsonLikeFormats.some(format => contentType?.indexOf(format) > -1)) { if (!isPretty) return bodyBuf; return jsonBeautify(JSON.parse(bodyBuf), null, 2, 80); - } else if (xmlLikeFormats.some(format => contentType?.indexOf(format) > -1)) { + } else if (xmlLikeFormats.some(format => contentType?.indexOf(format) > -1)) { if (!isPretty) return bodyBuf; return xmlBeautify(bodyBuf, { indentation: ' ', @@ -157,49 +158,55 @@ export const EntryBodySection: React.FC = ({ return jsonBeautify(protobufDecoded, null, 2, 80); } } catch (error) { - console.error(error); + if(isDecodeGrpc) + setIsDecodeGrpc(false); + if (!String(error).includes("More than one message in")){ + console.error(error); + } } return bodyBuf; } return {content && content?.length > 0 && -
- {supportsPrettying &&
- {setIsPretty(!isPretty)}}/> + title={title} + color={color} + query={`${selector} == r".*"`} + > +
+ {supportsPrettying &&
+ { setIsPretty(!isPretty) }} />
} - {supportsPrettying && Pretty} + {supportsPrettying && Pretty} -
- {setShowLineNumbers(!showLineNumbers)}}/> +
+ { setShowLineNumbers(!showLineNumbers) }} />
- Line numbers - - {isBase64Encoding &&
- {setDecodeBase64(!decodeBase64)}}/> + Line numbers + {isBase64Encoding &&
+ { setDecodeBase64(!decodeBase64) }} />
} - {isBase64Encoding && Decode Base64} -
+ {isBase64Encoding && Decode Base64} + {!isDecodeGrpc && More than one message in protobuf payload is not supported} +
- + } } + interface EntrySectionProps { title: string, color: string, arrayToIterate: any[], } -export const EntryTableSection: React.FC = ({title, color, arrayToIterate}) => { +export const EntryTableSection: React.FC = ({ title, color, arrayToIterate }) => { let arrayToIterateSorted: any[]; if (arrayToIterate) { arrayToIterateSorted = arrayToIterate.sort((a, b) => { @@ -220,7 +227,7 @@ export const EntryTableSection: React.FC = ({title, color, ar - {arrayToIterateSorted.map(({name, value, selector}, index) => = ({title, color, ar />)}
-
: + : } } @@ -247,7 +254,7 @@ interface EntryPolicySectionCollapsibleTitleProps { setExpanded: any; } -const EntryPolicySectionCollapsibleTitle: React.FC = ({label, matched, expanded, setExpanded}) => { +const EntryPolicySectionCollapsibleTitle: React.FC = ({ label, matched, expanded, setExpanded }) => { return
- {label} - {matched} + {label} + {matched}
@@ -273,28 +280,28 @@ interface EntryPolicySectionContainerProps { children?: any; } -export const EntryPolicySectionContainer: React.FC = ({label, matched, children}) => { +export const EntryPolicySectionContainer: React.FC = ({ label, matched, children }) => { const [expanded, setExpanded] = useState(false); return } + title={} > {children} } -export const EntryTablePolicySection: React.FC = ({title, color, latency, arrayToIterate}) => { +export const EntryTablePolicySection: React.FC = ({ title, color, latency, arrayToIterate }) => { return { arrayToIterate && arrayToIterate.length > 0 ? - - - - {arrayToIterate.map(({rule, matched}, index) => { + +
+ + {arrayToIterate.map(({ rule, matched }, index) => { return ( - = latency : true)? "Success" : "Failure"}> + = latency : true) ? "Success" : "Failure"}> { { @@ -330,11 +337,11 @@ export const EntryTablePolicySection: React.FC = ({titl ) } - ) - } - -
-
+ ) + } + + +
: No rules could be applied to this request. }
@@ -347,7 +354,7 @@ interface EntryContractSectionProps { contractContent: string, } -export const EntryContractSection: React.FC = ({color, requestReason, responseReason, contractContent}) => { +export const EntryContractSection: React.FC = ({ color, requestReason, responseReason, contractContent }) => { return {requestReason && {requestReason} diff --git a/ui/package.json b/ui/package.json index 4d6e96dc2..096d2b5b8 100644 --- a/ui/package.json +++ b/ui/package.json @@ -27,7 +27,6 @@ "node-fetch": "^3.1.1", "node-sass": "^6.0.0", "numeral": "^2.0.6", - "protobuf-decoder": "^0.1.0", "react": "^17.0.2", "react-copy-to-clipboard": "^5.0.3", "react-dom": "^17.0.2", From 32ba653d127a6e4baa005278505d2d2020a166c7 Mon Sep 17 00:00:00 2001 From: lirazyehezkel <61656597+lirazyehezkel@users.noreply.github.com> Date: Wed, 20 Apr 2022 14:34:16 +0300 Subject: [PATCH 09/17] TLS icon z index (#1028) --- .../TrafficViewer/EntryListItem/EntryListItem.module.sass | 1 - 1 file changed, 1 deletion(-) diff --git a/ui-common/src/components/TrafficViewer/EntryListItem/EntryListItem.module.sass b/ui-common/src/components/TrafficViewer/EntryListItem/EntryListItem.module.sass index 69ca738f8..199749224 100644 --- a/ui-common/src/components/TrafficViewer/EntryListItem/EntryListItem.module.sass +++ b/ui-common/src/components/TrafficViewer/EntryListItem/EntryListItem.module.sass @@ -67,7 +67,6 @@ .capture img height: 14px - z-index: 1000 margin-top: 12px margin-left: -2px From d76f24edb8ca9b4550dbb288062e4d93bea61d21 Mon Sep 17 00:00:00 2001 From: RoyUP9 <87927115+RoyUP9@users.noreply.github.com> Date: Wed, 20 Apr 2022 14:53:07 +0300 Subject: [PATCH 10/17] Fixed tapper socket error on failure (#1029) --- agent/main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/agent/main.go b/agent/main.go index b2598f2df..0bd951c39 100644 --- a/agent/main.go +++ b/agent/main.go @@ -320,6 +320,7 @@ func dialSocketWithRetry(socketAddress string, retryAmount int, retryDelay time. for i := 1; i < retryAmount; i++ { socketConnection, _, err := dialer.Dial(socketAddress, nil) if err != nil { + lastErr = err if i < retryAmount { logger.Log.Infof("socket connection to %s failed: %v, retrying %d out of %d in %d seconds...", socketAddress, err, i, retryAmount, retryDelay/time.Second) time.Sleep(retryDelay) From 9b475a78f9cd816080f0e633daa2940037ee63e2 Mon Sep 17 00:00:00 2001 From: lirazyehezkel <61656597+lirazyehezkel@users.noreply.github.com> Date: Wed, 20 Apr 2022 15:12:36 +0300 Subject: [PATCH 11/17] Started listening entry time (#1030) --- ui-common/src/components/TrafficViewer/EntriesList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-common/src/components/TrafficViewer/EntriesList.tsx b/ui-common/src/components/TrafficViewer/EntriesList.tsx index 693c6597a..f14c8bd90 100644 --- a/ui-common/src/components/TrafficViewer/EntriesList.tsx +++ b/ui-common/src/components/TrafficViewer/EntriesList.tsx @@ -212,7 +212,7 @@ export const EntriesList: React.FC = ({
Displaying {entries?.length > MAX_ENTRIES ? MAX_ENTRIES : entries?.length} results out of {queriedTotal} total
- {startTime !== 0 &&
Started listening at First traffic entry time Date: Sat, 23 Apr 2022 23:45:15 -0700 Subject: [PATCH 12/17] Fix the CLI build error for Windows target (#1031) --- cli/Makefile | 20 ++++++++++---------- cli/config/configStructs/tapConfig.go | 5 ----- cli/go.mod | 5 ----- cli/go.sum | 12 ------------ 4 files changed, 10 insertions(+), 32 deletions(-) diff --git a/cli/Makefile b/cli/Makefile index 7a78898df..112a403db 100644 --- a/cli/Makefile +++ b/cli/Makefile @@ -36,16 +36,16 @@ build-base: ## Build mizu CLI binary (select platform via GOOS / GOARCH env vari (cd bin && shasum -a 256 mizu_${SUFFIX} > mizu_${SUFFIX}.sha256) build-all: ## Build for all supported platforms. - @echo "Compiling for every OS and Platform" - @mkdir -p bin && sed s/_VER_/$(VER)/g README.md.TEMPLATE > bin/README.md - @$(MAKE) build GOOS=linux GOARCH=amd64 - @$(MAKE) build GOOS=linux GOARCH=arm64 - @$(MAKE) build GOOS=darwin GOARCH=amd64 - @$(MAKE) build GOOS=darwin GOARCH=arm64 - @$(MAKE) build GOOS=windows GOARCH=amd64 - @mv ./bin/mizu_windows_amd64 ./bin/mizu.exe - @echo "---------" - @find ./bin -ls + echo "Compiling for every OS and Platform" && \ + mkdir -p bin && sed s/_VER_/$(VER)/g README.md.TEMPLATE > bin/README.md && \ + $(MAKE) build GOOS=linux GOARCH=amd64 && \ + $(MAKE) build GOOS=linux GOARCH=arm64 && \ + $(MAKE) build GOOS=darwin GOARCH=amd64 && \ + $(MAKE) build GOOS=darwin GOARCH=arm64 && \ + $(MAKE) build GOOS=windows GOARCH=amd64 && \ + mv ./bin/mizu_windows_amd64 ./bin/mizu.exe && \ + echo "---------" && \ + find ./bin -ls clean: ## Clean all build artifacts. go clean diff --git a/cli/config/configStructs/tapConfig.go b/cli/config/configStructs/tapConfig.go index 2d45c264d..f2cdd612a 100644 --- a/cli/config/configStructs/tapConfig.go +++ b/cli/config/configStructs/tapConfig.go @@ -11,7 +11,6 @@ import ( "github.com/up9inc/mizu/cli/uiUtils" "github.com/up9inc/mizu/shared" - basenine "github.com/up9inc/basenine/server/lib" "github.com/up9inc/mizu/shared/logger" "github.com/up9inc/mizu/shared/units" ) @@ -79,10 +78,6 @@ func (config *TapConfig) GetInsertionFilter() string { } } } - _, err := basenine.Parse(insertionFilter) - if err != nil { - logger.Log.Warningf(uiUtils.Warning, fmt.Sprintf("Insertion filter syntax error: %v", err)) - } return insertionFilter } diff --git a/cli/go.mod b/cli/go.mod index acf9db04b..b2e6b30a9 100644 --- a/cli/go.mod +++ b/cli/go.mod @@ -11,7 +11,6 @@ require ( github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 github.com/spf13/cobra v1.3.0 github.com/spf13/pflag v1.0.5 - github.com/up9inc/basenine/server/lib v0.0.0-20220419100955-e2ca51087607 github.com/up9inc/mizu/shared v0.0.0 github.com/up9inc/mizu/tap/api v0.0.0 golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 @@ -33,11 +32,8 @@ require ( github.com/MakeNowJust/heredoc v1.0.0 // indirect github.com/PuerkitoBio/purell v1.1.1 // indirect github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect - github.com/alecthomas/participle/v2 v2.0.0-alpha7 // indirect github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5 // indirect - github.com/clbanning/mxj/v2 v2.5.5 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/dlclark/regexp2 v1.4.0 // indirect github.com/docker/go-units v0.4.0 // indirect github.com/evanphx/json-patch v5.6.0+incompatible // indirect github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect @@ -72,7 +68,6 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect - github.com/ohler55/ojg v1.14.0 // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect diff --git a/cli/go.sum b/cli/go.sum index 6156cedfe..df79ed5cd 100644 --- a/cli/go.sum +++ b/cli/go.sum @@ -83,10 +83,6 @@ github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tN github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= -github.com/alecthomas/participle/v2 v2.0.0-alpha7 h1:cK4vjj0VSgb3lN1nuKA5F7dw+1s1pWBe5bx7nNCnN+c= -github.com/alecthomas/participle/v2 v2.0.0-alpha7/go.mod h1:NumScqsC42o9x+dGj8/YqsIfhrIQjFEOFovxotbBirA= -github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1 h1:GDQdwm/gAcJcLAKQQZGOJ4knlw+7rfEQQcmwTbt4p5E= -github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -120,8 +116,6 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5P github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= -github.com/clbanning/mxj/v2 v2.5.5 h1:oT81vUeEiQQ/DcHbzSytRngP6Ky9O+L+0Bw0zSJag9E= -github.com/clbanning/mxj/v2 v2.5.5/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= @@ -155,8 +149,6 @@ github.com/denisbrodbeck/machineid v1.0.1 h1:geKr9qtkB876mXguW2X6TU4ZynleN6ezuMS github.com/denisbrodbeck/machineid v1.0.1/go.mod h1:dJUwb7PTidGDeYyUBmXZ2GphQBbjJCrnectwCyxcUSI= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E= -github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= @@ -487,8 +479,6 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWb github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/ohler55/ojg v1.14.0 h1:DyHomsCwofNswmKj7BLMdx51xnKbXxgIo1rVWCaBcNk= -github.com/ohler55/ojg v1.14.0/go.mod h1:3+GH+0PggMKocQtbZCrFifal3yRpHiBT4QUkxFJI6e8= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA= github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -600,8 +590,6 @@ github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69 github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= -github.com/up9inc/basenine/server/lib v0.0.0-20220419100955-e2ca51087607 h1:gCOwbfjsLslDw63yj/3l9d5TH7ikhIWHd7j0lE9U26U= -github.com/up9inc/basenine/server/lib v0.0.0-20220419100955-e2ca51087607/go.mod h1:v0hIh31iwDGbkkdeSSppdMNm1oIigfCA2mG2XajKnf8= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg= github.com/xlab/treeprint v1.1.0 h1:G/1DjNkPpfZCFt9CSh6b5/nY4VimlbHF3Rh4obvtzDk= From df269fa95079dad3d6339da33ec1691f881127d9 Mon Sep 17 00:00:00 2001 From: leon-up9 <97597983+leon-up9@users.noreply.github.com> Date: Sun, 24 Apr 2022 10:20:19 +0300 Subject: [PATCH 13/17] method changed to useCallback (#1032) height for horizontal scroll like in Ent Co-authored-by: Leon <> Co-authored-by: lirazyehezkel <61656597+lirazyehezkel@users.noreply.github.com> --- .../src/components/ServiceMapModal/ServiceMapModal.tsx | 8 +++++--- ui/src/index.sass | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ui-common/src/components/ServiceMapModal/ServiceMapModal.tsx b/ui-common/src/components/ServiceMapModal/ServiceMapModal.tsx index 9737891c4..8a223a196 100644 --- a/ui-common/src/components/ServiceMapModal/ServiceMapModal.tsx +++ b/ui-common/src/components/ServiceMapModal/ServiceMapModal.tsx @@ -130,7 +130,7 @@ export const ServiceMapModal: React.FC = ({ isOpen, onClos return [...resolved, ...unResolved] }, [serviceMapApiData]) - const filterServiceMap = (newProtocolsFilters?: any[], newServiceFilters?: string[]) => { + const filterServiceMap = useCallback((newProtocolsFilters?: any[], newServiceFilters?: string[]) => { const filterProt = newProtocolsFilters || checkedProtocols const filterService = newServiceFilters || checkedServices setCheckedProtocols(filterProt) @@ -140,12 +140,14 @@ export const ServiceMapModal: React.FC = ({ isOpen, onClos edges: serviceMapApiData.edges?.filter(edge => filterProt.includes(edge.protocol.abbr)).map(mapEdgesDatatoGraph) } setGraphData(newGraphData); - } + }, [checkedProtocols, checkedServices, serviceMapApiData]) + + useEffect(() => { if (checkedServices.length > 0) return // only after refresh filterServiceMap(checkedProtocols, getServicesForFilter.map(x => x.key).filter(serviceName => !Utils.isIpAddress(serviceName))) - }, [getServicesForFilter]) + }, [getServicesForFilter, checkedServices]) useEffect(() => { getServiceMapData() diff --git a/ui/src/index.sass b/ui/src/index.sass index 38bdd9f0e..b9fd88849 100644 --- a/ui/src/index.sass +++ b/ui/src/index.sass @@ -139,6 +139,7 @@ button ::-webkit-scrollbar width: 6px + height: 6px ::-webkit-scrollbar-thumb background-color: $light-blue-color From b5c5a8934b78dcf97135d168fdf1f1aec856aa95 Mon Sep 17 00:00:00 2001 From: leon-up9 <97597983+leon-up9@users.noreply.github.com> Date: Sun, 24 Apr 2022 10:28:00 +0300 Subject: [PATCH 14/17] Fix/ui/Service-map-GUI-issues_TRA-4499 (#1034) * LoadingOverlay z-index * resizable max width servicemap edges background color * z-index as overlay Co-authored-by: Leon <> --- .../ServiceMapModal/ServiceMapModal.tsx | 2 +- .../ServiceMapModal/ServiceMapOptions.ts | 4 ++-- ui-common/src/components/UI/Resizeable.tsx | 16 +++++++--------- .../components/style/LoadingOverlay.module.sass | 1 + 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/ui-common/src/components/ServiceMapModal/ServiceMapModal.tsx b/ui-common/src/components/ServiceMapModal/ServiceMapModal.tsx index 8a223a196..93729d514 100644 --- a/ui-common/src/components/ServiceMapModal/ServiceMapModal.tsx +++ b/ui-common/src/components/ServiceMapModal/ServiceMapModal.tsx @@ -178,7 +178,7 @@ export const ServiceMapModal: React.FC = ({ isOpen, onClos
- +
= ({ children, minWidth }) => { +const Resizeable: React.FC = ({ children, minWidth, maxWidth }) => { const resizeble = useRef(null) let mousePos = { x: 0, y: 0 } let elementDimention = { w: 0, h: 0 } @@ -47,14 +48,11 @@ const Resizeable: React.FC = ({ children, minWidth }) => { }; return ( - -
- {children} -
- {/*
-- FutureUse*/} -
- -
+
+ {children} +
+ {/*
-- FutureUse*/} +
); }; diff --git a/ui-common/src/components/style/LoadingOverlay.module.sass b/ui-common/src/components/style/LoadingOverlay.module.sass index 2fd08b3bc..495a38ff3 100644 --- a/ui-common/src/components/style/LoadingOverlay.module.sass +++ b/ui-common/src/components/style/LoadingOverlay.module.sass @@ -8,6 +8,7 @@ align-items: center justify-content: center background-color: rgba(25, 25, 25, 0.5) + z-index: 1000 .loadingOverlaySpinner width: 60px From 2de57a6630d179041414b0aac73242da2547f272 Mon Sep 17 00:00:00 2001 From: Igor Gov Date: Sun, 24 Apr 2022 11:23:59 +0300 Subject: [PATCH 15/17] Fix: websocket timeouts when many traffic etries sent (#1038) --- agent/pkg/api/socket_routes.go | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/agent/pkg/api/socket_routes.go b/agent/pkg/api/socket_routes.go index eddf160cd..085617bcc 100644 --- a/agent/pkg/api/socket_routes.go +++ b/agent/pkg/api/socket_routes.go @@ -123,22 +123,23 @@ func SendToSocket(socketId int, message []byte) error { return fmt.Errorf("socket %v is disconnected", socketId) } - var sent = false - time.AfterFunc(time.Second*5, func() { - if !sent { - logger.Log.Error("socket timed out") - socketCleanup(socketId, socketObj) - } - }) - socketObj.lock.Lock() // gorilla socket panics from concurrent writes to a single socket - err := socketObj.connection.WriteMessage(1, message) - socketObj.lock.Unlock() - sent = true + defer socketObj.lock.Unlock() - if err != nil { - return fmt.Errorf("failed to write message to socket %v, err: %w", socketId, err) + if connectedWebsockets[socketId] == nil { + return fmt.Errorf("socket %v is disconnected", socketId) } + + if err := socketObj.connection.SetWriteDeadline(time.Now().Add(time.Second * 10)); err != nil { + socketCleanup(socketId, socketObj) + return fmt.Errorf("error setting timeout to socket %v, err: %v", socketId, err) + } + + if err := socketObj.connection.WriteMessage(websocket.TextMessage, message); err != nil { + socketCleanup(socketId, socketObj) + return fmt.Errorf("failed to write message to socket %v, err: %v", socketId, err) + } + return nil } From 6a15bf1aedfdd79a8508e05752cde86207715881 Mon Sep 17 00:00:00 2001 From: RoyUP9 <87927115+RoyUP9@users.noreply.github.com> Date: Sun, 24 Apr 2022 11:28:50 +0300 Subject: [PATCH 16/17] Fixed OAS showing unresolved services (#1037) --- agent/pkg/oas/oas_generator.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/agent/pkg/oas/oas_generator.go b/agent/pkg/oas/oas_generator.go index 2d39e1722..bfcaca712 100644 --- a/agent/pkg/oas/oas_generator.go +++ b/agent/pkg/oas/oas_generator.go @@ -142,17 +142,18 @@ func (g *defaultOasGenerator) runGenerator() { func (g *defaultOasGenerator) handleEntry(mizuEntry *api.Entry) { if mizuEntry.Protocol.Name == "http" { + dest := mizuEntry.Destination.Name + if dest == "" { + logger.Log.Debugf("OAS: Unresolved entry %d", mizuEntry.Id) + return + } + entry, err := har.NewEntry(mizuEntry.Request, mizuEntry.Response, mizuEntry.StartTime, mizuEntry.ElapsedTime) if err != nil { logger.Log.Warningf("Failed to turn MizuEntry %d into HAR Entry: %s", mizuEntry.Id, err) return } - dest := mizuEntry.Destination.Name - if dest == "" { - dest = mizuEntry.Destination.IP + ":" + mizuEntry.Destination.Port - } - entryWSource := &EntryWithSource{ Entry: *entry, Source: mizuEntry.Source.Name, From 95a37c877ef6a032401386801b7036ea444643ac Mon Sep 17 00:00:00 2001 From: leon-up9 <97597983+leon-up9@users.noreply.github.com> Date: Sun, 24 Apr 2022 11:53:30 +0300 Subject: [PATCH 17/17] fix/ui/Service-map-filtering-is-not-updated-after-refresh_TRA-4497 (#1033) * filter graph when refresh * change to const * listen only for getServicesForFilter Co-authored-by: Leon <> Co-authored-by: Igor Gov --- .../ServiceMapModal/ServiceMapModal.tsx | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/ui-common/src/components/ServiceMapModal/ServiceMapModal.tsx b/ui-common/src/components/ServiceMapModal/ServiceMapModal.tsx index 93729d514..266e1c108 100644 --- a/ui-common/src/components/ServiceMapModal/ServiceMapModal.tsx +++ b/ui-common/src/components/ServiceMapModal/ServiceMapModal.tsx @@ -78,15 +78,8 @@ export const ServiceMapModal: React.FC = ({ isOpen, onClos const serviceMapData: ServiceMapGraph = await getServiceMapDataApi() setServiceMapApiData(serviceMapData) const newGraphData: GraphData = { nodes: [], edges: [] } - - if (serviceMapData.nodes) { - newGraphData.nodes = serviceMapData.nodes.map(mapNodesDatatoGraph) - } - - if (serviceMapData.edges) { - newGraphData.edges = serviceMapData.edges.map(mapEdgesDatatoGraph) - } - + newGraphData.nodes = serviceMapData.nodes.map(mapNodesDatatoGraph) + newGraphData.edges = serviceMapData.edges.map(mapEdgesDatatoGraph) setGraphData(newGraphData) } catch (ex) { toast.error("An error occurred while loading Mizu Service Map, see console for mode details", { containerId: TOAST_CONTAINER_ID }); @@ -145,9 +138,11 @@ export const ServiceMapModal: React.FC = ({ isOpen, onClos useEffect(() => { - if (checkedServices.length > 0) return // only after refresh - filterServiceMap(checkedProtocols, getServicesForFilter.map(x => x.key).filter(serviceName => !Utils.isIpAddress(serviceName))) - }, [getServicesForFilter, checkedServices]) + if (checkedServices.length > 0) + filterServiceMap() + else + filterServiceMap(checkedProtocols, getServicesForFilter.map(x => x.key).filter(serviceName => !Utils.isIpAddress(serviceName))) + }, [getServicesForFilter]) useEffect(() => { getServiceMapData()