mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-30 19:47:47 +03:00
Adds random id to each assay
This commit is contained in:
22
src/utils.cc
22
src/utils.cc
@@ -15,6 +15,14 @@
|
||||
|
||||
#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"
|
||||
|
||||
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user