View | Details | Raw Unified | Return to bug 260263
Collapse All | Expand All

(-)b/security/crowdsec/Makefile (-15 / +92 lines)
Lines 1-45 Link Here
1
PORTNAME=	crowdsec
1
PORTNAME=	crowdsec
2
PORTVERSION=	1.1.1
2
PORTVERSION=	1.2.1	# NOTE: change BUILD_VERSION and BUILD_TAG as well
3
DISTVERSIONPREFIX=	v
3
DISTVERSIONPREFIX=	v
4
CATEGORIES=	security
4
CATEGORIES=	security
5
5
6
MAINTAINER=	sbz@FreeBSD.org
6
MAINTAINER=	marco@crowdsec.net
7
COMMENT=	Crowdsec lightweight and collaborative security engine
7
COMMENT=	CrowdSec lightweight and collaborative security engine
8
8
9
LICENSE=	MIT
9
LICENSE=	MIT
10
LICENSE_FILE=	${WRKSRC}/LICENSE
10
LICENSE_FILE=	${WRKSRC}/LICENSE
11
11
12
USES=		go:modules
12
BUILD_DEPENDS=	git:devel/git@lite \
13
		go:lang/go \
14
		jq:textproc/jq
15
16
USES=		gmake
17
18
USE_GITHUB=	yes
19
GH_ACCOUNT=	crowdsecurity
20
GH_PROJECT=	crowdsec
21
#GH_TAGNAME is automatically set from DISTVERSION
13
22
14
USE_RC_SUBR=	crowdsec
23
USE_RC_SUBR=	crowdsec
15
24
16
GO_MODULE=	github.com/crowdsecurity/crowdsec
25
USE_RC_SUBR=	crowdsec
17
26
18
GO_BUILDFLAGS=	-ldflags "-s -w \
27
SUB_FILES=	pkg-message \
19
		-X github.com/crowdsecurity/crowdsec/pkg/cwversion.Version=v${PORTVERSION} \
28
		pkg-deinstall
20
		-X github.com/crowdsecurity/crowdsec/pkg/cwversion.System=freebsd \
21
		-X github.com/crowdsecurity/crowdsec/pkg/cwversion.BuildDate=`date -u '+%Y-%m-%d_%I:%M:%S%p'`"
22
29
23
GO_TARGET=	./cmd/crowdsec \
30
# BUILD_VERSION=$(git describe --tags $(git rev-list --tags --max-count=1))
24
		./cmd/crowdsec-cli
31
# BUILD_TAG=$(git rev-parse HEAD)
32
MAKE_ENV=	BUILD_VERSION="v1.2.1" \
33
		BUILD_TAG="dd03d073558e380c283afe66942f537c3da647ff"
25
34
26
SUB_FILES=	pkg-message
35
PLUGIN_DIR=	${PREFIX}/lib/crowdsec/plugins
36
STAGE_PLUGINS=	${STAGEDIR}${PLUGIN_DIR}
37
STAGE_BIN=	${STAGEDIR}${PREFIX}/bin
27
38
28
post-patch:
39
post-patch:
29
	@${REINPLACE_CMD} 's,/etc/crowdsec/,${ETCDIR}/,g' \
40
	@${REINPLACE_CMD} 's,/etc/crowdsec/,${ETCDIR}/,g' \
30
		${WRKSRC}/pkg/csconfig/config.go \
41
		${WRKSRC}/pkg/csconfig/config.go \
42
		${WRKSRC}/pkg/cstest/hubtest_item.go \
31
		${WRKSRC}/cmd/crowdsec-cli/machines.go \
43
		${WRKSRC}/cmd/crowdsec-cli/machines.go \
32
		${WRKSRC}/cmd/crowdsec-cli/main.go \
44
		${WRKSRC}/cmd/crowdsec-cli/main.go \
33
		${WRKSRC}/cmd/crowdsec/main.go
45
		${WRKSRC}/cmd/crowdsec/main.go \
46
		${WRKSRC}/config/config.yaml \
47
		${WRKSRC}/config/profiles.yaml
48
49
	@${REINPLACE_CMD} 's,/var/lib/,/var/db/,g' \
50
		${WRKSRC}/pkg/csconfig/config.go \
51
		${WRKSRC}/pkg/metabase/database.go \
52
		${WRKSRC}/config/config.yaml \
53
		${WRKSRC}/config/profiles.yaml
34
54
35
do-install:
55
do-install:
56
	#
57
	# Binaries
58
	#
59
60
	${INSTALL_PROGRAM} ${WRKSRC}/cmd/crowdsec/crowdsec ${STAGE_BIN}/
61
	${INSTALL_PROGRAM} ${WRKSRC}/cmd/crowdsec-cli/cscli ${STAGE_BIN}/
62
	${LN} -s cscli ${STAGE_BIN}/crowdsec-cli
63
64
	@${MKDIR} ${STAGE_PLUGINS}
65
	${INSTALL_PROGRAM} ${WRKSRC}/plugins/notifications/http/notification-http ${STAGE_PLUGINS}/
66
	${INSTALL_PROGRAM} ${WRKSRC}/plugins/notifications/slack/notification-slack ${STAGE_PLUGINS}/
67
	${INSTALL_PROGRAM} ${WRKSRC}/plugins/notifications/splunk/notification-splunk ${STAGE_PLUGINS}/
68
69
	#
70
	# Configuration
71
	#
72
36
	@${MKDIR} ${STAGEDIR}${ETCDIR}
73
	@${MKDIR} ${STAGEDIR}${ETCDIR}
37
	@(cd ${WRKSRC}/config && ${COPYTREE_SHARE} . ${STAGEDIR}${ETCDIR})
74
	@(cd ${WRKSRC}/config && ${COPYTREE_SHARE} . ${STAGEDIR}${ETCDIR})
38
75
76
	@${MV} ${STAGEDIR}${ETCDIR}/acquis.yaml \
77
		${STAGEDIR}${ETCDIR}/acquis.yaml.sample
78
39
	@${MV} ${STAGEDIR}${ETCDIR}/config.yaml \
79
	@${MV} ${STAGEDIR}${ETCDIR}/config.yaml \
40
		${STAGEDIR}${ETCDIR}/config.yaml.sample
80
		${STAGEDIR}${ETCDIR}/config.yaml.sample
41
81
42
	${INSTALL_PROGRAM} ${WRKDIR}/bin/crowdsec ${STAGEDIR}${PREFIX}/bin
82
	@${MV} ${STAGEDIR}${ETCDIR}/profiles.yaml \
43
	${INSTALL_PROGRAM} ${WRKDIR}/bin/crowdsec-cli ${STAGEDIR}${PREFIX}/bin
83
		${STAGEDIR}${ETCDIR}/profiles.yaml.sample
84
85
	# managed by "cscli simulation"
86
	@${MV} ${STAGEDIR}${ETCDIR}/simulation.yaml \
87
		${STAGEDIR}${ETCDIR}/simulation.yaml.sample
88
89
	#
90
	# Plugin configuration
91
	#
92
93
	@${MKDIR} ${STAGEDIR}${ETCDIR}/notifications
94
95
	@${MKDIR} ${STAGEDIR}${ETCDIR}/notifications/http
96
	@${MV} ${WRKSRC}/plugins/notifications/http/http.yaml \
97
		${STAGEDIR}${ETCDIR}/notifications/http/http.yaml.sample
98
99
	@${MKDIR} ${STAGEDIR}${ETCDIR}/notifications/slack
100
	@${MV} ${WRKSRC}/plugins/notifications/slack/slack.yaml \
101
		${STAGEDIR}${ETCDIR}/notifications/slack/slack.yaml.sample
102
103
	@${MKDIR} ${STAGEDIR}${ETCDIR}/notifications/splunk
104
	@${MV} ${WRKSRC}/plugins/notifications/splunk/splunk.yaml \
105
		${STAGEDIR}${ETCDIR}/notifications/splunk/splunk.yaml.sample
106
107
	# updated by "cscli machines" at first service start
108
	@${MV} ${STAGEDIR}${ETCDIR}/local_api_credentials.yaml \
109
		${STAGEDIR}${ETCDIR}/local_api_credentials.yaml.sample
110
111
	# updated by "cscli capi" at first service start
112
	@${MV} ${STAGEDIR}${ETCDIR}/online_api_credentials.yaml \
113
		${STAGEDIR}${ETCDIR}/online_api_credentials.yaml.sample
114
115
	#
116
	# Data
117
	#
118
119
	@${MKDIR} ${STAGEDIR}${ETCDIR}/hub
120
	@${MKDIR} ${STAGEDIR}/var/db/crowdsec/data
44
121
45
.include <bsd.port.mk>
122
.include <bsd.port.mk>
(-)b/security/crowdsec/distinfo (-5 / +3 lines)
Lines 1-5 Link Here
1
TIMESTAMP = 1626257804
1
TIMESTAMP = 1637702390
2
SHA256 (go/security_crowdsec/crowdsec-v1.1.1/v1.1.1.mod) = f764f7d850f1e2306f6764e534ace7261f7dc99f3b4884c2b0f617cb791b35de
2
SHA256 (crowdsecurity-crowdsec-v1.2.1_GH0.tar.gz) = e3a9bbb70b1995a83c5001d06dbbcb5f59d43e4d7c18b60548f305a62d2dd6a3
3
SIZE (go/security_crowdsec/crowdsec-v1.1.1/v1.1.1.mod) = 3295
3
SIZE (crowdsecurity-crowdsec-v1.2.1_GH0.tar.gz) = 659398
4
SHA256 (go/security_crowdsec/crowdsec-v1.1.1/v1.1.1.zip) = f7e63641a67392d57412ab1ff86a26ae4deeb9fc8460542f6258f7c9f56238e9
5
SIZE (go/security_crowdsec/crowdsec-v1.1.1/v1.1.1.zip) = 640252
(-)b/security/crowdsec/files/crowdsec.in (-13 / +35 lines)
Lines 22-30 rcvar=crowdsec_enable Link Here
22
22
23
load_rc_config $name
23
load_rc_config $name
24
24
25
: ${crowdsec_enable:="NO"}
25
: "${crowdsec_enable:=NO}"
26
: ${crowdsec_config:="%%PREFIX%%/etc/crowdsec/config.yaml"}
26
: "${crowdsec_config:=%%PREFIX%%/etc/crowdsec/config.yaml}"
27
: ${crowdsec_flags:=""}
27
: "${crowdsec_flags:=}"
28
28
29
pidfile=/var/run/${name}.pid
29
pidfile=/var/run/${name}.pid
30
required_files="$crowdsec_config"
30
required_files="$crowdsec_config"
Lines 35-61 configtest_cmd="${name}_configtest" Link Here
35
extra_commands="configtest reload"
35
extra_commands="configtest reload"
36
36
37
crowdsec_precmd() {
37
crowdsec_precmd() {
38
    if [ ! -d %%PREFIX%%/etc/crowdsec/hub ]; then
38
    cs_cli() {
39
        %%PREFIX%%/bin/crowdsec-cli hub update || :
39
        "%%PREFIX%%/bin/cscli" -c "${crowdsec_config}" "$@"
40
    }
41
    Config() {
42
        cs_cli config show --key "Config.$1"
43
    }
44
45
    HUB_DIR=$(Config ConfigPaths.HubDir)
46
    if ! ls -1qA "$HUB_DIR/*" >/dev/null 2>&1; then
47
        echo "Fetching hub inventory"
48
        cs_cli hub update || :
49
    fi
50
51
    if [ -z "$(cs_cli machines list -o raw)" ]; then
52
        echo "Registering LAPI"
53
        cs_cli machines add --auto || :
40
    fi
54
    fi
41
    if [ -z "`%%PREFIX%%/bin/crowdsec-cli machines list -o raw`" ]; then
55
42
        %%PREFIX%%/bin/crowdsec-cli machines add --auto || :
56
    CONFIG_DIR=$(Config ConfigPaths.ConfigDir)
57
    if [ ! -s "${CONFIG_DIR}/online_api_credentials.yaml" ]; then
58
        echo "Registering CAPI"
59
        cs_cli capi register || :
43
    fi
60
    fi
44
    if [ ! -s %%PREFIX%%/etc/crowdsec/online_api_credentials.yaml ]; then
61
45
        %%PREFIX%%/bin/crowdsec-cli capi register || :
62
    cs_cli collections inspect crowdsecurity/linux >/dev/null || cs_cli collections install crowdsecurity/linux || :
63
64
    DATA_DIR=$(Config ConfigPaths.DataDir)
65
    if [ ! -f "${DATA_DIR}/GeoLite2-City.mmdb" ]; then
66
        echo "Installing GeoIP enricher"
67
        cs_cli parsers install crowdsecurity/geoip-enrich || :
46
    fi
68
    fi
47
}
69
}
48
70
49
crowdsec_start()
71
crowdsec_start()
50
{
72
{
51
	/usr/sbin/daemon -f -p ${pidfile} -t "${desc}" \
73
    /usr/sbin/daemon -f -p ${pidfile} -t "${desc}" -- \
52
		${command} -c ${crowdsec_config} ${crowdsec_flags}
74
        ${command} -c ${crowdsec_config} ${crowdsec_flags}
53
}
75
}
54
76
55
crowdsec_configtest()
77
crowdsec_configtest()
56
{
78
{
57
	echo "Performing sanity check on ${name} configuration."
79
    echo "Performing sanity check on ${name} configuration."
58
	eval ${command} -c ${crowdsec_config} -t
80
        eval ${command} -c ${crowdsec_config} -t
59
}
81
}
60
82
61
run_rc_command "$1"
83
run_rc_command "$1"
(-)b/security/crowdsec/files/patch-Makefile (+11 lines)
Added Link Here
1
--- Makefile.orig	2021-11-17 09:15:38 UTC
2
+++ Makefile
3
@@ -42,7 +42,7 @@ BUILD_VERSION?="$(shell git describe --tags `git rev-l
4
 BUILD_GOVERSION="$(shell go version | cut -d " " -f3 | sed -E 's/[go]+//g')"
5
 BUILD_CODENAME=$(shell cat RELEASE.json | jq -r .CodeName)
6
 BUILD_TIMESTAMP=$(shell date +%F"_"%T)
7
-BUILD_TAG="$(shell git rev-parse HEAD)"
8
+BUILD_TAG?="$(shell git rev-parse HEAD)"
9
 
10
 export LD_OPTS=-ldflags "-s -w -X github.com/crowdsecurity/crowdsec/pkg/cwversion.Version=$(BUILD_VERSION) \
11
 -X github.com/crowdsecurity/crowdsec/pkg/cwversion.System=$(SYSTEM) \
(-)b/security/crowdsec/files/pkg-deinstall.in (+8 lines)
Added Link Here
1
#!/bin/sh
2
3
case $2 in
4
       DEINSTALL)
5
               service crowdsec stop || :
6
               ;;
7
esac
8
(-)b/security/crowdsec/files/pkg-message.in (-2 / +9 lines)
Lines 4-13 Link Here
4
4
5
crowdsec is installed.
5
crowdsec is installed.
6
6
7
You need to edit the agent config file %%ETCDIR%%/crowdsec.yaml and
7
You need to check/edit the following files in %%ETCDIR%% as described in https://doc.crowdsec.net/docs/configuration/crowdsec_configuration
8
enable rc via sysrc.
8
9
 - config.yaml: main configuration
10
 - acquis.yaml: where to find logs to parse (this port does not include automatic discovery of the running services)
11
 - profiles.yaml: remediation policies (ban, duration, etc)
12
13
Then you can enable the daemon via sysrc and run it.
9
14
10
# sysrc crowdsec_enable="YES"
15
# sysrc crowdsec_enable="YES"
16
crowdsec_enable: NO -> YES
17
# service crowdsec start
11
EOM
18
EOM
12
}
19
}
13
]
20
]
(-)b/security/crowdsec/pkg-plist (-11 / +20 lines)
Lines 1-12 Link Here
1
@sample %%ETCDIR%%/config.yaml.sample
1
@mode 0755
2
bin/crowdsec
2
bin/crowdsec
3
bin/cscli
3
bin/crowdsec-cli
4
bin/crowdsec-cli
4
%%ETCDIR%%/acquis.yaml
5
@mode 0600
5
%%ETCDIR%%/crowdsec.service
6
@sample %%ETCDIR%%/local_api_credentials.yaml.sample
6
%%ETCDIR%%/crowdsec_pull
7
@sample %%ETCDIR%%/online_api_credentials.yaml.sample
7
%%ETCDIR%%/dev.yaml
8
@mode 0644
8
%%ETCDIR%%/local_api_credentials.yaml
9
@sample %%ETCDIR%%/acquis.yaml.sample
9
%%ETCDIR%%/online_api_credentials.yaml
10
@sample %%ETCDIR%%/config.yaml.sample
11
@sample %%ETCDIR%%/profiles.yaml.sample
12
@sample %%ETCDIR%%/simulation.yaml.sample
13
@sample %%ETCDIR%%/notifications/http/http.yaml.sample
14
@sample %%ETCDIR%%/notifications/slack/slack.yaml.sample
15
@sample %%ETCDIR%%/notifications/splunk/splunk.yaml.sample
10
%%ETCDIR%%/patterns/aws
16
%%ETCDIR%%/patterns/aws
11
%%ETCDIR%%/patterns/bacula
17
%%ETCDIR%%/patterns/bacula
12
%%ETCDIR%%/patterns/bro
18
%%ETCDIR%%/patterns/bro
Lines 31-36 bin/crowdsec-cli Link Here
31
%%ETCDIR%%/patterns/smb
37
%%ETCDIR%%/patterns/smb
32
%%ETCDIR%%/patterns/ssh
38
%%ETCDIR%%/patterns/ssh
33
%%ETCDIR%%/patterns/tcpdump
39
%%ETCDIR%%/patterns/tcpdump
34
%%ETCDIR%%/profiles.yaml
40
@mode 0755
35
%%ETCDIR%%/simulation.yaml
41
lib/crowdsec/plugins/notification-http
36
%%ETCDIR%%/user.yaml
42
lib/crowdsec/plugins/notification-slack
43
lib/crowdsec/plugins/notification-splunk
44
@dir %%ETCDIR%%/hub
45
@dir /var/db/crowdsec/data
46
@dir /var/db/crowdsec
37
- 

Return to bug 260263