mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-15 23:55:03 +03:00
Fix regression test and example: checking if rules are loaded ok
It was checking only the amount of rules loaded, which could be 0 if only configuration directives are loaded.
This commit is contained in:
parent
e94226f1d8
commit
15893e312b
@ -38,7 +38,7 @@ int main (int argc, char **argv)
|
|||||||
rules = msc_create_rules_set();
|
rules = msc_create_rules_set();
|
||||||
|
|
||||||
ret = msc_rules_add_file(rules, main_rule_uri, &error);
|
ret = msc_rules_add_file(rules, main_rule_uri, &error);
|
||||||
if (ret == 0) {
|
if (ret < 0) {
|
||||||
fprintf(stderr, "Problems loading the rules --\n");
|
fprintf(stderr, "Problems loading the rules --\n");
|
||||||
fprintf(stderr, "%s\n", error);
|
fprintf(stderr, "%s\n", error);
|
||||||
goto end;
|
goto end;
|
||||||
@ -48,7 +48,7 @@ int main (int argc, char **argv)
|
|||||||
ret = msc_rules_add_remote(rules, "test",
|
ret = msc_rules_add_remote(rules, "test",
|
||||||
"https://www.modsecurity.org/modsecurity-regression-test-secremoterules.txt",
|
"https://www.modsecurity.org/modsecurity-regression-test-secremoterules.txt",
|
||||||
&error);
|
&error);
|
||||||
if (ret == 0) {
|
if (ret < 0) {
|
||||||
fprintf(stderr, "Problems loading the rules --\n");
|
fprintf(stderr, "Problems loading the rules --\n");
|
||||||
fprintf(stderr, "%s\n", error);
|
fprintf(stderr, "%s\n", error);
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -97,7 +97,7 @@ void perform_unit_test(std::vector<RegressionTest *> *tests,
|
|||||||
" (ModSecurity regression test utility)");
|
" (ModSecurity regression test utility)");
|
||||||
modsec_rules = new ModSecurity::Rules(debug_log);
|
modsec_rules = new ModSecurity::Rules(debug_log);
|
||||||
|
|
||||||
if (modsec_rules->load(t->rules.c_str(), filename) == false) {
|
if (modsec_rules->load(t->rules.c_str(), filename) < 0) {
|
||||||
if (t->parser_error.empty() == true) {
|
if (t->parser_error.empty() == true) {
|
||||||
std::cerr << "parse failed." << std::endl;
|
std::cerr << "parse failed." << std::endl;
|
||||||
std::cout << modsec_rules->getParserError() << std::endl;
|
std::cout << modsec_rules->getParserError() << std::endl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user