Adds support to load remote rules

This commit is contained in:
Felipe Zimmerle
2015-07-23 14:36:11 -03:00
parent 70bc15cb73
commit 76b34af357
15 changed files with 449 additions and 74 deletions

View File

@@ -11,4 +11,4 @@ CLEANFILES =
# make maintainer-clean
MAINTAINERCLEANFILES = \
Makefile.in

View File

@@ -1,3 +1,7 @@
SecRuleEngine On
SecDebugLog /tmp/modsec_debug.log
SecDebugLogLevel 9
SecRule ARGS:test "@detectSQLi" "allow"
SecRule ARGS|ARGS:test "!@contains asdfsafdt" "allow"
SecRule ARGS "@detectSQLi" "allow"

View File

@@ -24,6 +24,8 @@ char main_rule_uri[] = "basic_rules.conf";
int main (int argc, char **argv)
{
int ret = 1;
const char *error = NULL;
ModSecurity *modsec = NULL;
Assay *assay = NULL;
Rules *rules = NULL;
@@ -34,7 +36,24 @@ int main (int argc, char **argv)
"example on how to use ModSecurity API");
rules = msc_create_rules_set();
msc_rules_add_file(rules, main_rule_uri);
ret = msc_rules_add_file(rules, main_rule_uri, &error);
if (ret == 0) {
fprintf(stderr, "Problems loading the rules --\n");
fprintf(stderr, "%s\n", error);
goto end;
}
msc_rules_dump(rules);
ret = msc_rules_add_remote(rules, "test",
"https://www.modsecurity.org/modsecurity-regression-test-secremoterules.txt",
&error);
if (ret == 0) {
fprintf(stderr, "Problems loading the rules --\n");
fprintf(stderr, "%s\n", error);
goto end;
}
msc_rules_dump(rules);
assay = msc_new_assay(modsec, rules);
@@ -46,7 +65,7 @@ int main (int argc, char **argv)
msc_process_request_body(assay);
msc_process_response_headers(assay);
msc_process_response_body(assay);
end:
msc_rules_cleanup(rules);
msc_cleanup(modsec);