mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-08-15 07:05:27 +00:00
Upgrade Basenine to 0.3.0
, do a refactor to enable redact
helper and update the cheatsheet (#614)
* Upgrade Basenine version from `0.2.26` to `0.3.0` * Remove `Summarize` method from `Dissector` interface and refactor the data structures in `tap/api/api.go` * Rename `MizuEntry` to `Entry` and `BaseEntryDetails` to `BaseEntry` * Populate `ContractStatus` field as well * Update the cheatsheet * Upgrade the Basenine version in the helm chart as well * Remove a forgoten `console.log` call
This commit is contained in:
parent
1ba444dba1
commit
80e881fee2
@ -17,7 +17,7 @@ require (
|
|||||||
github.com/orcaman/concurrent-map v0.0.0-20210106121528-16402b402231
|
github.com/orcaman/concurrent-map v0.0.0-20210106121528-16402b402231
|
||||||
github.com/ory/kratos-client-go v0.8.2-alpha.1
|
github.com/ory/kratos-client-go v0.8.2-alpha.1
|
||||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||||
github.com/up9inc/basenine/client/go v0.0.0-20220107003657-7c0578359920
|
github.com/up9inc/basenine/client/go v0.0.0-20220110083745-04fbc6c2068d
|
||||||
github.com/up9inc/mizu/shared v0.0.0
|
github.com/up9inc/mizu/shared v0.0.0
|
||||||
github.com/up9inc/mizu/tap v0.0.0
|
github.com/up9inc/mizu/tap v0.0.0
|
||||||
github.com/up9inc/mizu/tap/api v0.0.0
|
github.com/up9inc/mizu/tap/api v0.0.0
|
||||||
|
@ -472,8 +472,8 @@ github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
|
|||||||
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
||||||
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
|
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
|
||||||
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
|
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
|
||||||
github.com/up9inc/basenine/client/go v0.0.0-20220107003657-7c0578359920 h1:QQpgRleNNpxxAG/rKmk4dwJh0jHyRaQz4QOVlPmqv1c=
|
github.com/up9inc/basenine/client/go v0.0.0-20220110083745-04fbc6c2068d h1:WTz53dcfqCIWZpZLQoHbIcNc21s0ZHEZH7EqMPp99qQ=
|
||||||
github.com/up9inc/basenine/client/go v0.0.0-20220107003657-7c0578359920/go.mod h1:SvJGPoa/6erhUQV7kvHBwM/0x5LyO6XaG2lUaCaKiUI=
|
github.com/up9inc/basenine/client/go v0.0.0-20220110083745-04fbc6c2068d/go.mod h1:SvJGPoa/6erhUQV7kvHBwM/0x5LyO6XaG2lUaCaKiUI=
|
||||||
github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw=
|
github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw=
|
||||||
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f h1:p4VB7kIXpOQvVn1ZaTIVp+3vuYAXFe3OJEvjbUYJLaA=
|
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f h1:p4VB7kIXpOQvVn1ZaTIVp+3vuYAXFe3OJEvjbUYJLaA=
|
||||||
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
|
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
|
||||||
|
@ -119,15 +119,12 @@ func startReadingChannel(outputItems <-chan *tapApi.OutputChannelItem, extension
|
|||||||
extension := extensionsMap[item.Protocol.Name]
|
extension := extensionsMap[item.Protocol.Name]
|
||||||
resolvedSource, resolvedDestionation := resolveIP(item.ConnectionInfo)
|
resolvedSource, resolvedDestionation := resolveIP(item.ConnectionInfo)
|
||||||
mizuEntry := extension.Dissector.Analyze(item, resolvedSource, resolvedDestionation)
|
mizuEntry := extension.Dissector.Analyze(item, resolvedSource, resolvedDestionation)
|
||||||
baseEntry := extension.Dissector.Summarize(mizuEntry)
|
|
||||||
mizuEntry.Base = baseEntry
|
|
||||||
if extension.Protocol.Name == "http" {
|
if extension.Protocol.Name == "http" {
|
||||||
if !disableOASValidation {
|
if !disableOASValidation {
|
||||||
var httpPair tapApi.HTTPRequestResponsePair
|
var httpPair tapApi.HTTPRequestResponsePair
|
||||||
json.Unmarshal([]byte(mizuEntry.HTTPPair), &httpPair)
|
json.Unmarshal([]byte(mizuEntry.HTTPPair), &httpPair)
|
||||||
|
|
||||||
contract := handleOAS(ctx, doc, router, httpPair.Request.Payload.RawRequest, httpPair.Response.Payload.RawResponse, contractContent)
|
contract := handleOAS(ctx, doc, router, httpPair.Request.Payload.RawRequest, httpPair.Response.Payload.RawResponse, contractContent)
|
||||||
baseEntry.ContractStatus = contract.Status
|
|
||||||
mizuEntry.ContractStatus = contract.Status
|
mizuEntry.ContractStatus = contract.Status
|
||||||
mizuEntry.ContractRequestReason = contract.RequestReason
|
mizuEntry.ContractRequestReason = contract.RequestReason
|
||||||
mizuEntry.ContractResponseReason = contract.ResponseReason
|
mizuEntry.ContractResponseReason = contract.ResponseReason
|
||||||
@ -137,7 +134,7 @@ func startReadingChannel(outputItems <-chan *tapApi.OutputChannelItem, extension
|
|||||||
harEntry, err := utils.NewEntry(mizuEntry.Request, mizuEntry.Response, mizuEntry.StartTime, mizuEntry.ElapsedTime)
|
harEntry, err := utils.NewEntry(mizuEntry.Request, mizuEntry.Response, mizuEntry.StartTime, mizuEntry.ElapsedTime)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
rules, _, _ := models.RunValidationRulesState(*harEntry, mizuEntry.Destination.Name)
|
rules, _, _ := models.RunValidationRulesState(*harEntry, mizuEntry.Destination.Name)
|
||||||
baseEntry.Rules = rules
|
mizuEntry.Rules = rules
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ import (
|
|||||||
"github.com/up9inc/mizu/shared"
|
"github.com/up9inc/mizu/shared"
|
||||||
"github.com/up9inc/mizu/shared/debounce"
|
"github.com/up9inc/mizu/shared/debounce"
|
||||||
"github.com/up9inc/mizu/shared/logger"
|
"github.com/up9inc/mizu/shared/logger"
|
||||||
|
tapApi "github.com/up9inc/mizu/tap/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
type EventHandlers interface {
|
type EventHandlers interface {
|
||||||
@ -131,18 +132,10 @@ func websocketHandler(w http.ResponseWriter, r *http.Request, eventHandlers Even
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var dataMap map[string]interface{}
|
var entry *tapApi.Entry
|
||||||
err = json.Unmarshal(bytes, &dataMap)
|
err = json.Unmarshal(bytes, &entry)
|
||||||
|
|
||||||
var base map[string]interface{}
|
base := tapApi.Summarize(entry)
|
||||||
switch dataMap["base"].(type) {
|
|
||||||
case map[string]interface{}:
|
|
||||||
base = dataMap["base"].(map[string]interface{})
|
|
||||||
base["id"] = uint(dataMap["id"].(float64))
|
|
||||||
default:
|
|
||||||
logger.Log.Debugf("Base field has an unrecognized type: %+v", dataMap)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
baseEntryBytes, _ := models.CreateBaseEntryWebSocketMessage(base)
|
baseEntryBytes, _ := models.CreateBaseEntryWebSocketMessage(base)
|
||||||
SendToSocket(socketId, baseEntryBytes)
|
SendToSocket(socketId, baseEntryBytes)
|
||||||
|
@ -64,8 +64,8 @@ func GetEntries(c *gin.Context) {
|
|||||||
var dataSlice []interface{}
|
var dataSlice []interface{}
|
||||||
|
|
||||||
for _, row := range data {
|
for _, row := range data {
|
||||||
var dataMap map[string]interface{}
|
var entry *tapApi.Entry
|
||||||
err = json.Unmarshal(row, &dataMap)
|
err = json.Unmarshal(row, &entry)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusBadRequest, gin.H{
|
||||||
"error": true,
|
"error": true,
|
||||||
@ -76,8 +76,7 @@ func GetEntries(c *gin.Context) {
|
|||||||
return // exit
|
return // exit
|
||||||
}
|
}
|
||||||
|
|
||||||
base := dataMap["base"].(map[string]interface{})
|
base := tapApi.Summarize(entry)
|
||||||
base["id"] = uint(dataMap["id"].(float64))
|
|
||||||
|
|
||||||
dataSlice = append(dataSlice, base)
|
dataSlice = append(dataSlice, base)
|
||||||
}
|
}
|
||||||
@ -95,9 +94,19 @@ func GetEntries(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetEntry(c *gin.Context) {
|
func GetEntry(c *gin.Context) {
|
||||||
|
singleEntryRequest := &models.SingleEntryRequest{}
|
||||||
|
|
||||||
|
if err := c.BindQuery(singleEntryRequest); err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, err)
|
||||||
|
}
|
||||||
|
validationError := validation.Validate(singleEntryRequest)
|
||||||
|
if validationError != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, validationError)
|
||||||
|
}
|
||||||
|
|
||||||
id, _ := strconv.Atoi(c.Param("id"))
|
id, _ := strconv.Atoi(c.Param("id"))
|
||||||
var entry tapApi.MizuEntry
|
var entry *tapApi.Entry
|
||||||
bytes, err := basenine.Single(shared.BasenineHost, shared.BaseninePort, id)
|
bytes, err := basenine.Single(shared.BasenineHost, shared.BaseninePort, id, singleEntryRequest.Query)
|
||||||
if Error(c, err) {
|
if Error(c, err) {
|
||||||
return // exit
|
return // exit
|
||||||
}
|
}
|
||||||
@ -125,7 +134,7 @@ func GetEntry(c *gin.Context) {
|
|||||||
json.Unmarshal(inrec, &rules)
|
json.Unmarshal(inrec, &rules)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSON(http.StatusOK, tapApi.MizuEntryWrapper{
|
c.JSON(http.StatusOK, tapApi.EntryWrapper{
|
||||||
Protocol: entry.Protocol,
|
Protocol: entry.Protocol,
|
||||||
Representation: string(representation),
|
Representation: string(representation),
|
||||||
BodySize: bodySize,
|
BodySize: bodySize,
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
"github.com/up9inc/mizu/tap"
|
"github.com/up9inc/mizu/tap"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetEntry(r *tapApi.MizuEntry, v tapApi.DataUnmarshaler) error {
|
func GetEntry(r *tapApi.Entry, v tapApi.DataUnmarshaler) error {
|
||||||
return v.UnmarshalData(r)
|
return v.UnmarshalData(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,6 +28,10 @@ type EntriesRequest struct {
|
|||||||
TimeoutMs int `form:"timeoutMs" validate:"min=1"`
|
TimeoutMs int `form:"timeoutMs" validate:"min=1"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SingleEntryRequest struct {
|
||||||
|
Query string `form:"query"`
|
||||||
|
}
|
||||||
|
|
||||||
type EntriesResponse struct {
|
type EntriesResponse struct {
|
||||||
Data []interface{} `json:"data"`
|
Data []interface{} `json:"data"`
|
||||||
Meta *basenine.Metadata `json:"meta"`
|
Meta *basenine.Metadata `json:"meta"`
|
||||||
@ -35,7 +39,7 @@ type EntriesResponse struct {
|
|||||||
|
|
||||||
type WebSocketEntryMessage struct {
|
type WebSocketEntryMessage struct {
|
||||||
*shared.WebSocketMessageMetadata
|
*shared.WebSocketMessageMetadata
|
||||||
Data map[string]interface{} `json:"data,omitempty"`
|
Data *tapApi.BaseEntry `json:"data,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type WebSocketTappedEntryMessage struct {
|
type WebSocketTappedEntryMessage struct {
|
||||||
@ -74,7 +78,7 @@ type WebSocketStartTimeMessage struct {
|
|||||||
Data int64 `json:"data"`
|
Data int64 `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateBaseEntryWebSocketMessage(base map[string]interface{}) ([]byte, error) {
|
func CreateBaseEntryWebSocketMessage(base *tapApi.BaseEntry) ([]byte, error) {
|
||||||
message := &WebSocketEntryMessage{
|
message := &WebSocketEntryMessage{
|
||||||
WebSocketMessageMetadata: &shared.WebSocketMessageMetadata{
|
WebSocketMessageMetadata: &shared.WebSocketMessageMetadata{
|
||||||
MessageType: shared.WebSocketMessageTypeEntry,
|
MessageType: shared.WebSocketMessageTypeEntry,
|
||||||
|
@ -243,7 +243,7 @@ func syncEntriesImpl(token string, model string, envPrefix string, uploadInterva
|
|||||||
var dataMap map[string]interface{}
|
var dataMap map[string]interface{}
|
||||||
err = json.Unmarshal(dataBytes, &dataMap)
|
err = json.Unmarshal(dataBytes, &dataMap)
|
||||||
|
|
||||||
var entry tapApi.MizuEntry
|
var entry tapApi.Entry
|
||||||
if err := json.Unmarshal([]byte(dataBytes), &entry); err != nil {
|
if err := json.Unmarshal([]byte(dataBytes), &entry); err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ container:
|
|||||||
port: 9099
|
port: 9099
|
||||||
image:
|
image:
|
||||||
repository: "709825985650.dkr.ecr.us-east-1.amazonaws.com/up9/basenine"
|
repository: "709825985650.dkr.ecr.us-east-1.amazonaws.com/up9/basenine"
|
||||||
tag: "v0.2.26"
|
tag: "v0.3.0"
|
||||||
kratos:
|
kratos:
|
||||||
name: "kratos"
|
name: "kratos"
|
||||||
port: 4433
|
port: 4433
|
||||||
|
@ -17,5 +17,5 @@ const (
|
|||||||
BasenineHost = "127.0.0.1"
|
BasenineHost = "127.0.0.1"
|
||||||
BaseninePort = "9099"
|
BaseninePort = "9099"
|
||||||
BasenineImageRepo = "ghcr.io/up9inc/basenine"
|
BasenineImageRepo = "ghcr.io/up9inc/basenine"
|
||||||
BasenineImageTag = "v0.2.26"
|
BasenineImageTag = "v0.3.0"
|
||||||
)
|
)
|
||||||
|
@ -81,7 +81,7 @@ type OutputChannelItem struct {
|
|||||||
Timestamp int64
|
Timestamp int64
|
||||||
ConnectionInfo *ConnectionInfo
|
ConnectionInfo *ConnectionInfo
|
||||||
Pair *RequestResponsePair
|
Pair *RequestResponsePair
|
||||||
Summary *BaseEntryDetails
|
Summary *BaseEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
type SuperTimer struct {
|
type SuperTimer struct {
|
||||||
@ -97,8 +97,7 @@ type Dissector interface {
|
|||||||
Register(*Extension)
|
Register(*Extension)
|
||||||
Ping()
|
Ping()
|
||||||
Dissect(b *bufio.Reader, isClient bool, tcpID *TcpID, counterPair *CounterPair, superTimer *SuperTimer, superIdentifier *SuperIdentifier, emitter Emitter, options *TrafficFilteringOptions) error
|
Dissect(b *bufio.Reader, isClient bool, tcpID *TcpID, counterPair *CounterPair, superTimer *SuperTimer, superIdentifier *SuperIdentifier, emitter Emitter, options *TrafficFilteringOptions) error
|
||||||
Analyze(item *OutputChannelItem, resolvedSource string, resolvedDestination string) *MizuEntry
|
Analyze(item *OutputChannelItem, resolvedSource string, resolvedDestination string) *Entry
|
||||||
Summarize(entry *MizuEntry) *BaseEntryDetails
|
|
||||||
Represent(request map[string]interface{}, response map[string]interface{}) (object []byte, bodySize int64, err error)
|
Represent(request map[string]interface{}, response map[string]interface{}) (object []byte, bodySize int64, err error)
|
||||||
Macros() map[string]string
|
Macros() map[string]string
|
||||||
}
|
}
|
||||||
@ -117,7 +116,7 @@ func (e *Emitting) Emit(item *OutputChannelItem) {
|
|||||||
e.AppStats.IncMatchedPairs()
|
e.AppStats.IncMatchedPairs()
|
||||||
}
|
}
|
||||||
|
|
||||||
type MizuEntry struct {
|
type Entry struct {
|
||||||
Id uint `json:"id"`
|
Id uint `json:"id"`
|
||||||
Protocol Protocol `json:"proto"`
|
Protocol Protocol `json:"proto"`
|
||||||
Source *TCP `json:"src"`
|
Source *TCP `json:"src"`
|
||||||
@ -127,13 +126,13 @@ type MizuEntry struct {
|
|||||||
StartTime time.Time `json:"startTime"`
|
StartTime time.Time `json:"startTime"`
|
||||||
Request map[string]interface{} `json:"request"`
|
Request map[string]interface{} `json:"request"`
|
||||||
Response map[string]interface{} `json:"response"`
|
Response map[string]interface{} `json:"response"`
|
||||||
Base *BaseEntryDetails `json:"base"`
|
|
||||||
Summary string `json:"summary"`
|
Summary string `json:"summary"`
|
||||||
Method string `json:"method"`
|
Method string `json:"method"`
|
||||||
Status int `json:"status"`
|
Status int `json:"status"`
|
||||||
ElapsedTime int64 `json:"elapsedTime"`
|
ElapsedTime int64 `json:"elapsedTime"`
|
||||||
Path string `json:"path"`
|
Path string `json:"path"`
|
||||||
IsOutgoing bool `json:"isOutgoing,omitempty"`
|
IsOutgoing bool `json:"isOutgoing,omitempty"`
|
||||||
|
Rules ApplicableRules `json:"rules,omitempty"`
|
||||||
ContractStatus ContractStatus `json:"contractStatus,omitempty"`
|
ContractStatus ContractStatus `json:"contractStatus,omitempty"`
|
||||||
ContractRequestReason string `json:"contractRequestReason,omitempty"`
|
ContractRequestReason string `json:"contractRequestReason,omitempty"`
|
||||||
ContractResponseReason string `json:"contractResponseReason,omitempty"`
|
ContractResponseReason string `json:"contractResponseReason,omitempty"`
|
||||||
@ -141,22 +140,22 @@ type MizuEntry struct {
|
|||||||
HTTPPair string `json:"httpPair,omitempty"`
|
HTTPPair string `json:"httpPair,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type MizuEntryWrapper struct {
|
type EntryWrapper struct {
|
||||||
Protocol Protocol `json:"protocol"`
|
Protocol Protocol `json:"protocol"`
|
||||||
Representation string `json:"representation"`
|
Representation string `json:"representation"`
|
||||||
BodySize int64 `json:"bodySize"`
|
BodySize int64 `json:"bodySize"`
|
||||||
Data MizuEntry `json:"data"`
|
Data *Entry `json:"data"`
|
||||||
Rules []map[string]interface{} `json:"rulesMatched,omitempty"`
|
Rules []map[string]interface{} `json:"rulesMatched,omitempty"`
|
||||||
IsRulesEnabled bool `json:"isRulesEnabled"`
|
IsRulesEnabled bool `json:"isRulesEnabled"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type BaseEntryDetails struct {
|
type BaseEntry struct {
|
||||||
Id uint `json:"id"`
|
Id uint `json:"id"`
|
||||||
Protocol Protocol `json:"protocol,omitempty"`
|
Protocol Protocol `json:"proto,omitempty"`
|
||||||
Url string `json:"url,omitempty"`
|
Url string `json:"url,omitempty"`
|
||||||
Path string `json:"path,omitempty"`
|
Path string `json:"path,omitempty"`
|
||||||
Summary string `json:"summary,omitempty"`
|
Summary string `json:"summary,omitempty"`
|
||||||
StatusCode int `json:"statusCode"`
|
StatusCode int `json:"status"`
|
||||||
Method string `json:"method,omitempty"`
|
Method string `json:"method,omitempty"`
|
||||||
Timestamp int64 `json:"timestamp,omitempty"`
|
Timestamp int64 `json:"timestamp,omitempty"`
|
||||||
Source *TCP `json:"src"`
|
Source *TCP `json:"src"`
|
||||||
@ -182,11 +181,29 @@ type Contract struct {
|
|||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DataUnmarshaler interface {
|
func Summarize(entry *Entry) *BaseEntry {
|
||||||
UnmarshalData(*MizuEntry) error
|
return &BaseEntry{
|
||||||
|
Id: entry.Id,
|
||||||
|
Protocol: entry.Protocol,
|
||||||
|
Path: entry.Path,
|
||||||
|
Summary: entry.Summary,
|
||||||
|
StatusCode: entry.Status,
|
||||||
|
Method: entry.Method,
|
||||||
|
Timestamp: entry.Timestamp,
|
||||||
|
Source: entry.Source,
|
||||||
|
Destination: entry.Destination,
|
||||||
|
IsOutgoing: entry.IsOutgoing,
|
||||||
|
Latency: entry.ElapsedTime,
|
||||||
|
Rules: entry.Rules,
|
||||||
|
ContractStatus: entry.ContractStatus,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bed *BaseEntryDetails) UnmarshalData(entry *MizuEntry) error {
|
type DataUnmarshaler interface {
|
||||||
|
UnmarshalData(*Entry) error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (bed *BaseEntry) UnmarshalData(entry *Entry) error {
|
||||||
bed.Protocol = entry.Protocol
|
bed.Protocol = entry.Protocol
|
||||||
bed.Id = entry.Id
|
bed.Id = entry.Id
|
||||||
bed.Path = entry.Path
|
bed.Path = entry.Path
|
||||||
|
@ -223,7 +223,7 @@ func (d dissecting) Dissect(b *bufio.Reader, isClient bool, tcpID *api.TcpID, co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d dissecting) Analyze(item *api.OutputChannelItem, resolvedSource string, resolvedDestination string) *api.MizuEntry {
|
func (d dissecting) Analyze(item *api.OutputChannelItem, resolvedSource string, resolvedDestination string) *api.Entry {
|
||||||
request := item.Pair.Request.Payload.(map[string]interface{})
|
request := item.Pair.Request.Payload.(map[string]interface{})
|
||||||
reqDetails := request["details"].(map[string]interface{})
|
reqDetails := request["details"].(map[string]interface{})
|
||||||
|
|
||||||
@ -261,7 +261,7 @@ func (d dissecting) Analyze(item *api.OutputChannelItem, resolvedSource string,
|
|||||||
|
|
||||||
request["url"] = summary
|
request["url"] = summary
|
||||||
reqDetails["method"] = request["method"]
|
reqDetails["method"] = request["method"]
|
||||||
return &api.MizuEntry{
|
return &api.Entry{
|
||||||
Protocol: protocol,
|
Protocol: protocol,
|
||||||
Source: &api.TCP{
|
Source: &api.TCP{
|
||||||
Name: resolvedSource,
|
Name: resolvedSource,
|
||||||
@ -286,25 +286,6 @@ func (d dissecting) Analyze(item *api.OutputChannelItem, resolvedSource string,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d dissecting) Summarize(entry *api.MizuEntry) *api.BaseEntryDetails {
|
|
||||||
return &api.BaseEntryDetails{
|
|
||||||
Id: entry.Id,
|
|
||||||
Protocol: protocol,
|
|
||||||
Summary: entry.Summary,
|
|
||||||
StatusCode: entry.Status,
|
|
||||||
Method: entry.Method,
|
|
||||||
Timestamp: entry.Timestamp,
|
|
||||||
Source: entry.Source,
|
|
||||||
Destination: entry.Destination,
|
|
||||||
IsOutgoing: entry.IsOutgoing,
|
|
||||||
Latency: entry.ElapsedTime,
|
|
||||||
Rules: api.ApplicableRules{
|
|
||||||
Latency: 0,
|
|
||||||
Status: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d dissecting) Represent(request map[string]interface{}, response map[string]interface{}) (object []byte, bodySize int64, err error) {
|
func (d dissecting) Represent(request map[string]interface{}, response map[string]interface{}) (object []byte, bodySize int64, err error) {
|
||||||
bodySize = 0
|
bodySize = 0
|
||||||
representation := make(map[string]interface{}, 0)
|
representation := make(map[string]interface{}, 0)
|
||||||
|
@ -157,7 +157,7 @@ func (d dissecting) Dissect(b *bufio.Reader, isClient bool, tcpID *api.TcpID, co
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d dissecting) Analyze(item *api.OutputChannelItem, resolvedSource string, resolvedDestination string) *api.MizuEntry {
|
func (d dissecting) Analyze(item *api.OutputChannelItem, resolvedSource string, resolvedDestination string) *api.Entry {
|
||||||
var host, authority, path string
|
var host, authority, path string
|
||||||
|
|
||||||
request := item.Pair.Request.Payload.(map[string]interface{})
|
request := item.Pair.Request.Payload.(map[string]interface{})
|
||||||
@ -241,7 +241,7 @@ func (d dissecting) Analyze(item *api.OutputChannelItem, resolvedSource string,
|
|||||||
elapsedTime = 0
|
elapsedTime = 0
|
||||||
}
|
}
|
||||||
httpPair, _ := json.Marshal(item.Pair)
|
httpPair, _ := json.Marshal(item.Pair)
|
||||||
return &api.MizuEntry{
|
return &api.Entry{
|
||||||
Protocol: item.Protocol,
|
Protocol: item.Protocol,
|
||||||
Source: &api.TCP{
|
Source: &api.TCP{
|
||||||
Name: resolvedSource,
|
Name: resolvedSource,
|
||||||
@ -267,26 +267,6 @@ func (d dissecting) Analyze(item *api.OutputChannelItem, resolvedSource string,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d dissecting) Summarize(entry *api.MizuEntry) *api.BaseEntryDetails {
|
|
||||||
return &api.BaseEntryDetails{
|
|
||||||
Id: entry.Id,
|
|
||||||
Protocol: entry.Protocol,
|
|
||||||
Path: entry.Path,
|
|
||||||
Summary: entry.Summary,
|
|
||||||
StatusCode: entry.Status,
|
|
||||||
Method: entry.Method,
|
|
||||||
Timestamp: entry.Timestamp,
|
|
||||||
Source: entry.Source,
|
|
||||||
Destination: entry.Destination,
|
|
||||||
IsOutgoing: entry.IsOutgoing,
|
|
||||||
Latency: entry.ElapsedTime,
|
|
||||||
Rules: api.ApplicableRules{
|
|
||||||
Latency: 0,
|
|
||||||
Status: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func representRequest(request map[string]interface{}) (repRequest []interface{}) {
|
func representRequest(request map[string]interface{}) (repRequest []interface{}) {
|
||||||
details, _ := json.Marshal([]api.TableData{
|
details, _ := json.Marshal([]api.TableData{
|
||||||
{
|
{
|
||||||
|
@ -62,7 +62,7 @@ func (d dissecting) Dissect(b *bufio.Reader, isClient bool, tcpID *api.TcpID, co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d dissecting) Analyze(item *api.OutputChannelItem, resolvedSource string, resolvedDestination string) *api.MizuEntry {
|
func (d dissecting) Analyze(item *api.OutputChannelItem, resolvedSource string, resolvedDestination string) *api.Entry {
|
||||||
request := item.Pair.Request.Payload.(map[string]interface{})
|
request := item.Pair.Request.Payload.(map[string]interface{})
|
||||||
reqDetails := request["details"].(map[string]interface{})
|
reqDetails := request["details"].(map[string]interface{})
|
||||||
apiKey := ApiKey(reqDetails["apiKey"].(float64))
|
apiKey := ApiKey(reqDetails["apiKey"].(float64))
|
||||||
@ -146,7 +146,7 @@ func (d dissecting) Analyze(item *api.OutputChannelItem, resolvedSource string,
|
|||||||
if elapsedTime < 0 {
|
if elapsedTime < 0 {
|
||||||
elapsedTime = 0
|
elapsedTime = 0
|
||||||
}
|
}
|
||||||
return &api.MizuEntry{
|
return &api.Entry{
|
||||||
Protocol: _protocol,
|
Protocol: _protocol,
|
||||||
Source: &api.TCP{
|
Source: &api.TCP{
|
||||||
Name: resolvedSource,
|
Name: resolvedSource,
|
||||||
@ -171,25 +171,6 @@ func (d dissecting) Analyze(item *api.OutputChannelItem, resolvedSource string,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d dissecting) Summarize(entry *api.MizuEntry) *api.BaseEntryDetails {
|
|
||||||
return &api.BaseEntryDetails{
|
|
||||||
Id: entry.Id,
|
|
||||||
Protocol: _protocol,
|
|
||||||
Summary: entry.Summary,
|
|
||||||
StatusCode: entry.Status,
|
|
||||||
Method: entry.Method,
|
|
||||||
Timestamp: entry.Timestamp,
|
|
||||||
Source: entry.Source,
|
|
||||||
Destination: entry.Destination,
|
|
||||||
IsOutgoing: entry.IsOutgoing,
|
|
||||||
Latency: entry.ElapsedTime,
|
|
||||||
Rules: api.ApplicableRules{
|
|
||||||
Latency: 0,
|
|
||||||
Status: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d dissecting) Represent(request map[string]interface{}, response map[string]interface{}) (object []byte, bodySize int64, err error) {
|
func (d dissecting) Represent(request map[string]interface{}, response map[string]interface{}) (object []byte, bodySize int64, err error) {
|
||||||
bodySize = 0
|
bodySize = 0
|
||||||
representation := make(map[string]interface{}, 0)
|
representation := make(map[string]interface{}, 0)
|
||||||
|
@ -59,7 +59,7 @@ func (d dissecting) Dissect(b *bufio.Reader, isClient bool, tcpID *api.TcpID, co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d dissecting) Analyze(item *api.OutputChannelItem, resolvedSource string, resolvedDestination string) *api.MizuEntry {
|
func (d dissecting) Analyze(item *api.OutputChannelItem, resolvedSource string, resolvedDestination string) *api.Entry {
|
||||||
request := item.Pair.Request.Payload.(map[string]interface{})
|
request := item.Pair.Request.Payload.(map[string]interface{})
|
||||||
response := item.Pair.Response.Payload.(map[string]interface{})
|
response := item.Pair.Response.Payload.(map[string]interface{})
|
||||||
reqDetails := request["details"].(map[string]interface{})
|
reqDetails := request["details"].(map[string]interface{})
|
||||||
@ -80,7 +80,7 @@ func (d dissecting) Analyze(item *api.OutputChannelItem, resolvedSource string,
|
|||||||
if elapsedTime < 0 {
|
if elapsedTime < 0 {
|
||||||
elapsedTime = 0
|
elapsedTime = 0
|
||||||
}
|
}
|
||||||
return &api.MizuEntry{
|
return &api.Entry{
|
||||||
Protocol: protocol,
|
Protocol: protocol,
|
||||||
Source: &api.TCP{
|
Source: &api.TCP{
|
||||||
Name: resolvedSource,
|
Name: resolvedSource,
|
||||||
@ -106,25 +106,6 @@ func (d dissecting) Analyze(item *api.OutputChannelItem, resolvedSource string,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d dissecting) Summarize(entry *api.MizuEntry) *api.BaseEntryDetails {
|
|
||||||
return &api.BaseEntryDetails{
|
|
||||||
Id: entry.Id,
|
|
||||||
Protocol: protocol,
|
|
||||||
Summary: entry.Summary,
|
|
||||||
StatusCode: entry.Status,
|
|
||||||
Method: entry.Method,
|
|
||||||
Timestamp: entry.Timestamp,
|
|
||||||
Source: entry.Source,
|
|
||||||
Destination: entry.Destination,
|
|
||||||
IsOutgoing: entry.IsOutgoing,
|
|
||||||
Latency: entry.ElapsedTime,
|
|
||||||
Rules: api.ApplicableRules{
|
|
||||||
Latency: 0,
|
|
||||||
Status: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d dissecting) Represent(request map[string]interface{}, response map[string]interface{}) (object []byte, bodySize int64, err error) {
|
func (d dissecting) Represent(request map[string]interface{}, response map[string]interface{}) (object []byte, bodySize int64, err error) {
|
||||||
bodySize = 0
|
bodySize = 0
|
||||||
representation := make(map[string]interface{}, 0)
|
representation := make(map[string]interface{}, 0)
|
||||||
|
@ -69,9 +69,7 @@ const EntryTitle: React.FC<any> = ({protocol, data, bodySize, elapsedTime, updat
|
|||||||
</div>;
|
</div>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const EntrySummary: React.FC<any> = ({data, updateQuery}) => {
|
const EntrySummary: React.FC<any> = ({entry, updateQuery}) => {
|
||||||
const entry = data.base;
|
|
||||||
|
|
||||||
return <EntryItem
|
return <EntryItem
|
||||||
key={`entry-${entry.id}`}
|
key={`entry-${entry.id}`}
|
||||||
entry={entry}
|
entry={entry}
|
||||||
@ -92,7 +90,7 @@ export const EntryDetailed: React.FC<EntryDetailedProps> = ({entryData, updateQu
|
|||||||
elapsedTime={entryData.data.elapsedTime}
|
elapsedTime={entryData.data.elapsedTime}
|
||||||
updateQuery={updateQuery}
|
updateQuery={updateQuery}
|
||||||
/>
|
/>
|
||||||
{entryData.data && <EntrySummary data={entryData.data} updateQuery={updateQuery}/>}
|
{entryData.data && <EntrySummary entry={entryData.data} updateQuery={updateQuery}/>}
|
||||||
<>
|
<>
|
||||||
{entryData.data && <EntryViewer
|
{entryData.data && <EntryViewer
|
||||||
representation={entryData.representation}
|
representation={entryData.representation}
|
||||||
|
@ -20,11 +20,11 @@ interface TCPInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface Entry {
|
interface Entry {
|
||||||
protocol: ProtocolInterface,
|
proto: ProtocolInterface,
|
||||||
method?: string,
|
method?: string,
|
||||||
summary: string,
|
summary: string,
|
||||||
id: number,
|
id: number,
|
||||||
statusCode?: number;
|
status?: number;
|
||||||
timestamp: Date;
|
timestamp: Date;
|
||||||
src: TCPInterface,
|
src: TCPInterface,
|
||||||
dst: TCPInterface,
|
dst: TCPInterface,
|
||||||
@ -53,7 +53,7 @@ export const EntryItem: React.FC<EntryProps> = ({entry, focusedEntryId, setFocus
|
|||||||
|
|
||||||
const isSelected = focusedEntryId === entry.id.toString();
|
const isSelected = focusedEntryId === entry.id.toString();
|
||||||
|
|
||||||
const classification = getClassification(entry.statusCode)
|
const classification = getClassification(entry.status)
|
||||||
const numberOfRules = entry.rules.numberOfRules
|
const numberOfRules = entry.rules.numberOfRules
|
||||||
let ingoingIcon;
|
let ingoingIcon;
|
||||||
let outgoingIcon;
|
let outgoingIcon;
|
||||||
@ -123,7 +123,7 @@ export const EntryItem: React.FC<EntryProps> = ({entry, focusedEntryId, setFocus
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isStatusCodeEnabled = ((entry.protocol.name === "http" && "statusCode" in entry) || entry.statusCode !== 0);
|
const isStatusCodeEnabled = ((entry.proto.name === "http" && "status" in entry) || entry.status !== 0);
|
||||||
var endpointServiceContainer = "10px";
|
var endpointServiceContainer = "10px";
|
||||||
if (!isStatusCodeEnabled) endpointServiceContainer = "20px";
|
if (!isStatusCodeEnabled) endpointServiceContainer = "20px";
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ export const EntryItem: React.FC<EntryProps> = ({entry, focusedEntryId, setFocus
|
|||||||
setFocusedEntryId(entry.id.toString());
|
setFocusedEntryId(entry.id.toString());
|
||||||
}}
|
}}
|
||||||
style={{
|
style={{
|
||||||
border: isSelected ? `1px ${entry.protocol.backgroundColor} solid` : "1px transparent solid",
|
border: isSelected ? `1px ${entry.proto.backgroundColor} solid` : "1px transparent solid",
|
||||||
position: !headingMode ? "absolute" : "unset",
|
position: !headingMode ? "absolute" : "unset",
|
||||||
top: style['top'],
|
top: style['top'],
|
||||||
marginTop: !headingMode ? style['marginTop'] : "10px",
|
marginTop: !headingMode ? style['marginTop'] : "10px",
|
||||||
@ -145,12 +145,12 @@ export const EntryItem: React.FC<EntryProps> = ({entry, focusedEntryId, setFocus
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{!headingMode ? <Protocol
|
{!headingMode ? <Protocol
|
||||||
protocol={entry.protocol}
|
protocol={entry.proto}
|
||||||
horizontal={false}
|
horizontal={false}
|
||||||
updateQuery={updateQuery}
|
updateQuery={updateQuery}
|
||||||
/> : null}
|
/> : null}
|
||||||
{isStatusCodeEnabled && <div>
|
{isStatusCodeEnabled && <div>
|
||||||
<StatusCode statusCode={entry.statusCode} updateQuery={updateQuery}/>
|
<StatusCode statusCode={entry.status} updateQuery={updateQuery}/>
|
||||||
</div>}
|
</div>}
|
||||||
<div className={styles.endpointServiceContainer} style={{paddingLeft: endpointServiceContainer}}>
|
<div className={styles.endpointServiceContainer} style={{paddingLeft: endpointServiceContainer}}>
|
||||||
<Summary method={entry.method} summary={entry.summary} updateQuery={updateQuery}/>
|
<Summary method={entry.method} summary={entry.summary} updateQuery={updateQuery}/>
|
||||||
@ -171,7 +171,7 @@ export const EntryItem: React.FC<EntryProps> = ({entry, focusedEntryId, setFocus
|
|||||||
{entry.src.name ? entry.src.name : "[Unresolved]"}
|
{entry.src.name ? entry.src.name : "[Unresolved]"}
|
||||||
</span>
|
</span>
|
||||||
</Queryable>
|
</Queryable>
|
||||||
<SwapHorizIcon style={{color: entry.protocol.backgroundColor, marginTop: "-2px"}}></SwapHorizIcon>
|
<SwapHorizIcon style={{color: entry.proto.backgroundColor, marginTop: "-2px"}}></SwapHorizIcon>
|
||||||
<Queryable
|
<Queryable
|
||||||
query={`dst.name == "${entry.dst.name}"`}
|
query={`dst.name == "${entry.dst.name}"`}
|
||||||
updateQuery={updateQuery}
|
updateQuery={updateQuery}
|
||||||
|
@ -265,7 +265,7 @@ export const QueryForm: React.FC<QueryFormProps> = ({query, setQuery, background
|
|||||||
</Typography>
|
</Typography>
|
||||||
<br></br>
|
<br></br>
|
||||||
<Typography id="modal-modal-description">
|
<Typography id="modal-modal-description">
|
||||||
true if the given selector's value starts with the string:
|
true if the given selector's value starts with (similarly <code style={{fontSize: "14px"}}>endsWith</code>, <code style={{fontSize: "14px"}}>contains</code>) the string:
|
||||||
</Typography>
|
</Typography>
|
||||||
<SyntaxHighlighter
|
<SyntaxHighlighter
|
||||||
showLineNumbers={false}
|
showLineNumbers={false}
|
||||||
@ -273,19 +273,19 @@ export const QueryForm: React.FC<QueryFormProps> = ({query, setQuery, background
|
|||||||
language="python"
|
language="python"
|
||||||
/>
|
/>
|
||||||
<Typography id="modal-modal-description">
|
<Typography id="modal-modal-description">
|
||||||
true if the given selector's value ends with the string:
|
a field that contains a JSON encoded string can be filtered based a JSONPath:
|
||||||
</Typography>
|
</Typography>
|
||||||
<SyntaxHighlighter
|
<SyntaxHighlighter
|
||||||
showLineNumbers={false}
|
showLineNumbers={false}
|
||||||
code={`request.path.endsWith("something")`}
|
code={`response.content.text.json().some.path == "somevalue"`}
|
||||||
language="python"
|
language="python"
|
||||||
/>
|
/>
|
||||||
<Typography id="modal-modal-description">
|
<Typography id="modal-modal-description">
|
||||||
true if the given selector's value contains the string:
|
fields that contain sensitive information can be redacted:
|
||||||
</Typography>
|
</Typography>
|
||||||
<SyntaxHighlighter
|
<SyntaxHighlighter
|
||||||
showLineNumbers={false}
|
showLineNumbers={false}
|
||||||
code={`request.path.contains("something")`}
|
code={`and redact("request.path", "src.name")`}
|
||||||
language="python"
|
language="python"
|
||||||
/>
|
/>
|
||||||
<Typography id="modal-modal-description">
|
<Typography id="modal-modal-description">
|
||||||
|
@ -212,7 +212,7 @@ export const TrafficPage: React.FC<TrafficPageProps> = ({onTLSDetected, setAnaly
|
|||||||
setSelectedEntryData(null);
|
setSelectedEntryData(null);
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
const entryData = await api.getEntry(focusedEntryId);
|
const entryData = await api.getEntry(focusedEntryId, query);
|
||||||
setSelectedEntryData(entryData);
|
setSelectedEntryData(entryData);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response?.data?.type) {
|
if (error.response?.data?.type) {
|
||||||
|
@ -32,9 +32,8 @@
|
|||||||
fieldset
|
fieldset
|
||||||
border: none
|
border: none
|
||||||
|
|
||||||
$divider-breakpoint-1: 1474px
|
$divider-breakpoint-1: 1055px
|
||||||
$divider-breakpoint-2: 1366px
|
$divider-breakpoint-2: 1453px
|
||||||
$divider-breakpoint-3: 1980px
|
|
||||||
|
|
||||||
@media (max-width: $divider-breakpoint-1)
|
@media (max-width: $divider-breakpoint-1)
|
||||||
.divider1
|
.divider1
|
||||||
@ -43,7 +42,3 @@ $divider-breakpoint-3: 1980px
|
|||||||
@media (max-width: $divider-breakpoint-2)
|
@media (max-width: $divider-breakpoint-2)
|
||||||
.divider2
|
.divider2
|
||||||
display: none
|
display: none
|
||||||
|
|
||||||
@media (min-width: $divider-breakpoint-1) and (max-width: $divider-breakpoint-3)
|
|
||||||
.divider2
|
|
||||||
display: none
|
|
||||||
|
@ -38,8 +38,8 @@ export default class Api {
|
|||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
getEntry = async (id) => {
|
getEntry = async (id, query) => {
|
||||||
const response = await this.client.get(`/entries/${id}`);
|
const response = await this.client.get(`/entries/${id}?query=${query}`);
|
||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user