Skip to content

Commit

Permalink
fix: add user input validation
Browse files Browse the repository at this point in the history
Fixes #388

Signed-off-by: Boris Glimcher <Boris.Glimcher@emc.com>
  • Loading branch information
glimchb committed Jun 17, 2024
1 parent b60a837 commit a1c2abf
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions sztp-agent/cmd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Copyright (C) 2022 Red Hat.
package cmd

import (
"fmt"
"os"

"github.com/opiproject/sztp/sztp-agent/pkg/secureagent"
"github.com/spf13/cobra"
)
Expand All @@ -29,6 +32,14 @@ func NewDaemonCommand() *cobra.Command {
Use: "daemon",
Short: "Run the daemon command",
RunE: func(c *cobra.Command, args []string) error {
arrayChecker := [4]string{dhcpLeaseFile, devicePrivateKey, deviceEndEntityCert, bootstrapTrustAnchorCert}
for _, filePath := range arrayChecker {
info, err := os.Stat(filePath)
cobra.CheckErr(err)
if info.IsDir() {
return fmt.Errorf("must not be folder: %q", filePath)
}
}
err := c.Help()
cobra.CheckErr(err)
a := secureagent.NewAgent(bootstrapURL, serialNumber, dhcpLeaseFile, devicePassword, devicePrivateKey, deviceEndEntityCert, bootstrapTrustAnchorCert)
Expand Down

0 comments on commit a1c2abf

Please sign in to comment.