mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 13:56:01 +03:00
- src/modsecurity.cc - Replace the redundant type with "auto". - src/transaction.cc - Avoid this unnecessary copy by using a "const" reference. - test/common/custom_debug_log.cc - Use "=default" instead of the default implementation of this special member functions. - Removed the unnecessary destructor override instead. - Annotate this function with "override" or "final". - Removed the unnecessary destructor override instead. - Remove this "const" qualifier from the return type in all declarations. - test/common/modsecurity_test_context.h - Replace the redundant type with "auto". - test/regression/regression.cc - Use the "nullptr" literal. - Replace this declaration by a structured binding declaration. - Replace "reinterpret_cast" with a safer operation.
43 lines
1.3 KiB
C++
43 lines
1.3 KiB
C++
#ifndef TEST_COMMON_MODSECURITY_TEST_CONTEXT_H_
|
|
#define TEST_COMMON_MODSECURITY_TEST_CONTEXT_H_
|
|
|
|
#include "modsecurity/modsecurity.h"
|
|
#include "modsecurity/rules_set.h"
|
|
#include "modsecurity/transaction.h"
|
|
#include "custom_debug_log.h"
|
|
|
|
#include <sstream>
|
|
|
|
namespace modsecurity_test {
|
|
|
|
class ModSecurityTestContext {
|
|
public:
|
|
explicit ModSecurityTestContext(const std::string &connector)
|
|
: m_modsec_rules(new CustomDebugLog) {
|
|
m_modsec.setConnectorInformation(connector);
|
|
m_modsec.setServerLogCb(logCb);
|
|
}
|
|
~ModSecurityTestContext() = default;
|
|
|
|
modsecurity::Transaction create_transaction() {
|
|
return modsecurity::Transaction(&m_modsec,
|
|
&m_modsec_rules,
|
|
&m_server_log);
|
|
}
|
|
|
|
modsecurity::ModSecurity m_modsec;
|
|
modsecurity::RulesSet m_modsec_rules;
|
|
std::stringstream m_server_log;
|
|
|
|
private:
|
|
static void logCb(void *data, const void *msgv) {
|
|
auto msg = reinterpret_cast<const char *>(msgv);
|
|
auto ss = reinterpret_cast<std::stringstream *>(data);
|
|
*ss << msg << std::endl;
|
|
}
|
|
};
|
|
|
|
} // namespace modsecurity_test
|
|
|
|
#endif // TEST_COMMON_MODSECURITY_TEST_H_
|