mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Cosmetics: Fix some static analysis report
This commit is contained in:
@@ -30,7 +30,8 @@ namespace ctl {
|
|||||||
class RuleRemoveById : public Action {
|
class RuleRemoveById : public Action {
|
||||||
public:
|
public:
|
||||||
explicit RuleRemoveById(std::string action)
|
explicit RuleRemoveById(std::string action)
|
||||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
: Action(action, RunTimeOnlyIfMatchKind),
|
||||||
|
m_id(0) { }
|
||||||
|
|
||||||
bool init(std::string *error) override;
|
bool init(std::string *error) override;
|
||||||
bool evaluate(Rule *rule, Transaction *transaction) override;
|
bool evaluate(Rule *rule, Transaction *transaction) override;
|
||||||
|
@@ -30,7 +30,9 @@ namespace ctl {
|
|||||||
class RuleRemoveTargetById : public Action {
|
class RuleRemoveTargetById : public Action {
|
||||||
public:
|
public:
|
||||||
explicit RuleRemoveTargetById(std::string action)
|
explicit RuleRemoveTargetById(std::string action)
|
||||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
: Action(action, RunTimeOnlyIfMatchKind),
|
||||||
|
m_id(0),
|
||||||
|
m_target("") { }
|
||||||
|
|
||||||
bool init(std::string *error) override;
|
bool init(std::string *error) override;
|
||||||
bool evaluate(Rule *rule, Transaction *transaction) override;
|
bool evaluate(Rule *rule, Transaction *transaction) override;
|
||||||
|
@@ -33,8 +33,8 @@ namespace actions {
|
|||||||
class Phase : public Action {
|
class Phase : public Action {
|
||||||
public:
|
public:
|
||||||
explicit Phase(std::string action) : Action(action, ConfigurationKind),
|
explicit Phase(std::string action) : Action(action, ConfigurationKind),
|
||||||
m_secRulesPhase(0),
|
m_phase(0),
|
||||||
m_phase(0) { }
|
m_secRulesPhase(0) { }
|
||||||
|
|
||||||
bool init(std::string *error) override;
|
bool init(std::string *error) override;
|
||||||
bool evaluate(Rule *rule, Transaction *transaction) override;
|
bool evaluate(Rule *rule, Transaction *transaction) override;
|
||||||
|
@@ -31,7 +31,10 @@ namespace actions {
|
|||||||
class Redirect : public Action {
|
class Redirect : public Action {
|
||||||
public:
|
public:
|
||||||
explicit Redirect(const std::string &action)
|
explicit Redirect(const std::string &action)
|
||||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
: Action(action, RunTimeOnlyIfMatchKind),
|
||||||
|
m_status(0),
|
||||||
|
m_urlExpanded(""),
|
||||||
|
m_url("") { }
|
||||||
|
|
||||||
bool evaluate(Rule *rule, Transaction *transaction) override;
|
bool evaluate(Rule *rule, Transaction *transaction) override;
|
||||||
bool init(std::string *error) override;
|
bool init(std::string *error) override;
|
||||||
|
@@ -29,7 +29,11 @@ namespace actions {
|
|||||||
|
|
||||||
class SetVar : public Action {
|
class SetVar : public Action {
|
||||||
public:
|
public:
|
||||||
explicit SetVar(std::string action) : Action(action) { }
|
explicit SetVar(std::string action) : Action(action),
|
||||||
|
m_operation(SetVarOperation::setOperation),
|
||||||
|
m_collectionName(""),
|
||||||
|
m_variableName(""),
|
||||||
|
m_predicate("") { }
|
||||||
|
|
||||||
bool evaluate(Rule *rule, Transaction *transaction) override;
|
bool evaluate(Rule *rule, Transaction *transaction) override;
|
||||||
bool init(std::string *error) override;
|
bool init(std::string *error) override;
|
||||||
|
@@ -30,7 +30,8 @@ namespace actions {
|
|||||||
|
|
||||||
class Status : public Action {
|
class Status : public Action {
|
||||||
public:
|
public:
|
||||||
explicit Status(std::string action) : Action(action, 2) { }
|
explicit Status(std::string action) : Action(action, 2),
|
||||||
|
m_status(0) { }
|
||||||
|
|
||||||
bool init(std::string *error) override;
|
bool init(std::string *error) override;
|
||||||
bool evaluate(Rule *rule, Transaction *transaction, RuleMessage *rm)
|
bool evaluate(Rule *rule, Transaction *transaction, RuleMessage *rm)
|
||||||
|
@@ -42,17 +42,17 @@ namespace modsecurity {
|
|||||||
namespace audit_log {
|
namespace audit_log {
|
||||||
|
|
||||||
AuditLog::AuditLog()
|
AuditLog::AuditLog()
|
||||||
: m_status(OffAuditLogStatus),
|
: m_path1(""),
|
||||||
m_path1(""),
|
|
||||||
m_path2(""),
|
m_path2(""),
|
||||||
m_storage_dir(""),
|
m_storage_dir(""),
|
||||||
|
m_filePermission(0600),
|
||||||
|
m_directoryPermission(0766),
|
||||||
m_parts(AAuditLogPart | BAuditLogPart | CAuditLogPart | FAuditLogPart
|
m_parts(AAuditLogPart | BAuditLogPart | CAuditLogPart | FAuditLogPart
|
||||||
| HAuditLogPart | ZAuditLogPart),
|
| HAuditLogPart | ZAuditLogPart),
|
||||||
|
m_status(OffAuditLogStatus),
|
||||||
m_type(ParallelAuditLogType),
|
m_type(ParallelAuditLogType),
|
||||||
m_writer(NULL),
|
|
||||||
m_relevant(""),
|
m_relevant(""),
|
||||||
filePermission(0600),
|
m_writer(NULL),
|
||||||
directoryPermission(0766),
|
|
||||||
m_refereceCount(0) { }
|
m_refereceCount(0) { }
|
||||||
|
|
||||||
AuditLog::~AuditLog() {
|
AuditLog::~AuditLog() {
|
||||||
@@ -74,13 +74,13 @@ void AuditLog::refCountDecreaseAndCheck() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool AuditLog::setStorageDirMode(int permission) {
|
bool AuditLog::setStorageDirMode(int permission) {
|
||||||
this->directoryPermission = permission;
|
this->m_directoryPermission = permission;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool AuditLog::setFileMode(int permission) {
|
bool AuditLog::setFileMode(int permission) {
|
||||||
this->filePermission = permission;
|
this->m_filePermission = permission;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -166,8 +166,8 @@ class AuditLog {
|
|||||||
std::string m_path2;
|
std::string m_path2;
|
||||||
std::string m_storage_dir;
|
std::string m_storage_dir;
|
||||||
|
|
||||||
int filePermission;
|
int m_filePermission;
|
||||||
int directoryPermission;
|
int m_directoryPermission;
|
||||||
|
|
||||||
int m_parts;
|
int m_parts;
|
||||||
|
|
||||||
|
@@ -114,13 +114,13 @@ bool Parallel::write(Transaction *transaction, int parts) {
|
|||||||
|
|
||||||
utils::createDir((logPath +
|
utils::createDir((logPath +
|
||||||
logFilePath(&transaction->m_timeStamp, YearMonthDayDirectory)).c_str(),
|
logFilePath(&transaction->m_timeStamp, YearMonthDayDirectory)).c_str(),
|
||||||
m_audit->directoryPermission);
|
m_audit->m_directoryPermission);
|
||||||
utils::createDir((logPath +
|
utils::createDir((logPath +
|
||||||
logFilePath(&transaction->m_timeStamp, YearMonthDayDirectory
|
logFilePath(&transaction->m_timeStamp, YearMonthDayDirectory
|
||||||
| YearMonthDayAndTimeDirectory)).c_str(),
|
| YearMonthDayAndTimeDirectory)).c_str(),
|
||||||
m_audit->directoryPermission);
|
m_audit->m_directoryPermission);
|
||||||
|
|
||||||
fd = open(fileName.c_str(), O_CREAT | O_WRONLY, m_audit->filePermission);
|
fd = open(fileName.c_str(), O_CREAT | O_WRONLY, m_audit->m_filePermission);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -49,7 +49,6 @@ std::string MacroExpansion::expand(const std::string& input,
|
|||||||
modsecurity::Rule *rule, Transaction *transaction) {
|
modsecurity::Rule *rule, Transaction *transaction) {
|
||||||
std::string res;
|
std::string res;
|
||||||
size_t pos = input.find("%{");
|
size_t pos = input.find("%{");
|
||||||
std::string v;
|
|
||||||
|
|
||||||
if (pos != std::string::npos) {
|
if (pos != std::string::npos) {
|
||||||
res = input;
|
res = input;
|
||||||
@@ -73,23 +72,6 @@ std::string MacroExpansion::expand(const std::string& input,
|
|||||||
std::string var = std::string(variable, collection + 1,
|
std::string var = std::string(variable, collection + 1,
|
||||||
variable.length() - (collection + 1));
|
variable.length() - (collection + 1));
|
||||||
|
|
||||||
/*if (utils::string::toupper(col) == "RULE") {
|
|
||||||
if (rule == NULL) {
|
|
||||||
transaction->debug(9, "macro expansion: cannot resolve " \
|
|
||||||
"RULE variable without the Rule object");
|
|
||||||
goto ops;
|
|
||||||
}
|
|
||||||
modsecurity::Variables::Rule r("RULE:" + var);
|
|
||||||
std::vector<const collection::Variable *> l;
|
|
||||||
r.evaluateInternal(transaction, rule, &l);
|
|
||||||
if (l.size() > 0) {
|
|
||||||
v = l[0]->m_value;
|
|
||||||
variableValue = &v;
|
|
||||||
}
|
|
||||||
for (auto *i : l) {
|
|
||||||
delete i;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
if (utils::string::toupper(col) == "RULE") {
|
if (utils::string::toupper(col) == "RULE") {
|
||||||
variableValue = transaction->m_collections.resolveFirst(
|
variableValue = transaction->m_collections.resolveFirst(
|
||||||
"RULE:" + var);
|
"RULE:" + var);
|
||||||
@@ -113,7 +95,7 @@ std::string MacroExpansion::expand(const std::string& input,
|
|||||||
if (variableValue != NULL) {
|
if (variableValue != NULL) {
|
||||||
res.insert(start, *variableValue);
|
res.insert(start, *variableValue);
|
||||||
}
|
}
|
||||||
ops:
|
|
||||||
pos = res.find("%{");
|
pos = res.find("%{");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -58,8 +58,8 @@ class Operator {
|
|||||||
return evaluate(transaction, str);
|
return evaluate(transaction, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool m_negation;
|
|
||||||
std::string m_match_message;
|
std::string m_match_message;
|
||||||
|
bool m_negation;
|
||||||
std::string m_op;
|
std::string m_op;
|
||||||
std::string m_param;
|
std::string m_param;
|
||||||
|
|
||||||
|
@@ -35,8 +35,7 @@ class Rx : public Operator {
|
|||||||
public:
|
public:
|
||||||
/** @ingroup ModSecurity_Operator */
|
/** @ingroup ModSecurity_Operator */
|
||||||
Rx(std::string op, std::string param, bool negation)
|
Rx(std::string op, std::string param, bool negation)
|
||||||
: Operator(op, param, negation),
|
: Operator(op, param, negation) {
|
||||||
m_param(param) {
|
|
||||||
m_re = new Regex(param);
|
m_re = new Regex(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,7 +50,6 @@ class Rx : public Operator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_param;
|
|
||||||
Regex *m_re;
|
Regex *m_re;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -519,7 +519,6 @@ void Rule::executeActionsAfterFullMatch(Transaction *trasn,
|
|||||||
|
|
||||||
|
|
||||||
bool Rule::evaluate(Transaction *trasn) {
|
bool Rule::evaluate(Transaction *trasn) {
|
||||||
bool isThisAChainedRule = rule_id == 0;
|
|
||||||
bool globalRet = false;
|
bool globalRet = false;
|
||||||
std::vector<Variable *> *variables = this->variables;
|
std::vector<Variable *> *variables = this->variables;
|
||||||
bool recursiveGlobalRet;
|
bool recursiveGlobalRet;
|
||||||
@@ -571,13 +570,13 @@ bool Rule::evaluate(Transaction *trasn) {
|
|||||||
for (const collection::Variable *v : finalVars) {
|
for (const collection::Variable *v : finalVars) {
|
||||||
std::string value = v->m_value;
|
std::string value = v->m_value;
|
||||||
std::vector<std::string> values;
|
std::vector<std::string> values;
|
||||||
bool ret;
|
|
||||||
bool multiMatch = getActionsByName("multimatch").size() > 0;
|
bool multiMatch = getActionsByName("multimatch").size() > 0;
|
||||||
|
|
||||||
values = executeSecDefaultActionTransofrmations(trasn, value,
|
values = executeSecDefaultActionTransofrmations(trasn, value,
|
||||||
multiMatch);
|
multiMatch);
|
||||||
|
|
||||||
for (const std::string &valueTemp : values) {
|
for (const std::string &valueTemp : values) {
|
||||||
|
bool ret;
|
||||||
ret = executeOperatorAt(trasn, v->m_key, valueTemp);
|
ret = executeOperatorAt(trasn, v->m_key, valueTemp);
|
||||||
if (ret == true) {
|
if (ret == true) {
|
||||||
ruleMessage.m_match = resolveMatchMessage(v->m_key, value);
|
ruleMessage.m_match = resolveMatchMessage(v->m_key, value);
|
||||||
@@ -659,7 +658,6 @@ std::vector<actions::Action *> Rule::getActionsByName(const std::string& name) {
|
|||||||
|
|
||||||
|
|
||||||
bool Rule::containsTag(const std::string& name, Transaction *t) {
|
bool Rule::containsTag(const std::string& name, Transaction *t) {
|
||||||
std::vector<std::string *> ret;
|
|
||||||
for (auto &z : this->m_actionsRuntimePos) {
|
for (auto &z : this->m_actionsRuntimePos) {
|
||||||
actions::Tag *tag = dynamic_cast<actions::Tag *> (z);
|
actions::Tag *tag = dynamic_cast<actions::Tag *> (z);
|
||||||
if (tag != NULL && tag->getName(t) == name) {
|
if (tag != NULL && tag->getName(t) == name) {
|
||||||
|
@@ -39,7 +39,8 @@ namespace Utils {
|
|||||||
|
|
||||||
|
|
||||||
Regex::Regex(const std::string& pattern_)
|
Regex::Regex(const std::string& pattern_)
|
||||||
: pattern(pattern_) {
|
: pattern(pattern_),
|
||||||
|
m_ovector {0} {
|
||||||
const char *errptr = NULL;
|
const char *errptr = NULL;
|
||||||
int erroffset;
|
int erroffset;
|
||||||
|
|
||||||
@@ -86,7 +87,7 @@ std::list<SMatch> Regex::searchAll(const std::string& s) {
|
|||||||
int substring_length = ovector[2*i+1] - ovector[2*i];
|
int substring_length = ovector[2*i+1] - ovector[2*i];
|
||||||
|
|
||||||
match.match = std::string(subject, ovector[2*i],
|
match.match = std::string(subject, ovector[2*i],
|
||||||
ovector[2*i+1] - ovector[2*i]);
|
substring_length);
|
||||||
|
|
||||||
retList.push_front(match);
|
retList.push_front(match);
|
||||||
}
|
}
|
||||||
|
@@ -28,11 +28,13 @@ unusedLabel:src/unique_id.cc:222
|
|||||||
unusedLabel:src/unique_id.cc:224
|
unusedLabel:src/unique_id.cc:224
|
||||||
leakReturnValNotUsed:src/debug_log_writer_agent.cc:31
|
leakReturnValNotUsed:src/debug_log_writer_agent.cc:31
|
||||||
postfixOperator:*
|
postfixOperator:*
|
||||||
*:src/utils/mbedtls/base64.c
|
*:others/mbedtls/base64.c
|
||||||
*:src/utils/mbedtls/sha1.c
|
*:others/mbedtls/sha1.c
|
||||||
|
*:others/mbedtls/md5.c
|
||||||
readdirCalled:test/common/modsecurity_test.cc:114
|
readdirCalled:test/common/modsecurity_test.cc:114
|
||||||
missingInclude:*
|
missingInclude:*
|
||||||
unreadVariable:test/regression/regression.cc:380
|
unreadVariable:test/regression/regression.cc:380
|
||||||
shiftNegative:src/utils/msc_tree.cc
|
shiftNegative:src/utils/msc_tree.cc
|
||||||
nullPointerRedundantCheck:src/utils/msc_tree.cc:654
|
nullPointerRedundantCheck:src/utils/msc_tree.cc:654
|
||||||
|
*:test/benchmark/owasp-v3/util/av-scanning/runAV/common.c
|
||||||
|
functionStatic:*
|
||||||
|
Reference in New Issue
Block a user