Lint (type inference): remove redundant type declarations (#2111)
This commit is contained in:
parent
9faa49c7e8
commit
e161507d08
|
@ -29,8 +29,8 @@ var Client *apiclient.ApiClient
|
||||||
|
|
||||||
func DecisionsToTable(alerts *models.GetAlertsResponse, printMachine bool) error {
|
func DecisionsToTable(alerts *models.GetAlertsResponse, printMachine bool) error {
|
||||||
/*here we cheat a bit : to make it more readable for the user, we dedup some entries*/
|
/*here we cheat a bit : to make it more readable for the user, we dedup some entries*/
|
||||||
var spamLimit map[string]bool = make(map[string]bool)
|
spamLimit := make(map[string]bool)
|
||||||
var skipped = 0
|
skipped := 0
|
||||||
|
|
||||||
for aIdx := 0; aIdx < len(*alerts); aIdx++ {
|
for aIdx := 0; aIdx < len(*alerts); aIdx++ {
|
||||||
alertItem := (*alerts)[aIdx]
|
alertItem := (*alerts)[aIdx]
|
||||||
|
|
|
@ -29,7 +29,7 @@ func runPour(input chan types.Event, holders []leaky.BucketFactory, buckets *lea
|
||||||
//when in forensics mode, garbage collect buckets
|
//when in forensics mode, garbage collect buckets
|
||||||
if cConfig.Crowdsec.BucketsGCEnabled {
|
if cConfig.Crowdsec.BucketsGCEnabled {
|
||||||
if parsed.MarshaledTime != "" {
|
if parsed.MarshaledTime != "" {
|
||||||
var z *time.Time = &time.Time{}
|
z := &time.Time{}
|
||||||
if err := z.UnmarshalText([]byte(parsed.MarshaledTime)); err != nil {
|
if err := z.UnmarshalText([]byte(parsed.MarshaledTime)); err != nil {
|
||||||
log.Warningf("Failed to unmarshal time from event '%s' : %s", parsed.MarshaledTime, err)
|
log.Warningf("Failed to unmarshal time from event '%s' : %s", parsed.MarshaledTime, err)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -432,7 +432,7 @@ func (f *FileSource) tailFile(out chan types.Event, t *tomb.Tomb, tail *tail.Tai
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
case <-tail.Tomb.Dying(): //our tailer is dying
|
case <-tail.Dying(): //our tailer is dying
|
||||||
logger.Warningf("File reader of %s died", tail.Filename)
|
logger.Warningf("File reader of %s died", tail.Filename)
|
||||||
t.Kill(fmt.Errorf("dead reader for %s", tail.Filename))
|
t.Kill(fmt.Errorf("dead reader for %s", tail.Filename))
|
||||||
return fmt.Errorf("reader for %s is dead", tail.Filename)
|
return fmt.Errorf("reader for %s is dead", tail.Filename)
|
||||||
|
|
|
@ -19,7 +19,7 @@ func TestNewAlertContext(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "basic config test",
|
name: "basic config test",
|
||||||
contextToSend: map[string][]string{
|
contextToSend: map[string][]string{
|
||||||
"test": []string{"evt.Parsed.source_ip"},
|
"test": {"evt.Parsed.source_ip"},
|
||||||
},
|
},
|
||||||
valueLength: 100,
|
valueLength: 100,
|
||||||
expectedErr: nil,
|
expectedErr: nil,
|
||||||
|
@ -45,8 +45,8 @@ func TestEventToContext(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "basic test",
|
name: "basic test",
|
||||||
contextToSend: map[string][]string{
|
contextToSend: map[string][]string{
|
||||||
"source_ip": []string{"evt.Parsed.source_ip"},
|
"source_ip": {"evt.Parsed.source_ip"},
|
||||||
"nonexistent_field": []string{"evt.Parsed.nonexist"},
|
"nonexistent_field": {"evt.Parsed.nonexist"},
|
||||||
},
|
},
|
||||||
valueLength: 100,
|
valueLength: 100,
|
||||||
events: []types.Event{
|
events: []types.Event{
|
||||||
|
@ -67,9 +67,9 @@ func TestEventToContext(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "test many events",
|
name: "test many events",
|
||||||
contextToSend: map[string][]string{
|
contextToSend: map[string][]string{
|
||||||
"source_ip": []string{"evt.Parsed.source_ip"},
|
"source_ip": {"evt.Parsed.source_ip"},
|
||||||
"source_machine": []string{"evt.Parsed.source_machine"},
|
"source_machine": {"evt.Parsed.source_machine"},
|
||||||
"cve": []string{"evt.Parsed.cve"},
|
"cve": {"evt.Parsed.cve"},
|
||||||
},
|
},
|
||||||
valueLength: 100,
|
valueLength: 100,
|
||||||
events: []types.Event{
|
events: []types.Event{
|
||||||
|
@ -113,9 +113,9 @@ func TestEventToContext(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "test many events with result above max length (need truncate, keep only 2 on 3 elements)",
|
name: "test many events with result above max length (need truncate, keep only 2 on 3 elements)",
|
||||||
contextToSend: map[string][]string{
|
contextToSend: map[string][]string{
|
||||||
"source_ip": []string{"evt.Parsed.source_ip"},
|
"source_ip": {"evt.Parsed.source_ip"},
|
||||||
"source_machine": []string{"evt.Parsed.source_machine"},
|
"source_machine": {"evt.Parsed.source_machine"},
|
||||||
"uri": []string{"evt.Parsed.uri"},
|
"uri": {"evt.Parsed.uri"},
|
||||||
},
|
},
|
||||||
valueLength: 100,
|
valueLength: 100,
|
||||||
events: []types.Event{
|
events: []types.Event{
|
||||||
|
@ -159,9 +159,9 @@ func TestEventToContext(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "test one events with result above max length (need truncate on one element)",
|
name: "test one events with result above max length (need truncate on one element)",
|
||||||
contextToSend: map[string][]string{
|
contextToSend: map[string][]string{
|
||||||
"source_ip": []string{"evt.Parsed.source_ip"},
|
"source_ip": {"evt.Parsed.source_ip"},
|
||||||
"source_machine": []string{"evt.Parsed.source_machine"},
|
"source_machine": {"evt.Parsed.source_machine"},
|
||||||
"uri": []string{"evt.Parsed.uri"},
|
"uri": {"evt.Parsed.uri"},
|
||||||
},
|
},
|
||||||
valueLength: 100,
|
valueLength: 100,
|
||||||
events: []types.Event{
|
events: []types.Event{
|
||||||
|
|
|
@ -124,7 +124,7 @@ func TestAlertsListAsMachine(t *testing.T) {
|
||||||
Capacity: &tcapacity,
|
Capacity: &tcapacity,
|
||||||
CreatedAt: "2020-11-28T10:20:47+01:00",
|
CreatedAt: "2020-11-28T10:20:47+01:00",
|
||||||
Decisions: []*models.Decision{
|
Decisions: []*models.Decision{
|
||||||
&models.Decision{
|
{
|
||||||
Duration: &tduration,
|
Duration: &tduration,
|
||||||
ID: 1,
|
ID: 1,
|
||||||
Origin: &torigin,
|
Origin: &torigin,
|
||||||
|
@ -137,7 +137,7 @@ func TestAlertsListAsMachine(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Events: []*models.Event{
|
Events: []*models.Event{
|
||||||
&models.Event{
|
{
|
||||||
Meta: models.Meta{
|
Meta: models.Meta{
|
||||||
&models.MetaItems0{
|
&models.MetaItems0{
|
||||||
Key: "target_user",
|
Key: "target_user",
|
||||||
|
@ -149,8 +149,7 @@ func TestAlertsListAsMachine(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Timestamp: &ttimestamp,
|
Timestamp: &ttimestamp,
|
||||||
},
|
}, {
|
||||||
&models.Event{
|
|
||||||
Meta: models.Meta{
|
Meta: models.Meta{
|
||||||
&models.MetaItems0{
|
&models.MetaItems0{
|
||||||
Key: "target_user",
|
Key: "target_user",
|
||||||
|
@ -323,7 +322,7 @@ func TestAlertsGetAsMachine(t *testing.T) {
|
||||||
Capacity: &tcapacity,
|
Capacity: &tcapacity,
|
||||||
CreatedAt: "2020-11-28T10:20:47+01:00",
|
CreatedAt: "2020-11-28T10:20:47+01:00",
|
||||||
Decisions: []*models.Decision{
|
Decisions: []*models.Decision{
|
||||||
&models.Decision{
|
{
|
||||||
Duration: &tduration,
|
Duration: &tduration,
|
||||||
ID: 1,
|
ID: 1,
|
||||||
Origin: &torigin,
|
Origin: &torigin,
|
||||||
|
@ -336,7 +335,7 @@ func TestAlertsGetAsMachine(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Events: []*models.Event{
|
Events: []*models.Event{
|
||||||
&models.Event{
|
{
|
||||||
Meta: models.Meta{
|
Meta: models.Meta{
|
||||||
&models.MetaItems0{
|
&models.MetaItems0{
|
||||||
Key: "target_user",
|
Key: "target_user",
|
||||||
|
@ -348,8 +347,7 @@ func TestAlertsGetAsMachine(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Timestamp: &ttimestamp,
|
Timestamp: &ttimestamp,
|
||||||
},
|
}, {
|
||||||
&models.Event{
|
|
||||||
Meta: models.Meta{
|
Meta: models.Meta{
|
||||||
&models.MetaItems0{
|
&models.MetaItems0{
|
||||||
Key: "target_user",
|
Key: "target_user",
|
||||||
|
|
|
@ -82,7 +82,7 @@ func (pw *PluginWatcher) Start(tomb *tomb.Tomb) {
|
||||||
|
|
||||||
func (pw *PluginWatcher) watchPluginTicker(pluginName string) {
|
func (pw *PluginWatcher) watchPluginTicker(pluginName string) {
|
||||||
var watchTime time.Duration
|
var watchTime time.Duration
|
||||||
var watchCount int = -1
|
watchCount := -1
|
||||||
// Threshold can be set : by time, by count, or both
|
// Threshold can be set : by time, by count, or both
|
||||||
// if only time is set, honor it
|
// if only time is set, honor it
|
||||||
// if only count is set, put timer to 1 second and just check size
|
// if only count is set, put timer to 1 second and just check size
|
||||||
|
@ -108,7 +108,7 @@ func (pw *PluginWatcher) watchPluginTicker(pluginName string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ticker := time.NewTicker(watchTime)
|
ticker := time.NewTicker(watchTime)
|
||||||
var lastSend time.Time = time.Now()
|
lastSend := time.Now()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
|
|
|
@ -147,7 +147,7 @@ type FireResponse struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *SmokeItem) GetAttackDetails() []string {
|
func (c *SmokeItem) GetAttackDetails() []string {
|
||||||
var ret []string = make([]string, 0)
|
ret := make([]string, 0)
|
||||||
|
|
||||||
if c.AttackDetails != nil {
|
if c.AttackDetails != nil {
|
||||||
for _, b := range c.AttackDetails {
|
for _, b := range c.AttackDetails {
|
||||||
|
@ -158,7 +158,7 @@ func (c *SmokeItem) GetAttackDetails() []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *SmokeItem) GetBehaviors() []string {
|
func (c *SmokeItem) GetBehaviors() []string {
|
||||||
var ret []string = make([]string, 0)
|
ret := make([]string, 0)
|
||||||
|
|
||||||
if c.Behaviors != nil {
|
if c.Behaviors != nil {
|
||||||
for _, b := range c.Behaviors {
|
for _, b := range c.Behaviors {
|
||||||
|
@ -199,7 +199,7 @@ func (c *SmokeItem) GetBackgroundNoiseScore() int {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *SmokeItem) GetFalsePositives() []string {
|
func (c *SmokeItem) GetFalsePositives() []string {
|
||||||
var ret []string = make([]string, 0)
|
ret := make([]string, 0)
|
||||||
|
|
||||||
if c.Classifications.FalsePositives != nil {
|
if c.Classifications.FalsePositives != nil {
|
||||||
for _, b := range c.Classifications.FalsePositives {
|
for _, b := range c.Classifications.FalsePositives {
|
||||||
|
@ -221,7 +221,7 @@ func (c *SmokeItem) IsFalsePositive() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FireItem) GetAttackDetails() []string {
|
func (c *FireItem) GetAttackDetails() []string {
|
||||||
var ret []string = make([]string, 0)
|
ret := make([]string, 0)
|
||||||
|
|
||||||
if c.AttackDetails != nil {
|
if c.AttackDetails != nil {
|
||||||
for _, b := range c.AttackDetails {
|
for _, b := range c.AttackDetails {
|
||||||
|
@ -232,7 +232,7 @@ func (c *FireItem) GetAttackDetails() []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FireItem) GetBehaviors() []string {
|
func (c *FireItem) GetBehaviors() []string {
|
||||||
var ret []string = make([]string, 0)
|
ret := make([]string, 0)
|
||||||
|
|
||||||
if c.Behaviors != nil {
|
if c.Behaviors != nil {
|
||||||
for _, b := range c.Behaviors {
|
for _, b := range c.Behaviors {
|
||||||
|
@ -273,7 +273,7 @@ func (c *FireItem) GetBackgroundNoiseScore() int {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FireItem) GetFalsePositives() []string {
|
func (c *FireItem) GetFalsePositives() []string {
|
||||||
var ret []string = make([]string, 0)
|
ret := make([]string, 0)
|
||||||
|
|
||||||
if c.Classifications.FalsePositives != nil {
|
if c.Classifications.FalsePositives != nil {
|
||||||
for _, b := range c.Classifications.FalsePositives {
|
for _, b := range c.Classifications.FalsePositives {
|
||||||
|
|
|
@ -27,7 +27,7 @@ func BuildDecisionRequestWithFilter(query *ent.DecisionQuery, filter map[string]
|
||||||
var err error
|
var err error
|
||||||
var start_ip, start_sfx, end_ip, end_sfx int64
|
var start_ip, start_sfx, end_ip, end_sfx int64
|
||||||
var ip_sz int
|
var ip_sz int
|
||||||
var contains bool = true
|
var contains = true
|
||||||
/*if contains is true, return bans that *contains* the given value (value is the inner)
|
/*if contains is true, return bans that *contains* the given value (value is the inner)
|
||||||
else, return bans that are *contained* by the given value (value is the outer)*/
|
else, return bans that are *contained* by the given value (value is the outer)*/
|
||||||
|
|
||||||
|
@ -311,7 +311,7 @@ func (c *Client) DeleteDecisionsWithFilter(filter map[string][]string) (string,
|
||||||
var err error
|
var err error
|
||||||
var start_ip, start_sfx, end_ip, end_sfx int64
|
var start_ip, start_sfx, end_ip, end_sfx int64
|
||||||
var ip_sz int
|
var ip_sz int
|
||||||
var contains bool = true
|
var contains = true
|
||||||
/*if contains is true, return bans that *contains* the given value (value is the inner)
|
/*if contains is true, return bans that *contains* the given value (value is the inner)
|
||||||
else, return bans that are *contained* by the given value (value is the outer) */
|
else, return bans that are *contained* by the given value (value is the outer) */
|
||||||
|
|
||||||
|
@ -427,7 +427,7 @@ func (c *Client) SoftDeleteDecisionsWithFilter(filter map[string][]string) (stri
|
||||||
var err error
|
var err error
|
||||||
var start_ip, start_sfx, end_ip, end_sfx int64
|
var start_ip, start_sfx, end_ip, end_sfx int64
|
||||||
var ip_sz int
|
var ip_sz int
|
||||||
var contains bool = true
|
var contains = true
|
||||||
/*if contains is true, return bans that *contains* the given value (value is the inner)
|
/*if contains is true, return bans that *contains* the given value (value is the inner)
|
||||||
else, return bans that are *contained* by the given value (value is the outer)*/
|
else, return bans that are *contained* by the given value (value is the outer)*/
|
||||||
decisions := c.Ent.Decision.Query().Where(decision.UntilGT(time.Now().UTC()))
|
decisions := c.Ent.Decision.Query().Where(decision.UntilGT(time.Now().UTC()))
|
||||||
|
|
|
@ -53,7 +53,7 @@ var sampledata = map[string]cticlient.SmokeItem{
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
//1.2.3.7 is a ok guy, but part of a bad range
|
//1.2.3.7 is a ok guy, but part of a bad range
|
||||||
"1.2.3.7": cticlient.SmokeItem{},
|
"1.2.3.7": {},
|
||||||
}
|
}
|
||||||
|
|
||||||
const validApiKey = "my-api-key"
|
const validApiKey = "my-api-key"
|
||||||
|
|
|
@ -33,7 +33,7 @@ func NewBlackhole(bucketFactory *BucketFactory) (*Blackhole, error) {
|
||||||
|
|
||||||
func (bl *Blackhole) OnBucketOverflow(bucketFactory *BucketFactory) func(*Leaky, types.RuntimeAlert, *Queue) (types.RuntimeAlert, *Queue) {
|
func (bl *Blackhole) OnBucketOverflow(bucketFactory *BucketFactory) func(*Leaky, types.RuntimeAlert, *Queue) (types.RuntimeAlert, *Queue) {
|
||||||
return func(leaky *Leaky, alert types.RuntimeAlert, queue *Queue) (types.RuntimeAlert, *Queue) {
|
return func(leaky *Leaky, alert types.RuntimeAlert, queue *Queue) (types.RuntimeAlert, *Queue) {
|
||||||
var blackholed bool = false
|
var blackholed = false
|
||||||
var tmp []HiddenKey
|
var tmp []HiddenKey
|
||||||
// search if we are blackholed and refresh the slice
|
// search if we are blackholed and refresh the slice
|
||||||
for _, element := range bl.hiddenKeys {
|
for _, element := range bl.hiddenKeys {
|
||||||
|
|
|
@ -201,9 +201,9 @@ func FromFactory(bucketFactory BucketFactory) *Leaky {
|
||||||
func LeakRoutine(leaky *Leaky) error {
|
func LeakRoutine(leaky *Leaky) error {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
durationTickerChan <-chan time.Time = make(<-chan time.Time)
|
durationTickerChan = make(<-chan time.Time)
|
||||||
durationTicker *time.Ticker
|
durationTicker *time.Ticker
|
||||||
firstEvent bool = true
|
firstEvent = true
|
||||||
)
|
)
|
||||||
|
|
||||||
defer types.CatchPanic(fmt.Sprintf("crowdsec/LeakRoutine/%s", leaky.Name))
|
defer types.CatchPanic(fmt.Sprintf("crowdsec/LeakRoutine/%s", leaky.Name))
|
||||||
|
|
|
@ -31,7 +31,7 @@ type TestFile struct {
|
||||||
func TestBucket(t *testing.T) {
|
func TestBucket(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
envSetting = os.Getenv("TEST_ONLY")
|
envSetting = os.Getenv("TEST_ONLY")
|
||||||
tomb *tomb.Tomb = &tomb.Tomb{}
|
tomb = &tomb.Tomb{}
|
||||||
)
|
)
|
||||||
err := exprhelpers.Init(nil)
|
err := exprhelpers.Init(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -158,7 +158,7 @@ func ValidateFactory(bucketFactory *BucketFactory) error {
|
||||||
|
|
||||||
func LoadBuckets(cscfg *csconfig.CrowdsecServiceCfg, files []string, tomb *tomb.Tomb, buckets *Buckets) ([]BucketFactory, chan types.Event, error) {
|
func LoadBuckets(cscfg *csconfig.CrowdsecServiceCfg, files []string, tomb *tomb.Tomb, buckets *Buckets) ([]BucketFactory, chan types.Event, error) {
|
||||||
var (
|
var (
|
||||||
ret []BucketFactory = []BucketFactory{}
|
ret = []BucketFactory{}
|
||||||
response chan types.Event
|
response chan types.Event
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ type cfgTest struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func runTest(tests []cfgTest) error {
|
func runTest(tests []cfgTest) error {
|
||||||
var tomb *tomb.Tomb = &tomb.Tomb{}
|
var tomb = &tomb.Tomb{}
|
||||||
for idx, cfg := range tests {
|
for idx, cfg := range tests {
|
||||||
err := LoadBucket(&cfg.cfg, tomb)
|
err := LoadBucket(&cfg.cfg, tomb)
|
||||||
if cfg.loadable && err != nil {
|
if cfg.loadable && err != nil {
|
||||||
|
|
|
@ -25,13 +25,13 @@ func expectBucketCount(buckets *Buckets, expected int) error {
|
||||||
|
|
||||||
func TestGCandDump(t *testing.T) {
|
func TestGCandDump(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
buckets *Buckets = NewBuckets()
|
buckets = NewBuckets()
|
||||||
tomb *tomb.Tomb = &tomb.Tomb{}
|
tomb = &tomb.Tomb{}
|
||||||
)
|
)
|
||||||
|
|
||||||
var Holders = []BucketFactory{
|
var Holders = []BucketFactory{
|
||||||
//one overflowing soon + bh
|
//one overflowing soon + bh
|
||||||
BucketFactory{
|
{
|
||||||
Name: "test_counter_fast",
|
Name: "test_counter_fast",
|
||||||
Description: "test_counter_fast",
|
Description: "test_counter_fast",
|
||||||
Debug: true,
|
Debug: true,
|
||||||
|
@ -44,7 +44,7 @@ func TestGCandDump(t *testing.T) {
|
||||||
wgPour: buckets.wgPour,
|
wgPour: buckets.wgPour,
|
||||||
},
|
},
|
||||||
//one long counter
|
//one long counter
|
||||||
BucketFactory{
|
{
|
||||||
Name: "test_counter_slow",
|
Name: "test_counter_slow",
|
||||||
Description: "test_counter_slow",
|
Description: "test_counter_slow",
|
||||||
Debug: true,
|
Debug: true,
|
||||||
|
@ -56,7 +56,7 @@ func TestGCandDump(t *testing.T) {
|
||||||
wgPour: buckets.wgPour,
|
wgPour: buckets.wgPour,
|
||||||
},
|
},
|
||||||
//slow leaky
|
//slow leaky
|
||||||
BucketFactory{
|
{
|
||||||
Name: "test_leaky_slow",
|
Name: "test_leaky_slow",
|
||||||
Description: "test_leaky_slow",
|
Description: "test_leaky_slow",
|
||||||
Debug: true,
|
Debug: true,
|
||||||
|
@ -115,10 +115,10 @@ func TestGCandDump(t *testing.T) {
|
||||||
|
|
||||||
func TestShutdownBuckets(t *testing.T) {
|
func TestShutdownBuckets(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
buckets *Buckets = NewBuckets()
|
buckets = NewBuckets()
|
||||||
Holders = []BucketFactory{
|
Holders = []BucketFactory{
|
||||||
//one long counter
|
//one long counter
|
||||||
BucketFactory{
|
{
|
||||||
Name: "test_counter_slow",
|
Name: "test_counter_slow",
|
||||||
Description: "test_counter_slow",
|
Description: "test_counter_slow",
|
||||||
Debug: true,
|
Debug: true,
|
||||||
|
@ -130,7 +130,7 @@ func TestShutdownBuckets(t *testing.T) {
|
||||||
wgPour: buckets.wgPour,
|
wgPour: buckets.wgPour,
|
||||||
},
|
},
|
||||||
//slow leaky
|
//slow leaky
|
||||||
BucketFactory{
|
{
|
||||||
Name: "test_leaky_slow",
|
Name: "test_leaky_slow",
|
||||||
Description: "test_leaky_slow",
|
Description: "test_leaky_slow",
|
||||||
Debug: true,
|
Debug: true,
|
||||||
|
@ -142,7 +142,7 @@ func TestShutdownBuckets(t *testing.T) {
|
||||||
wgPour: buckets.wgPour,
|
wgPour: buckets.wgPour,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
tomb *tomb.Tomb = &tomb.Tomb{}
|
tomb = &tomb.Tomb{}
|
||||||
)
|
)
|
||||||
|
|
||||||
for idx := range Holders {
|
for idx := range Holders {
|
||||||
|
|
|
@ -210,7 +210,7 @@ func EventsFromQueue(queue *Queue) []*models.Event {
|
||||||
|
|
||||||
// alertFormatSource iterates over the queue to collect sources
|
// alertFormatSource iterates over the queue to collect sources
|
||||||
func alertFormatSource(leaky *Leaky, queue *Queue) (map[string]models.Source, string, error) {
|
func alertFormatSource(leaky *Leaky, queue *Queue) (map[string]models.Source, string, error) {
|
||||||
var sources map[string]models.Source = make(map[string]models.Source)
|
var sources = make(map[string]models.Source)
|
||||||
var source_type string
|
var source_type string
|
||||||
|
|
||||||
log.Debugf("Formatting (%s) - scope Info : scope_type:%s / scope_filter:%s", leaky.Name, leaky.scopeType.Scope, leaky.scopeType.Filter)
|
log.Debugf("Formatting (%s) - scope Info : scope_type:%s / scope_filter:%s", leaky.Name, leaky.scopeType.Scope, leaky.scopeType.Filter)
|
||||||
|
|
|
@ -139,7 +139,7 @@ func StopContainer(name string) error {
|
||||||
return fmt.Errorf("failed to create docker client : %s", err)
|
return fmt.Errorf("failed to create docker client : %s", err)
|
||||||
}
|
}
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
var to time.Duration = 20 * time.Second
|
to := 20 * time.Second
|
||||||
if err := cli.ContainerStop(ctx, name, &to); err != nil {
|
if err := cli.ContainerStop(ctx, name, &to); err != nil {
|
||||||
return fmt.Errorf("failed while stopping %s : %s", name, err)
|
return fmt.Errorf("failed while stopping %s : %s", name, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ func GenDateParse(date string) (string, time.Time) {
|
||||||
|
|
||||||
func ParseDate(in string, p *types.Event, x interface{}, plog *log.Entry) (map[string]string, error) {
|
func ParseDate(in string, p *types.Event, x interface{}, plog *log.Entry) (map[string]string, error) {
|
||||||
|
|
||||||
var ret map[string]string = make(map[string]string)
|
var ret = make(map[string]string)
|
||||||
var strDate string
|
var strDate string
|
||||||
var parsedDate time.Time
|
var parsedDate time.Time
|
||||||
if in != "" {
|
if in != "" {
|
||||||
|
|
|
@ -196,7 +196,7 @@ func loadTestFile(file string) []TestFile {
|
||||||
|
|
||||||
func matchEvent(expected types.Event, out types.Event, debug bool) ([]string, bool) {
|
func matchEvent(expected types.Event, out types.Event, debug bool) ([]string, bool) {
|
||||||
var retInfo []string
|
var retInfo []string
|
||||||
var valid bool = false
|
var valid = false
|
||||||
expectMaps := []map[string]string{expected.Parsed, expected.Meta, expected.Enriched}
|
expectMaps := []map[string]string{expected.Parsed, expected.Meta, expected.Enriched}
|
||||||
outMaps := []map[string]string{out.Parsed, out.Meta, out.Enriched}
|
outMaps := []map[string]string{out.Parsed, out.Meta, out.Enriched}
|
||||||
outLabels := []string{"Parsed", "Meta", "Enriched"}
|
outLabels := []string{"Parsed", "Meta", "Enriched"}
|
||||||
|
|
|
@ -245,7 +245,7 @@ var DumpFolder string
|
||||||
var StageParseCache map[string]map[string][]ParserResult
|
var StageParseCache map[string]map[string][]ParserResult
|
||||||
|
|
||||||
func Parse(ctx UnixParserCtx, xp types.Event, nodes []Node) (types.Event, error) {
|
func Parse(ctx UnixParserCtx, xp types.Event, nodes []Node) (types.Event, error) {
|
||||||
var event types.Event = xp
|
var 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 {
|
||||||
|
|
Loading…
Reference in a new issue