linter fixes, inefficient assignments
This commit is contained in:
parent
307f1c0e9e
commit
e643bb5b31
|
@ -93,7 +93,9 @@ API interaction:
|
||||||
Args: cobra.ExactArgs(0),
|
Args: cobra.ExactArgs(0),
|
||||||
Hidden: true,
|
Hidden: true,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
doc.GenMarkdownTree(rootCmd, "./doc/")
|
if err := doc.GenMarkdownTree(rootCmd, "./doc/"); err != nil {
|
||||||
|
log.Fatalf("Failed to generate cobra doc")
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
rootCmd.AddCommand(cmdDocGen)
|
rootCmd.AddCommand(cmdDocGen)
|
||||||
|
|
|
@ -69,7 +69,7 @@ func serveDaemon() error {
|
||||||
if d != nil {
|
if d != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
defer daemonCTX.Release()
|
defer daemonCTX.Release() //nolint:errcheck
|
||||||
err = daemon.ServeSignals()
|
err = daemon.ServeSignals()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("serveDaemon error : %s", err.Error())
|
return fmt.Errorf("serveDaemon error : %s", err.Error())
|
||||||
|
|
|
@ -113,7 +113,7 @@ func (ctx *ApiCtx) Init(cfg string, profile string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
//start the background go-routine
|
//start the background go-routine
|
||||||
go ctx.pushLoop()
|
go ctx.pushLoop() //nolint:errcheck
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -216,7 +216,6 @@ POLL_AGAIN:
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
log.Infof("(scenario) %s == %s", out.Overflow.Scenario, expected.Overflow.Scenario)
|
log.Infof("(scenario) %s == %s", out.Overflow.Scenario, expected.Overflow.Scenario)
|
||||||
valid = true
|
|
||||||
}
|
}
|
||||||
//Events_count
|
//Events_count
|
||||||
if out.Overflow.Events_count != expected.Overflow.Events_count {
|
if out.Overflow.Events_count != expected.Overflow.Events_count {
|
||||||
|
@ -225,7 +224,6 @@ POLL_AGAIN:
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
log.Infof("(Events_count) %d == %d", out.Overflow.Events_count, expected.Overflow.Events_count)
|
log.Infof("(Events_count) %d == %d", out.Overflow.Events_count, expected.Overflow.Events_count)
|
||||||
valid = true
|
|
||||||
}
|
}
|
||||||
//Source_ip
|
//Source_ip
|
||||||
if out.Overflow.Source_ip != expected.Overflow.Source_ip {
|
if out.Overflow.Source_ip != expected.Overflow.Source_ip {
|
||||||
|
@ -234,7 +232,6 @@ POLL_AGAIN:
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
log.Infof("(Source_ip) %s == %s", out.Overflow.Source_ip, expected.Overflow.Source_ip)
|
log.Infof("(Source_ip) %s == %s", out.Overflow.Source_ip, expected.Overflow.Source_ip)
|
||||||
valid = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//CheckFailed:
|
//CheckFailed:
|
||||||
|
|
|
@ -108,7 +108,7 @@ func (n *Node) validate(pctx *UnixParserCtx) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Node) process(p *types.Event, ctx UnixParserCtx) (bool, error) {
|
func (n *Node) process(p *types.Event, ctx UnixParserCtx) (bool, error) {
|
||||||
var NodeState bool = true
|
var NodeState bool
|
||||||
clog := n.logger
|
clog := n.logger
|
||||||
|
|
||||||
clog.Debugf("Event entering node")
|
clog.Debugf("Event entering node")
|
||||||
|
@ -124,7 +124,6 @@ func (n *Node) process(p *types.Event, ctx UnixParserCtx) (bool, error) {
|
||||||
case bool:
|
case bool:
|
||||||
/* filter returned false, don't process Node */
|
/* filter returned false, don't process Node */
|
||||||
if !out {
|
if !out {
|
||||||
NodeState = false
|
|
||||||
clog.Debugf("eval(FALSE) '%s'", n.Filter)
|
clog.Debugf("eval(FALSE) '%s'", n.Filter)
|
||||||
clog.Debugf("Event leaving node : ko")
|
clog.Debugf("Event leaving node : ko")
|
||||||
return false, nil
|
return false, nil
|
||||||
|
@ -132,7 +131,6 @@ func (n *Node) process(p *types.Event, ctx UnixParserCtx) (bool, error) {
|
||||||
default:
|
default:
|
||||||
clog.Warningf("Expr '%s' returned non-bool, abort : %T", n.Filter, output)
|
clog.Warningf("Expr '%s' returned non-bool, abort : %T", n.Filter, output)
|
||||||
clog.Debugf("Event leaving node : ko")
|
clog.Debugf("Event leaving node : ko")
|
||||||
NodeState = false
|
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
NodeState = true
|
NodeState = true
|
||||||
|
@ -424,10 +422,7 @@ func (n *Node) compile(pctx *UnixParserCtx) error {
|
||||||
err = n.SuccessNodes[idx].compile(pctx)
|
err = n.SuccessNodes[idx].compile(pctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
|
||||||
//n.logger.Debugf("Leaf compilation suceeded: %v\n", n.SuccessNodes[idx])
|
|
||||||
}
|
}
|
||||||
//set child node to parent stage
|
|
||||||
}
|
}
|
||||||
valid = true
|
valid = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -228,8 +228,8 @@ func stageidx(stage string, stages []string) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
func /*(u types.UnixParser)*/ Parse(ctx UnixParserCtx, xp types.Event, nodes []Node) (types.Event, error) {
|
func /*(u types.UnixParser)*/ Parse(ctx UnixParserCtx, xp types.Event, nodes []Node) (types.Event, error) {
|
||||||
var event types.Event
|
var event types.Event = xp
|
||||||
event = xp
|
|
||||||
/* the stage is undefined, probably line is freshly acquired, set to first stage !*/
|
/* the stage is undefined, probably line is freshly acquired, set to first stage !*/
|
||||||
if event.Stage == "" && len(ctx.Stages) > 0 {
|
if event.Stage == "" && len(ctx.Stages) > 0 {
|
||||||
event.Stage = ctx.Stages[0]
|
event.Stage = ctx.Stages[0]
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//nolint:unused // pluginDB is the interface for sqlite output plugin
|
||||||
type pluginDB struct {
|
type pluginDB struct {
|
||||||
CTX *sqlite.Context
|
CTX *sqlite.Context
|
||||||
}
|
}
|
||||||
|
@ -65,6 +66,7 @@ func (p *pluginDB) ReadAT(timeAT time.Time) ([]map[string]string, error) {
|
||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:unused // New is used by the plugin system
|
||||||
func New() interface{} {
|
func New() interface{} {
|
||||||
return &pluginDB{}
|
return &pluginDB{}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue