mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Removes chrono references to make it compile with gcc 4.8.x
This commit is contained in:
parent
933ade596c
commit
a4cf218a3e
@ -25,7 +25,6 @@
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <chrono>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
@ -189,7 +188,7 @@ class Assay {
|
||||
|
||||
std::string id;
|
||||
time_t timeStamp;
|
||||
std::chrono::system_clock::time_point start;
|
||||
clock_t start;
|
||||
int highest_severity;
|
||||
|
||||
private:
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <vector>
|
||||
#include <iomanip>
|
||||
#include <set>
|
||||
#include <cstdio>
|
||||
|
||||
#include "modsecurity/modsecurity.h"
|
||||
#include "modsecurity/intervention.h"
|
||||
@ -102,7 +103,7 @@ Assay::Assay(ModSecurity *ms, Rules *rules)
|
||||
m_requestBodyType(UnknownFormat),
|
||||
m_requestHeadersNames(NULL),
|
||||
m_responseHeadersNames(NULL),
|
||||
start(std::chrono::system_clock::now()),
|
||||
start(cpu_seconds()),
|
||||
m_ms(ms) {
|
||||
id = std::to_string(this->timeStamp) + \
|
||||
std::to_string(generate_assay_unique_id());
|
||||
|
13
src/utils.cc
13
src/utils.cc
@ -196,5 +196,18 @@ void createDir(std::string dir, int mode) {
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
double cpu_seconds(void) {
|
||||
struct timespec t;
|
||||
|
||||
if (!clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &t))
|
||||
return static_cast<double>(t.tv_sec)
|
||||
+ static_cast<double>(t.tv_nsec / 1000000000.0);
|
||||
else
|
||||
return static_cast<double>(clock()) /
|
||||
static_cast<double>(CLOCKS_PER_SEC);
|
||||
}
|
||||
|
||||
|
||||
} // namespace ModSecurity
|
||||
|
||||
|
@ -32,6 +32,7 @@ namespace ModSecurity {
|
||||
void chomp(std::string *str);
|
||||
std::string uri_decode(const std::string & sSrc);
|
||||
std::string tolower(std::string str);
|
||||
double cpu_seconds(void);
|
||||
} // namespace ModSecurity
|
||||
|
||||
#define SRC_UTILS_H_
|
||||
|
@ -19,10 +19,10 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <chrono>
|
||||
#include <utility>
|
||||
|
||||
#include "modsecurity/assay.h"
|
||||
#include "src/utils.h"
|
||||
|
||||
namespace ModSecurity {
|
||||
namespace Variables {
|
||||
@ -33,10 +33,9 @@ std::list<std::pair<std::string, std::string>>
|
||||
std::string res;
|
||||
std::pair<std::string, std::string> pair;
|
||||
|
||||
auto e = std::chrono::high_resolution_clock::now() - assay->start;
|
||||
double e = cpu_seconds() - assay->start;
|
||||
|
||||
res = std::to_string(
|
||||
std::chrono::duration_cast<std::chrono::microseconds>(e).count());
|
||||
res = std::to_string(e);
|
||||
|
||||
pair = std::make_pair(std::string("DURATION"), std::string(res));
|
||||
resl.push_back(pair);
|
||||
|
@ -37,7 +37,7 @@
|
||||
]
|
||||
},
|
||||
"expected":{
|
||||
"debug_log":"Target value: \"[0-9]+\""
|
||||
"debug_log":"Target value: \"[0-9\\.]+\""
|
||||
},
|
||||
"rules":[
|
||||
"SecRuleEngine On",
|
||||
|
Loading…
x
Reference in New Issue
Block a user