mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Adds first version of `processContentOffset'
This commit also includes an example application on how to use the `processContentOffset' method.
This commit is contained in:
committed by
Felipe Zimmerle
parent
7aae5dc183
commit
027d50b76b
40
examples/reading_logs_with_offset/Makefile.am
Normal file
40
examples/reading_logs_with_offset/Makefile.am
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
|
||||
noinst_PROGRAMS = read
|
||||
|
||||
read_SOURCES = \
|
||||
read.cc
|
||||
|
||||
read_LDADD = \
|
||||
$(top_builddir)/src/.libs/libmodsecurity.a \
|
||||
$(CURL_LDADD) \
|
||||
$(GEOIP_LDFLAGS) $(GEOIP_LDADD) \
|
||||
$(PCRE_LDADD) \
|
||||
$(YAJL_LDFLAGS) $(YAJL_LDADD) \
|
||||
$(LMDB_LDFLAGS) $(LMDB_LDADD) \
|
||||
$(LIBXML2_LDADD) \
|
||||
$(GLOBAL_LDADD)
|
||||
|
||||
|
||||
read_CPPFLAGS = \
|
||||
$(GLOBAL_CFLAGS) \
|
||||
-std=c++11 \
|
||||
-I$(top_builddir)/headers \
|
||||
-I$(top_builddir) \
|
||||
-g \
|
||||
-I../others \
|
||||
-fPIC \
|
||||
-O3 \
|
||||
$(GEOIP_CFLAGS) \
|
||||
$(GLOBAL_CPPFLAGS) \
|
||||
$(MODSEC_NO_LOGS) \
|
||||
$(YAJL_CFLAGS) \
|
||||
$(LMDB_CFLAGS) \
|
||||
$(PCRE_CFLAGS) \
|
||||
$(LIBXML2_CFLAGS)
|
||||
|
||||
|
||||
MAINTAINERCLEANFILES = \
|
||||
Makefile.in
|
||||
|
||||
|
34
examples/reading_logs_with_offset/read.cc
Normal file
34
examples/reading_logs_with_offset/read.cc
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <modsecurity/modsecurity.h>
|
||||
|
||||
|
||||
// Variable offset - REQUEST_HEADERS_NAMES
|
||||
|
||||
const char *request = "" \
|
||||
"GET /index.html?param1=value1¶m2=value1¶m3=value1 HTTP/\n" \
|
||||
"AuThOrIzAtIoN: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\n" \
|
||||
"Host: localhost\n" \
|
||||
"Content-Length: 27\n" \
|
||||
"Content-Type: application/x-www-form-urlencoded\n";
|
||||
|
||||
|
||||
int main() {
|
||||
modsecurity::ModSecurity msc;
|
||||
std::string json("");
|
||||
const char *err = NULL;
|
||||
int ret = 0;
|
||||
|
||||
ret = msc.processContentOffset(request, strlen(request),
|
||||
"o0,4v64,13v114,4v130,14v149,12t:lowercase", &json, &err);
|
||||
|
||||
if (ret >= 0) {
|
||||
std::cout << json << std::endl;
|
||||
} else {
|
||||
std::cout << err << std::endl;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
Reference in New Issue
Block a user