Skip to content

Commit 30ddc32

Browse files
committed
Update README.md: use submodule and use benchmark tool
1 parent 7c174e9 commit 30ddc32

File tree

1 file changed

+82
-1
lines changed

1 file changed

+82
-1
lines changed

README.md

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,15 @@ As a dynamic library, don’t forget that libmodsecurity must be installed to a
5757

5858
### Unix (Linux, MacOS, FreeBSD, …)
5959

60-
On unix the project uses autotools to help the compilation process.
60+
On unix the project uses autotools to help the compilation process. Please note that if you work with `git`, do not forget to initialize submodules and update them. Here is a brief howto:
61+
```shell
62+
$ git clone https://github.com/owasp-modsecurity/ModSecurity ModSecurity
63+
$ cd ModSecurity
64+
$ git submodule init
65+
$ git submodule update
66+
```
67+
68+
After that, you can start the build process:
6169

6270
```shell
6371
$ ./build.sh
@@ -235,6 +243,79 @@ $ make
235243
$ sudo make install
236244
```
237245

246+
### Benchmarking
247+
248+
The source tree has a Benchmark tool which can help to measure the library's performance. The tool is under the `test/benchmark/` directory. The build process also makes the binary here, so after the end of compiling you will have the tool.
249+
250+
To run, just type:
251+
252+
```shell
253+
cd test/benchmark
254+
$ ./benchmark
255+
Doing 1000000 transactions...
256+
257+
```
258+
259+
Okay, this is a bit much, but you can pass a lower value:
260+
261+
```shell
262+
$ ./benchmark 1000
263+
Doing 1000 transactions...
264+
```
265+
266+
To measure the time:
267+
```shell
268+
$ time ./benchmark 1000
269+
Doing 1000 transactions...
270+
271+
real 0m0.351s
272+
user 0m0.337s
273+
sys 0m0.022s
274+
```
275+
276+
This is very fast because the benchmark uses the minimal `modsecurity.conf.default` configuration, which has not so much rules:
277+
278+
```shell
279+
$ cat basic_rules.conf
280+
281+
Include "../../modsecurity.conf-recommended"
282+
283+
```
284+
285+
To measure it with real rules, you should run one of the download scripts in the same directory:
286+
287+
```shell
288+
$ ./download-owasp-v3-rules.sh
289+
Cloning into 'owasp-v3'...
290+
remote: Enumerating objects: 33007, done.
291+
remote: Counting objects: 100% (2581/2581), done.
292+
remote: Compressing objects: 100% (907/907), done.
293+
remote: Total 33007 (delta 2151), reused 2004 (delta 1638), pack-reused 30426
294+
Receiving objects: 100% (33007/33007), 9.02 MiB | 16.21 MiB/s, done.
295+
Resolving deltas: 100% (25927/25927), done.
296+
Switched to a new branch 'tag3.0.2'
297+
/path/to/ModSecurity/test/benchmark
298+
Done.
299+
300+
$ cat basic_rules.conf
301+
302+
Include "../../modsecurity.conf-recommended"
303+
304+
Include "owasp-v3/crs-setup.conf.example"
305+
Include "owasp-v3/rules/*.conf"
306+
```
307+
308+
Now the command will give much higher value.
309+
310+
#### How the benchark works
311+
312+
The tool is a simple embedding application which uses the library. It creates a ModSecurity and a RuleSet instance, then runs a loop with number of you passed. Creates a Transaction (object) and emulates real HTTP transactions.
313+
314+
A transaction is a HTTP/1.1 GET request with a few GET parameters. Added common headers then the response: headers and an XML body. Between the phases it checks did any intervention happen or not. Every transaction is created with same data.
315+
316+
Note, that the tool does not call the last phase (logging).
317+
318+
Please don't forget to reset the `basic_rules.conf` content if you want to try it with another rule set.
238319

239320
## Reporting Issues
240321

0 commit comments

Comments
 (0)