mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 13:56:01 +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 "actions/transformations/normalise_path.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -24,6 +26,7 @@
|
|||||||
|
|
||||||
#include "modsecurity/assay.h"
|
#include "modsecurity/assay.h"
|
||||||
#include "actions/transformations/transformation.h"
|
#include "actions/transformations/transformation.h"
|
||||||
|
#include "src/utils.h"
|
||||||
|
|
||||||
|
|
||||||
namespace ModSecurity {
|
namespace ModSecurity {
|
||||||
@ -37,16 +40,20 @@ NormalisePath::NormalisePath(std::string action)
|
|||||||
|
|
||||||
std::string NormalisePath::evaluate(std::string value,
|
std::string NormalisePath::evaluate(std::string value,
|
||||||
Assay *assay) {
|
Assay *assay) {
|
||||||
/**
|
int changed = 0;
|
||||||
* @todo Implement the transformation NormalisePath
|
|
||||||
*/
|
char *tmp = (char *) malloc(sizeof(char) * value.size() + 1);
|
||||||
if (assay) {
|
memcpy(tmp, value.c_str(), value.size() + 1);
|
||||||
#ifndef NO_LOGS
|
tmp[value.size()] = '\0';
|
||||||
assay->debug(4, "Transformation NormalisePath is not" \
|
|
||||||
" implemented yet.");
|
int i = normalize_path_inplace((unsigned char *)tmp,
|
||||||
#endif
|
value.size(), 0, &changed);
|
||||||
}
|
|
||||||
return value;
|
std::string ret("");
|
||||||
|
ret.assign(tmp, i);
|
||||||
|
free(tmp);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace transformations
|
} // namespace transformations
|
||||||
|
@ -37,11 +37,16 @@ namespace transformations {
|
|||||||
std::string NormalisePathWin::evaluate(std::string value,
|
std::string NormalisePathWin::evaluate(std::string value,
|
||||||
Assay *assay) {
|
Assay *assay) {
|
||||||
int changed;
|
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);
|
value.size(), 1, &changed);
|
||||||
|
|
||||||
std::string ret("");
|
std::string ret("");
|
||||||
ret.assign(tmp);
|
ret.assign(tmp, i);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -88,8 +88,8 @@ Transformation* Transformation::instantiate(std::string a) {
|
|||||||
IF_MATCH(lowercase) { return new LowerCase(a); }
|
IF_MATCH(lowercase) { return new LowerCase(a); }
|
||||||
IF_MATCH(md5) { return new Md5(a); }
|
IF_MATCH(md5) { return new Md5(a); }
|
||||||
IF_MATCH(none) { return new None(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(normalisePathWin) { return new NormalisePathWin(a); }
|
||||||
|
IF_MATCH(normalisePath) { return new NormalisePath(a); }
|
||||||
IF_MATCH(parity_even_7bit) { return new ParityEven7bit(a); }
|
IF_MATCH(parity_even_7bit) { return new ParityEven7bit(a); }
|
||||||
IF_MATCH(parity_odd_7bit) { return new ParityOdd7bit(a); }
|
IF_MATCH(parity_odd_7bit) { return new ParityOdd7bit(a); }
|
||||||
IF_MATCH(parity_zero_7bit) { return new ParityZero7bit(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