mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-15 23:55:03 +03:00
Adds random id to each assay
This commit is contained in:
parent
3112794025
commit
888b9622c7
@ -135,6 +135,7 @@ class Assay {
|
|||||||
int http_code_returned;
|
int http_code_returned;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::string id;
|
||||||
std::ofstream myfile;
|
std::ofstream myfile;
|
||||||
Rules *m_rules;
|
Rules *m_rules;
|
||||||
const char *m_clientIpAddress;
|
const char *m_clientIpAddress;
|
||||||
|
@ -85,6 +85,8 @@ Assay::Assay(ModSecurity *ms, Rules *rules)
|
|||||||
do_not_save_in_auditlog(false),
|
do_not_save_in_auditlog(false),
|
||||||
m_timeStamp(std::time(NULL)),
|
m_timeStamp(std::time(NULL)),
|
||||||
http_code_returned(200) {
|
http_code_returned(200) {
|
||||||
|
id = std::to_string(this->m_timeStamp) + \
|
||||||
|
std::to_string(generate_assay_unique_id());
|
||||||
m_rules->incrementReferenceCount();
|
m_rules->incrementReferenceCount();
|
||||||
this->debug(4, "Initialising transaction");
|
this->debug(4, "Initialising transaction");
|
||||||
}
|
}
|
||||||
|
@ -26,9 +26,7 @@ namespace ModSecurity {
|
|||||||
* @name ModSecurity
|
* @name ModSecurity
|
||||||
* @brief Initilizes ModSecurity CPP API
|
* @brief Initilizes ModSecurity CPP API
|
||||||
*
|
*
|
||||||
* ModSecurity initializer. Although it is not really doing anything
|
* ModSecurity initializer.
|
||||||
* in this version, further versions of this API may demands this to
|
|
||||||
* be executed.
|
|
||||||
*
|
*
|
||||||
* Example Usage:
|
* Example Usage:
|
||||||
* @code
|
* @code
|
||||||
@ -41,6 +39,7 @@ namespace ModSecurity {
|
|||||||
*/
|
*/
|
||||||
ModSecurity::ModSecurity() {
|
ModSecurity::ModSecurity() {
|
||||||
UniqueId::uniqueId();
|
UniqueId::uniqueId();
|
||||||
|
srand(time(NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -48,9 +47,7 @@ ModSecurity::ModSecurity() {
|
|||||||
* @name msc_init
|
* @name msc_init
|
||||||
* @brief Initilizes ModSecurity C API
|
* @brief Initilizes ModSecurity C API
|
||||||
*
|
*
|
||||||
* ModSecurity initializer. Although it is not really doing anything
|
* ModSecurity initializer.
|
||||||
* in this version, further versions of this API may demands this to
|
|
||||||
* be executed.
|
|
||||||
*
|
*
|
||||||
* Example Usage:
|
* Example Usage:
|
||||||
* @code
|
* @code
|
||||||
|
22
src/utils.cc
22
src/utils.cc
@ -15,6 +15,14 @@
|
|||||||
|
|
||||||
#include "src/utils.h"
|
#include "src/utils.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <random>
|
||||||
|
#include <memory>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
#include "modsecurity/modsecurity.h"
|
#include "modsecurity/modsecurity.h"
|
||||||
|
|
||||||
@ -33,5 +41,19 @@ std::vector<std::string> split(std::string str, char delimiter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double random_number(const double from, const double to) {
|
||||||
|
std::random_device rd;
|
||||||
|
|
||||||
|
return std::bind(
|
||||||
|
std::uniform_real_distribution<>{from, to},
|
||||||
|
std::default_random_engine{ rd() })();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double generate_assay_unique_id() {
|
||||||
|
return random_number(0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace ModSecurity
|
} // namespace ModSecurity
|
||||||
|
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
|
|
||||||
namespace ModSecurity {
|
namespace ModSecurity {
|
||||||
std::vector<std::string> split(std::string str, char delimiter);
|
std::vector<std::string> split(std::string str, char delimiter);
|
||||||
|
double random_number(const double from, const double to);
|
||||||
|
double generate_assay_unique_id();
|
||||||
} // namespace ModSecurity
|
} // namespace ModSecurity
|
||||||
|
|
||||||
#define SRC_UTILS_H_
|
#define SRC_UTILS_H_
|
||||||
|
Loading…
x
Reference in New Issue
Block a user