1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-13 19:28:55 +00:00

fix: add type conversion error judgment to avoid program panic (#6526)

fix: add type conversion error judgment to avoid program panic

Signed-off-by: wangshuai <wangshuai31@xiaomi.com>
Co-authored-by: wangshuai <wangshuai31@xiaomi.com>
Co-authored-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
Co-authored-by: Chip Zoller <chipzoller@gmail.com>
This commit is contained in:
Lion916 2023-06-14 22:24:45 +08:00 committed by GitHub
parent d3db3bc342
commit ee1e7a7add
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -115,7 +115,10 @@ func getValueAsStringMap(key string, data interface{}) (string, map[string]strin
return "", nil
}
dataMap := data.(map[string]interface{})
dataMap, ok := data.(map[string]interface{})
if !ok {
return "", nil
}
patternKey, val := getPatternValue(key, dataMap)
if val == nil {
@ -123,7 +126,13 @@ func getValueAsStringMap(key string, data interface{}) (string, map[string]strin
}
result := map[string]string{}
for k, v := range val.(map[string]interface{}) {
valMap, ok := val.(map[string]interface{})
if !ok {
return "", nil
}
for k, v := range valMap {
result[k] = v.(string)
}