more linter fixes (simplicity mostly)
This commit is contained in:
parent
db9e1e280d
commit
fe68914628
|
@ -10,7 +10,6 @@ import (
|
|||
|
||||
"github.com/crowdsecurity/crowdsec/pkg/cwhub"
|
||||
"github.com/crowdsecurity/crowdsec/pkg/outputs"
|
||||
"github.com/crowdsecurity/crowdsec/pkg/sqlite"
|
||||
"github.com/crowdsecurity/crowdsec/pkg/types"
|
||||
|
||||
"github.com/denisbrodbeck/machineid"
|
||||
|
@ -28,13 +27,10 @@ var (
|
|||
|
||||
var (
|
||||
apiConfigFile = "api.yaml"
|
||||
userID string // for flag parsing
|
||||
outputCTX *outputs.Output
|
||||
)
|
||||
|
||||
var userID string // for flag parsing
|
||||
var dbctx *sqlite.Context
|
||||
|
||||
var outputCTX *outputs.Output
|
||||
|
||||
func dumpCredentials() error {
|
||||
if config.output == "json" {
|
||||
credsYaml, err := json.Marshal(&outputCTX.API.Creds)
|
||||
|
|
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/crowdsecurity/crowdsec/pkg/acquisition"
|
||||
)
|
||||
|
||||
|
@ -25,7 +26,7 @@ func loadAcquisition() (*acquisition.FileAcquisCtx, error) {
|
|||
if acquisitionCTX == nil {
|
||||
return nil, fmt.Errorf("no inputs to process")
|
||||
}
|
||||
if cConfig.Profiling == true {
|
||||
if cConfig.Profiling {
|
||||
acquisitionCTX.Profiling = true
|
||||
}
|
||||
|
||||
|
|
|
@ -172,7 +172,7 @@ func AcquisStartReading(ctx *FileAcquisCtx, output chan types.Event, AcquisTomb
|
|||
/* start one go routine reading for each file, and pushing to chan output */
|
||||
for idx, fctx := range ctx.Files {
|
||||
log.Printf("starting reader file %d/%d : %s", idx, len(ctx.Files), fctx.Filename)
|
||||
if ctx.Profiling == true {
|
||||
if ctx.Profiling {
|
||||
fctx.Profiling = true
|
||||
}
|
||||
fctx := fctx
|
||||
|
@ -227,7 +227,7 @@ LOOP:
|
|||
if line.Text == "" { //skip empty lines
|
||||
continue
|
||||
}
|
||||
if ctx.Profiling == true {
|
||||
if ctx.Profiling {
|
||||
ReaderHits.With(prometheus.Labels{"source": ctx.Filename}).Inc()
|
||||
}
|
||||
l.Raw = line.Text
|
||||
|
|
|
@ -405,9 +405,9 @@ func FormatOverflow(l *Leaky, queue *Queue) types.SignalOccurence {
|
|||
am = fmt.Sprintf("%d IPs", len(sig.Sources))
|
||||
} else if len(sig.Sources) == 1 {
|
||||
if sig.Source != nil {
|
||||
am = fmt.Sprintf("%s", sig.Source.Ip.String())
|
||||
am = sig.Source.Ip.String()
|
||||
} else {
|
||||
am = fmt.Sprintf("??")
|
||||
am = "??"
|
||||
}
|
||||
} else {
|
||||
am = "UNKNOWN"
|
||||
|
|
|
@ -185,10 +185,10 @@ func (n *Node) process(p *types.Event, ctx UnixParserCtx) (bool, error) {
|
|||
clog.Debugf("Event leaving node : ko")
|
||||
return false, nil
|
||||
}
|
||||
switch output.(type) {
|
||||
switch out := output.(type) {
|
||||
case bool:
|
||||
/* filter returned false, don't process Node */
|
||||
if output.(bool) {
|
||||
if out {
|
||||
clog.Infof("Event is whitelisted by Expr !")
|
||||
p.Whitelisted = true
|
||||
set = true
|
||||
|
|
|
@ -39,10 +39,9 @@ func SetTargetByName(target string, value string, evt *types.Event) bool {
|
|||
if evt == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
//it's a hack, we do it for the user
|
||||
if strings.HasPrefix(target, "evt.") {
|
||||
target = target[4:]
|
||||
}
|
||||
target = strings.TrimPrefix(target, "evt.")
|
||||
|
||||
log.Debugf("setting target %s to %s", target, value)
|
||||
defer func() {
|
||||
|
@ -68,7 +67,6 @@ func SetTargetByName(target string, value string, evt *types.Event) bool {
|
|||
/*if we're in a map and the field doesn't exist, the user wants to add it :) */
|
||||
if (tmp == reflect.Value{}) || tmp.IsZero() {
|
||||
log.Debugf("map entry is zero in '%s'", target)
|
||||
//return false
|
||||
}
|
||||
iter.SetMapIndex(reflect.ValueOf(f), reflect.ValueOf(value))
|
||||
return true
|
||||
|
|
|
@ -28,7 +28,7 @@ func (p *pluginDB) Delete(target string) (int, error) {
|
|||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
log.Debugf("deleted '%s' entry from database", nbDel)
|
||||
log.Debugf("deleted '%d' entry from database", nbDel)
|
||||
return nbDel, nil
|
||||
}
|
||||
|
||||
|
@ -65,9 +65,5 @@ func (p *pluginDB) ReadAT(timeAT time.Time) ([]map[string]string, error) {
|
|||
return ret, nil
|
||||
}
|
||||
|
||||
func New() interface{} {
|
||||
return &pluginDB{}
|
||||
}
|
||||
|
||||
// empty main function is mandatory since we are in a main package
|
||||
func main() {}
|
||||
|
|
Loading…
Reference in a new issue