summaryrefslogtreecommitdiff
blob: 4d333424d03641c4b0da94983274001466271f63 (plain)
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
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

LUA_COMPAT=( lua5-{1..4} )

inherit lua-single

MY_P=${PN}-v${PV}

DESCRIPTION="Application firewall and intrusion detection"
HOMEPAGE="https://github.com/SpiderLabs/ModSecurity"
SRC_URI="https://github.com/SpiderLabs/ModSecurity/releases/download/v${PV}/${MY_P}.tar.gz"
S="${WORKDIR}/${MY_P}"

LICENSE="Apache-2.0"
SLOT="0"
KEYWORDS="amd64 ~arm ~arm64 ~ppc ~ppc64 ~riscv ~x86"
IUSE="doc fuzzyhash geoip geoip2 json lmdb lua pcre2"

REQUIRED_USE="lua? ( ${LUA_REQUIRED_USE} )"
RDEPEND="dev-libs/libpcre:=
	dev-libs/libxml2
	net-misc/curl
	fuzzyhash? ( app-crypt/ssdeep )
	geoip? ( dev-libs/geoip )
	geoip2? ( dev-libs/libmaxminddb )
	json? ( dev-libs/yajl )
	lmdb? ( dev-db/lmdb )
	lua? ( ${LUA_DEPS} )
	pcre2? ( dev-libs/libpcre2:= )"
DEPEND="${RDEPEND}"
BDEPEND="virtual/pkgconfig
	doc? ( app-doc/doxygen[dot] )"

DOCS=( AUTHORS CHANGES README.md modsecurity.conf-recommended unicode.mapping )

pkg_setup() {
	use lua && lua-single_pkg_setup
}

src_prepare() {
	default

	# 2 tests fail without portage too
	# https://github.com/SpiderLabs/ModSecurity/issues/2772
	sed -i '/test\/test-cases\/regression\/auditlog.json \\/d' Makefile.in || die
	sed -i '/test\/test-cases\/regression\/issue-2000.json \\/d' Makefile.in || die
	sed -i '/test\/test-cases\/regression\/config-secremoterules.json \\/d' Makefile.in || die
	sed -i '/test\/test-cases\/regression\/operator-ipMatchFromFile.json \\/d' Makefile.in || die
}

src_configure() {
	local myconf=(
		$(use_with fuzzyhash ssdeep)
		$(use_with geoip )
		$(use_with geoip2 maxmind)
		$(use_with json yajl)
		$(use_with lmdb)
		$(use_with lua)
		$(use_with pcre2)
	)

	econf "${myconf[@]}"
}

src_compile() {
	default

	if use doc; then
		cd doc && doxygen doxygen.cfg || die
	fi
}

src_install() {
	default
	use doc && dodoc -r doc/html
	find "${ED}" -name '*.la' -delete || die
}