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

Commit ef9bb80

Browse files
committed
fix semgrep linter
1 parent f8e635c commit ef9bb80

File tree

5 files changed

+10
-11
lines changed

5 files changed

+10
-11
lines changed

internal/alert/alert.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func New(options *common.Options, version string, log map[string]string) {
1616
config := options.Configs
1717
if config.Alert.Active {
1818
provider := utils.Title(config.Alert.Provider)
19-
field := reflect.ValueOf(&config.Notifications).Elem().FieldByName(provider)
19+
field := reflect.ValueOf(&config.Notifications).Elem().FieldByName(provider) // nosemgrep
2020

2121
if matchers.IsWebhook(provider, field.FieldByName("Webhook").String()) {
2222
token = field.FieldByName("Webhook").String()

internal/event/event.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ package event
33
import (
44
"encoding/json"
55
"fmt"
6+
"html/template"
67
"mime"
78
"net/http"
8-
"path"
99
"path/filepath"
1010
"strconv"
11-
"text/template"
1211

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

5554
go func() {
56-
err := http.ListenAndServe(fmt.Sprint(h, ":", strconv.Itoa(p)), mux)
55+
err := http.ListenAndServe(fmt.Sprint(h, ":", strconv.Itoa(p)), mux) // nosemgrep
5756
if err != nil {
5857
errors.Exit(err.Error())
5958
}
@@ -84,10 +83,10 @@ func (s *server) static(w http.ResponseWriter, r *http.Request) {
8483
return
8584
}
8685

87-
t, e := template.ParseFS(res, path.Join("./www", p))
86+
t, e := template.ParseFS(res, filepath.Join("www", p))
8887
if e != nil {
8988
w.WriteHeader(http.StatusNotFound)
90-
_, _ = w.Write([]byte(e.Error()))
89+
_, _ = w.Write([]byte(e.Error())) // nosemgrep
9190
return
9291
}
9392

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

107106
if e := t.Execute(w, data); e != nil {
108-
_, _ = w.Write([]byte(e.Error()))
107+
_, _ = w.Write([]byte(e.Error())) // nosemgrep
109108
w.WriteHeader(http.StatusInternalServerError)
110109
return
111110
}

internal/runner/metrics.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func startPrometheus(options *common.Options) {
4949
go func() {
5050
http.Handle(e, promhttp.Handler())
5151

52-
err := http.ListenAndServe(s, nil) // nosemgrep: go.lang.security.audit.net.use-tls.use-tls
52+
err := http.ListenAndServe(s, nil) // nosemgrep
5353
if err != nil {
5454
errors.Exit(err.Error())
5555
}

internal/runner/validator.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func validate(options *common.Options) {
4646
}
4747

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

186186
if config.Alert.Active {
187187
provider := utils.Title(config.Alert.Provider)
188-
field := reflect.ValueOf(&config.Notifications).Elem().FieldByName(provider)
188+
field := reflect.ValueOf(&config.Notifications).Elem().FieldByName(provider) // nosemgrep
189189

190190
switch provider {
191191
case "Slack", "Discord", "Mattermost":

pkg/cache/cache.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func Check() bool {
4141
return false
4242
}
4343

44-
if _, err := os.Stat(file); os.IsNotExist(err) {
44+
if _, err := os.Stat(file); err != nil {
4545
return false
4646
}
4747

0 commit comments

Comments
 (0)