Skip to content

Commit

Permalink
Fix gosec
Browse files Browse the repository at this point in the history
Signed-off-by: Yuri Shkuro <ys@uber.com>
  • Loading branch information
Yuri Shkuro committed Jul 4, 2020
1 parent 109ec16 commit 4e0118b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmd/anonymizer/app/anonymizer/anonymizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"hash/fnv"
"io/ioutil"
"os"
"path/filepath"
"sync"
"time"

Expand Down Expand Up @@ -70,8 +71,8 @@ func New(mappingFile string, logger *zap.Logger) *Anonymizer {
Operations: make(map[string]string),
},
}
if _, err := os.Stat(mappingFile); err == nil {
dat, err := ioutil.ReadFile(mappingFile)
if _, err := os.Stat(filepath.Clean(mappingFile)); err == nil {
dat, err := ioutil.ReadFile(filepath.Clean(mappingFile))
if err != nil {
logger.Fatal("Cannot load previous mapping", zap.Error(err))
}
Expand All @@ -98,7 +99,7 @@ func (a *Anonymizer) SaveMapping() {
a.logger.Error("Failed to marshal mapping file", zap.Error(err))
return
}
if err := ioutil.WriteFile(a.mappingFile, dat, os.ModePerm); err != nil {
if err := ioutil.WriteFile(filepath.Clean(a.mappingFile), dat, os.ModePerm); err != nil {
a.logger.Error("Failed to write mapping file", zap.Error(err))
return
}
Expand Down

0 comments on commit 4e0118b

Please sign in to comment.