mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Adds support to the transformation normalisePath and normalisePathWin
This commit is contained in:
parent
7ab75ac015
commit
7e826633f1
@ -15,6 +15,8 @@
|
||||
|
||||
#include "actions/transformations/normalise_path.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
@ -24,6 +26,7 @@
|
||||
|
||||
#include "modsecurity/assay.h"
|
||||
#include "actions/transformations/transformation.h"
|
||||
#include "src/utils.h"
|
||||
|
||||
|
||||
namespace ModSecurity {
|
||||
@ -37,16 +40,20 @@ NormalisePath::NormalisePath(std::string action)
|
||||
|
||||
std::string NormalisePath::evaluate(std::string value,
|
||||
Assay *assay) {
|
||||
/**
|
||||
* @todo Implement the transformation NormalisePath
|
||||
*/
|
||||
if (assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "Transformation NormalisePath is not" \
|
||||
" implemented yet.");
|
||||
#endif
|
||||
}
|
||||
return value;
|
||||
int changed = 0;
|
||||
|
||||
char *tmp = (char *) malloc(sizeof(char) * value.size() + 1);
|
||||
memcpy(tmp, value.c_str(), value.size() + 1);
|
||||
tmp[value.size()] = '\0';
|
||||
|
||||
int i = normalize_path_inplace((unsigned char *)tmp,
|
||||
value.size(), 0, &changed);
|
||||
|
||||
std::string ret("");
|
||||
ret.assign(tmp, i);
|
||||
free(tmp);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace transformations
|
||||
|
@ -37,11 +37,16 @@ namespace transformations {
|
||||
std::string NormalisePathWin::evaluate(std::string value,
|
||||
Assay *assay) {
|
||||
int changed;
|
||||
char *tmp = strdup(value.c_str());
|
||||
normalize_path_inplace((unsigned char *)tmp,
|
||||
|
||||
char *tmp = (char *) malloc(sizeof(char) * value.size() + 1);
|
||||
memcpy(tmp, value.c_str(), value.size() + 1);
|
||||
tmp[value.size()] = '\0';
|
||||
|
||||
int i = normalize_path_inplace((unsigned char *)tmp,
|
||||
value.size(), 1, &changed);
|
||||
|
||||
std::string ret("");
|
||||
ret.assign(tmp);
|
||||
ret.assign(tmp, i);
|
||||
free(tmp);
|
||||
|
||||
return ret;
|
||||
|
@ -88,8 +88,8 @@ Transformation* Transformation::instantiate(std::string a) {
|
||||
IF_MATCH(lowercase) { return new LowerCase(a); }
|
||||
IF_MATCH(md5) { return new Md5(a); }
|
||||
IF_MATCH(none) { return new None(a); }
|
||||
IF_MATCH(normalise_path) { return new NormalisePath(a); }
|
||||
IF_MATCH(normalisePathWin) { return new NormalisePathWin(a); }
|
||||
IF_MATCH(normalisePath) { return new NormalisePath(a); }
|
||||
IF_MATCH(parity_even_7bit) { return new ParityEven7bit(a); }
|
||||
IF_MATCH(parity_odd_7bit) { return new ParityOdd7bit(a); }
|
||||
IF_MATCH(parity_zero_7bit) { return new ParityZero7bit(a); }
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 76c4bd6460a870b481eb4d36fcead7818b20d7d9
|
||||
Subproject commit 26af965147db5aae11c56bebea9649f4ea7cb1d4
|
Loading…
x
Reference in New Issue
Block a user