1
0
Fork 0
mirror of https://github.com/gocsaf/csaf.git synced 2025-12-22 05:40:11 +01:00

Re-add unknown fields check (#681)
Some checks failed
generate-markdown / auto-update-readme (push) Has been cancelled
Go Test (oldstable) / build (push) Has been cancelled
Go / build (push) Has been cancelled
Go / run_modver (push) Has been cancelled

This commit is contained in:
JanHoefelmeyer 2025-10-01 11:14:09 +02:00 committed by GitHub
parent e3d2a58528
commit 05eae0a9ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -18,6 +18,8 @@ import (
// while not allowing trailing data // while not allowing trailing data
func StrictJSONParse(jsonData io.Reader, target any) error { func StrictJSONParse(jsonData io.Reader, target any) error {
decoder := json.NewDecoder(jsonData) decoder := json.NewDecoder(jsonData)
// Don't allow unknown fields
decoder.DisallowUnknownFields()
if err := decoder.Decode(target); err != nil { if err := decoder.Decode(target); err != nil {
return fmt.Errorf("JSON decoding error: %w", err) return fmt.Errorf("JSON decoding error: %w", err)