From 6b3e22e99ab3a4c9200875dc6d95062a711d4fbd Mon Sep 17 00:00:00 2001 From: mmetc <92726601+mmetc@users.noreply.github.com> Date: Tue, 21 Dec 2021 10:21:34 +0100 Subject: [PATCH 1/4] add LD_OPTS to "go test" (#1115) --- cmd/crowdsec/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) From f86e0c0a5aae3e8f83941023f4e75d0ec877fbc9 Mon Sep 17 00:00:00 2001 From: AlteredCoder <64792091+AlteredCoder@users.noreply.github.com> Date: Tue, 21 Dec 2021 10:23:30 +0100 Subject: [PATCH 2/4] don't send decisions with negative duration to bouncers (#1117) --- pkg/database/decisions.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) From 64d8c0357b9fb3d139db458295b93deec5df5471 Mon Sep 17 00:00:00 2001 From: mmetc <92726601+mmetc@users.noreply.github.com> Date: Wed, 22 Dec 2021 14:17:32 +0100 Subject: [PATCH 3/4] added debian/README.md --- .gitignore | 2 ++ debian/README.md | 14 ++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 debian/README.md 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/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 + From 6b13d73fcad7cb1770734f72c222bab1b3e95ba1 Mon Sep 17 00:00:00 2001 From: "Thibault \"bui\" Koechlin" Date: Wed, 22 Dec 2021 15:45:41 +0100 Subject: [PATCH 4/4] fix #1057 (#1120) --- cmd/crowdsec-cli/decisions.go | 5 +++++ 1 file changed, 5 insertions(+) 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 }