Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
276026f
Fix sign-compare warning in anchored set variable translation proxy
mikelolasagasti May 15, 2026
f097e3c
Fix unused-function warnings for intervention helpers in header
mikelolasagasti May 15, 2026
0391bb9
Fix sign-compare warning in utils::string::limitTo
mikelolasagasti May 15, 2026
7277a15
Fix -Wreorder in VariableDictElement constructor
mikelolasagasti May 15, 2026
e400f07
Fix -Wreorder in VariableRegex constructor
mikelolasagasti May 15, 2026
8eea1e2
Fix sign-compare warning in InitCol::init
mikelolasagasti May 15, 2026
302aa5f
Fix sign-compare warnings in ModSecurity::processContentOffset
mikelolasagasti May 15, 2026
6d2a3ef
Fix -Wreorder in Rx constructor
mikelolasagasti May 15, 2026
64a313f
Fix -Wreorder in RxGlobal constructor
mikelolasagasti May 15, 2026
f2e9299
Fix sign-compare warning in RulesSet::evaluate
mikelolasagasti May 15, 2026
a258be3
Remove unused variables in seclang parser runtime-var rules
mikelolasagasti May 15, 2026
9373721
Fix compiler warnings in msc_tree.cc
mikelolasagasti May 15, 2026
0f80253
Fix snprintf and sign-compare warnings in utf8_to_unicode
mikelolasagasti May 15, 2026
dc6ee8b
Fix sign-compare warning in html_entity_decode
mikelolasagasti May 15, 2026
5edbcdb
Fix sign-compare warning in CompressWhitespace::transform
mikelolasagasti May 15, 2026
d11afd7
Fix sign-compare warning in Multipart::process_part_data
mikelolasagasti May 15, 2026
1eaa654
Fix sign-compare warnings in ValidateUrlEncoding
mikelolasagasti May 15, 2026
5e1fe26
Fix sign-compare warning in PmFromFile::isComment
mikelolasagasti May 15, 2026
bb17fd7
Fix sign-compare warning in Driver::addSecRule
mikelolasagasti May 15, 2026
387ac55
Fix -Wreorder in Transaction constructor
mikelolasagasti May 15, 2026
905e100
Fix sign-compare in Transaction::processRequestBody
mikelolasagasti May 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class AnchoredSetVariableTranslationProxy {
m_fount(fount)
{
m_translate = [](const std::string *name, std::vector<const VariableValue *> *l) {
for (int i = 0; i < l->size(); ++i) {
for (std::vector<const VariableValue *>::size_type i = 0;
i < l->size(); ++i) {
VariableValue *newVariableValue = new VariableValue(name, &l->at(i)->getKey(), &l->at(i)->getKey());
const VariableValue *oldVariableValue = l->at(i);
l->at(i) = newVariableValue;
Expand Down
10 changes: 5 additions & 5 deletions headers/modsecurity/intervention.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,33 @@ typedef struct ModSecurityIntervention_t {

#ifdef __cplusplus
namespace intervention {
static void reset(ModSecurityIntervention_t *i) {
inline void reset(ModSecurityIntervention_t *i) {
i->status = 200;
i->pause = 0;
i->disruptive = 0;
}

static void clean(ModSecurityIntervention_t *i) {
inline void clean(ModSecurityIntervention_t *i) {
i->url = NULL;
i->log = NULL;
reset(i);
}

static void freeUrl(ModSecurityIntervention_t *i) {
inline void freeUrl(ModSecurityIntervention_t *i) {
if (i->url) {
free(i->url);
i->url = NULL;
}
}

static void freeLog(ModSecurityIntervention_t *i) {
inline void freeLog(ModSecurityIntervention_t *i) {
if (i->log) {
free(i->log);
i->log = NULL;
}
}

static void free(ModSecurityIntervention_t *i) {
inline void free(ModSecurityIntervention_t *i) {
freeUrl(i);
freeLog(i);
}
Expand Down
2 changes: 1 addition & 1 deletion src/actions/init_col.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace actions {


bool InitCol::init(std::string *error) {
int posEquals = m_parser_payload.find("=");
const std::string::size_type posEquals = m_parser_payload.find("=");

if (m_parser_payload.size() < 2) {
error->assign("Something wrong with initcol format: too small");
Expand Down
5 changes: 3 additions & 2 deletions src/actions/transformations/compress_whitespace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
}
}

const auto new_len = d - value.c_str();
const auto changed = new_len != value.length();
const std::string::size_type new_len = static_cast<std::string::size_type>(

Check warning on line 41 in src/actions/transformations/compress_whitespace.cc

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace the redundant type with "auto".

See more on https://sonarcloud.io/project/issues?id=owasp-modsecurity_ModSecurity&issues=AZ4rg9PW_UM1u-u3UotY&open=AZ4rg9PW_UM1u-u3UotY&pullRequest=3567
d - value.data());
const bool changed = new_len != value.length();
value.resize(new_len);
return changed;
}
Expand Down
2 changes: 1 addition & 1 deletion src/actions/transformations/html_entity_decode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ static inline bool inplace(std::string &value) {

HTML_ENT_OUT:

for (auto z = 0; z < copy; z++) {
for (std::string::size_type z = 0; z < copy; z++) {
*d++ = input[i++];
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/actions/transformations/utf8_to_unicode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ static inline bool encode(std::string &value) {
unicode_len = 2;
count += 6;
if (count <= len) {
int length = 0;
size_t length = 0;
/* compute character number */
d = ((c & 0x1F) << 6) | (*(utf + 1) & 0x3F);
*data++ = '%';
*data++ = 'u';
snprintf(reinterpret_cast<char *>(unicode),
sizeof(reinterpret_cast<char *>(unicode)),
sizeof(unicode),
"%x", d);
length = strlen(reinterpret_cast<char *>(unicode));

Expand All @@ -104,7 +104,7 @@ static inline bool encode(std::string &value) {
break;
}

for (std::string::size_type j = 0; j < length; j++) {
for (size_t j = 0; j < length; j++) {
*data++ = unicode[j];
}

Expand All @@ -126,15 +126,15 @@ static inline bool encode(std::string &value) {
unicode_len = 3;
count+=6;
if (count <= len) {
int length = 0;
size_t length = 0;
/* compute character number */
d = ((c & 0x0F) << 12)
| ((*(utf + 1) & 0x3F) << 6)
| (*(utf + 2) & 0x3F);
*data++ = '%';
*data++ = 'u';
snprintf(reinterpret_cast<char *>(unicode),
sizeof(reinterpret_cast<char *>(unicode)),
sizeof(unicode),
"%x", d);
length = strlen(reinterpret_cast<char *>(unicode));

Expand All @@ -156,7 +156,7 @@ static inline bool encode(std::string &value) {
break;
}

for (std::string::size_type j = 0; j < length; j++) {
for (size_t j = 0; j < length; j++) {
*data++ = unicode[j];
}

Expand Down Expand Up @@ -187,7 +187,7 @@ static inline bool encode(std::string &value) {
unicode_len = 4;
count+=7;
if (count <= len) {
int length = 0;
size_t length = 0;
/* compute character number */
d = ((c & 0x07) << 18)
| ((*(utf + 1) & 0x3F) << 12)
Expand All @@ -196,7 +196,7 @@ static inline bool encode(std::string &value) {
*data++ = '%';
*data++ = 'u';
snprintf(reinterpret_cast<char *>(unicode),
sizeof(reinterpret_cast<char *>(unicode)),
sizeof(unicode),
"%x", d);
length = strlen(reinterpret_cast<char *>(unicode));

Expand All @@ -218,7 +218,7 @@ static inline bool encode(std::string &value) {
break;
}

for (std::string::size_type j = 0; j < length; j++) {
for (size_t j = 0; j < length; j++) {
*data++ = unicode[j];
}

Expand Down
4 changes: 2 additions & 2 deletions src/modsecurity.cc
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ int ModSecurity::processContentOffset(const char *content, size_t len,
size.size());
yajl_gen_map_close(g);

if (stoi(startingAt) >= len) {
if (static_cast<size_t>(stoi(startingAt)) >= len) {
*err = "Offset is out of the content limits.";
return -1;
}
Expand Down Expand Up @@ -347,7 +347,7 @@ int ModSecurity::processContentOffset(const char *content, size_t len,
size.size());
yajl_gen_map_close(g);

if (stoi(startingAt) >= varValue.size()) {
if (static_cast<size_t>(stoi(startingAt)) >= varValue.size()) {
*err = "Offset is out of the variable limits.";
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion src/operators/pm_from_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ bool PmFromFile::isComment(const std::string &s) {
}
size_t pos = s.find("#");
if (pos != std::string::npos) {
for (int i = 0; i < pos; i++) {
for (size_t i = 0; i < pos; i++) {
if (!std::isspace(s[i])) {
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/operators/rx.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
public:
/** @ingroup ModSecurity_Operator */
explicit Rx(std::unique_ptr<RunTimeString> param)
: m_re(nullptr),
Operator("Rx", std::move(param)) {
: Operator("Rx", std::move(param)),
m_re(nullptr) {

Check warning on line 41 in src/operators/rx.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not use the constructor's initializer list for data member "m_re". Use the in-class initializer instead.

See more on https://sonarcloud.io/project/issues?id=owasp-modsecurity_ModSecurity&issues=AZ4rg9S3_UM1u-u3UotZ&open=AZ4rg9S3_UM1u-u3UotZ&pullRequest=3567
m_couldContainsMacro = true;
}

Expand Down
4 changes: 2 additions & 2 deletions src/operators/rx_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
public:
/** @ingroup ModSecurity_Operator */
explicit RxGlobal(std::unique_ptr<RunTimeString> param)
: m_re(nullptr),
Operator("RxGlobal", std::move(param)) {
: Operator("RxGlobal", std::move(param)),
m_re(nullptr) {

Check warning on line 41 in src/operators/rx_global.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not use the constructor's initializer list for data member "m_re". Use the in-class initializer instead.

See more on https://sonarcloud.io/project/issues?id=owasp-modsecurity_ModSecurity&issues=AZ4rg9TG_UM1u-u3Uota&open=AZ4rg9TG_UM1u-u3Uota&pullRequest=3567
m_couldContainsMacro = true;
}

Expand Down
3 changes: 1 addition & 2 deletions src/operators/validate_url_encoding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ namespace operators {

int ValidateUrlEncoding::validate_url_encoding(const char *input,
uint64_t input_length, size_t *offset) {
int i;
uint64_t i = 0;
*offset = 0;

if ((input == NULL) || (input_length == 0)) {
return -1;
}

i = 0;
while (i < input_length) {
if (input[i] == '%') {
if (i + 2 >= input_length) {
Expand Down
2 changes: 1 addition & 1 deletion src/parser/driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ int Driver::addSecRule(std::unique_ptr<RuleWithActions> r) {

for (int i = 0; i < modsecurity::Phases::NUMBER_OF_PHASES; i++) {
const Rules *rules = m_rulesSetPhases[i];
for (int j = 0; j < rules->size(); j++) {
for (size_t j = 0; j < rules->size(); j++) {
const RuleWithOperator *lr = dynamic_cast<RuleWithOperator *>(rules->at(j).get());
if (lr && lr->m_ruleId == rule->m_ruleId) {
m_parserError << "Rule id: " << std::to_string(rule->m_ruleId) \
Expand Down
13 changes: 0 additions & 13 deletions src/parser/seclang-parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -2588,92 +2588,79 @@ var:
| RUN_TIME_VAR_DUR
{
std::string name($1);
char z = name.at(0);
std::unique_ptr<Variable> c(new Duration(name));
$$ = std::move(c);
}

| RUN_TIME_VAR_BLD
{
std::string name($1);
char z = name.at(0);
std::unique_ptr<Variable> c(new ModsecBuild(name));
$$ = std::move(c);
}
| RUN_TIME_VAR_HSV
{
std::string name($1);
char z = name.at(0);
std::unique_ptr<Variable> c(new HighestSeverity(name));
$$ = std::move(c);
}
| RUN_TIME_VAR_REMOTE_USER
{
std::string name($1);
char z = name.at(0);
std::unique_ptr<Variable> c(new RemoteUser(name));
$$ = std::move(c);
}
| RUN_TIME_VAR_TIME
{
std::string name($1);
char z = name.at(0);
std::unique_ptr<Variable> c(new Time(name));
$$ = std::move(c);
}
| RUN_TIME_VAR_TIME_DAY
{
std::string name($1);
char z = name.at(0);
std::unique_ptr<Variable> c(new TimeDay(name));
$$ = std::move(c);
}
| RUN_TIME_VAR_TIME_EPOCH
{
std::string name($1);
char z = name.at(0);
std::unique_ptr<Variable> c(new TimeEpoch(name));
$$ = std::move(c);
}
| RUN_TIME_VAR_TIME_HOUR
{
std::string name($1);
char z = name.at(0);
std::unique_ptr<Variable> c(new TimeHour(name));
$$ = std::move(c);
}
| RUN_TIME_VAR_TIME_MIN
{
std::string name($1);
char z = name.at(0);
std::unique_ptr<Variable> c(new TimeMin(name));
$$ = std::move(c);
}
| RUN_TIME_VAR_TIME_MON
{
std::string name($1);
char z = name.at(0);
std::unique_ptr<Variable> c(new TimeMon(name));
$$ = std::move(c);
}
| RUN_TIME_VAR_TIME_SEC
{
std::string name($1);
char z = name.at(0);
std::unique_ptr<Variable> c(new TimeSec(name));
$$ = std::move(c);
}
| RUN_TIME_VAR_TIME_WDAY
{
std::string name($1);
char z = name.at(0);
std::unique_ptr<Variable> c(new TimeWDay(name));
$$ = std::move(c);
}
| RUN_TIME_VAR_TIME_YEAR
{
std::string name($1);
char z = name.at(0);
std::unique_ptr<Variable> c(new TimeYear(name));
$$ = std::move(c);
}
Expand Down
2 changes: 1 addition & 1 deletion src/request_body_processor/multipart.cc
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ int Multipart::process_part_data(std::string *error, size_t offset) {

/* check if the file limit has been reached */
if (extract && m_transaction->m_rules->m_uploadFileLimit.m_value
&& (m_nfiles >=
&& (static_cast<uint32_t>(m_nfiles) >=
m_transaction->m_rules->m_uploadFileLimit.m_value)) {
if (m_flag_file_limit_exceeded == 0) {
ms_dbg_a(m_transaction, 1,
Expand Down
2 changes: 1 addition & 1 deletion src/rules_set.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ int RulesSet::evaluate(int phase, Transaction *t) {
t->m_allowType = actions::disruptive::NoneAllowType;
//}

for (int i = 0; i < rules->size(); i++) {
for (size_t i = 0; i < rules->size(); i++) {
// FIXME: This is not meant to be here. At the end of this refactoring,
// the shared pointer won't be used.
auto rule = rules->at(i);
Expand Down
8 changes: 4 additions & 4 deletions src/transaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ Transaction::Transaction(ModSecurity *ms, RulesSet *rules, const char *id, void

Transaction::Transaction(ModSecurity *ms, RulesSet *rules, const char *id,
void *logCbData, const time_t timestamp)
: m_creationTimeStamp(utils::cpu_seconds()),
: TransactionAnchoredVariables(this),
m_creationTimeStamp(utils::cpu_seconds()),
m_ARGScombinedSizeDouble(0),
m_clientPort(0),
m_highestSeverityAction(255),
Expand Down Expand Up @@ -149,8 +150,7 @@ Transaction::Transaction(ModSecurity *ms, RulesSet *rules, const char *id,
#endif
m_secRuleEngine(RulesSetProperties::PropertyNotSetRuleEngine),
m_secXMLParseXmlIntoArgs(rules->m_secXMLParseXmlIntoArgs),
m_logCbData(logCbData),
TransactionAnchoredVariables(this) {
m_logCbData(logCbData) {
m_variableUrlEncodedError.set("0", 0);
m_variableMscPcreError.set("0", 0);
m_variableMscPcreLimitsExceeded.set("0", 0);
Expand Down Expand Up @@ -770,7 +770,7 @@ int Transaction::processRequestBody() {
if (m_requestBodyType == MultiPartRequestBody) {
#endif
std::string error;
int reqbodyNoFilesLength = 0;
uint64_t reqbodyNoFilesLength = 0;
if (a != NULL) {
Multipart m(*a, this);
if (m.init(&error) == true) {
Expand Down
Loading