mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
filter comment or blank line for pmFromFile operator
This commit is contained in:
parent
ea7cacf289
commit
7b1b00b5e1
@ -25,6 +25,23 @@
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
bool PmFromFile::isComment(const std::string &s) {
|
||||
if (s.size() == 0) {
|
||||
return true;
|
||||
}
|
||||
size_t pos = s.find("#");
|
||||
if (pos != std::string::npos) {
|
||||
for (int i = 0; i < pos; i++) {
|
||||
if (!std::isspace(s[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PmFromFile::init(const std::string &config, std::string *error) {
|
||||
std::istream *iss;
|
||||
@ -50,7 +67,9 @@ bool PmFromFile::init(const std::string &config, std::string *error) {
|
||||
}
|
||||
|
||||
for (std::string line; std::getline(*iss, line); ) {
|
||||
acmp_add_pattern(m_p, line.c_str(), NULL, NULL, line.length());
|
||||
if (isComment(line) == false) {
|
||||
acmp_add_pattern(m_p, line.c_str(), NULL, NULL, line.length());
|
||||
}
|
||||
}
|
||||
|
||||
while (m_p->is_failtree_done == 0) {
|
||||
|
@ -36,6 +36,8 @@ class PmFromFile : public Pm {
|
||||
: Pm(n, std::move(param)) { }
|
||||
|
||||
bool init(const std::string &file, std::string *error) override;
|
||||
|
||||
bool isComment(const std::string &s);
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user