Skip to content

Commit

Permalink
gosec fixes for issues #16 #17
Browse files Browse the repository at this point in the history
  • Loading branch information
phires committed Jun 10, 2024
1 parent f81a546 commit a3ae15d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ require (
github.com/asaskevich/EventBus v0.0.0-20200907212545-49d423059eef
github.com/go-sql-driver/mysql v1.8.1
github.com/gomodule/redigo v1.9.2
github.com/pires/go-proxyproto v0.7.0
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.8.0
golang.org/x/crypto v0.24.0
Expand Down
11 changes: 6 additions & 5 deletions log/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package log

import (
"bufio"
log "github.com/sirupsen/logrus"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
"sync"

log "github.com/sirupsen/logrus"
)

// custom logrus hook
Expand Down Expand Up @@ -90,7 +91,7 @@ func (hook *LogrusHook) setup(dest string) error {
} else if out == OutputStdout {
hook.w = os.Stdout
} else if out == OutputOff {
hook.w = ioutil.Discard
hook.w = io.Discard
} else {
if _, err := os.Stat(dest); err == nil {
// file exists open the file for appending
Expand All @@ -113,7 +114,7 @@ func (hook *LogrusHook) setup(dest string) error {

// openAppend opens the dest file for appending. Default to os.Stderr if it can't open dest
func (hook *LogrusHook) openAppend(dest string) (err error) {
fd, err := os.OpenFile(dest, os.O_APPEND|os.O_WRONLY, 0644)
fd, err := os.OpenFile(filepath.Clean(dest), os.O_APPEND|os.O_WRONLY, 0644)
if err != nil {
log.WithError(err).Error("Could not open log file for appending")
hook.w = os.Stderr
Expand All @@ -127,7 +128,7 @@ func (hook *LogrusHook) openAppend(dest string) (err error) {

// openCreate creates a new dest file for appending. Default to os.Stderr if it can't open dest
func (hook *LogrusHook) openCreate(dest string) (err error) {
fd, err := os.OpenFile(dest, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644)
fd, err := os.OpenFile(filepath.Clean(dest), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644)
if err != nil {
log.WithError(err).Error("Could not create log file")
hook.w = os.Stderr
Expand Down

0 comments on commit a3ae15d

Please sign in to comment.