Skip to content

Commit 7efd4f0

Browse files
authored
Merge branch 'master' into fix/conf_cleanup_pool
2 parents 683adce + 6d5f759 commit 7efd4f0

6 files changed

+82
-8
lines changed

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ addons:
1616
- liblmdb-dev
1717

1818
env:
19-
- VER_NGINX=1.13.4
20-
- VER_NGINX=1.12.1
19+
- VER_NGINX=1.13.10
20+
- VER_NGINX=1.12.2
2121

2222
before_script:
2323
- cd ..

AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
zimmerle = Felipe Zimmerle <[email protected]>
2+
defanator = Andrei Belov <[email protected]>

CHANGES

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1-
DD mmm YYYY - 1.0.0
1+
v1.0.x - YYYY-MMM-DD (To be released)
2+
-------------------------------------
3+
4+
- Fix memory leak in intervention processing
5+
[Issue #100 - @defanator]
6+
- Emit connector version in error log
7+
[Issue #88 - @defanator]
8+
- Fixed memory leak on config cleanup.
9+
[Issue #80 - @AirisX, @defanator]
10+
11+
12+
v1.0.0 - 2017-Dec-20
213
--------------------
314

4-
* First version of the ModSecurity-nginx
5-
[Felipe Zimmerle]
15+
- First version of ModSecurity-nginx connector
16+

release.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
git clean -xfdi
4+
git submodule foreach --recursive git clean -xfdi
5+
6+
VERSION=`git describe --tags`
7+
DIR_NAME="modsecurity-nginx-$VERSION"
8+
TAR_NAME="modsecurity-nginx-$VERSION.tar.gz"
9+
10+
MY_DIR=${PWD##*/}
11+
12+
cd ..
13+
tar --transform "s/^$MY_DIR/$DIR_NAME/" -cvzf $TAR_NAME --exclude .git $MY_DIR
14+
15+
sha256sum $TAR_NAME > $TAR_NAME.sha256
16+
gpg --detach-sign -a $TAR_NAME
17+
18+
cd -
19+
echo $TAR_NAME ": done."
20+

src/ngx_http_modsecurity_common.h

+31
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,37 @@
2626
#include <modsecurity/transaction.h>
2727
#include <modsecurity/rules.h>
2828

29+
30+
/**
31+
* TAG_NUM:
32+
*
33+
* Alpha - 001
34+
* Beta - 002
35+
* Dev - 010
36+
* Rc1 - 051
37+
* Rc2 - 052
38+
* ... - ...
39+
* Release- 100
40+
*
41+
*/
42+
43+
#define MODSECURITY_NGINX_MAJOR "1"
44+
#define MODSECURITY_NGINX_MINOR "0"
45+
#define MODSECURITY_NGINX_PATCHLEVEL "0"
46+
#define MODSECURITY_NGINX_TAG ""
47+
#define MODSECURITY_NGINX_TAG_NUM "100"
48+
49+
#define MODSECURITY_NGINX_VERSION MODSECURITY_NGINX_MAJOR "." \
50+
MODSECURITY_NGINX_MINOR "." MODSECURITY_NGINX_PATCHLEVEL \
51+
MODSECURITY_NGINX_TAG
52+
53+
#define MODSECURITY_NGINX_VERSION_NUM MODSECURITY_NGINX_MAJOR \
54+
MODSECURITY_NGINX_MINOR MODSECURITY_NGINX_PATCHLEVEL \
55+
MODSECURITY_NGINX_TAG_NUM
56+
57+
#define MODSECURITY_NGINX_WHOAMI "ModSecurity-nginx v" \
58+
MODSECURITY_NGINX_VERSION
59+
2960
typedef struct {
3061
ngx_str_t name;
3162
ngx_str_t value;

src/ngx_http_modsecurity_module.c

+14-3
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ ngx_inline char *ngx_str_to_char(ngx_str_t a, ngx_pool_t *p)
132132
ngx_inline int
133133
ngx_http_modsecurity_process_intervention (Transaction *transaction, ngx_http_request_t *r)
134134
{
135+
char *log = NULL;
135136
ModSecurityIntervention intervention;
136137
intervention.status = 200;
137138
intervention.url = NULL;
@@ -145,11 +146,16 @@ ngx_http_modsecurity_process_intervention (Transaction *transaction, ngx_http_re
145146
return 0;
146147
}
147148

149+
log = intervention.log;
148150
if (intervention.log == NULL) {
149-
intervention.log = "(no log message was specified)";
151+
log = "(no log message was specified)";
150152
}
151153

152-
ngx_log_error(NGX_LOG_WARN, (ngx_log_t *)r->connection->log, 0, "%s", intervention.log);
154+
ngx_log_error(NGX_LOG_WARN, (ngx_log_t *)r->connection->log, 0, "%s", log);
155+
156+
if (intervention.log != NULL) {
157+
free(intervention.log);
158+
}
153159

154160
if (intervention.url != NULL)
155161
{
@@ -496,6 +502,8 @@ ngx_http_modsecurity_create_main_conf(ngx_conf_t *cf)
496502
{
497503
ngx_http_modsecurity_conf_t *conf;
498504

505+
ngx_log_error(NGX_LOG_NOTICE, cf->log, 0, MODSECURITY_NGINX_WHOAMI);
506+
499507
/* ngx_pcalloc already sets all of this scructure to zeros. */
500508
conf = ngx_http_modsecurity_create_conf(cf);
501509

@@ -515,7 +523,7 @@ ngx_http_modsecurity_create_main_conf(ngx_conf_t *cf)
515523
}
516524

517525
/* Provide our connector information to LibModSecurity */
518-
msc_set_connector_info(conf->modsec, "ModSecurity-nginx v0.1.1-beta");
526+
msc_set_connector_info(conf->modsec, MODSECURITY_NGINX_WHOAMI);
519527
msc_set_log_cb(conf->modsec, ngx_http_modsecurity_log);
520528

521529
return conf;
@@ -545,6 +553,7 @@ static void *ngx_http_modsecurity_create_conf(ngx_conf_t *cf)
545553
conf->enable = NGX_CONF_UNSET;
546554
conf->sanity_checks_enabled = NGX_CONF_UNSET;
547555
conf->rules_set = msc_create_rules_set();
556+
conf->modsec = NULL;
548557
conf->pool = cf->pool;
549558

550559
cln = ngx_pool_cleanup_add(cf->pool, 0);
@@ -652,9 +661,11 @@ ngx_http_modsecurity_config_cleanup(void *data)
652661

653662
old_pool = ngx_http_modsecurity_pcre_malloc_init(t->pool);
654663
msc_rules_cleanup(t->rules_set);
664+
msc_cleanup(t->modsec);
655665
ngx_http_modsecurity_pcre_malloc_done(old_pool);
656666

657667
t->rules_set = NULL;
668+
t->modsec = NULL;
658669
}
659670

660671

0 commit comments

Comments
 (0)