Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 26f08cb

Browse files
committed
Makes re2 detectable by the build scripts
1 parent 2fa100b commit 26f08cb

File tree

13 files changed

+310
-28
lines changed

13 files changed

+310
-28
lines changed

‎build/re2.m4

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
dnl Check for RE2 Libraries
2+
dnl CHECK_RE2(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
3+
4+
AC_DEFUN([PROG_RE2], [
5+
6+
# Needed if pkg-config will be used.
7+
AC_REQUIRE([PKG_PROG_PKG_CONFIG])
8+
9+
# Possible names for the re2 library/package (pkg-config)
10+
RE2_POSSIBLE_LIB_NAMES="re2"
11+
12+
# Possible extensions for the library
13+
RE2_POSSIBLE_EXTENSIONS="so la sl dll dylib"
14+
15+
# Possible paths (if pkg-config was not found, proceed with the file lookup)
16+
RE2_POSSIBLE_PATHS="/usr/lib /usr/local/lib /usr/local/libre2 /usr/local/re2 /usr/local /opt/libre2 /opt/re2 /opt /usr /usr/lib64"
17+
18+
# Variables to be set by this very own script.
19+
RE2_VERSION=""
20+
RE2_CFLAGS=""
21+
RE2_CPPFLAGS=""
22+
RE2_LDADD=""
23+
RE2_LDFLAGS=""
24+
25+
AC_ARG_WITH(
26+
re2,
27+
AC_HELP_STRING(
28+
[--with-re2=PATH],
29+
[Path to re2 prefix or config script]
30+
)
31+
)
32+
33+
if test "x${with_re2}" == "xno"; then
34+
AC_DEFINE(HAVE_GEOIP, 0, [Support for RE2 was disabled by the utilization of --without-re2 or --with-re2=no])
35+
AC_MSG_NOTICE([Support for RE2 was disabled by the utilization of --without-re2 or --with-re2=no])
36+
RE2_DISABLED=yes
37+
else
38+
if test "x${with_re2}" == "xyes"; then
39+
RE2_MANDATORY=yes
40+
AC_MSG_NOTICE([RE2 support was marked as mandatory by the utilization of --with-re2=yes])
41+
fi
42+
# for x in ${RE2_POSSIBLE_LIB_NAMES}; do
43+
# CHECK_FOR_RE2_AT(${x})
44+
# if test -n "${RE2_VERSION}"; then
45+
# break
46+
# fi
47+
# done
48+
49+
# if test "x${with_re2}" != "xyes" or test "x${with_re2}" == "xyes"; then
50+
if test "x${with_re2}" == "x" || test "x${with_re2}" == "xyes"; then
51+
# Nothing about GeoIP was informed, using the pkg-config to figure things out.
52+
if test -n "${PKG_CONFIG}"; then
53+
RE2_PKG_NAME=""
54+
for x in ${RE2_POSSIBLE_LIB_NAMES}; do
55+
if ${PKG_CONFIG} --exists ${x}; then
56+
RE2_PKG_NAME="$x"
57+
break
58+
fi
59+
done
60+
fi
61+
AC_MSG_NOTICE([Nothing about GeoIP was informed during the configure phase. Trying to detect it on the platform...])
62+
if test -n "${RE2_PKG_NAME}"; then
63+
# Package was found using the pkg-config scripts
64+
RE2_VERSION="`${PKG_CONFIG} ${RE2_PKG_NAME} --modversion`"
65+
RE2_CFLAGS="`${PKG_CONFIG} ${RE2_PKG_NAME} --cflags`"
66+
RE2_LDADD="`${PKG_CONFIG} ${RE2_PKG_NAME} --libs-only-l`"
67+
RE2_LDFLAGS="`${PKG_CONFIG} ${RE2_PKG_NAME} --libs-only-L --libs-only-other`"
68+
RE2_DISPLAY="${RE2_LDADD}, ${RE2_CFLAGS}"
69+
else
70+
# If pkg-config did not find anything useful, go over file lookup.
71+
for x in ${RE2_POSSIBLE_LIB_NAMES}; do
72+
CHECK_FOR_RE2_AT(${x})
73+
if test -n "${RE2_VERSION}"; then
74+
break
75+
fi
76+
done
77+
fi
78+
fi
79+
if test "x${with_re2}" != "x"; then
80+
# An specific path was informed, lets check.
81+
RE2_MANDATORY=yes
82+
CHECK_FOR_RE2_AT(${with_re2})
83+
fi
84+
# fi
85+
fi
86+
87+
if test -z "${RE2_LDADD}"; then
88+
if test -z "${RE2_MANDATORY}"; then
89+
if test -z "${RE2_DISABLED}"; then
90+
AC_MSG_NOTICE([RE2 library was not found])
91+
RE2_FOUND=0
92+
else
93+
RE2_FOUND=2
94+
fi
95+
else
96+
AC_MSG_ERROR([RE2 was explicitly referenced but it was not found])
97+
RE2_FOUND=-1
98+
fi
99+
else
100+
RE2_FOUND=1
101+
AC_MSG_NOTICE([using RE2 v${RE2_VERSION}])
102+
RE2_CFLAGS="-DWITH_RE2 ${RE2_CFLAGS}"
103+
RE2_DISPLAY="${RE2_LDADD}, ${RE2_CFLAGS}"
104+
AC_SUBST(RE2_VERSION)
105+
AC_SUBST(RE2_LDADD)
106+
AC_SUBST(RE2_LIBS)
107+
AC_SUBST(RE2_LDFLAGS)
108+
AC_SUBST(RE2_CFLAGS)
109+
AC_SUBST(RE2_DISPLAY)
110+
fi
111+
112+
113+
114+
AC_SUBST(RE2_FOUND)
115+
116+
]) # AC_DEFUN [PROG_RE2]
117+
118+
119+
AC_DEFUN([CHECK_FOR_RE2_AT], [
120+
path=1ドル
121+
for y in ${RE2_POSSIBLE_EXTENSIONS}; do
122+
for z in ${RE2_POSSIBLE_LIB_NAMES}; do
123+
if test -e "${path}/${z}.${y}"; then
124+
re2_lib_path="${path}/"
125+
re2_lib_name="${z}"
126+
re2_lib_file="${re2_lib_path}/${z}.${y}"
127+
break
128+
fi
129+
if test -e "${path}/lib${z}.${y}"; then
130+
re2_lib_path="${path}/"
131+
re2_lib_name="${z}"
132+
re2_lib_file="${re2_lib_path}/lib${z}.${y}"
133+
break
134+
fi
135+
if test -e "${path}/lib/lib${z}.${y}"; then
136+
re2_lib_path="${path}/lib/"
137+
re2_lib_name="${z}"
138+
re2_lib_file="${re2_lib_path}/lib${z}.${y}"
139+
break
140+
fi
141+
if test -e "${path}/lib/x86_64-linux-gnu/lib${z}.${y}"; then
142+
re2_lib_path="${path}/lib/x86_64-linux-gnu/"
143+
re2_lib_name="${z}"
144+
re2_lib_file="${re2_lib_path}/lib${z}.${y}"
145+
break
146+
fi
147+
done
148+
if test -n "$re2_lib_path"; then
149+
break
150+
fi
151+
done
152+
if test -e "${path}/include/re2_parse.h"; then
153+
re2_inc_path="${path}/include"
154+
elif test -e "${path}/re2_parse.h"; then
155+
re2_inc_path="${path}"
156+
elif test -e "${path}/include/re2/re2_parse.h"; then
157+
re2_inc_path="${path}/include"
158+
fi
159+
160+
if test -n "${re2_lib_path}"; then
161+
AC_MSG_NOTICE([RE2 library found at: ${re2_lib_file}])
162+
fi
163+
164+
if test -n "${re2_inc_path}"; then
165+
AC_MSG_NOTICE([RE2 headers found at: ${re2_inc_path}])
166+
fi
167+
168+
if test -n "${re2_lib_path}" -a -n "${re2_inc_path}"; then
169+
# TODO: Compile a piece of code to check the version.
170+
RE2_CFLAGS="-I${re2_inc_path}"
171+
RE2_LDADD="-l${re2_lib_name}"
172+
RE2_LDFLAGS="-L${re2_lib_path}"
173+
RE2_DISPLAY="${re2_lib_file}, ${re2_inc_path}"
174+
fi
175+
]) # AC_DEFUN [CHECK_FOR_RE2_AT]

‎configure.ac

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ AM_CONDITIONAL([SSDEEP_CFLAGS], [test "SSDEEP_CFLAGS" != ""])
105105
CHECK_LUA
106106
AM_CONDITIONAL([LUA_CFLAGS], [test "LUA_CFLAGS" != ""])
107107

108+
# Check for RE2
109+
PROG_RE2
110+
AM_CONDITIONAL([RE2_CFLAGS], [test "RE2_CFLAGS" != ""])
108111

109112
#
110113
# Check for curl
@@ -549,6 +552,68 @@ if test "x$LUA_FOUND" = "x2"; then
549552
fi
550553

551554

555+
## REGEX
556+
echo " + Regular expression engine"
557+
558+
REGEX_SELECTED_RE2=" "
559+
REGEX_SELECTED_PCRE=" "
560+
561+
if test "x$RE2_FOUND" = "x1"; then
562+
MSC_REGEX_ENG="re2"
563+
fi
564+
if test "x$PCRE_FOUND" = "x1"; then
565+
MSC_REGEX_ENG="pcre"
566+
fi
567+
568+
AC_SUBST(MSC_REGEX_ENG)
569+
570+
if test "x$MSC_REGEX_ENG" = "xpcre"; then
571+
MSC_REGEX_ENG_IS_PCRE=1
572+
REGEX_SELECTED_PCRE="[[selected]]"
573+
AC_SUBST(MSC_REGEX_ENG_IS_PCRE)
574+
fi
575+
if test "x$MSC_REGEX_ENG" = "xre2"; then
576+
MSC_REGEX_ENG_IS_RE2=1
577+
REGEX_SELECTED_PCRE="[[selected]]"
578+
AC_SUBST(MSC_REGEX_ENG_IS_RE2)
579+
fi
580+
581+
582+
#### RE2
583+
if test "x$RE2_FOUND" = "x0"; then
584+
echo " * RE2 (experimental) ....not found"
585+
fi
586+
if test "x$RE2_FOUND" = "x1"; then
587+
echo -n " * RE2 (experimental) ${REGEX_SELECTED_RE2} ....found "
588+
if ! test "x$RE2_VERSION" = "x"; then
589+
echo "v${RE2_VERSION}"
590+
else
591+
echo ""
592+
fi
593+
echo " ${RE2_DISPLAY}"
594+
fi
595+
if test "x$RE2_FOUND" = "x2"; then
596+
echo " * RE2 (experimental) ....disabled"
597+
fi
598+
599+
#### PCRE
600+
if test "x$PCRE_FOUND" = "x0"; then
601+
echo " * PCRE ....not found"
602+
fi
603+
if test "x$PCRE_FOUND" = "x1"; then
604+
echo -n " * PCRE ${REGEX_SELECTED_PCRE} ....found "
605+
if ! test "x$PCRE_VERSION" = "x"; then
606+
echo "v${PCRE_VERSION}"
607+
else
608+
echo ""
609+
fi
610+
echo " ${PCRE_DISPLAY}"
611+
fi
612+
if test "x$PCRE_FOUND" = "x2"; then
613+
echo " * PCRE ....disabled"
614+
fi
615+
616+
552617
echo " "
553618
echo " Other Options"
554619
if test $buildTestUtilities = true; then

‎examples/reading_logs_via_rule_message/Makefile.am

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ simple_request_LDADD = \
1616
$(LUA_LDADD) \
1717
$(PCRE_LDADD) \
1818
$(SSDEEP_LDADD) \
19-
$(YAJL_LDADD)
19+
$(YAJL_LDADD) \
20+
$(RE2_LDADD)
2021

2122
simple_request_LDFLAGS = \
2223
$(GEOIP_LDFLAGS) \
@@ -25,7 +26,8 @@ simple_request_LDFLAGS = \
2526
$(LUA_LDFLAGS) \
2627
$(MAXMIND_LDFLAGS) \
2728
$(SSDEEP_LDFLAGS) \
28-
$(YAJL_LDFLAGS)
29+
$(YAJL_LDFLAGS) \
30+
$(RE2_LDFLAGS)
2931

3032
simple_request_CPPFLAGS = \
3133
$(GLOBAL_CFLAGS) \
@@ -43,7 +45,8 @@ simple_request_CPPFLAGS = \
4345
$(LMDB_CFLAGS) \
4446
$(LUA_CFLAGS) \
4547
$(PCRE_CFLAGS) \
46-
$(LIBXML2_CFLAGS)
48+
$(LIBXML2_CFLAGS) \
49+
$(RE2_CFLAGS)
4750

4851

4952
MAINTAINERCLEANFILES = \

‎examples/reading_logs_with_offset/Makefile.am

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@ read_LDADD = \
1616
$(LUA_LDADD) \
1717
$(PCRE_LDADD) \
1818
$(SSDEEP_LDADD) \
19-
$(YAJL_LDADD)
19+
$(YAJL_LDADD) \
20+
$(RE2_LDADD)
2021

2122
read_LDFLAGS = \
2223
$(GEOIP_LDFLAGS) \
2324
$(LMDB_LDFLAGS) \
2425
$(LUA_LDFLAGS) \
2526
$(SSDEEP_LDFLAGS) \
2627
$(MAXMIND_LDFLAGS) \
27-
$(YAJL_LDFLAGS)
28+
$(YAJL_LDFLAGS) \
29+
$(RE2_LDFLAGS)
2830

2931
read_CPPFLAGS = \
3032
$(GLOBAL_CFLAGS) \
@@ -43,7 +45,8 @@ read_CPPFLAGS = \
4345
$(LMDB_CFLAGS) \
4446
$(LUA_CFLAGS) \
4547
$(PCRE_CFLAGS) \
46-
$(LIBXML2_CFLAGS)
48+
$(LIBXML2_CFLAGS) \
49+
$(RE2_CFLAGS)
4750

4851

4952
MAINTAINERCLEANFILES = \

‎examples/using_bodies_in_chunks/Makefile.am

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ simple_request_LDADD = \
1616
$(LUA_LDADD) \
1717
$(PCRE_LDADD) \
1818
$(SSDEEP_LDADD) \
19-
$(YAJL_LDADD)
19+
$(YAJL_LDADD) \
20+
$(RE2_LDADD)
2021

2122
simple_request_LDFLAGS = \
2223
$(GEOIP_LDFLAGS) \
@@ -25,7 +26,8 @@ simple_request_LDFLAGS = \
2526
-lpthread \
2627
$(LUA_LDFLAGS) \
2728
$(SSDEEP_LDFLAGS) \
28-
$(YAJL_LDFLAGS)
29+
$(YAJL_LDFLAGS) \
30+
$(RE2_LDFLAGS)
2931

3032
simple_request_CPPFLAGS = \
3133
$(GLOBAL_CFLAGS) \
@@ -44,7 +46,8 @@ simple_request_CPPFLAGS = \
4446
$(LMDB_CFLAGS) \
4547
$(LUA_CFLAGS) \
4648
$(PCRE_CFLAGS) \
47-
$(LIBXML2_CFLAGS)
49+
$(LIBXML2_CFLAGS) \
50+
$(RE2_CFLAGS)
4851

4952
MAINTAINERCLEANFILES = \
5053
Makefile.in

‎src/Makefile.am

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,8 @@ libmodsecurity_la_CPPFLAGS = \
316316
$(SSDEEP_CFLAGS) \
317317
$(MAXMIND_CFLAGS) \
318318
$(LUA_CFLAGS) \
319-
$(LIBXML2_CFLAGS)
319+
$(LIBXML2_CFLAGS) \
320+
$(RE2_CFLAGS)
320321

321322

322323
libmodsecurity_la_LDFLAGS = \
@@ -331,6 +332,7 @@ libmodsecurity_la_LDFLAGS = \
331332
$(SSDEEP_LDFLAGS) \
332333
$(MAXMIND_LDFLAGS) \
333334
$(YAJL_LDFLAGS) \
335+
$(RE2_LDFLAGS) \
334336
-version-info @MSC_VERSION_INFO@
335337

336338

@@ -346,5 +348,6 @@ libmodsecurity_la_LIBADD = \
346348
$(PCRE_LDADD) \
347349
$(MAXMIND_LDADD) \
348350
$(SSDEEP_LDADD) \
349-
$(YAJL_LDADD)
351+
$(YAJL_LDADD) \
352+
$(RE2_LDADD)
350353

‎src/parser/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ libmodsec_parser_la_CPPFLAGS = \
2626
$(YAJL_CFLAGS) \
2727
$(LMDB_CFLAGS) \
2828
$(PCRE_CFLAGS) \
29-
$(LIBXML2_CFLAGS)
29+
$(LIBXML2_CFLAGS) \
30+
$(RE2_CFLAGS)
3031

3132
test.cc: seclang-parser.hh
3233
cat seclang-parser.hh | sed "s/return \*new (yyas_<T> ()) T (t)/return *new (yyas_<T> ()) T (std::move((T\&)t))/g" > seclang-parser.hh.fix && mv seclang-parser.hh.fix seclang-parser.hh

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /