2020#include " src/request_body_processor/json.h"
2121
2222#include < chrono>
23+ #include < cstddef>
2324#include < cstdint>
2425#include < memory>
2526#include < string>
2627
28+ #include " modsecurity/transaction.h"
2729#include " src/request_body_processor/json_adapter.h"
2830#include " src/request_body_processor/json_instrumentation.h"
2931
3032
3133namespace modsecurity ::RequestBodyProcessor {
3234
3335static const double json_depth_limit_default = 10000.0 ;
34- static const char * json_depth_limit_exceeded_msg = " . Parsing depth limit exceeded" ;
36+ static const char *const json_depth_limit_exceeded_msg =
37+ " . Parsing depth limit exceeded" ;
3538
3639namespace {
3740
@@ -119,11 +122,7 @@ JsonSinkStatus addStringViewAsSinkStatus(JSON *json, std::string_view value) {
119122} // namespace
120123
121124JSON::JSON (Transaction *transaction) : m_transaction(transaction),
122- m_current_key (" " ),
123- m_data(" " ),
124- m_max_depth(json_depth_limit_default),
125- m_current_depth(0 ),
126- m_depth_limit_exceeded(false ) {
125+ m_max_depth (json_depth_limit_default) {
127126}
128127
129128
@@ -185,11 +184,11 @@ bool JSON::complete(std::string *err) {
185184
186185
187186int JSON::addArgument (const std::string& value) {
188- std::string data ( " " ) ;
187+ std::string data;
189188 std::string path;
190189
191- for (size_t i = 0 ; i < m_containers.size (); i++) {
192- const JSONContainerArray *a = dynamic_cast <JSONContainerArray *>(
190+ for (size_t i = 0 ; i < m_containers.size (); i++) {
191+ const auto *a = dynamic_cast <JSONContainerArray *>(
193192 m_containers[i].get ());
194193 path = path + m_containers[i]->m_name ;
195194 if (a != nullptr ) {
@@ -199,8 +198,8 @@ int JSON::addArgument(const std::string& value) {
199198 }
200199 }
201200
202- if (m_containers.size () > 0 ) {
203- JSONContainerArray *a = dynamic_cast <JSONContainerArray *>(
201+ if (! m_containers.empty () ) {
202+ auto *a = dynamic_cast <JSONContainerArray *>(
204203 m_containers.back ().get ());
205204 if (a) {
206205 a->m_elementCounter ++;
0 commit comments