diff --git a/security/crowdsec/Makefile b/security/crowdsec/Makefile index 6fad13f10378..7e0cf429c350 100644 --- a/security/crowdsec/Makefile +++ b/security/crowdsec/Makefile @@ -1,135 +1,140 @@ PORTNAME= crowdsec -PORTVERSION= 1.2.3 # NOTE: change BUILD_VERSION and BUILD_TAG as well -PORTREVISION= 1 +PORTVERSION= 1.3.2 # NOTE: change BUILD_VERSION and BUILD_TAG as well DISTVERSIONPREFIX= v CATEGORIES= security MAINTAINER= marco@crowdsec.net COMMENT= CrowdSec lightweight and collaborative security engine LICENSE= MIT LICENSE_FILE= ${WRKSRC}/LICENSE BUILD_DEPENDS= git:devel/git@lite \ go:lang/go \ jq:textproc/jq USES= gmake +ALL_TARGET= build USE_GITHUB= yes GH_ACCOUNT= crowdsecurity GH_PROJECT= crowdsec -GH_TAGNAME= v1.2.3-freebsd +GH_TAGNAME= v1.3.2-freebsd-wip #GH_TAGNAME is automatically set from DISTVERSION +OPTIONS_DEFINE= FIREWALL_BOUNCER +OPTIONS_DEFAULT= + +FIREWALL_BOUNCER_DESC= Depend on security/crowdsec-firewall-bouncer +FIREWALL_BOUNCER_RUN_DEPENDS= crowdsec-firewall-bouncer>=0.0.23.r2:security/crowdsec-firewall-bouncer + USE_RC_SUBR= crowdsec -SUB_FILES= pkg-message \ - pkg-install \ - pkg-deinstall +SUB_FILES= pkg-deinstall pkg-install pkg-message -# BUILD_VERSION=$(git describe --tags $(git rev-list --tags --max-count=1)) -# BUILD_TAG=$(git rev-parse HEAD) -MAKE_ENV= BUILD_VERSION="v1.2.3" \ - BUILD_TAG="fc4be1e0ffc5888f2824358464cb2426cd4472e1" +MAKE_ENV= BUILD_VERSION="v1.3.2" \ + BUILD_TAG="716251323da59f1ce04fb1fc38af0a72629b5d78" \ + DEFAULT_CONFIGDIR="${PREFIX}/etc/crowdsec" \ + DEFAULT_DATADIR="/var/db/crowdsec/data" PLUGIN_DIR= ${PREFIX}/lib/crowdsec/plugins STAGE_PLUGINS= ${STAGEDIR}${PLUGIN_DIR} STAGE_BIN= ${STAGEDIR}${PREFIX}/bin post-patch: @${REINPLACE_CMD} 's,/etc/crowdsec/,${ETCDIR}/,g' \ - ${WRKSRC}/pkg/csconfig/config.go \ - ${WRKSRC}/pkg/cstest/hubtest_item.go \ - ${WRKSRC}/cmd/crowdsec-cli/machines.go \ - ${WRKSRC}/cmd/crowdsec-cli/main.go \ - ${WRKSRC}/cmd/crowdsec/main.go \ ${WRKSRC}/config/config.yaml \ ${WRKSRC}/config/profiles.yaml @${REINPLACE_CMD} 's,/var/lib/,/var/db/,g' \ - ${WRKSRC}/pkg/csconfig/config.go \ - ${WRKSRC}/pkg/metabase/database.go \ ${WRKSRC}/config/config.yaml \ ${WRKSRC}/config/profiles.yaml do-install: # # Binaries # ${INSTALL_PROGRAM} ${WRKSRC}/cmd/crowdsec/crowdsec ${STAGE_BIN}/ ${INSTALL_PROGRAM} ${WRKSRC}/cmd/crowdsec-cli/cscli ${STAGE_BIN}/ ${LN} -s cscli ${STAGE_BIN}/crowdsec-cli @${MKDIR} ${STAGE_PLUGINS} ${INSTALL_PROGRAM} ${WRKSRC}/plugins/notifications/email/notification-email ${STAGE_PLUGINS}/ ${INSTALL_PROGRAM} ${WRKSRC}/plugins/notifications/http/notification-http ${STAGE_PLUGINS}/ ${INSTALL_PROGRAM} ${WRKSRC}/plugins/notifications/slack/notification-slack ${STAGE_PLUGINS}/ ${INSTALL_PROGRAM} ${WRKSRC}/plugins/notifications/splunk/notification-splunk ${STAGE_PLUGINS}/ # # Configuration # @${MKDIR} ${STAGEDIR}${ETCDIR} @(cd ${WRKSRC}/config && ${COPYTREE_SHARE} . ${STAGEDIR}${ETCDIR}) @${MV} ${STAGEDIR}${ETCDIR}/acquis.yaml \ ${STAGEDIR}${ETCDIR}/acquis.yaml.sample @${MV} ${STAGEDIR}${ETCDIR}/config.yaml \ ${STAGEDIR}${ETCDIR}/config.yaml.sample + @${MV} ${STAGEDIR}${ETCDIR}/console.yaml \ + ${STAGEDIR}${ETCDIR}/console.yaml.sample + @${MV} ${STAGEDIR}${ETCDIR}/profiles.yaml \ ${STAGEDIR}${ETCDIR}/profiles.yaml.sample # managed by "cscli simulation" @${MV} ${STAGEDIR}${ETCDIR}/simulation.yaml \ ${STAGEDIR}${ETCDIR}/simulation.yaml.sample # # Plugin configuration # @${MKDIR} ${STAGEDIR}${ETCDIR}/notifications @${MKDIR} ${STAGEDIR}${ETCDIR}/notifications/email @${MV} ${WRKSRC}/plugins/notifications/email/email.yaml \ - ${STAGEDIR}${ETCDIR}/notifications/email/email.yaml.sample + ${STAGEDIR}${ETCDIR}/notifications/email.yaml.sample @${MKDIR} ${STAGEDIR}${ETCDIR}/notifications/http @${MV} ${WRKSRC}/plugins/notifications/http/http.yaml \ - ${STAGEDIR}${ETCDIR}/notifications/http/http.yaml.sample + ${STAGEDIR}${ETCDIR}/notifications/http.yaml.sample @${MKDIR} ${STAGEDIR}${ETCDIR}/notifications/slack @${MV} ${WRKSRC}/plugins/notifications/slack/slack.yaml \ - ${STAGEDIR}${ETCDIR}/notifications/slack/slack.yaml.sample + ${STAGEDIR}${ETCDIR}/notifications/slack.yaml.sample @${MKDIR} ${STAGEDIR}${ETCDIR}/notifications/splunk @${MV} ${WRKSRC}/plugins/notifications/splunk/splunk.yaml \ - ${STAGEDIR}${ETCDIR}/notifications/splunk/splunk.yaml.sample + ${STAGEDIR}${ETCDIR}/notifications/splunk.yaml.sample # updated by "cscli machines" at first service start @${MV} ${STAGEDIR}${ETCDIR}/local_api_credentials.yaml \ ${STAGEDIR}${ETCDIR}/local_api_credentials.yaml.sample # updated by "cscli capi" at first service start @${MV} ${STAGEDIR}${ETCDIR}/online_api_credentials.yaml \ ${STAGEDIR}${ETCDIR}/online_api_credentials.yaml.sample # # Data # @${MKDIR} ${STAGEDIR}${ETCDIR}/hub @${MKDIR} ${STAGEDIR}/var/db/crowdsec/data # - # Log rotation + # Cleanup # - @${MKDIR} ${STAGEDIR}${EXAMPLESDIR} - ${INSTALL_DATA} ${FILESDIR}/crowdsec.conf-newsyslog ${STAGEDIR}${PREFIX}/etc/newsyslog.conf.d/crowdsec.conf.sample - + @${RM} ${STAGEDIR}${ETCDIR}/crowdsec.service + @${RM} ${STAGEDIR}${ETCDIR}/dev.yaml + @${RM} ${STAGEDIR}${ETCDIR}/user.yaml + @${RMDIR} ${STAGEDIR}${ETCDIR}/notifications/email + @${RMDIR} ${STAGEDIR}${ETCDIR}/notifications/http + @${RMDIR} ${STAGEDIR}${ETCDIR}/notifications/slack + @${RMDIR} ${STAGEDIR}${ETCDIR}/notifications/splunk + .include diff --git a/security/crowdsec/distinfo b/security/crowdsec/distinfo index a87959633114..562330baea8d 100644 --- a/security/crowdsec/distinfo +++ b/security/crowdsec/distinfo @@ -1,3 +1,3 @@ -TIMESTAMP = 1642022158 -SHA256 (crowdsecurity-crowdsec-v1.2.3-v1.2.3-freebsd_GH0.tar.gz) = 9b3dd5fcc7b67cf89a1a661009a215b9a7f7a0efeb598456480e57fbd6e9bb4b -SIZE (crowdsecurity-crowdsec-v1.2.3-v1.2.3-freebsd_GH0.tar.gz) = 19122216 +TIMESTAMP = 1646686224 +SHA256 (crowdsecurity-crowdsec-v1.3.2-v1.3.2-freebsd-wip_GH0.tar.gz) = e805f8e60213fd49fa2e0fa182d6d91591dc26f378733139bd5609b5b914d5b3 +SIZE (crowdsecurity-crowdsec-v1.3.2-v1.3.2-freebsd-wip_GH0.tar.gz) = 20005916 diff --git a/security/crowdsec/files/crowdsec.conf-newsyslog b/security/crowdsec/files/crowdsec.conf-newsyslog deleted file mode 100644 index 560519c5a99f..000000000000 --- a/security/crowdsec/files/crowdsec.conf-newsyslog +++ /dev/null @@ -1,3 +0,0 @@ -# logfilename [owner:group] mode count size(kb) when flags [/pid_file] [sig_num] -/var/log/crowdsec.log root:wheel 644 10 20480 * JC /var/run/crowdsec.pid -/var/log/crowdsec_api.log root:wheel 644 10 20480 * JC /var/run/crowdsec.pid diff --git a/security/crowdsec/files/crowdsec.in b/security/crowdsec/files/crowdsec.in index 113d66aed599..a63e7ca47da9 100644 --- a/security/crowdsec/files/crowdsec.in +++ b/security/crowdsec/files/crowdsec.in @@ -1,84 +1,85 @@ #!/bin/sh # PROVIDE: crowdsec +# BEFORE: crowdsec_firewall # REQUIRE: LOGIN DAEMON NETWORKING # KEYWORD: shutdown # # Add the following lines to /etc/rc.conf.local or /etc/rc.conf # to enable this service: # # crowdsec_enable (bool): Set it to YES to enable crowdsec agent. # Default is "NO". # crowdsec_config (str): Set the agent config path. # Default is "%%PREFIX%%/etc/crowdsec/config.yaml". # crowdsec_flags (str): Set the extra flags to run agent. # Default is "" . /etc/rc.subr name=crowdsec desc="Crowdsec Agent" rcvar=crowdsec_enable load_rc_config $name : "${crowdsec_enable:=NO}" : "${crowdsec_config:=%%PREFIX%%/etc/crowdsec/config.yaml}" : "${crowdsec_flags:=}" pidfile=/var/run/${name}.pid required_files="$crowdsec_config" command="%%PREFIX%%/bin/${name}" start_cmd="${name}_start" start_precmd="${name}_precmd" configtest_cmd="${name}_configtest" extra_commands="configtest reload" crowdsec_precmd() { cs_cli() { "%%PREFIX%%/bin/cscli" -c "${crowdsec_config}" "$@" } Config() { cs_cli config show --key "Config.$1" } HUB_DIR=$(Config ConfigPaths.HubDir) if ! ls -1qA "$HUB_DIR"/* >/dev/null 2>&1; then echo "Fetching hub inventory" cs_cli hub update || : fi if [ "$(cs_cli machines list -o json)" = "[]" ]; then echo "Registering LAPI" cs_cli machines add --auto || : fi CONFIG_DIR=$(Config ConfigPaths.ConfigDir) if [ ! -s "${CONFIG_DIR}/online_api_credentials.yaml" ]; then echo "Registering CAPI" cs_cli capi register || : fi # This would work but takes 30secs to timeout while reading the metrics, because crowdsec is not running yet. # cs_cli collections inspect crowdsecurity/freebsd 2>/dev/null | grep ^installed | grep -q true || \ # cs_cli collections install crowdsecurity/freebsd || : # So we just check for the file if [ ! -e "${CONFIG_DIR}/collections/freebsd.yaml" ]; then cs_cli collections install crowdsecurity/freebsd || : fi } crowdsec_start() { /usr/sbin/daemon -f -p ${pidfile} -t "${desc}" -- \ ${command} -c "${crowdsec_config}" ${crowdsec_flags} } crowdsec_configtest() { echo "Performing sanity check on ${name} configuration." eval ${command} -c ${crowdsec_config} -t } run_rc_command "$1" diff --git a/security/crowdsec/files/patch-Makefile b/security/crowdsec/files/patch-Makefile index 840e31a44477..68ea23023ecf 100644 --- a/security/crowdsec/files/patch-Makefile +++ b/security/crowdsec/files/patch-Makefile @@ -1,26 +1,12 @@ ---- Makefile.orig 2021-12-21 21:18:22 UTC +--- Makefile.orig 2022-02-10 09:11:04 UTC +++ Makefile -@@ -44,14 +44,14 @@ BUILD_CODENAME=$(shell cat RELEASE.json | jq -r .CodeN - BUILD_TIMESTAMP=$(shell date +%F"_"%T) - BUILD_TAG?="$(shell git rev-parse HEAD)" +@@ -58,8 +58,8 @@ LD_OPTS_VARS= \ + -X github.com/crowdsecurity/crowdsec/pkg/csconfig.defaultConfigDir=$(DEFAULT_CONFIGDIR) \ + -X github.com/crowdsecurity/crowdsec/pkg/csconfig.defaultDataDir=$(DEFAULT_DATADIR) --export LD_OPTS=-ldflags "-s -w -X github.com/crowdsecurity/crowdsec/pkg/cwversion.Version=$(BUILD_VERSION) \ -+export LD_OPTS=-mod vendor -modcacherw -ldflags "-s -w -X github.com/crowdsecurity/crowdsec/pkg/cwversion.Version=$(BUILD_VERSION) \ - -X github.com/crowdsecurity/crowdsec/pkg/cwversion.System=$(SYSTEM) \ - -X github.com/crowdsecurity/crowdsec/pkg/cwversion.BuildDate=$(BUILD_TIMESTAMP) \ - -X github.com/crowdsecurity/crowdsec/pkg/cwversion.Codename=$(BUILD_CODENAME) \ - -X github.com/crowdsecurity/crowdsec/pkg/cwversion.Tag=$(BUILD_TAG) \ - -X github.com/crowdsecurity/crowdsec/pkg/cwversion.GoVersion=$(BUILD_GOVERSION)" +-export LD_OPTS=-ldflags "-s -w $(LD_OPTS_VARS)" +-export LD_OPTS_STATIC=-ldflags "-s -w $(LD_OPTS_VARS) -extldflags '-static'" ++export LD_OPTS=-mod vendor -modcacherw -ldflags "-s -w $(LD_OPTS_VARS)" ++export LD_OPTS_STATIC=-mod vendor -modcacherw -ldflags "-s -w $(LD_OPTS_VARS) -extldflags '-static'" --export LD_OPTS_STATIC=-ldflags "-s -w -X github.com/crowdsecurity/crowdsec/pkg/cwversion.Version=$(BUILD_VERSION) \ -+export LD_OPTS_STATIC=-mod vendor -modcacherw -ldflags "-s -w -X github.com/crowdsecurity/crowdsec/pkg/cwversion.Version=$(BUILD_VERSION) \ - -X github.com/crowdsecurity/crowdsec/pkg/cwversion.BuildDate=$(BUILD_TIMESTAMP) \ - -X github.com/crowdsecurity/crowdsec/pkg/cwversion.Codename=$(BUILD_CODENAME) \ - -X github.com/crowdsecurity/crowdsec/pkg/cwversion.Tag=$(BUILD_TAG) \ -@@ -176,4 +176,4 @@ check_release: - release: check_release build package - - .PHONY: --release_static: check_release static package_static -\ No newline at end of file -+release_static: check_release static package_static + RELDIR = crowdsec-$(BUILD_VERSION) diff --git a/security/crowdsec/pkg-plist b/security/crowdsec/pkg-plist index 635dcc3da591..730535931c6d 100644 --- a/security/crowdsec/pkg-plist +++ b/security/crowdsec/pkg-plist @@ -1,50 +1,49 @@ @mode 0755 bin/crowdsec bin/cscli bin/crowdsec-cli @mode 0600 @sample %%ETCDIR%%/local_api_credentials.yaml.sample @sample %%ETCDIR%%/online_api_credentials.yaml.sample @mode 0644 @sample %%ETCDIR%%/acquis.yaml.sample @sample %%ETCDIR%%/config.yaml.sample +@sample %%ETCDIR%%/console.yaml.sample @sample %%ETCDIR%%/profiles.yaml.sample @sample %%ETCDIR%%/simulation.yaml.sample -@sample %%ETCDIR%%/notifications/email/email.yaml.sample -@sample %%ETCDIR%%/notifications/http/http.yaml.sample -@sample %%ETCDIR%%/notifications/slack/slack.yaml.sample -@sample %%ETCDIR%%/notifications/splunk/splunk.yaml.sample +@sample %%ETCDIR%%/notifications/email.yaml.sample +@sample %%ETCDIR%%/notifications/http.yaml.sample +@sample %%ETCDIR%%/notifications/slack.yaml.sample +@sample %%ETCDIR%%/notifications/splunk.yaml.sample %%ETCDIR%%/patterns/aws %%ETCDIR%%/patterns/bacula %%ETCDIR%%/patterns/bro %%ETCDIR%%/patterns/cowrie_honeypot %%ETCDIR%%/patterns/exim %%ETCDIR%%/patterns/firewalls %%ETCDIR%%/patterns/haproxy %%ETCDIR%%/patterns/java %%ETCDIR%%/patterns/junos %%ETCDIR%%/patterns/linux-syslog %%ETCDIR%%/patterns/mcollective %%ETCDIR%%/patterns/modsecurity %%ETCDIR%%/patterns/mongodb %%ETCDIR%%/patterns/mysql %%ETCDIR%%/patterns/nagios %%ETCDIR%%/patterns/nginx %%ETCDIR%%/patterns/paths %%ETCDIR%%/patterns/postgresql %%ETCDIR%%/patterns/rails %%ETCDIR%%/patterns/redis %%ETCDIR%%/patterns/ruby %%ETCDIR%%/patterns/smb %%ETCDIR%%/patterns/ssh %%ETCDIR%%/patterns/tcpdump -@sample etc/newsyslog.conf.d/crowdsec.conf.sample @mode 0755 lib/crowdsec/plugins/notification-email lib/crowdsec/plugins/notification-http lib/crowdsec/plugins/notification-slack lib/crowdsec/plugins/notification-splunk @dir %%ETCDIR%%/hub @dir /var/db/crowdsec/data @dir /var/db/crowdsec -@dir etc/newsyslog.conf.d