Skip to content

Commit 0051eb6

Browse files
interface-conversion-check
1 parent 7106c1f commit 0051eb6

1 file changed

Lines changed: 27 additions & 3 deletions

File tree

internal/wrappers/client.go

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,7 @@ func extractAZPFromToken(astToken string) (string, error) {
986986
}
987987

988988
func GetUniqueID() string {
989+
var uniqueID string
989990
isAllowed := false
990991
accessToken, err := GetAccessToken()
991992
if err != nil {
@@ -1003,8 +1004,31 @@ func GetUniqueID() string {
10031004
logger.PrintIfVerbose("Failed to get JWT claims")
10041005
return ""
10051006
}
1006-
for _, engine := range claims["ast-license"].(map[string]interface{})["LicenseData"].(map[string]interface{})["allowedEngines"].([]interface{}) {
1007-
if strings.EqualFold(engine.(string), "Checkmarx Developer Assist") {
1007+
1008+
astLicense, ok := claims["ast-license"].(map[string]interface{})
1009+
if !ok {
1010+
logger.PrintIfVerbose("Failed to get ast-license from claims")
1011+
return ""
1012+
}
1013+
1014+
licenseData, ok := astLicense["LicenseData"].(map[string]interface{})
1015+
if !ok {
1016+
logger.PrintIfVerbose("Failed to get LicenseData from ast-license")
1017+
return ""
1018+
}
1019+
1020+
allowedEngines, ok := licenseData["allowedEngines"].([]interface{})
1021+
if !ok {
1022+
logger.PrintIfVerbose("Failed to get allowedEngines from LicenseData")
1023+
return ""
1024+
}
1025+
1026+
for _, engine := range allowedEngines {
1027+
engineStr, ok := engine.(string)
1028+
if !ok {
1029+
continue
1030+
}
1031+
if strings.EqualFold(engineStr, "Checkmarx Developer Assist") {
10081032
isAllowed = true
10091033
break
10101034
}
@@ -1014,7 +1038,7 @@ func GetUniqueID() string {
10141038
logger.PrintIfVerbose("User does not not have permission to standalone dev asists feature")
10151039
return ""
10161040
}
1017-
uniqueID := viper.GetString(commonParams.UniqueIDConfigKey)
1041+
uniqueID = viper.GetString(commonParams.UniqueIDConfigKey)
10181042
if uniqueID != "" {
10191043
return uniqueID
10201044
}

0 commit comments

Comments
 (0)