gosec

This commit is contained in:
naiba 2021-09-04 12:42:51 +08:00
parent 67faa7a63d
commit e40026f6cc
8 changed files with 13 additions and 14 deletions

View File

@ -23,4 +23,4 @@ jobs:
- name: Run Gosec Security Scanner
uses: securego/gosec@master
with:
args: ./...
args: -exclude=G104 ./...

View File

@ -290,9 +290,9 @@ func handleCommandTask(task *pb.Task, result *pb.TaskResult) {
}
timeout := time.NewTimer(time.Hour * 2)
if utils.IsWindows() {
cmd = exec.Command("cmd", "/c", task.GetData())
cmd = exec.Command("cmd", "/c", task.GetData()) // #nosec
} else {
cmd = exec.Command("sh", "-c", task.GetData())
cmd = exec.Command("sh", "-c", task.GetData()) // #nosec
}
cmd.Env = os.Environ()
pg.AddProcess(cmd)

View File

@ -32,7 +32,7 @@ func Start() (*Pty, error) {
if shellPath == "" {
return nil, errors.New("没有可用终端")
}
cmd := exec.Command(shellPath)
cmd := exec.Command(shellPath) // #nosec
cmd.Env = append(os.Environ(), "TERM=xterm")
tty, err := opty.Start(cmd)
return &Pty{tty: tty, cmd: cmd}, err

View File

@ -29,10 +29,10 @@ func ServeWeb(port uint) *http.Server {
return t.Format("2006年1月2号 15:04:05")
},
"safe": func(s string) template.HTML {
return template.HTML(s)
return template.HTML(s) // #nosec
},
"tag": func(s string) template.HTML {
return template.HTML(`<` + s + `>`)
return template.HTML(`<` + s + `>`) // #nosec
},
"stf": func(s uint64) string {
return time.Unix(int64(s), 0).Format("2006年1月2号 15:04")

View File

@ -81,7 +81,7 @@ func (n *Notification) Send(message string) error {
}
transCfg := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: verifySSL},
TLSClientConfig: &tls.Config{InsecureSkipVerify: verifySSL}, // #nosec
}
client := &http.Client{Transport: transCfg, Timeout: time.Minute * 10}

View File

@ -43,6 +43,5 @@ func (s Server) Marshal() template.JS {
tag, _ := json.Marshal(s.Tag)
note, _ := json.Marshal(s.Note)
secret, _ := json.Marshal(s.Secret)
return template.JS(fmt.Sprintf(`{"ID":%d,"Name":%s,"Secret":%s,"DisplayIndex":%d,"Tag":%s,"Note":%s}`,
s.ID, name, secret, s.DisplayIndex, tag, note))
return template.JS(fmt.Sprintf(`{"ID":%d,"Name":%s,"Secret":%s,"DisplayIndex":%d,"Tag":%s,"Note":%s}`, s.ID, name, secret, s.DisplayIndex, tag, note)) // #nosec
}

View File

@ -1,7 +1,7 @@
package utils
import (
"crypto/md5"
"crypto/md5" // #nosec
"encoding/hex"
"math/rand"
"os"
@ -34,11 +34,11 @@ func RandStringBytesMaskImprSrcUnsafe(n int) string {
remain--
}
return *(*string)(unsafe.Pointer(&b))
return *(*string)(unsafe.Pointer(&b)) //#nosec
}
func MD5(plantext string) string {
hash := md5.New()
hash := md5.New() // #nosec
hash.Write([]byte(plantext))
return hex.EncodeToString(hash.Sum(nil))
}

View File

@ -1,7 +1,7 @@
package dao
import (
"crypto/md5"
"crypto/md5" // #nosec
"encoding/hex"
"log"
"sync"
@ -45,7 +45,7 @@ func OnDeleteNotification(id uint64) {
func SendNotification(desc string, muteable bool) {
if muteable {
// 通知防骚扰策略
nID := hex.EncodeToString(md5.New().Sum([]byte(desc)))
nID := hex.EncodeToString(md5.New().Sum([]byte(desc))) // #nosec
var flag bool
if cacheN, has := Cache.Get(nID); has {
nHistory := cacheN.(NotificationHistory)