mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Adds support to the action `ver'
This commit is contained in:
parent
77900ed4e2
commit
5a2a81a568
@ -117,7 +117,8 @@ ACTIONS = \
|
||||
actions/transformations/url_decode.cc \
|
||||
actions/transformations/url_decode_uni.cc \
|
||||
actions/transformations/url_encode.cc \
|
||||
actions/transformations/utf8_to_unicode.cc
|
||||
actions/transformations/utf8_to_unicode.cc \
|
||||
actions/ver.cc
|
||||
|
||||
|
||||
OPERATORS = \
|
||||
|
46
src/actions/ver.cc
Normal file
46
src/actions/ver.cc
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* ModSecurity, http://www.modsecurity.org/
|
||||
* Copyright (c) 2015 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
||||
*
|
||||
* You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* If any of the files related to licensing are missing or if you have any
|
||||
* other questions related to licensing please contact Trustwave Holdings, Inc.
|
||||
* directly using the email address security@modsecurity.org.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "actions/ver.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "actions/action.h"
|
||||
#include "modsecurity/transaction.h"
|
||||
#include "src/utils.h"
|
||||
#include "modsecurity/rule.h"
|
||||
#include "src/macro_expansion.h"
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
Ver::Ver(std::string action)
|
||||
: Action(action, ConfigurationKind),
|
||||
m_ver(action) {
|
||||
if (m_ver.at(0) == '\'') {
|
||||
m_ver.erase(0, 1);
|
||||
m_ver.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Ver::evaluate(Rule *rule, Transaction *transaction) {
|
||||
rule->m_ver = m_ver;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
44
src/actions/ver.h
Normal file
44
src/actions/ver.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* ModSecurity, http://www.modsecurity.org/
|
||||
* Copyright (c) 2015 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
||||
*
|
||||
* You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* If any of the files related to licensing are missing or if you have any
|
||||
* other questions related to licensing please contact Trustwave Holdings, Inc.
|
||||
* directly using the email address security@modsecurity.org.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "actions/action.h"
|
||||
|
||||
#ifndef SRC_ACTIONS_VER_H_
|
||||
#define SRC_ACTIONS_VER_H_
|
||||
|
||||
class Transaction;
|
||||
|
||||
namespace modsecurity {
|
||||
class Transaction;
|
||||
namespace actions {
|
||||
|
||||
|
||||
class Ver : public Action {
|
||||
public:
|
||||
explicit Ver(std::string action);
|
||||
|
||||
bool evaluate(Rule *rule, Transaction *transaction) override;
|
||||
|
||||
private:
|
||||
std::string m_ver;
|
||||
};
|
||||
|
||||
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
||||
|
||||
#endif // SRC_ACTIONS_VER_H_
|
@ -31,6 +31,7 @@ class Driver;
|
||||
#include "actions/log_data.h"
|
||||
#include "actions/redirect.h"
|
||||
#include "actions/rev.h"
|
||||
#include "actions/ver.h"
|
||||
#include "actions/tag.h"
|
||||
#include "actions/transformations/transformation.h"
|
||||
#include "actions/transformations/none.h"
|
||||
@ -67,6 +68,7 @@ using modsecurity::actions::Severity;
|
||||
using modsecurity::actions::Tag;
|
||||
using modsecurity::actions::Redirect;
|
||||
using modsecurity::actions::Rev;
|
||||
using modsecurity::actions::Ver;
|
||||
using modsecurity::actions::Msg;
|
||||
using modsecurity::actions::Phase;
|
||||
using modsecurity::actions::transformations::None;
|
||||
@ -987,7 +989,7 @@ act:
|
||||
}
|
||||
| ACTION_VER
|
||||
{
|
||||
$$ = Action::instantiate($1);
|
||||
$$ = new Ver($1);
|
||||
}
|
||||
| ACTION_MATURITY
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user