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

Commit

Permalink
fix semgrep linter
Browse files Browse the repository at this point in the history
  • Loading branch information
dwisiswant0 committed Jun 29, 2022
1 parent f8e635c commit ef9bb80
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion internal/alert/alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func New(options *common.Options, version string, log map[string]string) {
config := options.Configs
if config.Alert.Active {
provider := utils.Title(config.Alert.Provider)
field := reflect.ValueOf(&config.Notifications).Elem().FieldByName(provider)
field := reflect.ValueOf(&config.Notifications).Elem().FieldByName(provider) // nosemgrep

if matchers.IsWebhook(provider, field.FieldByName("Webhook").String()) {
token = field.FieldByName("Webhook").String()
Expand Down
11 changes: 5 additions & 6 deletions internal/event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ package event
import (
"encoding/json"
"fmt"
"html/template"
"mime"
"net/http"
"path"
"path/filepath"
"strconv"
"text/template"

"github.com/goji/httpauth"
"github.com/projectdiscovery/gologger"
Expand Down Expand Up @@ -53,7 +52,7 @@ func Run(options *common.Options, version string) *server {
}

go func() {
err := http.ListenAndServe(fmt.Sprint(h, ":", strconv.Itoa(p)), mux)
err := http.ListenAndServe(fmt.Sprint(h, ":", strconv.Itoa(p)), mux) // nosemgrep
if err != nil {
errors.Exit(err.Error())
}
Expand Down Expand Up @@ -84,10 +83,10 @@ func (s *server) static(w http.ResponseWriter, r *http.Request) {
return
}

t, e := template.ParseFS(res, path.Join("./www", p))
t, e := template.ParseFS(res, filepath.Join("www", p))
if e != nil {
w.WriteHeader(http.StatusNotFound)
_, _ = w.Write([]byte(e.Error()))
_, _ = w.Write([]byte(e.Error())) // nosemgrep
return
}

Expand All @@ -105,7 +104,7 @@ func (s *server) static(w http.ResponseWriter, r *http.Request) {
}

if e := t.Execute(w, data); e != nil {
_, _ = w.Write([]byte(e.Error()))
_, _ = w.Write([]byte(e.Error())) // nosemgrep
w.WriteHeader(http.StatusInternalServerError)
return
}
Expand Down
2 changes: 1 addition & 1 deletion internal/runner/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func startPrometheus(options *common.Options) {
go func() {
http.Handle(e, promhttp.Handler())

err := http.ListenAndServe(s, nil) // nosemgrep: go.lang.security.audit.net.use-tls.use-tls
err := http.ListenAndServe(s, nil) // nosemgrep
if err != nil {
errors.Exit(err.Error())
}
Expand Down
4 changes: 2 additions & 2 deletions internal/runner/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func validate(options *common.Options) {
}

f, errOutput := os.OpenFile(config.Logs.File.Path,
os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600)
if errOutput != nil {
errors.Exit(errOutput.Error())
}
Expand Down Expand Up @@ -185,7 +185,7 @@ func notification(options *common.Options) {

if config.Alert.Active {
provider := utils.Title(config.Alert.Provider)
field := reflect.ValueOf(&config.Notifications).Elem().FieldByName(provider)
field := reflect.ValueOf(&config.Notifications).Elem().FieldByName(provider) // nosemgrep

switch provider {
case "Slack", "Discord", "Mattermost":
Expand Down
2 changes: 1 addition & 1 deletion pkg/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func Check() bool {
return false
}

if _, err := os.Stat(file); os.IsNotExist(err) {
if _, err := os.Stat(file); err != nil {
return false
}

Expand Down

0 comments on commit ef9bb80

Please sign in to comment.