diff --git a/.gitignore b/.gitignore index 6d8c340e1..ef8480590 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ *.dll *.so *.dylib +*~ +.pc # Test binary, built with `go test -c` *.test diff --git a/cmd/crowdsec-cli/decisions.go b/cmd/crowdsec-cli/decisions.go index 5f86c59e8..c487bbf7f 100644 --- a/cmd/crowdsec-cli/decisions.go +++ b/cmd/crowdsec-cli/decisions.go @@ -34,6 +34,7 @@ var ( func DecisionsToTable(alerts *models.GetAlertsResponse) error { /*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) + var skipped = 0 /*process in reverse order to keep the latest item only*/ for aIdx := len(*alerts) - 1; aIdx >= 0; aIdx-- { @@ -42,6 +43,7 @@ func DecisionsToTable(alerts *models.GetAlertsResponse) error { for _, decisionItem := range alertItem.Decisions { spamKey := fmt.Sprintf("%t:%s:%s:%s", *decisionItem.Simulated, *decisionItem.Type, *decisionItem.Scope, *decisionItem.Value) if _, ok := spamLimit[spamKey]; ok { + skipped++ continue } spamLimit[spamKey] = true @@ -100,6 +102,9 @@ func DecisionsToTable(alerts *models.GetAlertsResponse) error { } } table.Render() // Send output + if skipped > 0 { + fmt.Printf("%d duplicated entries skipped\n", skipped) + } } return nil } diff --git a/cmd/crowdsec/Makefile b/cmd/crowdsec/Makefile index 9980b9004..6e636c1cc 100644 --- a/cmd/crowdsec/Makefile +++ b/cmd/crowdsec/Makefile @@ -23,7 +23,7 @@ static: clean $(GOBUILD) $(LD_OPTS_STATIC) -o $(CROWDSEC_BIN) -v -a -tags netgo test: - $(GOTEST) -v ./... + $(GOTEST) $(LD_OPTS) -v ./... clean: rm -f $(CROWDSEC_BIN) diff --git a/debian/README.md b/debian/README.md new file mode 100644 index 000000000..82e43e9fb --- /dev/null +++ b/debian/README.md @@ -0,0 +1,14 @@ + +# Building Debian/Ubuntu packages + +It is not recommended to build your own packages for production environments. + +However, if you want to experiment and contribute: + +* Update the changelog (at least give it a correct version number) +* Run "QUILT_PATCHES=debian/patches quilt push -a && quilt refresh" + +We do the above in the build pipeline, so you'll have to do it manually before running: + +* dpkg-buildpackage -uc -us -b + diff --git a/pkg/database/decisions.go b/pkg/database/decisions.go index 5f542db50..3132dce4d 100644 --- a/pkg/database/decisions.go +++ b/pkg/database/decisions.go @@ -222,7 +222,7 @@ func (c *Client) QueryExpiredDecisionsSinceWithFilters(since time.Time, filters } func (c *Client) QueryNewDecisionsSinceWithFilters(since time.Time, filters map[string][]string) ([]*ent.Decision, error) { - query := c.Ent.Decision.Query().Where(decision.CreatedAtGT(since)) + query := c.Ent.Decision.Query().Where(decision.CreatedAtGT(since)).Where(decision.UntilGT(time.Now())) query, err := BuildDecisionRequestWithFilter(query, filters) if err != nil { c.Log.Warningf("QueryNewDecisionsSinceWithFilters : %s", err)