Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
fix: golang security checks by gosec, G104
Browse files Browse the repository at this point in the history
  • Loading branch information
soulteary committed Apr 4, 2024
1 parent a1f6460 commit e3d5c25
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion internal/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package flags

import (
"flag"
"fmt"
"strings"

"github.com/soulteary/webhook/internal/hook"
Expand Down Expand Up @@ -30,7 +31,10 @@ func ParseEnvs() AppFlags {
hooks := strings.Split(GetEnvStr(ENV_KEY_HOOKS, ""), ",")
var hooksFiles hook.HooksFiles
for _, hook := range hooks {
hooksFiles.Set(hook)
err := hooksFiles.Set(hook)
if err != nil {
fmt.Println("Error parsing hooks from environment variable: ", err)
}
}
if len(hooksFiles) > 0 {
flags.HooksFiles = hooksFiles
Expand Down
10 changes: 8 additions & 2 deletions internal/middleware/dumper.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ func Dumper(w io.Writer) func(http.Handler) http.Handler {
buf.WriteString(sc.Text() + "\n")
}

w.Write(buf.Bytes())
_, err = w.Write(buf.Bytes())
if err != nil {
fmt.Println("Error writing to debug writer before buf reset: ", err)
}
buf.Reset()

// Dump Response
Expand Down Expand Up @@ -79,7 +82,10 @@ func Dumper(w io.Writer) func(http.Handler) http.Handler {
buf.WriteString(sc.Text() + "\n")
}
}
w.Write(buf.Bytes())
_, err = w.Write(buf.Bytes())
if err != nil {
fmt.Println("Error writing to debug writer: ", err)
}
})
}
}
Expand Down

0 comments on commit e3d5c25

Please sign in to comment.