Created
June 26, 2018 16:21
-
-
Save p0pr0ck5/c5045eb3b6107917db771be3ef1df08b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* ModSecurity, http://www.modsecurity.org/ | |
* Copyright (c) 2015 Trustwave Holdings, Inc. (http://www.trustwave.com/) | |
* | |
* You may not use this file except in compliance with | |
* the License. You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* If any of the files related to licensing are missing or if you have any | |
* other questions related to licensing please contact Trustwave Holdings, Inc. | |
* directly using the email address security@modsecurity.org. | |
* | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sys/time.h> | |
#include "modsecurity/modsecurity.h" | |
#include "modsecurity/rules.h" | |
char main_rule_uri[] = "basic_rules.conf"; | |
float timedifference_msec(struct timeval t0, struct timeval t1) | |
{ | |
return (t1.tv_sec - t0.tv_sec) * 1000.0f + (t1.tv_usec - t0.tv_usec) / 1000.0f; | |
} | |
int main (int argc, char **argv) | |
{ | |
int ret, i; | |
char name[100] = { 0 }; | |
const char *error = NULL; | |
ModSecurity *modsec; | |
Transaction *transaction = NULL; | |
Rules *rules; | |
float elapsed; | |
i = 1; | |
modsec = msc_init(); | |
msc_set_connector_info(modsec, "ModSecurity-test v0.0.1-alpha (Simple " \ | |
"example on how to use ModSecurity API"); | |
rules = msc_create_rules_set(); | |
struct timeval stop, start; | |
gettimeofday(&start, NULL); | |
for (i; i < atoi(argv[1]); ++i) { | |
//printf("Doing %d\n", i); | |
sprintf(name, "/tmp/modsec-rules-6464-%d.conf", i); | |
ret = msc_rules_add_file(rules, name, &error); | |
if (ret < 0) { | |
fprintf(stderr, "Problems loading the rules --\n"); | |
fprintf(stderr, "%s\n", error); | |
goto end; | |
} | |
} | |
gettimeofday(&stop, NULL); | |
elapsed = timedifference_msec(start, stop); | |
printf("took %f\n", elapsed); | |
end: | |
msc_rules_cleanup(rules); | |
msc_cleanup(modsec); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment