summaryrefslogtreecommitdiff
path: root/security/wazuh-manager/Makefile
blob: 0a7563ed443f7258d4c86b68fa98578e1ee53c11 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
PORTNAME=	wazuh
DISTVERSIONPREFIX=	v
DISTVERSION=	4.9.2
CATEGORIES=	security
MASTER_SITES=	https://packages.wazuh.com/deps/30/libraries/sources/:wazuh_sources \
		LOCAL/acm/${PORTNAME}/:wazuh_cache
PKGNAMESUFFIX=	-manager
DISTFILES=	${EXTERNAL_DISTFILES} \
		${PORTNAME}-cache-any-${DISTVERSION}${EXTRACT_SUFX}:wazuh_cache \
		${PORTNAME}-python-${DISTVERSION}${EXTRACT_SUFX}:wazuh_cache
DIST_SUBDIR=	${PORTNAME}-${DISTVERSION}
EXTRACT_ONLY=	${DISTNAME}${EXTRACT_SUFX}

MAINTAINER=	acm@FreeBSD.org
COMMENT=	Security tool to monitor and check logs and intrusions (manager)
WWW=		https://wazuh.com/

LICENSE=	GPLv2
LICENSE_FILE=	${WRKSRC}/LICENSE

ONLY_FOR_ARCHS=	aarch64 amd64

BUILD_DEPENDS=	cmake:devel/cmake-core \
		autoconf>=2.71:devel/autoconf \
		bash>0:shells/bash
LIB_DEPENDS+=	libcurl.so:ftp/curl \
		libgdbm.so:databases/gdbm \
		libnghttp2.so:www/libnghttp2 \
		libffi.so:devel/libffi \
		libarrow.so:databases/arrow \
		libepoll-shim.so:devel/libepoll-shim
RUN_DEPENDS=	bash>0:shells/bash

USES=		cpe gmake perl5 python:3.11 readline shebangfix sqlite:3 uidfix

USE_GITHUB=	yes
GH_TUPLE=	alonsobsd:wazuh-freebsd:${WAZUH_EXTRAFILE_TAGNAME}:wazuh

USE_RC_SUBR=	${PORTNAME}${PKGNAMESUFFIX}

MAKE_ARGS+=	TARGET=server INSTALLDIR=${WAZUHPREFIX} INSTALL_SHARED="${INSTALL_LIB}" PYTHON_SOURCE=yes OPTIMIZE_CPYTHON=no

WAZUH_CACHEFILE=	${PORTNAME}-cache-any-${DISTVERSION}${EXTRACT_SUFX}
WAZUH_EXTRAFILE=	alonsobsd-${PORTNAME}-freebsd-${WAZUH_EXTRAFILE_TAGNAME}_GH0${EXTRACT_SUFX}
WAZUH_EXTRAFILE_TAGNAME=cd0051b

EXTERNAL_DISTFILES=	audit-userspace.tar.gz:wazuh_sources \
			benchmark.tar.gz:wazuh_sources \
			bzip2.tar.gz:wazuh_sources \
			cJSON.tar.gz:wazuh_sources \
			cpp-httplib.tar.gz:wazuh_sources \
			cpython.tar.gz:wazuh_cache \
			curl.tar.gz:wazuh_sources \
			flatbuffers.tar.gz:wazuh_sources \
			googletest.tar.gz:wazuh_sources \
			http-request.tar.gz:wazuh_cache \
			jemalloc.tar.gz:wazuh_sources \
			libarchive.tar.gz:wazuh_sources \
			libdb.tar.gz:wazuh_sources \
			libffi.tar.gz:wazuh_sources \
			libpcre2.tar.gz:wazuh_sources \
			libplist.tar.gz:wazuh_sources	\
			libyaml.tar.gz:wazuh_sources \
			lua.tar.gz:wazuh_sources \
			lzma.tar.gz:wazuh_sources \
			msgpack.tar.gz:wazuh_sources \
			nlohmann.tar.gz:wazuh_sources \
			openssl.tar.gz:wazuh_sources \
			popt.tar.gz:wazuh_sources \
			procps.tar.gz:wazuh_sources \
			rocksdb.tar.gz:wazuh_sources \
			sqlite.tar.gz:wazuh_sources \
			zlib.tar.gz:wazuh_sources

OPTIONS_DEFINE=	INOTIFY PRELUDE ZEROMQ
OPTIONS_GROUP_DATABASE=	MYSQL PGSQL
OPTIONS_GROUP=		DATABASE

INOTIFY_LIB_DEPENDS=	libinotify.so:devel/libinotify
PRELUDE_LIB_DEPENDS=	libprelude.so:security/libprelude
ZEROMQ_LIB_DEPENDS=	libczmq.so:net/czmq

INOTIFY_DESC=	Kevent based real time monitoring
PRELUDE_DESC=	Sensor support from Prelude SIEM
ZEROMQ_DESC=	ZeroMQ support

ZEROMQ_MAKE_ENV=	USE_ZEROMQ=yes
PRELUDE_MAKE_ENV=	USE_PRELUDE=yes
INOTIFY_MAKE_ENV=	USE_INOTIFY=yes
INOTIFY_USES=	pkgconfig
PGSQL_MAKE_ARGS=DATABASE=pgsql
PGSQL_USES=	pgsql
MYSQL_MAKE_ARGS=DATABASE=mysql
MYSQL_USES=	mysql

WAZUH_USER=	wazuh
WAZUH_GROUP=	wazuh
USERS=		${WAZUH_USER}
GROUPS=		${WAZUH_GROUP}

SUB_FILES=	pkg-message
CONFLICTS=	ossec-* wazuh-agent

WZBIN_FILES=	agent_control wazuh-logcollector wazuh-execd  manage_agents wazuh-modulesd \
		wazuh-agentlessd wazuh-analysisd wazuh-monitord wazuh-reportd wazuh-maild \
		wazuh-logtest-legacy wazuh-csyslogd wazuh-dbd verify-agent-conf clear_stats \
		wazuh-regex wazuh-integratord wazuh-db wazuh-remoted wazuh-authd wazuh-keystore

WZARBIN_FILES=	default-firewall-drop pf npf ipfw firewalld-drop disable-account \
		host-deny ip-customblock restart-wazuh route-null kaspersky wazuh-slack

WZSHEBANG_FILES=chardetect connexion cygdb cython cythonize f2py fixup_pubsub_v1_keywords.py \
		futurize httpx jp.py jsonschema normalizer openapi-spec-validator pasteurize \
		pyrsa-decrypt pyrsa-encrypt pyrsa-keygen pyrsa-priv2pub pyrsa-sign \
		pyrsa-verify rstpep2html.py rst2s5.py rst2xetex.py rst2man.py rst2odt.py \
		rst2latex.py rst2pseudoxml.py rst2odt_prepstyles.py rst2html.py rst2html5.py \
		rst2html4.py rst2xml.py tabulate uvicorn wsdump.py

WAZUHMOD660=	/queue/indexer /queue/vd
WAZUHMOD750=	/ /logs/wazuh /logs/archives /logs/alerts /logs/firewall \
		/logs/api /logs/cluster /bin /lib /queue /queue/agentless \
		/queue/db /queue/diff /queue/fts /queue/keystore /queue/logcollector \
		/queue/syscollector /queue/syscollector/db  /ruleset \
		/ruleset/decoders /ruleset/rules /ruleset/sca /wodles \
		/active-response /active-response/bin /agentless /var /backup \
		/backup/db /backup/agents /backup/groups /backup/shared \
		/wodles/aws /wodles/aws/buckets_s3 /wodles/aws/services /wodles/aws/subscribers \
		/wodles/azure /wodles/azure/azure_services /wodles/azure/db \
		/wodles/docker /wodles/gcloud /wodles/gcloud/buckets /wodles/gcloud/pubsub \
		/stats /integrations

WAZUHMOD770=	/etc/decoders /etc/lists /etc/lists/amazon /etc/rootcheck \
		/etc/rules /etc/shared/default /logs /queue/agent-groups \
		/queue/alerts /queue/cluster /queue/fim /queue/fim/db \
		/queue/rids /queue/sockets /queue/tasks /etc /etc/shared \
		/.ssh /var/db /var/download /var/db/agents /var/run /var/upgrade \
		/var/selinux /var/wodles /var/multigroups /queue/rids /queue/router

WAZUHPREFIX=	/var/ossec

WZPYTHONWHEELS=	cffi-1.15.1-cp311-cp311-${FBSD_VERSION_BASE}_${ARCH_BASE}.whl \
		cryptography-42.0.4-cp311-cp311-${FBSD_VERSION_BASE}_${ARCH_BASE}.whl \
		greenlet-2.0.2-cp311-cp311-${FBSD_VERSION_BASE}_${ARCH_BASE}.whl \
		grpcio-1.66.2-cp311-cp311-${FBSD_VERSION_BASE}_${ARCH_BASE}.whl \
		lazy_object_proxy-1.10.0-cp311-cp311-${FBSD_VERSION_BASE}_${ARCH_BASE}.whl \
		MarkupSafe-2.1.2-cp311-cp311-${FBSD_VERSION_BASE}_${ARCH_BASE}.whl \
		multidict-5.2.0-cp311-cp311-${FBSD_VERSION_BASE}_${ARCH_BASE}.whl \
		numpy-1.26.4-cp311-cp311-${FBSD_VERSION_BASE}_${ARCH_BASE}.whl \
		psutil-5.9.0-cp311-cp311-${FBSD_VERSION_BASE}_${ARCH_BASE}.whl \
		pyarrow-18.0.0-cp311-cp311-${FBSD_VERSION_BASE}_${ARCH_BASE}.whl \
		PyYAML-6.0.1-cp311-cp311-${FBSD_VERSION_BASE}_${ARCH_BASE}.whl \
		rpds_py-0.15.2-cp311-cp311-${FBSD_VERSION_BASE}_${ARCH_BASE}.whl \
		uvloop-0.17.0-cp311-cp311-${FBSD_VERSION_BASE}_${ARCH_BASE}.whl

ARCH_BASE=	${ARCH:S/aarch64/arm64/g}
UNAME_r=	${_OSRELEASE:tl}
FBSD_RELEASE=	freebsd_${UNAME_r:S/./_/g:S/-/_/g}

.include <bsd.port.pre.mk>

.if ${ARCH} == "aarch64" && ${OSVERSION} < 1400000
IGNORE=		FreeBSD ${OSVERSION} ${ARCH} is not supported
.endif

.if ${ARCH} != "aarch64"
FBSD13_PATCH_LEVEL=	_p1
FBSD14_PATCH_LEVEL=	_p5
.endif

.if ${OSVERSION} >= 1300139 && ${OSVERSION} < 1400000
FBSD_VERSION_BASE=freebsd_13_4_release${FBSD13_PATCH_LEVEL}
FBSD_MAJOR_VERSION=13
WAZUH_CACHENAME=${PORTNAME}-cache-fbsd13-${ARCH}-${DISTVERSION}
DISTFILES+=	${WAZUH_CACHENAME}${EXTRACT_SUFX}:wazuh_cache
.elif ${OSVERSION} >= 1400000 && ${OSVERSION} < 1500000
FBSD_VERSION_BASE=freebsd_14_1_release${FBSD14_PATCH_LEVEL}
FBSD_MAJOR_VERSION=14
WAZUH_CACHENAME=${PORTNAME}-cache-fbsd14-${ARCH}-${DISTVERSION}
DISTFILES+=	${WAZUH_CACHENAME}${EXTRACT_SUFX}:wazuh_cache
.elif ${OSVERSION} >= 1500000
FBSD_VERSION_BASE=freebsd_15_0_current
FBSD_MAJOR_VERSION=15
WAZUH_CACHENAME=${PORTNAME}-cache-fbsd15-${ARCH}-${DISTVERSION}
DISTFILES+=     ${WAZUH_CACHENAME}${EXTRACT_SUFX}:wazuh_cache
.else
IGNORE=		FreeBSD ${OSVERSION} ${ARCH} is not supported
.endif

post-extract:
.for FILE in ${EXTERNAL_DISTFILES}
.if ${FILE} == "http-request.tar.gz:wazuh_cache"
	@cd ${WRKSRC}/src/shared_modules && ${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} ${_DISTDIR}/${FILE:S/:wazuh_cache//} ${EXTRACT_AFTER_ARGS}
.else
	@cd ${WRKSRC}/src/external && ${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} ${_DISTDIR}/${FILE:S/:wazuh_sources//:S/:wazuh_cache//} ${EXTRACT_AFTER_ARGS}
.endif
.endfor
	@cd ${WRKDIR} && ${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} ${_DISTDIR}/${WAZUH_EXTRAFILE} ${EXTRACT_AFTER_ARGS}
	@${MV} ${WRKDIR}/${PORTNAME}-freebsd-${WAZUH_EXTRAFILE_TAGNAME} ${WRKDIR}/wazuh-freebsd

	@cd ${WRKSRC}/src && ${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} ${_DISTDIR}/${WAZUH_CACHEFILE} ${EXTRACT_AFTER_ARGS}
	@cd ${WRKSRC}/src && ${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} ${_DISTDIR}/${WAZUH_CACHENAME}${EXTRACT_SUFX} ${EXTRACT_AFTER_ARGS}
	@cd ${WRKSRC}/src && ${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} ${_DISTDIR}/${PORTNAME}-python-${DISTVERSION}${EXTRACT_SUFX} ${EXTRACT_AFTER_ARGS}

.	for FILE in ${WZPYTHONWHEELS}
		@${MV} ${WRKSRC}/src/wazuh-cache/${FILE} ${WRKSRC}/src/wazuh-cache/${FILE:S/${FBSD_VERSION_BASE}/${FBSD_RELEASE}/}
.	endfor
	@${RM} ${WRKSRC}/src/external/cpython/python ${WRKSRC}/src/external/cpython/libpython* ${WRKSRC}/src/external/cpython/Modules/*.o

	@${MKDIR} ${WRKSRC}/ruleset/sca/freebsd
	@cd ${WRKDIR}/wazuh-freebsd/var/ossec/ruleset/sca && ${CP} *.yml ${WRKSRC}/ruleset/sca/freebsd/
	${FIND} ${WRKSRC}/ruleset/sca -type f -name "*.yml" -exec ${MV} "{}" "{}.disabled" \;

post-patch:
	${REINPLACE_CMD} -e 's|CC=|CC?=|g' -e 's|AR=|AR?=|g' ${WRKSRC}/src/external/bzip2/Makefile
	${REINPLACE_CMD} -e 's|^\( *MULTIARCH=\).*--print-multiarch.*|\1|' ${WRKSRC}/src/external/cpython/configure
	${REINPLACE_CMD} -e 's|coroutine|coroutines|g' ${WRKSRC}/framework/wazuh/core/cluster/client.py \
		${WRKSRC}/framework/wazuh/rbac/decorators.py

do-build:
	cd ${WRKSRC}/src/ && ${SETENV} ${MAKE_ENV} STAGEDIR=${STAGEDIR} \
		${MAKE_CMD} ${MAKE_ARGS}

do-install:
	${MKDIR} ${STAGEDIR}${WAZUHPREFIX}/bin
	${MKDIR} ${STAGEDIR}${WAZUHPREFIX}/lib
	${MKDIR} ${STAGEDIR}${WAZUHPREFIX}/tmp
	${MKDIR} ${STAGEDIR}${WAZUHPREFIX}/templates
	${MKDIR} ${STAGEDIR}${WAZUHPREFIX}/.ssh

.for DIRE in ${WAZUHMOD660}
	${MKDIR} -m 0660 ${STAGEDIR}${WAZUHPREFIX}${DIRE}
.endfor

.for DIRE in ${WAZUHMOD750}
	${MKDIR} -m 0750 ${STAGEDIR}${WAZUHPREFIX}${DIRE}
.endfor

.for DIRE in ${WAZUHMOD770}
	${MKDIR} -m 0770 ${STAGEDIR}${WAZUHPREFIX}${DIRE}
.endfor

	${INSTALL_DATA} /dev/null ${STAGEDIR}${WAZUHPREFIX}/logs/ossec.log
	${INSTALL_DATA} /dev/null ${STAGEDIR}${WAZUHPREFIX}/logs/ossec.json
	${INSTALL_DATA} /dev/null ${STAGEDIR}${WAZUHPREFIX}/logs/active-responses.log

.for FILE in ${WZBIN_FILES}
	${INSTALL_PROGRAM} ${WRKSRC}/src/${FILE} ${STAGEDIR}${WAZUHPREFIX}/bin
.endfor
	${INSTALL_PROGRAM} ${WRKSRC}/src/syscheckd/build/bin/wazuh-syscheckd ${STAGEDIR}${WAZUHPREFIX}/bin
	${INSTALL_SCRIPT} ${WRKSRC}/src/init/wazuh-server.sh ${STAGEDIR}${WAZUHPREFIX}/bin/wazuh-control

	${TOUCH} ${STAGEDIR}${WAZUHPREFIX}/etc/localtime

	${INSTALL_DATA} ${WRKSRC}/etc/internal_options.conf ${STAGEDIR}${WAZUHPREFIX}/etc
	${INSTALL_DATA} ${WRKSRC}/src/wazuh_modules/syscollector/norm_config.json ${STAGEDIR}${WAZUHPREFIX}/queue/syscollector
	${INSTALL_DATA} ${WRKSRC}/etc/local_internal_options.conf ${STAGEDIR}${WAZUHPREFIX}/etc/local_internal_options.conf.sample

	${INSTALL_DATA} /dev/null ${STAGEDIR}${WAZUHPREFIX}/etc/client.keys.sample

	${INSTALL_DATA} ${WRKSRC}/etc/ossec-server.conf ${STAGEDIR}${WAZUHPREFIX}/etc/ossec.conf.sample

	${INSTALL_SCRIPT} ${WRKSRC}/src/agentlessd/scripts/* ${STAGEDIR}${WAZUHPREFIX}/agentless/

.for FILE in ${WZARBIN_FILES}
	${INSTALL_PROGRAM} ${WRKSRC}/src/${FILE} ${STAGEDIR}${WAZUHPREFIX}/active-response/bin
.endfor
	${INSTALL_SCRIPT} ${WRKSRC}/src/active-response/*.sh ${STAGEDIR}${WAZUHPREFIX}/active-response/bin
	${INSTALL_SCRIPT} ${WRKSRC}/src/active-response/*.py ${STAGEDIR}${WAZUHPREFIX}/active-response/bin

	${INSTALL_PROGRAM} ${WRKSRC}/src/default-firewall-drop ${STAGEDIR}${WAZUHPREFIX}/active-response/bin/firewall-drop

# Install rules files
	${INSTALL_DATA} ${WRKSRC}/ruleset/rules/*.xml ${STAGEDIR}${WAZUHPREFIX}/ruleset/rules
	${INSTALL_DATA} ${WRKDIR}/wazuh-freebsd/var/ossec/ruleset/rules/*.xml ${STAGEDIR}${WAZUHPREFIX}/ruleset/rules

# Install decoders files
	${INSTALL_DATA} ${WRKSRC}/ruleset/decoders/*.xml ${STAGEDIR}${WAZUHPREFIX}/ruleset/decoders
	${INSTALL_DATA} ${WRKDIR}/wazuh-freebsd/var/ossec/ruleset/decoders/*.xml ${STAGEDIR}${WAZUHPREFIX}/ruleset/decoders

	${INSTALL_DATA} ${WRKSRC}/ruleset/rootcheck/db/*.txt ${STAGEDIR}${WAZUHPREFIX}/etc/rootcheck

	${INSTALL_DATA} ${WRKSRC}/etc/local_decoder.xml ${STAGEDIR}${WAZUHPREFIX}/etc/decoders/local_decoder.xml.sample
	${INSTALL_DATA} ${WRKSRC}/etc/local_rules.xml ${STAGEDIR}${WAZUHPREFIX}/etc/rules/local_rules.xml.sample

	${INSTALL_DATA} ${WRKSRC}/ruleset/lists/amazon/* ${STAGEDIR}${WAZUHPREFIX}/etc/lists/amazon/
	${INSTALL_DATA} ${WRKSRC}/ruleset/lists/audit-keys ${STAGEDIR}${WAZUHPREFIX}/etc/lists/audit-keys
	${INSTALL_DATA} ${WRKSRC}/ruleset/lists/security-eventchannel ${STAGEDIR}${WAZUHPREFIX}/etc/lists/security-eventchannel

	${INSTALL_SCRIPT} ${WRKSRC}/integrations/maltiverse.py ${STAGEDIR}${WAZUHPREFIX}/integrations/maltiverse.py
	${INSTALL_SCRIPT} ${WRKSRC}/integrations/pagerduty.py ${STAGEDIR}${WAZUHPREFIX}/integrations/pagerduty.py
	${INSTALL_SCRIPT} ${WRKSRC}/integrations/slack.py ${STAGEDIR}${WAZUHPREFIX}/integrations/slack.py
	${INSTALL_SCRIPT} ${WRKSRC}/integrations/shuffle.py ${STAGEDIR}${WAZUHPREFIX}/integrations/shuffle.py
	${INSTALL_SCRIPT} ${WRKSRC}/integrations/virustotal.py ${STAGEDIR}${WAZUHPREFIX}/integrations/virustotal.py

	${INSTALL_DATA} /dev/null ${STAGEDIR}${WAZUHPREFIX}/queue/agents-timestamp
	${INSTALL_DATA} ${WRKSRC}/ruleset/rootcheck/db/*.txt ${STAGEDIR}${WAZUHPREFIX}/etc/shared/default
	${INSTALL_DATA} ${WRKSRC}/etc/agent.conf ${STAGEDIR}${WAZUHPREFIX}/etc/shared/default/agent.conf.sample
	${INSTALL_DATA} ${WRKSRC}/etc/agent.conf ${STAGEDIR}${WAZUHPREFIX}/etc/shared/agent-template.conf

	${INSTALL_SCRIPT} ${WRKSRC}/wodles/__init__.py ${STAGEDIR}${WAZUHPREFIX}/wodles/__init__.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/utils.py ${STAGEDIR}${WAZUHPREFIX}/wodles/utils.py

	${INSTALL_SCRIPT} ${WRKSRC}/wodles/aws/aws_s3.py ${STAGEDIR}${WAZUHPREFIX}/wodles/aws/aws-s3.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/aws/__init__.py ${STAGEDIR}${WAZUHPREFIX}/wodles/aws/__init__.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/aws/aws_tools.py ${STAGEDIR}${WAZUHPREFIX}/wodles/aws/aws_tools.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/aws/wazuh_integration.py ${STAGEDIR}${WAZUHPREFIX}/wodles/aws/wazuh_integration.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/aws/buckets_s3/aws_bucket.py ${STAGEDIR}${WAZUHPREFIX}/wodles/aws/buckets_s3/aws_bucket.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/aws/buckets_s3/cloudtrail.py ${STAGEDIR}${WAZUHPREFIX}/wodles/aws/buckets_s3/cloudtrail.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/aws/buckets_s3/config.py ${STAGEDIR}${WAZUHPREFIX}/wodles/aws/buckets_s3/config.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/aws/buckets_s3/guardduty.py ${STAGEDIR}${WAZUHPREFIX}/wodles/aws/buckets_s3/guardduty.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/aws/buckets_s3/__init__.py ${STAGEDIR}${WAZUHPREFIX}/wodles/aws/buckets_s3/__init__.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/aws/buckets_s3/load_balancers.py ${STAGEDIR}${WAZUHPREFIX}/wodles/aws/buckets_s3/load_balancers.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/aws/buckets_s3/server_access.py ${STAGEDIR}${WAZUHPREFIX}/wodles/aws/buckets_s3/server_access.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/aws/buckets_s3/umbrella.py ${STAGEDIR}${WAZUHPREFIX}/wodles/aws/buckets_s3/umbrella.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/aws/buckets_s3/vpcflow.py ${STAGEDIR}${WAZUHPREFIX}/wodles/aws/buckets_s3/vpcflow.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/aws/buckets_s3/waf.py ${STAGEDIR}${WAZUHPREFIX}/wodles/aws/buckets_s3/waf.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/aws/services/aws_service.py ${STAGEDIR}${WAZUHPREFIX}/wodles/aws/services/aws_service.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/aws/services/cloudwatchlogs.py ${STAGEDIR}${WAZUHPREFIX}/wodles/aws/services/cloudwatchlogs.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/aws/services/__init__.py ${STAGEDIR}${WAZUHPREFIX}/wodles/aws/services/__init__.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/aws/services/inspector.py ${STAGEDIR}${WAZUHPREFIX}/wodles/aws/services/inspector.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/aws/subscribers/__init__.py ${STAGEDIR}${WAZUHPREFIX}/wodles/aws/subscribers/__init__.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/aws/subscribers/sqs_queue.py ${STAGEDIR}${WAZUHPREFIX}/wodles/aws/subscribers/sqs_queue.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/aws/subscribers/s3_log_handler.py ${STAGEDIR}${WAZUHPREFIX}/wodles/aws/subscribers/s3_log_handler.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/aws/subscribers/sqs_message_processor.py ${STAGEDIR}${WAZUHPREFIX}/wodles/aws/subscribers/sqs_message_processor.py

	${INSTALL_SCRIPT} ${WRKSRC}/framework/wrappers/generic_wrapper.sh ${STAGEDIR}${WAZUHPREFIX}/wodles/aws/aws-s3

	${INSTALL_SCRIPT} ${WRKSRC}/wodles/gcloud/exceptions.py ${STAGEDIR}${WAZUHPREFIX}/wodles/gcloud/exceptions.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/gcloud/gcloud.py ${STAGEDIR}${WAZUHPREFIX}/wodles/gcloud/gcloud.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/gcloud/integration.py ${STAGEDIR}${WAZUHPREFIX}/wodles/gcloud/integration.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/gcloud/tools.py ${STAGEDIR}${WAZUHPREFIX}/wodles/gcloud/tools.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/gcloud/buckets/bucket.py ${STAGEDIR}${WAZUHPREFIX}/wodles/gcloud/buckets/bucket.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/gcloud/buckets/access_logs.py ${STAGEDIR}${WAZUHPREFIX}/wodles/gcloud/buckets/access_logs.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/gcloud/pubsub/subscriber.py ${STAGEDIR}${WAZUHPREFIX}/wodles/gcloud/pubsub/subscriber.py
	${INSTALL_SCRIPT} ${WRKSRC}/framework/wrappers/generic_wrapper.sh ${STAGEDIR}${WAZUHPREFIX}/wodles/gcloud/gcloud

	${INSTALL_SCRIPT} ${WRKSRC}/wodles/docker-listener/DockerListener.py ${STAGEDIR}${WAZUHPREFIX}/wodles/docker/DockerListener.py
	${INSTALL_SCRIPT} ${WRKSRC}/framework/wrappers/generic_wrapper.sh ${STAGEDIR}${WAZUHPREFIX}/wodles/docker/DockerListener

	${INSTALL_SCRIPT} ${WRKSRC}/wodles/azure/azure-logs.py ${STAGEDIR}${WAZUHPREFIX}/wodles/azure/azure-logs.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/azure/azure_utils.py ${STAGEDIR}${WAZUHPREFIX}/wodles/azure/azure_utils.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/azure/azure_services/__init__.py ${STAGEDIR}${WAZUHPREFIX}/wodles/azure/azure_services/__init__.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/azure/azure_services/analytics.py ${STAGEDIR}${WAZUHPREFIX}/wodles/azure/azure_services/analytics.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/azure/azure_services/graph.py ${STAGEDIR}${WAZUHPREFIX}/wodles/azure/azure_services/graph.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/azure/azure_services/storage.py ${STAGEDIR}${WAZUHPREFIX}/wodles/azure/azure_services/storage.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/azure/db/__init__.py ${STAGEDIR}${WAZUHPREFIX}/wodles/azure/db/__init__.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/azure/db/orm.py ${STAGEDIR}${WAZUHPREFIX}/wodles/azure/db/orm.py
	${INSTALL_SCRIPT} ${WRKSRC}/wodles/azure/db/utils.py ${STAGEDIR}${WAZUHPREFIX}/wodles/azure/db/utils.py
	${INSTALL_SCRIPT} ${WRKSRC}/framework/wrappers/generic_wrapper.sh ${STAGEDIR}${WAZUHPREFIX}/wodles/azure/azure-logs

	${INSTALL_SCRIPT} ${WRKSRC}/framework/wrappers/generic_wrapper.sh ${STAGEDIR}${WAZUHPREFIX}/integrations/maltiverse
	${INSTALL_SCRIPT} ${WRKSRC}/framework/wrappers/generic_wrapper.sh ${STAGEDIR}${WAZUHPREFIX}/integrations/pagerduty
	${INSTALL_SCRIPT} ${WRKSRC}/framework/wrappers/generic_wrapper.sh ${STAGEDIR}${WAZUHPREFIX}/integrations/slack
	${INSTALL_SCRIPT} ${WRKSRC}/framework/wrappers/generic_wrapper.sh ${STAGEDIR}${WAZUHPREFIX}/integrations/virustotal
	${INSTALL_SCRIPT} ${WRKSRC}/framework/wrappers/generic_wrapper.sh ${STAGEDIR}${WAZUHPREFIX}/integrations/shuffle

# Install SCA files
	${FIND} ${WRKSRC}/ruleset/sca -type f -name "*.yml.disabled" -exec ${INSTALL_DATA} "{}" ${STAGEDIR}${WAZUHPREFIX}/ruleset/sca/ \;

	${INSTALL_LIB} ${WRKSRC}/src/libwazuhext.so ${STAGEDIR}${WAZUHPREFIX}/lib
	${INSTALL_LIB} ${WRKSRC}/src/libwazuhshared.so ${STAGEDIR}${WAZUHPREFIX}/lib
	${INSTALL_LIB} ${WRKSRC}/src/build/shared_modules/content_manager/libcontent_manager.so ${STAGEDIR}${WAZUHPREFIX}/lib
	${INSTALL_LIB} ${WRKSRC}/src/build/shared_modules/indexer_connector/libindexer_connector.so ${STAGEDIR}${WAZUHPREFIX}/lib
	${INSTALL_LIB} ${WRKSRC}/src/build/shared_modules/router/librouter.so ${STAGEDIR}${WAZUHPREFIX}/lib
	${INSTALL_LIB} ${WRKSRC}/src/build/wazuh_modules/vulnerability_scanner/libvulnerability_scanner.so ${STAGEDIR}${WAZUHPREFIX}/lib
	${INSTALL_LIB} ${WRKSRC}/src/data_provider/build/lib/libsysinfo.so ${STAGEDIR}${WAZUHPREFIX}/lib
	${INSTALL_LIB} ${WRKSRC}/src/external/jemalloc/lib/libjemalloc.so.2 ${STAGEDIR}${WAZUHPREFIX}/lib
	${INSTALL_LIB} ${WRKSRC}/src/external/rocksdb/build/librocksdb.so.8.3.2 ${STAGEDIR}${WAZUHPREFIX}/lib
	${INSTALL_LIB} ${WRKSRC}/src/shared_modules/dbsync/build/lib/libdbsync.so ${STAGEDIR}${WAZUHPREFIX}/lib
	${INSTALL_LIB} ${WRKSRC}/src/shared_modules/rsync/build/lib/librsync.so ${STAGEDIR}${WAZUHPREFIX}/lib
	${INSTALL_LIB} ${WRKSRC}/src/syscheckd/build/lib/libfimdb.so ${STAGEDIR}${WAZUHPREFIX}/lib
	${INSTALL_LIB} ${WRKSRC}/src/wazuh_modules/syscollector/build/lib/libsyscollector.so ${STAGEDIR}${WAZUHPREFIX}/lib

	${INSTALL_DATA} ${WRKSRC}/src/wazuh_modules/vulnerability_scanner/indexer/template/index-template.json ${STAGEDIR}${WAZUHPREFIX}/templates/vd_states_template.json

	cd ${WRKSRC}/src/ && ${SETENV} ${MAKE_ENV} STAGEDIR=${STAGEDIR} \
		${MAKE_CMD} install_python ${MAKE_ARGS}
	cd ${WRKSRC}/src/ && ${SETENV} ${MAKE_ENV} STAGEDIR=${STAGEDIR} \
		${MAKE_CMD} install_dependencies ${MAKE_ARGS}
	cd ${WRKSRC}/src/ && ${SETENV} ${MAKE_ENV} STAGEDIR=${STAGEDIR} \
		${MAKE_CMD} install_framework ${MAKE_ARGS}
	cd ${WRKSRC}/src/ && ${SETENV} ${MAKE_ENV} STAGEDIR=${STAGEDIR} \
		${MAKE_CMD} install_api ${MAKE_ARGS}
	cd ${WRKSRC}/src/ && ${SETENV} ${MAKE_ENV} STAGEDIR=${STAGEDIR} \
		${MAKE_CMD} install_mitre ${MAKE_ARGS}
	cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} \
		${MAKE_CMD} --quiet -C framework install INSTALLDIR=${STAGEDIR}${WAZUHPREFIX}
	cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} \
		${MAKE_CMD} --quiet -C api install INSTALLDIR=${STAGEDIR}${WAZUHPREFIX}

	@cd ${STAGEDIR}${WAZUHPREFIX}/framework/python/lib && \
		${STAGEDIR}${WAZUHPREFIX}/framework/python/bin/python3 -m compileall -x 'bad_coding|badsyntax|lib2to3/tests/data' -f -p ${WAZUHPREFIX}/framework/python/lib/ "python3.11"
	@cd ${STAGEDIR}${WAZUHPREFIX}/framework/python/lib && \
		${STAGEDIR}${WAZUHPREFIX}/framework/python/bin/python3 -O -m compileall -x 'bad_coding|badsyntax|lib2to3/tests/data' -f -p ${WAZUHPREFIX}/framework/python/lib/ "python3.11"
	@cd ${STAGEDIR}${WAZUHPREFIX}/framework/python/lib && \
		${STAGEDIR}${WAZUHPREFIX}/framework/python/bin/python3 -OO -m compileall -x 'bad_coding|badsyntax|lib2to3/tests/data' -f -p ${WAZUHPREFIX}/framework/python/lib/ "python3.11"

	${MKDIR} ${STAGEDIR}${WAZUHPREFIX}/packages_files/manager_installation_scripts/etc/templates
	${MKDIR} ${STAGEDIR}${WAZUHPREFIX}/packages_files/manager_installation_scripts/databases
	${MKDIR} ${STAGEDIR}${WAZUHPREFIX}/packages_files/manager_installation_scripts/src

	cd ${WRKSRC}/etc/templates && ${COPYTREE_SHARE} config \
		${STAGEDIR}${WAZUHPREFIX}/packages_files/manager_installation_scripts/etc/templates/
	cd ${WRKSRC}/src && ${COPYTREE_SHARE} init \
		${STAGEDIR}${WAZUHPREFIX}/packages_files/manager_installation_scripts/src/
	cd ${WRKSRC}/ruleset && ${COPYTREE_SHARE} sca \
		${STAGEDIR}${WAZUHPREFIX}/packages_files/manager_installation_scripts/

	${INSTALL_SCRIPT} ${WRKSRC}/gen_ossec.sh ${STAGEDIR}${WAZUHPREFIX}/packages_files/manager_installation_scripts/
	${INSTALL_SCRIPT} ${WRKSRC}/add_localfiles.sh ${STAGEDIR}${WAZUHPREFIX}/packages_files/manager_installation_scripts/
	${INSTALL_DATA} ${WRKSRC}/src/os_dbd/mysql.schema ${STAGEDIR}${WAZUHPREFIX}/packages_files/manager_installation_scripts/databases
	${INSTALL_DATA} ${WRKSRC}/src/os_dbd/postgresql.schema ${STAGEDIR}${WAZUHPREFIX}/packages_files/manager_installation_scripts/databases

post-install:
	@${STRIP_CMD} ${STAGEDIR}${WAZUHPREFIX}/framework/python/bin/python3.11
	@${FIND} ${STAGEDIR}${WAZUHPREFIX}/framework -type f -name "*.so" -exec ${STRIP_CMD} "{}" \;
.for FILE in ${WZSHEBANG_FILES}
	@${REINPLACE_CMD} -i "" -e 's|${STAGEDIR}||g' ${STAGEDIR}${WAZUHPREFIX}/framework/python/bin/${FILE}
.endfor

.include <bsd.port.post.mk>