diff --git a/security/crowdsec/Makefile b/security/crowdsec/Makefile index e32e54821012..3b0c6efe05c1 100644 --- a/security/crowdsec/Makefile +++ b/security/crowdsec/Makefile @@ -1,168 +1,173 @@ PORTNAME= crowdsec DISTVERSIONPREFIX= v -DISTVERSION= 1.5.5 -PORTREVISION= 1 +DISTVERSION= 1.6.0 CATEGORIES= security MAINTAINER= marco@crowdsec.net COMMENT= CrowdSec lightweight and collaborative security engine WWW= https://github.com/crowdsecurity/crowdsec LICENSE= MIT LICENSE_FILE= ${WRKSRC}/LICENSE LIB_DEPENDS= libabsl_base.so:devel/abseil \ libre2.so:devel/re2 USES= go:1.21,modules pkgconfig -_COMMIT= d2d788c5 +_COMMIT= 4b8e6cd7 _BUILD_DATE= $$(date -u "+%F_%T") USE_RC_SUBR= crowdsec GO_MODULE= github.com/crowdsecurity/crowdsec -GO_TARGET= ./cmd/crowdsec ./cmd/crowdsec-cli ./cmd/notification-email ./cmd/notification-http ./cmd/notification-sentinel ./cmd/notification-slack ./cmd/notification-splunk +GO_TARGET= ./cmd/crowdsec \ + ./cmd/crowdsec-cli \ + ./cmd/notification-email \ + ./cmd/notification-http \ + ./cmd/notification-sentinel \ + ./cmd/notification-slack \ + ./cmd/notification-splunk GO_BUILDFLAGS= -v -trimpath -tags netgo,osusergo,sqlite_omit_load_extension,re2_cgo \ -ldflags="\ -a -s -w \ -X github.com/crowdsecurity/go-cs-lib/version.Version=${DISTVERSIONPREFIX}${DISTVERSION}-freebsd \ -X github.com/crowdsecurity/go-cs-lib/version.BuildDate=${_BUILD_DATE} \ -X github.com/crowdsecurity/go-cs-lib/version.Tag=${_COMMIT} \ - -X $(GO_MODULE)/pkg/cwversion.Codename=alphaga \ - -X $(GO_MODULE)/pkg/csconfig.defaultConfigDir=${PREFIX}/etc/crowdsec \ - -X $(GO_MODULE)/pkg/csconfig.defaultDataDir=/var/db/crowdsec/data \ - -X $(GO_MODULE)/pkg/cwversion.Libre2=C++" + -X ${GO_MODULE}/pkg/cwversion.Codename=alphaga \ + -X ${GO_MODULE}/pkg/csconfig.defaultConfigDir=${PREFIX}/etc/crowdsec \ + -X ${GO_MODULE}/pkg/csconfig.defaultDataDir=/var/db/crowdsec/data \ + -X ${GO_MODULE}/pkg/cwversion.Libre2=C++" SUB_FILES= pkg-deinstall pkg-install pkg-message crowdsec.cron upgrade-hub OPTIONS_DEFINE= FIREWALL_BOUNCER OPTIONS_DEFAULT= FIREWALL_BOUNCER_DESC= Depend on security/crowdsec-firewall-bouncer FIREWALL_BOUNCER_RUN_DEPENDS= crowdsec-firewall-bouncer>=0.0.27:security/crowdsec-firewall-bouncer 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}/config/config.yaml @${REINPLACE_CMD} 's,/var/lib/,/var/db/,g' \ ${WRKSRC}/config/config.yaml do-install: # # Binaries # ${INSTALL_PROGRAM} ${WRKDIR}/bin/crowdsec ${STAGE_BIN}/ ${INSTALL_PROGRAM} ${WRKDIR}/bin/crowdsec-cli ${STAGE_BIN}/cscli # keep this around for compatibility ${LN} -s cscli ${STAGE_BIN}/crowdsec-cli @${MKDIR} ${STAGE_PLUGINS} ${INSTALL_PROGRAM} ${WRKDIR}/bin/notification-email ${STAGE_PLUGINS}/ ${INSTALL_PROGRAM} ${WRKDIR}/bin/notification-http ${STAGE_PLUGINS}/ ${INSTALL_PROGRAM} ${WRKDIR}/bin/notification-sentinel ${STAGE_PLUGINS}/ ${INSTALL_PROGRAM} ${WRKDIR}/bin/notification-slack ${STAGE_PLUGINS}/ ${INSTALL_PROGRAM} ${WRKDIR}/bin/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}/cmd/notification-email/email.yaml \ ${STAGEDIR}${ETCDIR}/notifications/email.yaml.sample @${MKDIR} ${STAGEDIR}${ETCDIR}/notifications/http @${MV} ${WRKSRC}/cmd/notification-http/http.yaml \ ${STAGEDIR}${ETCDIR}/notifications/http.yaml.sample @${MKDIR} ${STAGEDIR}${ETCDIR}/notifications/sentinel @${MV} ${WRKSRC}/cmd/notification-sentinel/sentinel.yaml \ ${STAGEDIR}${ETCDIR}/notifications/sentinel.yaml.sample @${MKDIR} ${STAGEDIR}${ETCDIR}/notifications/slack @${MV} ${WRKSRC}/cmd/notification-slack/slack.yaml \ ${STAGEDIR}${ETCDIR}/notifications/slack.yaml.sample @${MKDIR} ${STAGEDIR}${ETCDIR}/notifications/splunk @${MV} ${WRKSRC}/cmd/notification-splunk/splunk.yaml \ ${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 # # Cron # @${MKDIR} ${STAGEDIR}${PREFIX}/libexec/crowdsec ${INSTALL_DATA} ${WRKDIR}/upgrade-hub \ ${STAGEDIR}${PREFIX}/libexec/crowdsec/upgrade-hub # # Cleanup # @${RM} ${STAGEDIR}${ETCDIR}/acquis_win.yaml @${RM} ${STAGEDIR}${ETCDIR}/config_win_no_lapi.yaml @${RM} ${STAGEDIR}${ETCDIR}/config_win.yaml @${RM} ${STAGEDIR}${ETCDIR}/crowdsec.cron.daily @${RM} ${STAGEDIR}${ETCDIR}/crowdsec.service + @${RM} ${STAGEDIR}${ETCDIR}/context.yaml + @${RM} ${STAGEDIR}${ETCDIR}/detect.yaml @${RM} ${STAGEDIR}${ETCDIR}/dev.yaml @${RM} ${STAGEDIR}${ETCDIR}/user.yaml - @${RM} ${STAGEDIR}${ETCDIR}/detect.yaml - @${RM} ${STAGEDIR}${ETCDIR}/context.yaml @${RMDIR} ${STAGEDIR}${ETCDIR}/notifications/email @${RMDIR} ${STAGEDIR}${ETCDIR}/notifications/http @${RMDIR} ${STAGEDIR}${ETCDIR}/notifications/sentinel @${RMDIR} ${STAGEDIR}${ETCDIR}/notifications/slack @${RMDIR} ${STAGEDIR}${ETCDIR}/notifications/splunk post-install: @${MKDIR} ${STAGEDIR}${PREFIX}/etc/cron.d ${INSTALL_DATA} ${WRKDIR}/crowdsec.cron ${STAGEDIR}${PREFIX}/etc/cron.d/crowdsec .include diff --git a/security/crowdsec/distinfo b/security/crowdsec/distinfo index 504d0e7fa0c5..0a0ed29eef9c 100644 --- a/security/crowdsec/distinfo +++ b/security/crowdsec/distinfo @@ -1,5 +1,5 @@ -TIMESTAMP = 1698136810 -SHA256 (go/security_crowdsec/crowdsec-v1.5.5/v1.5.5.mod) = a3047c2f98e4c26c4d8dff645893e3a19ff6e10ef00bc2dafcbe68a3e4415d19 -SIZE (go/security_crowdsec/crowdsec-v1.5.5/v1.5.5.mod) = 9647 -SHA256 (go/security_crowdsec/crowdsec-v1.5.5/v1.5.5.zip) = 0013a4e3201fe3d71a62b13df09fb32a05906ce29029a7257be8cb850bc41ed5 -SIZE (go/security_crowdsec/crowdsec-v1.5.5/v1.5.5.zip) = 1345499 +TIMESTAMP = 1706093904 +SHA256 (go/security_crowdsec/crowdsec-v1.6.0/v1.6.0.mod) = bf62cad10105ba50e3e0778651341cb7eca13ff5785c79a206ca8a5d42b90fed +SIZE (go/security_crowdsec/crowdsec-v1.6.0/v1.6.0.mod) = 10099 +SHA256 (go/security_crowdsec/crowdsec-v1.6.0/v1.6.0.zip) = c7cb4870cbcc848cf4c36161021930bc77f490f2701bcebdace6ad27a400a73f +SIZE (go/security_crowdsec/crowdsec-v1.6.0/v1.6.0.zip) = 1440975 diff --git a/security/crowdsec/files/crowdsec.in b/security/crowdsec/files/crowdsec.in index e84eeacf57e4..eb72069392a8 100644 --- a/security/crowdsec/files/crowdsec.in +++ b/security/crowdsec/files/crowdsec.in @@ -1,125 +1,125 @@ #!/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_machine_name (str): Name for the crowdsec instance when it's running its own lapi. # Default is "localhost". # crowdsec_flags (str): Set the extra flags to run the 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_machine_name:=localhost}" : "${crowdsec_flags:=}" pidfile=/var/run/${name}.pid required_files="$crowdsec_config" command="%%PREFIX%%/bin/${name}" start_cmd="${name}_start" stop_cmd="${name}_stop" 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 CONFIG_DIR=$(Config ConfigPaths.ConfigDir) # Is the LAPI enabled on this node? if [ "$(cs_cli config show --key Config.API.Server.Enable)" != "false" ]; then # There are no machines, we create the main one if [ "$(cs_cli machines list -o json)" = "[]" ]; then echo "Registering LAPI" - cs_cli machines add "${crowdsec_machine_name}" --auto || : + cs_cli machines add "${crowdsec_machine_name}" --auto --force --error || : fi # Register to the central server to receive the community blocklist and more if [ ! -s "${CONFIG_DIR}/online_api_credentials.yaml" ]; then echo "Registering CAPI" cs_cli capi register || : fi 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_stop() { if [ ! -f "$pidfile" ]; then echo "${name} is not running." return fi pid=$(cat "$pidfile") if kill -0 "$pid" >/dev/null 2>&1; then echo "Stopping ${name}." kill -s TERM "$pid" >/dev/null 2>&1 # shellcheck disable=SC2034 for i in $(seq 1 20); do sleep 1 if ! kill -0 "$pid" >/dev/null 2>&1; then rm -f "$pidfile" return fi done echo "Timeout, terminating ${name} with SIGKILL." kill -s KILL "$pid" >/dev/null 2>&1 rm -f "$pidfile" else echo "${name} is not running." 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." if "$command" -c "$crowdsec_config" -t -error; then echo "Configuration test OK" fi } run_rc_command "$1" diff --git a/security/crowdsec/files/pkg-install.in b/security/crowdsec/files/pkg-install.in index 9c13af959b40..74bccb12c1ab 100644 --- a/security/crowdsec/files/pkg-install.in +++ b/security/crowdsec/files/pkg-install.in @@ -1,10 +1,11 @@ #!/bin/sh case $2 in "POST-INSTALL") + cscli hub update -o human --error > /dev/null if [ -e /var/run/crowdsec.running ]; then service crowdsec start rm -f /var/run/crowdsec.running fi ;; esac diff --git a/security/crowdsec/files/upgrade-hub.in b/security/crowdsec/files/upgrade-hub.in index 27faaf3f598b..2364169f4425 100644 --- a/security/crowdsec/files/upgrade-hub.in +++ b/security/crowdsec/files/upgrade-hub.in @@ -1,17 +1,17 @@ #!/bin/sh test -x /usr/local/bin/cscli || exit 0 # favor the opnsense plugin's cron if it's there test -e /usr/local/etc/cron.d/oscrowdsec.cron && exit 0 /usr/local/bin/cscli --error -o human hub update upgraded=$(/usr/local/bin/cscli --error -o human hub upgrade) if [ -n "$upgraded" ]; then # splay initial metrics push sleep "$(jot -r 1 1 60)" - service crowdsec onestatus && service crowdsec reload + service crowdsec onestatus && service crowdsec onereload fi exit 0