Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/transaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1707,7 +1707,9 @@ std::string Transaction::toJSON(int parts) {


void Transaction::serverLog(std::shared_ptr<RuleMessage> rm) {
m_ms->serverLog(m_logCbData, rm);
if (m_logCbData) {
m_ms->serverLog(m_logCbData, rm);
}
}


Expand Down
34 changes: 28 additions & 6 deletions test/benchmark/benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,38 @@ char ip[] = "200.249.12.31";

char rules_file[] = "basic_rules.conf";

const char* const help_message = "Usage: benchmark [num_iterations|-h|-?|--help]";

#define NUM_REQUESTS 10000
int main(int argc, char *argv[]) {

unsigned long long NUM_REQUESTS(10000);

int main(int argc, char *argv[]) {
int i = 0;
if (argc > 1) {
if (0 == strcmp(argv[1], "-h") ||
0 == strcmp(argv[1], "-?") ||
0 == strcmp(argv[1], "--help")) {
std::cout << help_message << std::endl;
return 0;
}
errno = 0;
unsigned long long upper = strtoull(argv[1], 0, 10);
if (!errno && upper) {
NUM_REQUESTS = upper;
} else {
if (errno) {
perror("Invalid number of iterations");
} else {
std::cerr << "Failed to convert '" << argv[1] << "' to integer value" << std::endl
<< help_message << std::endl;
return -1;
}
}
}
std::cout << "Doing " << NUM_REQUESTS << " transactions...\n";
modsecurity::ModSecurity *modsec;
modsecurity::Rules *rules;
modsecurity::ModSecurityIntervention it;

modsecurity::intervention::reset(&it);
modsec = new modsecurity::ModSecurity();
modsec->setConnectorInformation("ModSecurity-benchmark v0.0.1-alpha" \
" (ModSecurity benchmark utility)");
Expand All @@ -86,8 +108,8 @@ int main(int argc, char *argv[]) {
return -1;
}

for (i = 0; i < NUM_REQUESTS; i++) {
std::cout << "Proceeding with request " << i << std::endl;
for (unsigned long long i = 0; i < NUM_REQUESTS; i++) {
//std::cout << "Proceeding with request " << i << std::endl;

Transaction *modsecTransaction = new Transaction(modsec, rules, NULL);
modsecTransaction->processConnection(ip, 12345, "127.0.0.1", 80);
Expand Down