Skip to content

Commit

Permalink
Merge branch 'main' into fix-1336
Browse files Browse the repository at this point in the history
  • Loading branch information
AkashKumar7902 committed Jan 22, 2024
2 parents e9a4fc4 + 8e6f0f8 commit 3c27439
Show file tree
Hide file tree
Showing 36 changed files with 1,093 additions and 669 deletions.
5 changes: 4 additions & 1 deletion cmd/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ func (t *Record) GetRecordConfig(path *string, proxyPort *uint32, appCmd *string
}
confRecord, err := readRecordConfig(configFilePath)
if err != nil {
return fmt.Errorf("failed to get the record config from config file due to error: %s", err)
t.logger.Error("failed to get the record config from config file due to error: %s", zap.Error(err))
t.logger.Info("You have probably edited the config file incorrectly. Please follow the guide below.")
fmt.Println(utils.ConfigGuide)
return nil
}
if len(*path) == 0 {
*path = confRecord.Path
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func modifyToSentryLogger(log *zap.Logger, client *sentry.Client) *zap.Logger {
}
}
sentry.ConfigureScope(func(scope *sentry.Scope) {
scope.SetTag("Keploy Version", utils.KeployVersion)
scope.SetTag("Keploy Version", utils.Version)
scope.SetTag("Linux Kernel Version", kernelVersion)
scope.SetTag("Architecture", arch)
scope.SetTag("Installation ID", installationID)
Expand Down
5 changes: 4 additions & 1 deletion cmd/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ func (t *Test) getTestConfig(path *string, proxyPort *uint32, appCmd *string, te
}
confTest, err := readTestConfig(configFilePath)
if err != nil {
return fmt.Errorf("failed to get the test config from config file due to error: %s", err)
t.logger.Error("failed to get the test config from config file due to error: %s", zap.Error(err))
t.logger.Info("You have probably edited the config file incorrectly. Please follow the guide below.")
fmt.Println(utils.ConfigGuide)
return nil
}
if len(*path) == 0 {
*path = confTest.Path
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ require (

require (
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.0 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKoh
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY=
Expand Down
4 changes: 1 addition & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,14 @@ func main() {
if version == "" {
version = "2-dev"
}
utils.KeployVersion = version
utils.Version = version
fmt.Println(logo, " ")
fmt.Printf("version: %v\n\n", version)
//Initialise sentry.
err := sentry.Init(sentry.ClientOptions{
Dsn: dsn,
TracesSampleRate: 1.0,
})
//Set the version
utils.KeployVersion = version
log.Level = 0
if err != nil {
log.Debug("Could not initialise sentry.", err)
Expand Down
Binary file modified pkg/hooks/bpf_bpfel_arm64.o
Binary file not shown.
Binary file modified pkg/hooks/bpf_bpfel_x86.o
Binary file not shown.
10 changes: 6 additions & 4 deletions pkg/hooks/connection/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,24 @@ func NewFactory(inactivityThreshold time.Duration, logger *zap.Logger) *Factory
}
}

func (factory *Factory) HandleReadyConnections(db platform.TestCaseDB, ctx context.Context, filters *models.Filters) {
// ProcessActiveTrackers iterates over all connection the trackers and checks if they are complete. If so, it captures the ingress call and
// deletes the tracker. If the tracker is inactive for a long time, it deletes it.
func (factory *Factory) ProcessActiveTrackers(db platform.TestCaseDB, ctx context.Context, filters *models.Filters) {
factory.mutex.Lock()
defer factory.mutex.Unlock()
var trackersToDelete []structs.ConnID
for connID, tracker := range factory.connections {
ok, requestBuf, responseBuf, reqTimestampTest, resTimestampTest := tracker.IsComplete()
if ok {

if len(requestBuf) == 0 && len(responseBuf) == 0 {
factory.logger.Debug("Empty request or response", zap.Any("RecvBufLength", len(requestBuf)), zap.Any("SentBufLength", len(responseBuf)))
if len(requestBuf) == 0 || len(responseBuf) == 0 {
factory.logger.Warn("failed processing a request due to invalid request or response", zap.Any("Request Size", len(requestBuf)), zap.Any("Response Size", len(responseBuf)))
continue
}

parsedHttpReq, err := pkg.ParseHTTPRequest(requestBuf)
if err != nil {
factory.logger.Error("failed to parse the http request from byte array", zap.Error(err))
factory.logger.Error("failed to parse the http request from byte array", zap.Error(err), zap.Any("requestBuf", requestBuf))
continue
}
parsedHttpRes, err := pkg.ParseHTTPResponse(responseBuf, parsedHttpReq)
Expand Down
Loading

0 comments on commit 3c27439

Please sign in to comment.