From fea5f78aa2c67a04ac019bee217b461326ca6fcc Mon Sep 17 00:00:00 2001 From: Surya Date: Fri, 19 Jul 2024 09:58:04 +0000 Subject: [PATCH] gosec fixes --- gonvme_tcp_fc.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gonvme_tcp_fc.go b/gonvme_tcp_fc.go index c8a02fd..0278e46 100644 --- a/gonvme_tcp_fc.go +++ b/gonvme_tcp_fc.go @@ -100,14 +100,16 @@ func (nvme *NVMe) getFCHostInfo() ([]FCHBAInfo, error) { for _, m := range match { var FCHostInfo FCHBAInfo - data, err := os.ReadFile(path.Join(m, "port_name")) + portNamePath := path.Join(m, "port_name") + data, err := os.ReadFile(filepath.Clean(portNamePath)) if err != nil { log.Errorf("match: %s failed to read port_name file: %s", match, err.Error()) continue } FCHostInfo.PortName = strings.TrimSpace(string(data)) - data, err = os.ReadFile(path.Join(m, "node_name")) + nodeNamePath := path.Join(m, "node_name") + data, err = os.ReadFile(filepath.Clean(nodeNamePath)) if err != nil { log.Errorf("match: %s failed to read node_name file: %s", match, err.Error()) continue @@ -426,7 +428,7 @@ func (nvme *NVMe) getInitiators(filename string) ([]string, error) { } // get the contents of the initiator config file - out, err := os.ReadFile(init) + out, err := os.ReadFile(filepath.Clean(init)) if err != nil { log.Errorf("Error gathering initiator names: %v", err) }