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