From 25bb571f148fd5a985f35b1c3ff72cfc97e1afc0 Mon Sep 17 00:00:00 2001 From: Jason Berry <1776037+skyblaster@users.noreply.github.com> Date: Sat, 14 Dec 2024 14:32:08 -0800 Subject: [PATCH] Add JSON formatting check to the add-ign function --- cmd/kvpctl/main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/kvpctl/main.go b/cmd/kvpctl/main.go index 190b48d..1d4ee10 100644 --- a/cmd/kvpctl/main.go +++ b/cmd/kvpctl/main.go @@ -4,6 +4,7 @@ package main import ( "bytes" + "encoding/json" "errors" "fmt" "os" @@ -225,6 +226,10 @@ func addIgnFile(vm *hypervctl.VirtualMachine, inputFilename string) error { if err != nil { return err } + var js json.RawMessage + if err := json.Unmarshal(b, &js); err != nil { + return fmt.Errorf("invalid JSON format: %v", err) + } parts, err := ginsu.Dice(bytes.NewReader(b)) if err != nil { return err