Skip to content

Commit bd5f3c2

Browse files
removed unique id logs
1 parent dac29b8 commit bd5f3c2

File tree

4 files changed

+12
-22
lines changed

4 files changed

+12
-22
lines changed

internal/commands/auth.go

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -119,28 +119,26 @@ func NewAuthCommand(authWrapper wrappers.AuthWrapper, telemetryWrapper wrappers.
119119

120120
func validLogin(telemetryWrapper wrappers.TelemetryWrapper) func(cmd *cobra.Command, args []string) error {
121121
return func(cmd *cobra.Command, args []string) error {
122-
defer func() {
123-
logger.PrintIfVerbose("Calling GetUniqueId func")
122+
clientID := viper.GetString(params.AccessKeyIDConfigKey)
123+
clientSecret := viper.GetString(params.AccessKeySecretConfigKey)
124+
apiKey := viper.GetString(params.AstAPIKey)
125+
if (clientID != "" && clientSecret != "") || apiKey != "" {
126+
authWrapper := wrappers.NewAuthHTTPWrapper()
127+
authWrapper.SetPath(viper.GetString(params.ScansPathKey))
128+
err := authWrapper.ValidateLogin()
129+
124130
uniqueID := wrappers.GetUniqueID()
125131
if uniqueID != "" {
126-
logger.PrintIfVerbose("Set unique id: " + uniqueID)
127-
err := telemetryWrapper.SendAIDataToLog(&wrappers.DataForAITelemetry{
132+
telemetryErr := telemetryWrapper.SendAIDataToLog(&wrappers.DataForAITelemetry{
128133
UniqueID: uniqueID,
129134
Type: "authentication",
130135
SubType: "authentication",
131136
})
132-
if err != nil {
133-
logger.PrintIfVerbose("Failed to send telemetry data: " + err.Error())
137+
if telemetryErr != nil {
138+
logger.PrintIfVerbose("Failed to send telemetry data: " + telemetryErr.Error())
134139
}
135140
}
136-
}()
137-
clientID := viper.GetString(params.AccessKeyIDConfigKey)
138-
clientSecret := viper.GetString(params.AccessKeySecretConfigKey)
139-
apiKey := viper.GetString(params.AstAPIKey)
140-
if (clientID != "" && clientSecret != "") || apiKey != "" {
141-
authWrapper := wrappers.NewAuthHTTPWrapper()
142-
authWrapper.SetPath(viper.GetString(params.ScansPathKey))
143-
err := authWrapper.ValidateLogin()
141+
144142
if err != nil {
145143
return errors.Errorf("%s", err)
146144
}

internal/commands/telemetry.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package commands
22

33
import (
44
"github.com/MakeNowJust/heredoc"
5-
"github.com/checkmarx/ast-cli/internal/logger"
65
"github.com/checkmarx/ast-cli/internal/params"
76
"github.com/checkmarx/ast-cli/internal/wrappers"
87
"github.com/pkg/errors"
@@ -60,7 +59,6 @@ func runTelemetryAI(telemetryWrapper wrappers.TelemetryWrapper) func(*cobra.Comm
6059
status, _ := cmd.Flags().GetString("status")
6160
totalCount, _ := cmd.Flags().GetInt("total-count")
6261
uniqueID := wrappers.GetUniqueID()
63-
logger.PrintIfVerbose("unique id: " + uniqueID)
6462
err := telemetryWrapper.SendAIDataToLog(&wrappers.DataForAITelemetry{
6563
AIProvider: aiProvider,
6664
ProblemSeverity: problemSeverity,

internal/wrappers/client.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,11 @@ func setAgentNameAndOrigin(req *http.Request, isAuth bool) {
132132

133133
originStr := viper.GetString(commonParams.OriginKey)
134134
req.Header.Set("Cx-Origin", originStr)
135-
logger.PrintIfVerbose("getting unique id")
136135

137136
if !isAuth {
138137
uniqueID := GetUniqueID()
139138
if uniqueID != "" {
140139
req.Header.Set("UniqueId", uniqueID)
141-
logger.PrintIfVerbose("unique id: " + uniqueID)
142140
}
143141
}
144142
}

internal/wrappers/jwt-helper.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,21 +214,17 @@ func GetUniqueID() string {
214214
}
215215

216216
// Generate new unique id
217-
logger.PrintIfVerbose("Generating new unique id")
218217
currentUser, err := user.Current()
219218
if err != nil {
220219
logger.PrintIfVerbose("Failed to get user: " + err.Error())
221220
return ""
222221
}
223222
username := currentUser.Username
224223
username = strings.TrimSpace(username)
225-
logger.PrintIfVerbose("Username to be used for unique id: " + username)
226224
if strings.Contains(username, "\\") {
227225
username = strings.Split(username, "\\")[1]
228226
}
229227
uniqueID = uuid.New().String() + "_" + username
230-
231-
logger.PrintIfVerbose("Unique id: " + uniqueID)
232228
viper.Set(commonParams.UniqueIDConfigKey, uniqueID)
233229
configFilePath, _ := configuration.GetConfigFilePath()
234230
err = configuration.SafeWriteSingleConfigKeyString(configFilePath, commonParams.UniqueIDConfigKey, uniqueID)

0 commit comments

Comments
 (0)