Adds missing ctl_request_body.*

This commit is contained in:
Felipe Zimmerle 2016-10-31 13:16:34 -03:00
parent 75a5000b16
commit 721983a05a
No known key found for this signature in database
GPG Key ID: E6DFB08CE8B11277
2 changed files with 98 additions and 0 deletions

View File

@ -0,0 +1,54 @@
/*
* 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/ctl_request_body_access.h"
#include <iostream>
#include <string>
#include "modsecurity/rules_properties.h"
#include "modsecurity/transaction.h"
namespace modsecurity {
namespace actions {
bool CtlRequestBodyAccess::init(std::string *error) {
std::string what(m_parser_payload, 18, m_parser_payload.size() - 18);
if (what == "true") {
m_request_body_access = true;
} else if (what == "false") {
m_request_body_access = false;
} else {
error->assign("Internal error. Expected: true or false, got: " \
+ m_parser_payload);
return false;
}
return true;
}
bool CtlRequestBodyAccess::evaluate(Rule *rule, Transaction *transaction) {
if (m_request_body_access) {
transaction->m_requestBodyAccess = RulesProperties::TrueConfigBoolean;
} else {
transaction->m_requestBodyAccess = RulesProperties::FalseConfigBoolean;
}
return true;
}
} // namespace actions
} // namespace modsecurity

View 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"
#include "modsecurity/transaction.h"
#include "src/utils.h"
#ifndef SRC_ACTIONS_CTL_REQUEST_BODY_ACCESS_H_
#define SRC_ACTIONS_CTL_REQUEST_BODY_ACCESS_H_
namespace modsecurity {
namespace actions {
class CtlRequestBodyAccess : public Action {
public:
explicit CtlRequestBodyAccess(std::string action)
: Action(action, RunTimeOnlyIfMatchKind),
m_request_body_access(false) { }
bool init(std::string *error) override;
bool evaluate(Rule *rule, Transaction *transaction) override;
bool m_request_body_access;
};
} // namespace actions
} // namespace modsecurity
#endif // SRC_ACTIONS_CTL_REQUEST_BODY_ACCESS_H_