-
Notifications
You must be signed in to change notification settings - Fork 156
/
validate.go
52 lines (46 loc) · 1.25 KB
/
validate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) 2018 Zededa, Inc.
// SPDX-License-Identifier: Apache-2.0
package zedagent
import (
"fmt"
"unicode/utf8"
zconfig "github.com/lf-edge/eve-api/go/config"
)
func readValidateConfig(validateFile string) (bool, *zconfig.EdgeDevConfig) {
config, _, err := readSavedProtoMessageConfig(zedcloudCtx, "https://",
validateFile)
if err != nil {
fmt.Printf("getconfig: %v\n", err)
return false, nil
}
return true, config
}
// Check various strings to make sure they are valid UTF-8
// Note that byte strings like the Siginfo.Signature will fail this check.
func validateConfigUTF8(config *zconfig.EdgeDevConfig) bool {
valid := true
Apps := config.GetApps()
for _, cfgApp := range Apps {
for i, intfEnt := range cfgApp.Interfaces {
if len(intfEnt.Lispsignature) != 0 {
fmt.Printf("lispSignature for app %s intf %d <%v>\n",
cfgApp.Displayname, i,
intfEnt.Lispsignature)
if utf8.ValidString(intfEnt.Lispsignature) {
fmt.Printf("lispSignature valid\n")
} else {
fmt.Printf("lispSignature is invalid UTF-8\n")
valid = false
}
}
}
}
cfgOsList := config.GetBase()
for _, cfgOs := range cfgOsList {
if cfgOs.GetBaseOSVersion() == "" {
// Empty slot - silently ignore
continue
}
}
return valid
}