mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-15 23:55:03 +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 <fstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <chrono>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -189,7 +188,7 @@ class Assay {
|
|||||||
|
|
||||||
std::string id;
|
std::string id;
|
||||||
time_t timeStamp;
|
time_t timeStamp;
|
||||||
std::chrono::system_clock::time_point start;
|
clock_t start;
|
||||||
int highest_severity;
|
int highest_severity;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
#include "modsecurity/modsecurity.h"
|
#include "modsecurity/modsecurity.h"
|
||||||
#include "modsecurity/intervention.h"
|
#include "modsecurity/intervention.h"
|
||||||
@ -102,7 +103,7 @@ Assay::Assay(ModSecurity *ms, Rules *rules)
|
|||||||
m_requestBodyType(UnknownFormat),
|
m_requestBodyType(UnknownFormat),
|
||||||
m_requestHeadersNames(NULL),
|
m_requestHeadersNames(NULL),
|
||||||
m_responseHeadersNames(NULL),
|
m_responseHeadersNames(NULL),
|
||||||
start(std::chrono::system_clock::now()),
|
start(cpu_seconds()),
|
||||||
m_ms(ms) {
|
m_ms(ms) {
|
||||||
id = std::to_string(this->timeStamp) + \
|
id = std::to_string(this->timeStamp) + \
|
||||||
std::to_string(generate_assay_unique_id());
|
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
|
#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
|
} // namespace ModSecurity
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ namespace ModSecurity {
|
|||||||
void chomp(std::string *str);
|
void chomp(std::string *str);
|
||||||
std::string uri_decode(const std::string & sSrc);
|
std::string uri_decode(const std::string & sSrc);
|
||||||
std::string tolower(std::string str);
|
std::string tolower(std::string str);
|
||||||
|
double cpu_seconds(void);
|
||||||
} // namespace ModSecurity
|
} // namespace ModSecurity
|
||||||
|
|
||||||
#define SRC_UTILS_H_
|
#define SRC_UTILS_H_
|
||||||
|
@ -19,10 +19,10 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <chrono>
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "modsecurity/assay.h"
|
#include "modsecurity/assay.h"
|
||||||
|
#include "src/utils.h"
|
||||||
|
|
||||||
namespace ModSecurity {
|
namespace ModSecurity {
|
||||||
namespace Variables {
|
namespace Variables {
|
||||||
@ -33,10 +33,9 @@ std::list<std::pair<std::string, std::string>>
|
|||||||
std::string res;
|
std::string res;
|
||||||
std::pair<std::string, std::string> pair;
|
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(
|
res = std::to_string(e);
|
||||||
std::chrono::duration_cast<std::chrono::microseconds>(e).count());
|
|
||||||
|
|
||||||
pair = std::make_pair(std::string("DURATION"), std::string(res));
|
pair = std::make_pair(std::string("DURATION"), std::string(res));
|
||||||
resl.push_back(pair);
|
resl.push_back(pair);
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"expected":{
|
"expected":{
|
||||||
"debug_log":"Target value: \"[0-9]+\""
|
"debug_log":"Target value: \"[0-9\\.]+\""
|
||||||
},
|
},
|
||||||
"rules":[
|
"rules":[
|
||||||
"SecRuleEngine On",
|
"SecRuleEngine On",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user