From bd06926267e3c019503bdd2ac9216066bd4e3733 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Sat, 30 Apr 2022 18:09:34 +0200 Subject: [PATCH] Add security integrity check (#344) --- cmd/security_integrity.go | 42 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 cmd/security_integrity.go diff --git a/cmd/security_integrity.go b/cmd/security_integrity.go new file mode 100644 index 00000000..485859ed --- /dev/null +++ b/cmd/security_integrity.go @@ -0,0 +1,42 @@ +package cmd + +import ( + "fmt" + + helper "github.com/home-assistant/cli/client" + log "github.com/sirupsen/logrus" + "github.com/spf13/cobra" +) + +var securityIntegrityCmd = &cobra.Command{ + Use: "integrity", + Aliases: []string{"int", "trust"}, + Short: "Execute security integrity check", + Long: ` +This command execute a full system integrity check. +This need content trust to be enabled.`, + Example: ` + ha security integrity`, + Run: func(cmd *cobra.Command, args []string) { + log.WithField("args", args).Debug("security") + + section := "security" + command := "integrity" + + ProgressSpinner.Start() + resp, err := helper.GenericJSONPost(section, command, nil) + ProgressSpinner.Stop() + + if err != nil { + fmt.Println(err) + ExitWithError = true + } else { + ExitWithError = !helper.ShowJSONResponse(resp) + } + }, +} + +func init() { + // add cmd to root command + securityCmd.AddCommand(securityIntegrityCmd) +}