mirror of
https://github.com/kubeshark/kubeshark.git
synced 2026-03-02 17:50:30 +00:00
Compare commits
5 Commits
28.0-dev22
...
28.0-dev27
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cdbacff996 | ||
|
|
cf127c781c | ||
|
|
852a5ff045 | ||
|
|
371e513249 | ||
|
|
97cce32e3f |
@@ -64,6 +64,8 @@ it('right side sanity test', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
serviceMapCheck();
|
||||||
|
|
||||||
checkIllegalFilter('invalid filter');
|
checkIllegalFilter('invalid filter');
|
||||||
|
|
||||||
checkFilter({
|
checkFilter({
|
||||||
@@ -188,7 +190,7 @@ function checkFilter(filterDetails){
|
|||||||
const entriesForDeeperCheck = 5;
|
const entriesForDeeperCheck = 5;
|
||||||
|
|
||||||
it(`checking the filter: ${name}`, function () {
|
it(`checking the filter: ${name}`, function () {
|
||||||
cy.get('#total-entries').then(number => {
|
cy.get('#total-entries').should('not.have.text', '0').then(number => {
|
||||||
const totalEntries = number.text();
|
const totalEntries = number.text();
|
||||||
|
|
||||||
// checks the hover on the last entry (the only one in DOM at the beginning)
|
// checks the hover on the last entry (the only one in DOM at the beginning)
|
||||||
@@ -320,3 +322,42 @@ function checkOnlyLineNumberes(jsonItems, decodedText) {
|
|||||||
cy.get(`${Cypress.env('bodyJsonClass')} >`).should('have.length', 1).and('have.text', decodedText);
|
cy.get(`${Cypress.env('bodyJsonClass')} >`).should('have.length', 1).and('have.text', decodedText);
|
||||||
cy.get(`${Cypress.env('bodyJsonClass')} > >`).should('have.length', jsonItems)
|
cy.get(`${Cypress.env('bodyJsonClass')} > >`).should('have.length', jsonItems)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function serviceMapCheck() {
|
||||||
|
it('service map test', function () {
|
||||||
|
cy.intercept(`${Cypress.env('testUrl')}/servicemap/get`).as('serviceMapRequest');
|
||||||
|
cy.get('#total-entries').should('not.have.text', '0').then(() => {
|
||||||
|
cy.get('#total-entries').invoke('text').then(entriesNum => {
|
||||||
|
cy.get('[alt="service-map"]').click();
|
||||||
|
cy.wait('@serviceMapRequest').then(({response}) => {
|
||||||
|
const body = response.body;
|
||||||
|
const nodeParams = {
|
||||||
|
destination: 'httpbin.mizu-tests',
|
||||||
|
source: '127.0.0.1'
|
||||||
|
};
|
||||||
|
serviceMapAPICheck(body, parseInt(entriesNum), nodeParams);
|
||||||
|
cy.reload();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function serviceMapAPICheck(body, entriesNum, nodeParams) {
|
||||||
|
const {nodes, edges} = body;
|
||||||
|
|
||||||
|
expect(nodes.length).to.equal(Object.keys(nodeParams).length, `Expected nodes count`);
|
||||||
|
|
||||||
|
expect(edges.some(edge => edge.source.name === nodeParams.source)).to.be.true;
|
||||||
|
expect(edges.some(edge => edge.destination.name === nodeParams.destination)).to.be.true;
|
||||||
|
|
||||||
|
let count = 0;
|
||||||
|
edges.forEach(edge => {
|
||||||
|
count += edge.count;
|
||||||
|
if (edge.destination.name === nodeParams.destination) {
|
||||||
|
expect(edge.source.name).to.equal(nodeParams.source);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(count).to.equal(entriesNum);
|
||||||
|
}
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ func runInApiServerMode(namespace string) *gin.Engine {
|
|||||||
if err := config.LoadConfig(); err != nil {
|
if err := config.LoadConfig(); err != nil {
|
||||||
logger.Log.Fatalf("Error loading config file %v", err)
|
logger.Log.Fatalf("Error loading config file %v", err)
|
||||||
}
|
}
|
||||||
app.ConfigureBasenineServer(shared.BasenineHost, shared.BaseninePort)
|
app.ConfigureBasenineServer(shared.BasenineHost, shared.BaseninePort, config.Config.MaxDBSizeBytes, config.Config.LogLevel)
|
||||||
startTime = time.Now().UnixNano() / int64(time.Millisecond)
|
startTime = time.Now().UnixNano() / int64(time.Millisecond)
|
||||||
api.StartResolving(namespace)
|
api.StartResolving(namespace)
|
||||||
|
|
||||||
@@ -216,7 +216,7 @@ func enableExpFeatureIfNeeded() {
|
|||||||
oas.GetOasGeneratorInstance().Start()
|
oas.GetOasGeneratorInstance().Start()
|
||||||
}
|
}
|
||||||
if config.Config.ServiceMap {
|
if config.Config.ServiceMap {
|
||||||
servicemap.GetInstance().SetConfig(config.Config)
|
servicemap.GetInstance().Enable()
|
||||||
}
|
}
|
||||||
elastic.GetInstance().Configure(config.Config.Elastic)
|
elastic.GetInstance().Configure(config.Config.Elastic)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import (
|
|||||||
"github.com/op/go-logging"
|
"github.com/op/go-logging"
|
||||||
basenine "github.com/up9inc/basenine/client/go"
|
basenine "github.com/up9inc/basenine/client/go"
|
||||||
"github.com/up9inc/mizu/agent/pkg/api"
|
"github.com/up9inc/mizu/agent/pkg/api"
|
||||||
"github.com/up9inc/mizu/agent/pkg/config"
|
|
||||||
"github.com/up9inc/mizu/agent/pkg/controllers"
|
"github.com/up9inc/mizu/agent/pkg/controllers"
|
||||||
"github.com/up9inc/mizu/shared/logger"
|
"github.com/up9inc/mizu/shared/logger"
|
||||||
tapApi "github.com/up9inc/mizu/tap/api"
|
tapApi "github.com/up9inc/mizu/tap/api"
|
||||||
@@ -63,20 +62,18 @@ func LoadExtensions() {
|
|||||||
controllers.InitExtensionsMap(ExtensionsMap)
|
controllers.InitExtensionsMap(ExtensionsMap)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConfigureBasenineServer(host string, port string) {
|
func ConfigureBasenineServer(host string, port string, dbSize int64, logLevel logging.Level) {
|
||||||
if !wait.New(
|
if !wait.New(
|
||||||
wait.WithProto("tcp"),
|
wait.WithProto("tcp"),
|
||||||
wait.WithWait(200*time.Millisecond),
|
wait.WithWait(200*time.Millisecond),
|
||||||
wait.WithBreak(50*time.Millisecond),
|
wait.WithBreak(50*time.Millisecond),
|
||||||
wait.WithDeadline(5*time.Second),
|
wait.WithDeadline(5*time.Second),
|
||||||
wait.WithDebug(config.Config.LogLevel == logging.DEBUG),
|
wait.WithDebug(logLevel == logging.DEBUG),
|
||||||
).Do([]string{fmt.Sprintf("%s:%s", host, port)}) {
|
).Do([]string{fmt.Sprintf("%s:%s", host, port)}) {
|
||||||
logger.Log.Panicf("Basenine is not available!")
|
logger.Log.Panicf("Basenine is not available!")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Limit the database size to default 200MB
|
if err := basenine.Limit(host, port, dbSize); err != nil {
|
||||||
err := basenine.Limit(host, port, config.Config.MaxDBSizeBytes)
|
|
||||||
if err != nil {
|
|
||||||
logger.Log.Panicf("Error while limiting database size: %v", err)
|
logger.Log.Panicf("Error while limiting database size: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,8 +81,7 @@ func ConfigureBasenineServer(host string, port string) {
|
|||||||
for _, extension := range Extensions {
|
for _, extension := range Extensions {
|
||||||
macros := extension.Dissector.Macros()
|
macros := extension.Dissector.Macros()
|
||||||
for macro, expanded := range macros {
|
for macro, expanded := range macros {
|
||||||
err = basenine.Macro(host, port, macro, expanded)
|
if err := basenine.Macro(host, port, macro, expanded); err != nil {
|
||||||
if err != nil {
|
|
||||||
logger.Log.Panicf("Error while adding a macro: %v", err)
|
logger.Log.Panicf("Error while adding a macro: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import (
|
|||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
"github.com/up9inc/mizu/shared"
|
|
||||||
tapApi "github.com/up9inc/mizu/tap/api"
|
tapApi "github.com/up9inc/mizu/tap/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -59,9 +58,7 @@ type ServiceMapControllerSuite struct {
|
|||||||
|
|
||||||
func (s *ServiceMapControllerSuite) SetupTest() {
|
func (s *ServiceMapControllerSuite) SetupTest() {
|
||||||
s.c = NewServiceMapController()
|
s.c = NewServiceMapController()
|
||||||
s.c.service.SetConfig(&shared.MizuAgentConfig{
|
s.c.service.Enable()
|
||||||
ServiceMap: true,
|
|
||||||
})
|
|
||||||
s.c.service.NewTCPEntry(TCPEntryA, TCPEntryB, ProtocolHttp)
|
s.c.service.NewTCPEntry(TCPEntryA, TCPEntryB, ProtocolHttp)
|
||||||
|
|
||||||
s.w = httptest.NewRecorder()
|
s.w = httptest.NewRecorder()
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package servicemap
|
|||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/up9inc/mizu/shared"
|
|
||||||
"github.com/up9inc/mizu/shared/logger"
|
"github.com/up9inc/mizu/shared/logger"
|
||||||
tapApi "github.com/up9inc/mizu/tap/api"
|
tapApi "github.com/up9inc/mizu/tap/api"
|
||||||
)
|
)
|
||||||
@@ -26,13 +25,13 @@ func GetInstance() ServiceMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type serviceMap struct {
|
type serviceMap struct {
|
||||||
config *shared.MizuAgentConfig
|
enabled bool
|
||||||
graph *graph
|
graph *graph
|
||||||
entriesProcessed int
|
entriesProcessed int
|
||||||
}
|
}
|
||||||
|
|
||||||
type ServiceMap interface {
|
type ServiceMap interface {
|
||||||
SetConfig(config *shared.MizuAgentConfig)
|
Enable()
|
||||||
IsEnabled() bool
|
IsEnabled() bool
|
||||||
NewTCPEntry(source *tapApi.TCP, destination *tapApi.TCP, protocol *tapApi.Protocol)
|
NewTCPEntry(source *tapApi.TCP, destination *tapApi.TCP, protocol *tapApi.Protocol)
|
||||||
GetStatus() ServiceMapStatus
|
GetStatus() ServiceMapStatus
|
||||||
@@ -46,7 +45,7 @@ type ServiceMap interface {
|
|||||||
|
|
||||||
func newServiceMap() *serviceMap {
|
func newServiceMap() *serviceMap {
|
||||||
return &serviceMap{
|
return &serviceMap{
|
||||||
config: nil,
|
enabled: false,
|
||||||
entriesProcessed: 0,
|
entriesProcessed: 0,
|
||||||
graph: newDirectedGraph(),
|
graph: newDirectedGraph(),
|
||||||
}
|
}
|
||||||
@@ -156,15 +155,12 @@ func (s *serviceMap) addEdge(u, v *entryData, p *tapApi.Protocol) {
|
|||||||
s.entriesProcessed++
|
s.entriesProcessed++
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *serviceMap) SetConfig(config *shared.MizuAgentConfig) {
|
func (s *serviceMap) Enable() {
|
||||||
s.config = config
|
s.enabled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *serviceMap) IsEnabled() bool {
|
func (s *serviceMap) IsEnabled() bool {
|
||||||
if s.config != nil && s.config.ServiceMap {
|
return s.enabled
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *serviceMap) NewTCPEntry(src *tapApi.TCP, dst *tapApi.TCP, p *tapApi.Protocol) {
|
func (s *serviceMap) NewTCPEntry(src *tapApi.TCP, dst *tapApi.TCP, p *tapApi.Protocol) {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
"github.com/up9inc/mizu/shared"
|
|
||||||
tapApi "github.com/up9inc/mizu/tap/api"
|
tapApi "github.com/up9inc/mizu/tap/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -96,9 +95,7 @@ func (s *ServiceMapDisabledSuite) SetupTest() {
|
|||||||
|
|
||||||
func (s *ServiceMapEnabledSuite) SetupTest() {
|
func (s *ServiceMapEnabledSuite) SetupTest() {
|
||||||
s.instance = GetInstance()
|
s.instance = GetInstance()
|
||||||
s.instance.SetConfig(&shared.MizuAgentConfig{
|
s.instance.Enable()
|
||||||
ServiceMap: true,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ServiceMapDisabledSuite) TestServiceMapInstance() {
|
func (s *ServiceMapDisabledSuite) TestServiceMapInstance() {
|
||||||
|
|||||||
@@ -829,7 +829,7 @@ func (provider *Provider) ApplyMizuTapperDaemonSet(ctx context.Context, namespac
|
|||||||
if tls {
|
if tls {
|
||||||
mizuCmd = append(mizuCmd, "--tls")
|
mizuCmd = append(mizuCmd, "--tls")
|
||||||
}
|
}
|
||||||
|
|
||||||
if serviceMesh || tls {
|
if serviceMesh || tls {
|
||||||
mizuCmd = append(mizuCmd, "--procfs", procfsMountPath)
|
mizuCmd = append(mizuCmd, "--procfs", procfsMountPath)
|
||||||
}
|
}
|
||||||
@@ -939,24 +939,6 @@ func (provider *Provider) ApplyMizuTapperDaemonSet(ctx context.Context, namespac
|
|||||||
sysfsVolumeMount := applyconfcore.VolumeMount().WithName(sysfsVolumeName).WithMountPath(sysfsMountPath).WithReadOnly(true)
|
sysfsVolumeMount := applyconfcore.VolumeMount().WithName(sysfsVolumeName).WithMountPath(sysfsMountPath).WithReadOnly(true)
|
||||||
agentContainer.WithVolumeMounts(sysfsVolumeMount)
|
agentContainer.WithVolumeMounts(sysfsVolumeMount)
|
||||||
|
|
||||||
volumeName := ConfigMapName
|
|
||||||
configMapVolume := applyconfcore.VolumeApplyConfiguration{
|
|
||||||
Name: &volumeName,
|
|
||||||
VolumeSourceApplyConfiguration: applyconfcore.VolumeSourceApplyConfiguration{
|
|
||||||
ConfigMap: &applyconfcore.ConfigMapVolumeSourceApplyConfiguration{
|
|
||||||
LocalObjectReferenceApplyConfiguration: applyconfcore.LocalObjectReferenceApplyConfiguration{
|
|
||||||
Name: &volumeName,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
mountPath := shared.ConfigDirPath
|
|
||||||
configMapVolumeMount := applyconfcore.VolumeMountApplyConfiguration{
|
|
||||||
Name: &volumeName,
|
|
||||||
MountPath: &mountPath,
|
|
||||||
}
|
|
||||||
agentContainer.WithVolumeMounts(&configMapVolumeMount)
|
|
||||||
|
|
||||||
podSpec := applyconfcore.PodSpec()
|
podSpec := applyconfcore.PodSpec()
|
||||||
podSpec.WithHostNetwork(true)
|
podSpec.WithHostNetwork(true)
|
||||||
podSpec.WithDNSPolicy(core.DNSClusterFirstWithHostNet)
|
podSpec.WithDNSPolicy(core.DNSClusterFirstWithHostNet)
|
||||||
@@ -967,7 +949,7 @@ func (provider *Provider) ApplyMizuTapperDaemonSet(ctx context.Context, namespac
|
|||||||
podSpec.WithContainers(agentContainer)
|
podSpec.WithContainers(agentContainer)
|
||||||
podSpec.WithAffinity(affinity)
|
podSpec.WithAffinity(affinity)
|
||||||
podSpec.WithTolerations(noExecuteToleration, noScheduleToleration)
|
podSpec.WithTolerations(noExecuteToleration, noScheduleToleration)
|
||||||
podSpec.WithVolumes(&configMapVolume, procfsVolume, sysfsVolume)
|
podSpec.WithVolumes(procfsVolume, sysfsVolume)
|
||||||
|
|
||||||
podTemplate := applyconfcore.PodTemplateSpec()
|
podTemplate := applyconfcore.PodTemplateSpec()
|
||||||
podTemplate.WithLabels(map[string]string{
|
podTemplate.WithLabels(map[string]string{
|
||||||
@@ -981,7 +963,7 @@ func (provider *Provider) ApplyMizuTapperDaemonSet(ctx context.Context, namespac
|
|||||||
labelSelector.WithMatchLabels(map[string]string{"app": tapperPodName})
|
labelSelector.WithMatchLabels(map[string]string{"app": tapperPodName})
|
||||||
|
|
||||||
applyOptions := metav1.ApplyOptions{
|
applyOptions := metav1.ApplyOptions{
|
||||||
Force: true,
|
Force: true,
|
||||||
FieldManager: fieldManagerName,
|
FieldManager: fieldManagerName,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {toast} from "react-toastify";
|
|||||||
import {useRecoilValue} from "recoil";
|
import {useRecoilValue} from "recoil";
|
||||||
import focusedEntryIdAtom from "../recoil/focusedEntryId";
|
import focusedEntryIdAtom from "../recoil/focusedEntryId";
|
||||||
import Api from "../helpers/api";
|
import Api from "../helpers/api";
|
||||||
|
import queryAtom from "../recoil/query";
|
||||||
|
|
||||||
const useStyles = makeStyles(() => ({
|
const useStyles = makeStyles(() => ({
|
||||||
entryTitle: {
|
entryTitle: {
|
||||||
@@ -82,6 +83,7 @@ const api = Api.getInstance();
|
|||||||
export const EntryDetailed = () => {
|
export const EntryDetailed = () => {
|
||||||
|
|
||||||
const focusedEntryId = useRecoilValue(focusedEntryIdAtom);
|
const focusedEntryId = useRecoilValue(focusedEntryIdAtom);
|
||||||
|
const query = useRecoilValue(queryAtom);
|
||||||
const [entryData, setEntryData] = useState(null);
|
const [entryData, setEntryData] = useState(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -89,7 +91,7 @@ export const EntryDetailed = () => {
|
|||||||
setEntryData(null);
|
setEntryData(null);
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
const entryData = await api.getEntry(focusedEntryId);
|
const entryData = await api.getEntry(focusedEntryId, query);
|
||||||
setEntryData(entryData);
|
setEntryData(entryData);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response?.data?.type) {
|
if (error.response?.data?.type) {
|
||||||
|
|||||||
Reference in New Issue
Block a user