mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-16 07:56:12 +03:00
Merge pull request #3212 from eduar-hte/defensive-intervention
Do not assume ModSecurityIntervention argument to transaction::intervention has been initialized/cleaned
This commit is contained in:
commit
1d6e72e8e2
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@ -12,8 +12,8 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-22.04]
|
os: [ubuntu-22.04]
|
||||||
platform:
|
platform:
|
||||||
- {label: "x64", arch: "amd64", configure: "--enable-assertions=yes"}
|
- {label: "x64", arch: "amd64", configure: ""}
|
||||||
- {label: "x32", arch: "i386", configure: "PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32 --enable-assertions=yes"}
|
- {label: "x32", arch: "i386", configure: "PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32"}
|
||||||
compiler:
|
compiler:
|
||||||
- {label: "gcc", cc: "gcc", cxx: "g++"}
|
- {label: "gcc", cc: "gcc", cxx: "g++"}
|
||||||
- {label: "clang", cc: "clang", cxx: "clang++"}
|
- {label: "clang", cc: "clang", cxx: "clang++"}
|
||||||
@ -66,7 +66,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
CC: ${{ matrix.compiler.cc }}
|
CC: ${{ matrix.compiler.cc }}
|
||||||
CXX: ${{ matrix.compiler.cxx }}
|
CXX: ${{ matrix.compiler.cxx }}
|
||||||
run: ./configure ${{ matrix.platform.configure }} ${{ matrix.configure.opt }}
|
run: ./configure ${{ matrix.platform.configure }} ${{ matrix.configure.opt }} --enable-assertions=yes
|
||||||
- uses: ammaraskar/gcc-problem-matcher@master
|
- uses: ammaraskar/gcc-problem-matcher@master
|
||||||
- name: make
|
- name: make
|
||||||
run: make -j `nproc`
|
run: make -j `nproc`
|
||||||
|
@ -1470,30 +1470,39 @@ int Transaction::processLogging() {
|
|||||||
*
|
*
|
||||||
* Intervention can generate a log event and/or perform a disruptive action.
|
* Intervention can generate a log event and/or perform a disruptive action.
|
||||||
*
|
*
|
||||||
* @param Pointer ModSecurityIntervention structure
|
* If the return value is true, all fields in the ModSecurityIntervention
|
||||||
|
* parameter have been initialized and are safe to access.
|
||||||
|
* If the return value is false, no changes to the ModSecurityIntervention
|
||||||
|
* parameter have been made.
|
||||||
|
*
|
||||||
|
* @param it Pointer to ModSecurityIntervention structure
|
||||||
* @retval true A intervention should be made.
|
* @retval true A intervention should be made.
|
||||||
* @retval false Nothing to be done.
|
* @retval false Nothing to be done.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
bool Transaction::intervention(ModSecurityIntervention *it) {
|
bool Transaction::intervention(ModSecurityIntervention *it) {
|
||||||
|
const auto disruptive = m_it.disruptive;
|
||||||
if (m_it.disruptive) {
|
if (m_it.disruptive) {
|
||||||
if (m_it.url) {
|
if (m_it.url) {
|
||||||
it->url = strdup(m_it.url);
|
it->url = strdup(m_it.url);
|
||||||
|
} else {
|
||||||
|
it->url = NULL;
|
||||||
}
|
}
|
||||||
it->disruptive = m_it.disruptive;
|
it->disruptive = m_it.disruptive;
|
||||||
it->status = m_it.status;
|
it->status = m_it.status;
|
||||||
|
|
||||||
if (m_it.log != NULL) {
|
if (m_it.log != NULL) {
|
||||||
std::string log("");
|
std::string log(m_it.log);
|
||||||
log.append(m_it.log);
|
utils::string::replaceAll(log, "%d",
|
||||||
utils::string::replaceAll(&log, std::string("%d"),
|
|
||||||
std::to_string(it->status));
|
std::to_string(it->status));
|
||||||
it->log = strdup(log.c_str());
|
it->log = strdup(log.c_str());
|
||||||
|
} else {
|
||||||
|
it->log = NULL;
|
||||||
}
|
}
|
||||||
intervention::reset(&m_it);
|
intervention::reset(&m_it);
|
||||||
}
|
}
|
||||||
|
|
||||||
return it->disruptive;
|
return disruptive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2260,11 +2269,16 @@ extern "C" void msc_transaction_cleanup(Transaction *transaction) {
|
|||||||
*
|
*
|
||||||
* Intervention can generate a log event and/or perform a disruptive action.
|
* Intervention can generate a log event and/or perform a disruptive action.
|
||||||
*
|
*
|
||||||
* @param transaction ModSecurity transaction.
|
* If the return value is not zero, all fields in the ModSecurityIntervention
|
||||||
|
* parameter have been initialized and are safe to access.
|
||||||
|
* If the return value is zero, no changes to the ModSecurityIntervention
|
||||||
|
* parameter have been made.
|
||||||
*
|
*
|
||||||
* @return Pointer to ModSecurityIntervention structure
|
* @param transaction ModSecurity transaction.
|
||||||
* @retval >0 A intervention should be made.
|
* @param it Pointer to ModSecurityIntervention structure
|
||||||
* @retval NULL Nothing to be done.
|
* @returns If an intervention should be made
|
||||||
|
* @retval >0 A intervention should be made.
|
||||||
|
* @retval 0 Nothing to be done.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
extern "C" int msc_intervention(Transaction *transaction,
|
extern "C" int msc_intervention(Transaction *transaction,
|
||||||
|
@ -254,11 +254,11 @@ unsigned char *c2x(unsigned what, unsigned char *where) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void replaceAll(std::string *str, const std::string& from,
|
void replaceAll(std::string &str, std::string_view from,
|
||||||
const std::string& to) {
|
std::string_view to) {
|
||||||
size_t start_pos = 0;
|
size_t start_pos = 0;
|
||||||
while ((start_pos = str->find(from, start_pos)) != std::string::npos) {
|
while ((start_pos = str.find(from, start_pos)) != std::string::npos) {
|
||||||
str->replace(start_pos, from.length(), to);
|
str.replace(start_pos, from.length(), to);
|
||||||
start_pos += to.length();
|
start_pos += to.length();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,8 +68,8 @@ std::vector<std::string> ssplit(std::string str, char delimiter);
|
|||||||
std::pair<std::string, std::string> ssplit_pair(const std::string& str, char delimiter);
|
std::pair<std::string, std::string> ssplit_pair(const std::string& str, char delimiter);
|
||||||
std::vector<std::string> split(std::string str, char delimiter);
|
std::vector<std::string> split(std::string str, char delimiter);
|
||||||
void chomp(std::string *str);
|
void chomp(std::string *str);
|
||||||
void replaceAll(std::string *str, const std::string& from,
|
void replaceAll(std::string &str, std::string_view from,
|
||||||
const std::string& to);
|
std::string_view to);
|
||||||
std::string removeWhiteSpacesIfNeeded(std::string a);
|
std::string removeWhiteSpacesIfNeeded(std::string a);
|
||||||
std::string parserSanitizer(std::string a);
|
std::string parserSanitizer(std::string a);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user