diff --git a/golang/vaas/examples/vaasctl/vaas.go b/golang/vaas/examples/vaasctl/vaas.go index 1054c324..bd2980ae 100644 --- a/golang/vaas/examples/vaasctl/vaas.go +++ b/golang/vaas/examples/vaasctl/vaas.go @@ -35,14 +35,22 @@ func main() { if !exists { log.Fatal("no Client Secret set") } + tokenEndpoint, exists := os.LookupEnv("TOKEN_URL") + if !exists { + tokenEndpoint = "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token" + } + vaasURL, exists := os.LookupEnv("VAAS_URL") + if !exists { + vaasURL = "wss://gateway.production.vaas.gdatasecurity.de" + } - auth := authenticator.NewWithDefaultTokenEndpoint(clientID, clientSecret) + auth := authenticator.New(clientID, clientSecret, tokenEndpoint) - vaasClient := vaas.NewWithDefaultEndpoint(options.VaasOptions{ + vaasClient := vaas.New(options.VaasOptions{ UseHashLookup: true, UseCache: false, EnableLogs: false, - }) + }, vaasURL) ctx, webSocketCancel := context.WithCancel(context.Background()) termChan, err := vaasClient.Connect(ctx, auth) @@ -98,7 +106,7 @@ func checkFile(ctx context.Context, fileList []string, vaasClient vaas.Vaas) err } for _, result := range results { - fmt.Println(result.Sha256, result.Verdict) + fmt.Println(result.Sha256, result.Verdict, result.Detection) } } return nil diff --git a/golang/vaas/pkg/vaas/vaas.go b/golang/vaas/pkg/vaas/vaas.go index 11650670..9c9f2bd2 100644 --- a/golang/vaas/pkg/vaas/vaas.go +++ b/golang/vaas/pkg/vaas/vaas.go @@ -653,8 +653,9 @@ func (v *vaas) listenWebSocket(ctx context.Context) chan error { } func (v *vaas) readWebSocket(termChan chan<- error) { - var verdictResponse msg.VerdictResponse for { + var verdictResponse msg.VerdictResponse + err := v.websocketConnection.ReadJSON(&verdictResponse) if err == nil { v.openRequestsMutex.Lock() diff --git a/golang/vaas/v2/examples/vaasctl/vaas.go b/golang/vaas/v2/examples/vaasctl/vaas.go index fe046b7e..a4969b7f 100644 --- a/golang/vaas/v2/examples/vaasctl/vaas.go +++ b/golang/vaas/v2/examples/vaasctl/vaas.go @@ -34,14 +34,22 @@ func main() { if !exists { log.Fatal("no Client Secret set") } + tokenEndpoint, exists := os.LookupEnv("TOKEN_URL") + if !exists { + tokenEndpoint = "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token" + } + vaasURL, exists := os.LookupEnv("VAAS_URL") + if !exists { + vaasURL = "wss://gateway.production.vaas.gdatasecurity.de" + } - auth := authenticator.NewWithDefaultTokenEndpoint(clientID, clientSecret) + auth := authenticator.New(clientID, clientSecret, tokenEndpoint) - vaasClient := vaas.NewWithDefaultEndpoint(options.VaasOptions{ + vaasClient := vaas.New(options.VaasOptions{ UseHashLookup: true, UseCache: false, EnableLogs: false, - }) + }, vaasURL) connectCtx, webSocketCancel := context.WithTimeout(context.Background(), 5*time.Second) defer webSocketCancel() @@ -100,7 +108,7 @@ func checkFile(ctx context.Context, fileList []string, vaasClient vaas.Vaas) err } for _, result := range results { - fmt.Println(result.Sha256, result.Verdict) + fmt.Println(result.Sha256, result.Verdict, result.Detection) } } return nil diff --git a/golang/vaas/v2/pkg/vaas/vaas.go b/golang/vaas/v2/pkg/vaas/vaas.go index 35601848..30cacf56 100644 --- a/golang/vaas/v2/pkg/vaas/vaas.go +++ b/golang/vaas/v2/pkg/vaas/vaas.go @@ -651,8 +651,9 @@ func (v *vaas) listenWebSocket() <-chan error { defer close(errorChan) defer close(v.termChan) - var verdictResponse msg.VerdictResponse for { + var verdictResponse msg.VerdictResponse + err := v.websocketConnection.ReadJSON(&verdictResponse) if err == nil { v.openRequestsMutex.Lock()