Minor updates to simplify code and remove cppcheck suppressions

This commit is contained in:
Eduardo Arias 2024-04-28 12:01:20 -03:00
parent fde9d279b0
commit 94b68b2514
3 changed files with 8 additions and 12 deletions

View File

@ -46,7 +46,7 @@ std::string ModSecurityTest<T>::header() {
}
template <class T>
bool ModSecurityTest<T>::load_test_json(std::string file) {
bool ModSecurityTest<T>::load_test_json(const std::string &file) {
char errbuf[1024];
yajl_val node;
@ -76,13 +76,12 @@ bool ModSecurityTest<T>::load_test_json(std::string file) {
u->filename = file;
if (this->count(u->filename + ":" + u->name) == 0) {
std::vector<T *> *vector = new std::vector<T *>;
vector->push_back(u);
auto vec = new std::vector<T *>;
vec->push_back(u);
std::string filename(u->filename + ":" + u->name);
std::pair<std::string, std::vector<T*>*> a(filename, vector);
this->insert(a);
this->insert({filename, vec});
} else {
std::vector<T *> *vec = this->at(u->filename + ":" + u->name);
auto vec = this->at(u->filename + ":" + u->name);
vec->push_back(u);
}
}
@ -95,7 +94,7 @@ bool ModSecurityTest<T>::load_test_json(std::string file) {
template <class T>
std::pair<std::string, std::vector<T *>>*
ModSecurityTest<T>::load_tests(std::string path) {
ModSecurityTest<T>::load_tests(const std::string &path) {
DIR *dir;
struct dirent *ent;
struct stat buffer;

View File

@ -39,8 +39,8 @@ template <class T> class ModSecurityTest :
std::string header();
void cmd_options(int, char **);
std::pair<std::string, std::vector<T *>>* load_tests();
std::pair<std::string, std::vector<T *>>* load_tests(std::string path);
bool load_test_json(std::string);
std::pair<std::string, std::vector<T *>>* load_tests(const std::string &path);
bool load_test_json(const std::string &file);
std::string target;
bool verbose = false;

View File

@ -43,7 +43,6 @@ functionStatic:src/engine/lua.h:70
functionStatic:src/engine/lua.h:71
functionConst:src/utils/geo_lookup.h:49
useInitializationList:src/operators/rbl.h:69
constStatement:test/common/modsecurity_test.cc:82
functionStatic:src/operators/geo_lookup.h:35
duplicateBreak:src/operators/validate_utf8_encoding.cc
syntaxError:src/transaction.cc:62
@ -55,8 +54,6 @@ rethrowNoCurrentException:src/rule_with_actions.cc:127
ctunullpointer:src/rule_with_actions.cc:244
ctunullpointer:src/rule_with_operator.cc:135
ctunullpointer:src/rule_with_operator.cc:95
passedByValue:test/common/modsecurity_test.cc:49
passedByValue:test/common/modsecurity_test.cc:98
unreadVariable:src/rule_with_operator.cc:219
uninitvar:src/operators/verify_cpf.cc:77