mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-06-24 15:24:17 +00:00
fix null source in mizu fetch
fix null source in mizu fetch
This commit is contained in:
commit
672accba0c
@ -93,13 +93,16 @@ func GetHARs(c *fiber.Ctx) error {
|
|||||||
harEntry.Request.URL = utils.SetHostname(harEntry.Request.URL, entryData.ResolvedDestination)
|
harEntry.Request.URL = utils.SetHostname(harEntry.Request.URL, entryData.ResolvedDestination)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var fileName string
|
||||||
sourceOfEntry := entryData.ResolvedSource
|
sourceOfEntry := entryData.ResolvedSource
|
||||||
if sourceOfEntry != "" {
|
if sourceOfEntry != "" {
|
||||||
// naively assumes the proper service source is http
|
// naively assumes the proper service source is http
|
||||||
sourceOfEntry = fmt.Sprintf("http://%s", sourceOfEntry)
|
sourceOfEntry = fmt.Sprintf("http://%s", sourceOfEntry)
|
||||||
|
//replace / from the file name cause they end up creating a corrupted folder
|
||||||
|
fileName = fmt.Sprintf("%s.har", strings.ReplaceAll(sourceOfEntry, "/", "_"))
|
||||||
|
} else {
|
||||||
|
fileName = "unknown_source.har"
|
||||||
}
|
}
|
||||||
//replace / from the file name cause they end up creating a corrupted folder
|
|
||||||
fileName := fmt.Sprintf("%s.har", strings.ReplaceAll(sourceOfEntry, "/", "_"))
|
|
||||||
if harOfSource, ok := harsObject[fileName]; ok {
|
if harOfSource, ok := harsObject[fileName]; ok {
|
||||||
harOfSource.Log.Entries = append(harOfSource.Log.Entries, &harEntry)
|
harOfSource.Log.Entries = append(harOfSource.Log.Entries, &harEntry)
|
||||||
} else {
|
} else {
|
||||||
@ -119,7 +122,7 @@ func GetHARs(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
// leave undefined when no source is present, otherwise modeler assumes source is empty string ""
|
// leave undefined when no source is present, otherwise modeler assumes source is empty string ""
|
||||||
if sourceOfEntry != "" {
|
if sourceOfEntry != "" {
|
||||||
harsObject[fileName].Log.Creator.Source = sourceOfEntry
|
harsObject[fileName].Log.Creator.Source = &sourceOfEntry
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,5 +105,5 @@ type ExtendedLog struct {
|
|||||||
|
|
||||||
type ExtendedCreator struct {
|
type ExtendedCreator struct {
|
||||||
*har.Creator
|
*har.Creator
|
||||||
Source string `json:"_source"`
|
Source *string `json:"_source"`
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user