Refactor telemetry checks, relax method validation

Reformat telemetry pre-checks in misc/api.func for clearer multi-line condition handling and remove stray whitespace around the curl response logging. Tweak misc/build.func comment line (minor encoding/visual cleanup). In misc/data/service.go remove the strict allowedMethod map and its validation so the 'method' field is treated as optional/flexible; keep sanitization and numeric validations unchanged. These changes improve readability and allow custom method values without breaking behavior.
This commit is contained in:
CanbiZ (MickLesk)
2026-02-09 16:51:51 +01:00
parent 7c3688cd0a
commit ce375b02aa
3 changed files with 16 additions and 12 deletions

View File

@@ -320,9 +320,6 @@ var (
"fedora": true, "rocky": true, "alma": true, "centos": true,
"opensuse": true, "gentoo": true, "openeuler": true,
}
// Allowed values for 'method' field
allowedMethod = map[string]bool{"default": true, "advanced": true, "": true}
)
func sanitizeShort(s string, max int) string {
@@ -371,10 +368,8 @@ func validate(in *TelemetryIn) error {
return errors.New("invalid os_type")
}
// method is optional but if provided must be valid
if !allowedMethod[in.Method] {
return errors.New("invalid method")
}
// method is optional and flexible - just sanitized, no strict validation
// Values like "default", "advanced", "mydefaults-global", "mydefaults-app" are all valid
// Validate numeric ranges
if in.CTType < 0 || in.CTType > 2 {