Skip to content

Commit

Permalink
Verified JSON support
Browse files Browse the repository at this point in the history
  • Loading branch information
cybik committed Nov 21, 2024
1 parent 0c8ea2c commit 45c8911
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions cmd/sbctl/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@ import (
"github.com/spf13/cobra"
)

type VerifiedFile struct {
FileName string `json:"file_name"`
FileIsSigned bool `json:"is_signed"`
}

var (
ErrInvalidHeader = errors.New("invalid pe header")
verifyCmd = &cobra.Command{
Use: "verify",
Short: "Find and check if files in the ESP are signed or not",
RunE: RunVerify,
}
verifiedFiles = make([]VerifiedFile, 0)
)

func VerifyOneFile(state *config.State, f string) error {
Expand Down Expand Up @@ -52,11 +58,16 @@ func VerifyOneFile(state *config.State, f string) error {
if err != nil {
return err
}

file_entry := &VerifiedFile{FileName: f, FileIsSigned: false}
if ok {
logging.Ok("%s is signed", f)
file_entry.FileIsSigned = true
} else {
logging.NotOk("%s is not signed", f)
}
verifiedFiles = append(verifiedFiles, file_entry)

return nil
}

Expand Down Expand Up @@ -91,6 +102,11 @@ func RunVerify(cmd *cobra.Command, args []string) error {
return err
}
}
if cmdOptions.JsonOutput {
if err := JsonOut(verifiedFiles); err != nil {
return err
}
}
return nil
}
logging.Print("Verifying file database and EFI images in %s...\n", espPath)
Expand Down Expand Up @@ -125,6 +141,11 @@ func RunVerify(cmd *cobra.Command, args []string) error {
}); err != nil {
return err
}
if cmdOptions.JsonOutput {
if err := JsonOut(verifiedFiles); err != nil {
return err
}
}
return nil
}

Expand Down

0 comments on commit 45c8911

Please sign in to comment.