Coding style fixes

This commit is contained in:
Felipe Zimmerle
2017-11-13 14:22:17 -03:00
parent 023e7acbad
commit 3fb71f32d8
40 changed files with 591 additions and 662 deletions

View File

@@ -44,7 +44,8 @@ void RemoteUser::evaluate(Transaction *transaction,
collection::Variable *var;
std::string header;
std::vector<const collection::Variable *> *l2 = new std::vector<const collection::Variable *>();
std::vector<const collection::Variable *> *l2 = \
new std::vector<const collection::Variable *>();
transaction->m_variableRequestHeaders.resolve("authorization", l2);
if (l2->size() < 1) {

View File

@@ -70,491 +70,349 @@ class Variable {
Variable(std::string name, VariableKind kind);
virtual ~Variable() { }
virtual void evaluate(Transaction *transaction,
virtual void evaluate(Transaction *t,
Rule *rule,
std::vector<const collection::Variable *> *l) = 0;
static std::string to_s(std::vector<Variable *> *variables);
static inline bool compareStrNoCase(const std::string &a, const std::string &b) {
static inline bool comp(const std::string &a, const std::string &b) {
return a.size() == b.size()
&& std::equal(a.begin(), a.end(), b.begin(),
[](char aa, char bb) {
return toupper(aa) == bb;
});
};
}
static void stringMatchResolveMulti(Transaction *transaction, const std::string &variable,
static void stringMatchResolveMulti(Transaction *t,
const std::string &variable,
std::vector<const collection::Variable *> *l) {
size_t collection = variable.find(".");
if (collection == std::string::npos) {
collection = variable.find(":");
}
if (collection == std::string::npos) {
if (compareStrNoCase(variable, "RESPONSE_CONTENT_TYPE")) {
transaction->m_variableResponseContentType.evaluate(l);
}
else if (compareStrNoCase(variable, "ARGS_COMBINED_SIZE")) {
transaction->m_variableARGScombinedSize.evaluate(l);
}
else if (compareStrNoCase(variable, "AUTH_TYPE")) {
transaction->m_variableAuthType.evaluate(l);
}
else if (compareStrNoCase(variable, "FILES_COMBINED_SIZE")) {
transaction->m_variableFilesCombinedSize.evaluate(l);
}
else if (compareStrNoCase(variable, "FULL_REQUEST")) {
transaction->m_variableFullRequest.evaluate(l);
}
else if (compareStrNoCase(variable, "FULL_REQUEST_LENGTH")) {
transaction->m_variableFullRequestLength.evaluate(l);
}
else if (compareStrNoCase(variable, "INBOUND_DATA_ERROR")) {
transaction->m_variableInboundDataError.evaluate(l);
}
else if (compareStrNoCase(variable, "MATCHED_VAR")) {
transaction->m_variableMatchedVar.evaluate(l);
}
else if (compareStrNoCase(variable, "MATCHED_VAR_NAME")) {
transaction->m_variableMatchedVarName.evaluate(l);
}
else if (compareStrNoCase(variable, "MULTIPART_CRLF_LF_LINES")) {
transaction->m_variableMultipartCrlfLFLines.evaluate(l);
}
else if (compareStrNoCase(variable, "MULTIPART_DATA_AFTER")) {
transaction->m_variableMultipartDataAfter.evaluate(l);
}
else if (compareStrNoCase(variable, "MULTIPART_FILE_LIMIT_EXCEEDED")) {
transaction->m_variableMultipartFileLimitExceeded.evaluate(l);
}
else if (compareStrNoCase(variable, "MULTIPART_STRICT_ERROR")) {
transaction->m_variableMultipartStrictError.evaluate(l);
}
else if (compareStrNoCase(variable, "MULTIPART_HEADER_FOLDING")) {
transaction->m_variableMultipartHeaderFolding.evaluate(l);
}
else if (compareStrNoCase(variable, "MULTIPART_INVALID_QUOTING")) {
transaction->m_variableMultipartInvalidQuoting.evaluate(l);
}
else if (compareStrNoCase(variable, "MULTIPART_INVALID_HEADER_FOLDING")) {
transaction->m_variableMultipartInvalidHeaderFolding.evaluate(l);
}
else if (compareStrNoCase(variable, "MULTIPART_UNMATCHED_BOUNDARY")) {
transaction->m_variableMultipartUnmatchedBoundary.evaluate(l);
}
else if (compareStrNoCase(variable, "OUTBOUND_DATA_ERROR")) {
transaction->m_variableOutboundDataError.evaluate(l);
}
else if (compareStrNoCase(variable, "PATH_INFO")) {
transaction->m_variablePathInfo.evaluate(l);
}
else if (compareStrNoCase(variable, "QUERY_STRING")) {
transaction->m_variableQueryString.evaluate(l);
}
else if (compareStrNoCase(variable, "REMOTE_ADDR")) {
transaction->m_variableRemoteAddr.evaluate(l);
}
else if (compareStrNoCase(variable, "REMOTE_HOST")) {
transaction->m_variableRemoteHost.evaluate(l);
}
else if (compareStrNoCase(variable, "REMOTE_PORT")) {
transaction->m_variableRemotePort.evaluate(l);
}
else if (compareStrNoCase(variable, "REQBODY_ERROR")) {
transaction->m_variableReqbodyError.evaluate(l);
}
else if (compareStrNoCase(variable, "REQBODY_ERROR_MSG")) {
transaction->m_variableReqbodyErrorMsg.evaluate(l);
}
else if (compareStrNoCase(variable, "REQBODY_PROCESSOR_ERROR_MSG")) {
transaction->m_variableReqbodyProcessorErrorMsg.evaluate(l);
}
else if (compareStrNoCase(variable, "REQBODY_PROCESSOR_ERROR")) {
transaction->m_variableReqbodyProcessorError.evaluate(l);
}
else if (compareStrNoCase(variable, "REQBODY_PROCESSOR")) {
transaction->m_variableReqbodyProcessor.evaluate(l);
}
else if (compareStrNoCase(variable, "REQUEST_BASENAME")) {
transaction->m_variableRequestBasename.evaluate(l);
}
else if (compareStrNoCase(variable, "REQUEST_BODY")) {
transaction->m_variableRequestBody.evaluate(l);
}
else if (compareStrNoCase(variable, "REQUEST_BODY_LENGTH")) {
transaction->m_variableRequestBodyLength.evaluate(l);
}
else if (compareStrNoCase(variable, "REQUEST_FILENAME")) {
transaction->m_variableRequestFilename.evaluate(l);
}
else if (compareStrNoCase(variable, "REQUEST_LINE")) {
transaction->m_variableRequestLine.evaluate(l);
}
else if (compareStrNoCase(variable, "REQUEST_METHOD")) {
transaction->m_variableRequestMethod.evaluate(l);
}
else if (compareStrNoCase(variable, "REQUEST_PROTOCOL")) {
transaction->m_variableRequestProtocol.evaluate(l);
}
else if (compareStrNoCase(variable, "REQUEST_URI")) {
transaction->m_variableRequestURI.evaluate(l);
}
else if (compareStrNoCase(variable, "REQUEST_URI_RAW")) {
transaction->m_variableRequestURIRaw.evaluate(l);
}
else if (compareStrNoCase(variable, "RESOURCE")) {
transaction->m_variableResource.evaluate(l);
}
else if (compareStrNoCase(variable, "RESPONSE_BODY")) {
transaction->m_variableResponseBody.evaluate(l);
}
else if (compareStrNoCase(variable, "RESPONSE_CONTENT_LENGTH")) {
transaction->m_variableResponseContentLength.evaluate(l);
}
else if (compareStrNoCase(variable, "RESPONSE_PROTOCOL")) {
transaction->m_variableResponseProtocol.evaluate(l);
}
else if (compareStrNoCase(variable, "RESPONSE_STATUS")) {
transaction->m_variableResponseStatus.evaluate(l);
}
else if (compareStrNoCase(variable, "SERVER_ADDR")) {
transaction->m_variableServerAddr.evaluate(l);
}
else if (compareStrNoCase(variable, "SERVER_NAME")) {
transaction->m_variableServerName.evaluate(l);
}
else if (compareStrNoCase(variable, "SERVER_PORT")) {
transaction->m_variableServerPort.evaluate(l);
}
else if (compareStrNoCase(variable, "SESSIONID")) {
transaction->m_variableSessionID.evaluate(l);
}
else if (compareStrNoCase(variable, "UNIQUE_ID")) {
transaction->m_variableUniqueID.evaluate(l);
}
else if (compareStrNoCase(variable, "URLENCODED_ERROR")) {
transaction->m_variableUrlEncodedError.evaluate(l);
}
else if (compareStrNoCase(variable, "USERID")) {
transaction->m_variableUserID.evaluate(l);
if (comp(variable, "RESPONSE_CONTENT_TYPE")) {
t->m_variableResponseContentType.evaluate(l);
} else if (comp(variable, "ARGS_COMBINED_SIZE")) {
t->m_variableARGScombinedSize.evaluate(l);
} else if (comp(variable, "AUTH_TYPE")) {
t->m_variableAuthType.evaluate(l);
} else if (comp(variable, "FILES_COMBINED_SIZE")) {
t->m_variableFilesCombinedSize.evaluate(l);
} else if (comp(variable, "FULL_REQUEST")) {
t->m_variableFullRequest.evaluate(l);
} else if (comp(variable, "FULL_REQUEST_LENGTH")) {
t->m_variableFullRequestLength.evaluate(l);
} else if (comp(variable, "INBOUND_DATA_ERROR")) {
t->m_variableInboundDataError.evaluate(l);
} else if (comp(variable, "MATCHED_VAR")) {
t->m_variableMatchedVar.evaluate(l);
} else if (comp(variable, "MATCHED_VAR_NAME")) {
t->m_variableMatchedVarName.evaluate(l);
} else if (comp(variable, "MULTIPART_CRLF_LF_LINES")) {
t->m_variableMultipartCrlfLFLines.evaluate(l);
} else if (comp(variable, "MULTIPART_DATA_AFTER")) {
t->m_variableMultipartDataAfter.evaluate(l);
} else if (comp(variable, "MULTIPART_FILE_LIMIT_EXCEEDED")) {
t->m_variableMultipartFileLimitExceeded.evaluate(l);
} else if (comp(variable, "MULTIPART_STRICT_ERROR")) {
t->m_variableMultipartStrictError.evaluate(l);
} else if (comp(variable, "MULTIPART_HEADER_FOLDING")) {
t->m_variableMultipartHeaderFolding.evaluate(l);
} else if (comp(variable, "MULTIPART_INVALID_QUOTING")) {
t->m_variableMultipartInvalidQuoting.evaluate(l);
} else if (comp(variable, "MULTIPART_INVALID_HEADER_FOLDING")) {
t->m_variableMultipartInvalidHeaderFolding.evaluate(l);
} else if (comp(variable, "MULTIPART_UNMATCHED_BOUNDARY")) {
t->m_variableMultipartUnmatchedBoundary.evaluate(l);
} else if (comp(variable, "OUTBOUND_DATA_ERROR")) {
t->m_variableOutboundDataError.evaluate(l);
} else if (comp(variable, "PATH_INFO")) {
t->m_variablePathInfo.evaluate(l);
} else if (comp(variable, "QUERY_STRING")) {
t->m_variableQueryString.evaluate(l);
} else if (comp(variable, "REMOTE_ADDR")) {
t->m_variableRemoteAddr.evaluate(l);
} else if (comp(variable, "REMOTE_HOST")) {
t->m_variableRemoteHost.evaluate(l);
} else if (comp(variable, "REMOTE_PORT")) {
t->m_variableRemotePort.evaluate(l);
} else if (comp(variable, "REQBODY_ERROR")) {
t->m_variableReqbodyError.evaluate(l);
} else if (comp(variable, "REQBODY_ERROR_MSG")) {
t->m_variableReqbodyErrorMsg.evaluate(l);
} else if (comp(variable, "REQBODY_PROCESSOR_ERROR_MSG")) {
t->m_variableReqbodyProcessorErrorMsg.evaluate(l);
} else if (comp(variable, "REQBODY_PROCESSOR_ERROR")) {
t->m_variableReqbodyProcessorError.evaluate(l);
} else if (comp(variable, "REQBODY_PROCESSOR")) {
t->m_variableReqbodyProcessor.evaluate(l);
} else if (comp(variable, "REQUEST_BASENAME")) {
t->m_variableRequestBasename.evaluate(l);
} else if (comp(variable, "REQUEST_BODY")) {
t->m_variableRequestBody.evaluate(l);
} else if (comp(variable, "REQUEST_BODY_LENGTH")) {
t->m_variableRequestBodyLength.evaluate(l);
} else if (comp(variable, "REQUEST_FILENAME")) {
t->m_variableRequestFilename.evaluate(l);
} else if (comp(variable, "REQUEST_LINE")) {
t->m_variableRequestLine.evaluate(l);
} else if (comp(variable, "REQUEST_METHOD")) {
t->m_variableRequestMethod.evaluate(l);
} else if (comp(variable, "REQUEST_PROTOCOL")) {
t->m_variableRequestProtocol.evaluate(l);
} else if (comp(variable, "REQUEST_URI")) {
t->m_variableRequestURI.evaluate(l);
} else if (comp(variable, "REQUEST_URI_RAW")) {
t->m_variableRequestURIRaw.evaluate(l);
} else if (comp(variable, "RESOURCE")) {
t->m_variableResource.evaluate(l);
} else if (comp(variable, "RESPONSE_BODY")) {
t->m_variableResponseBody.evaluate(l);
} else if (comp(variable, "RESPONSE_CONTENT_LENGTH")) {
t->m_variableResponseContentLength.evaluate(l);
} else if (comp(variable, "RESPONSE_PROTOCOL")) {
t->m_variableResponseProtocol.evaluate(l);
} else if (comp(variable, "RESPONSE_STATUS")) {
t->m_variableResponseStatus.evaluate(l);
} else if (comp(variable, "SERVER_ADDR")) {
t->m_variableServerAddr.evaluate(l);
} else if (comp(variable, "SERVER_NAME")) {
t->m_variableServerName.evaluate(l);
} else if (comp(variable, "SERVER_PORT")) {
t->m_variableServerPort.evaluate(l);
} else if (comp(variable, "SESSIONID")) {
t->m_variableSessionID.evaluate(l);
} else if (comp(variable, "UNIQUE_ID")) {
t->m_variableUniqueID.evaluate(l);
} else if (comp(variable, "URLENCODED_ERROR")) {
t->m_variableUrlEncodedError.evaluate(l);
} else if (comp(variable, "USERID")) {
t->m_variableUserID.evaluate(l);
} else {
transaction->m_collections.resolveMultiMatches(
variable, l);
t->m_collections.resolveMultiMatches(variable, l);
}
} else {
std::string col = std::string(variable, 0, collection);
std::string var = std::string(variable, collection + 1,
variable.length() - (collection + 1));
if (compareStrNoCase(col, "ARGS")) {
transaction->m_variableArgs.resolve(var, l);
}
else if (compareStrNoCase(variable, "ARGS_NAMES")) {
transaction->m_variableArgsNames.resolve(var, l);
}
else if (compareStrNoCase(variable, "ARGS_GET_NAMES")) {
transaction->m_variableArgsGetNames.resolve(var, l);
}
else if (compareStrNoCase(variable, "ARGS_POST_NAMES")) {
transaction->m_variableArgsPostNames.resolve(var, l);
}
else if (compareStrNoCase(col, "RULE")) {
transaction->m_variableRule.resolve(var, l);
}
else if (compareStrNoCase(col, "ARGS_GET")) {
transaction->m_variableArgsGet.resolve(var, l);
}
else if (compareStrNoCase(col, "ARGS_POST")) {
transaction->m_variableArgsPost.resolve(var, l);
}
else if (compareStrNoCase(col, "FILES_SIZES")) {
transaction->m_variableFilesSizes.resolve(var, l);
}
else if (compareStrNoCase(col, "FILES_NAMES")) {
transaction->m_variableFilesNames.resolve(var, l);
}
else if (compareStrNoCase(col, "FILES_TMP_CONTENT")) {
transaction->m_variableFilesTmpContent.resolve(var, l);
}
else if (compareStrNoCase(col, "MULTIPART_FILENAME")) {
transaction->m_variableMultiPartFileName.resolve(var, l);
}
else if (compareStrNoCase(col, "MULTIPART_NAME")) {
transaction->m_variableMultiPartName.resolve(var, l);
}
else if (compareStrNoCase(col, "MATCHED_VARS_NAMES")) {
transaction->m_variableMatchedVarsNames.resolve(var, l);
}
else if (compareStrNoCase(col, "MATCHED_VARS")) {
transaction->m_variableMatchedVars.resolve(var, l);
}
else if (compareStrNoCase(col, "FILES")) {
transaction->m_variableFiles.resolve(var, l);
}
else if (compareStrNoCase(col, "REQUEST_COOKIES")) {
transaction->m_variableRequestCookies.resolve(var, l);
}
else if (compareStrNoCase(col, "REQUEST_HEADERS")) {
transaction->m_variableRequestHeaders.resolve(var, l);
}
else if (compareStrNoCase(variable, "REQUEST_HEADERS_NAMES")) {
transaction->m_variableRequestHeadersNames.resolve(var, l);
}
else if (compareStrNoCase(col, "RESPONSE_HEADERS")) {
transaction->m_variableResponseHeaders.resolve(var, l);
}
else if (compareStrNoCase(variable, "RESPONSE_HEADERS_NAMES")) {
transaction->m_variableResponseHeadersNames.resolve(var, l);
}
else if (compareStrNoCase(col, "GEO")) {
transaction->m_variableGeo.resolve(var, l);
}
else if (compareStrNoCase(col, "REQUEST_COOKIES_NAMES")) {
transaction->m_variableRequestCookiesNames.resolve(var, l);
}
else if (compareStrNoCase(col, "FILES_TMPNAMES")) {
transaction->m_variableFilesTmpNames.resolve(var, l);
if (comp(col, "ARGS")) {
t->m_variableArgs.resolve(var, l);
} else if (comp(variable, "ARGS_NAMES")) {
t->m_variableArgsNames.resolve(var, l);
} else if (comp(variable, "ARGS_GET_NAMES")) {
t->m_variableArgsGetNames.resolve(var, l);
} else if (comp(variable, "ARGS_POST_NAMES")) {
t->m_variableArgsPostNames.resolve(var, l);
} else if (comp(col, "RULE")) {
t->m_variableRule.resolve(var, l);
} else if (comp(col, "ARGS_GET")) {
t->m_variableArgsGet.resolve(var, l);
} else if (comp(col, "ARGS_POST")) {
t->m_variableArgsPost.resolve(var, l);
} else if (comp(col, "FILES_SIZES")) {
t->m_variableFilesSizes.resolve(var, l);
} else if (comp(col, "FILES_NAMES")) {
t->m_variableFilesNames.resolve(var, l);
} else if (comp(col, "FILES_TMP_CONTENT")) {
t->m_variableFilesTmpContent.resolve(var, l);
} else if (comp(col, "MULTIPART_FILENAME")) {
t->m_variableMultiPartFileName.resolve(var, l);
} else if (comp(col, "MULTIPART_NAME")) {
t->m_variableMultiPartName.resolve(var, l);
} else if (comp(col, "MATCHED_VARS_NAMES")) {
t->m_variableMatchedVarsNames.resolve(var, l);
} else if (comp(col, "MATCHED_VARS")) {
t->m_variableMatchedVars.resolve(var, l);
} else if (comp(col, "FILES")) {
t->m_variableFiles.resolve(var, l);
} else if (comp(col, "REQUEST_COOKIES")) {
t->m_variableRequestCookies.resolve(var, l);
} else if (comp(col, "REQUEST_HEADERS")) {
t->m_variableRequestHeaders.resolve(var, l);
} else if (comp(variable, "REQUEST_HEADERS_NAMES")) {
t->m_variableRequestHeadersNames.resolve(var, l);
} else if (comp(col, "RESPONSE_HEADERS")) {
t->m_variableResponseHeaders.resolve(var, l);
} else if (comp(variable, "RESPONSE_HEADERS_NAMES")) {
t->m_variableResponseHeadersNames.resolve(var, l);
} else if (comp(col, "GEO")) {
t->m_variableGeo.resolve(var, l);
} else if (comp(col, "REQUEST_COOKIES_NAMES")) {
t->m_variableRequestCookiesNames.resolve(var, l);
} else if (comp(col, "FILES_TMPNAMES")) {
t->m_variableFilesTmpNames.resolve(var, l);
} else {
transaction->m_collections.resolveMultiMatches(col,
var, l);
t->m_collections.resolveMultiMatches(col, var, l);
}
}
}
static std::string stringMatchResolve(Transaction *transaction, const std::string &variable) {
std::unique_ptr<std::string> variableValue = nullptr;
static std::string stringMatchResolve(Transaction *t,
const std::string &variable) {
std::unique_ptr<std::string> vv = nullptr;
size_t collection = variable.find(".");
if (collection == std::string::npos) {
collection = variable.find(":");
}
if (collection == std::string::npos) {
if (compareStrNoCase(variable, "RESPONSE_CONTENT_TYPE")) {
variableValue = transaction->m_variableResponseContentType.resolveFirst();
}
else if (compareStrNoCase(variable, "ARGS_COMBINED_SIZE")) {
variableValue = transaction->m_variableARGScombinedSize.resolveFirst();
}
else if (compareStrNoCase(variable, "AUTH_TYPE")) {
variableValue = transaction->m_variableAuthType.resolveFirst();
}
else if (compareStrNoCase(variable, "FILES_COMBINED_SIZE")) {
variableValue = transaction->m_variableFilesCombinedSize.resolveFirst();
}
else if (compareStrNoCase(variable, "FULL_REQUEST")) {
variableValue = transaction->m_variableFullRequest.resolveFirst();
}
else if (compareStrNoCase(variable, "FULL_REQUEST_LENGTH")) {
variableValue = transaction->m_variableFullRequestLength.resolveFirst();
}
else if (compareStrNoCase(variable, "INBOUND_DATA_ERROR")) {
variableValue = transaction->m_variableInboundDataError.resolveFirst();
}
else if (compareStrNoCase(variable, "MATCHED_VAR")) {
variableValue = transaction->m_variableMatchedVar.resolveFirst();
}
else if (compareStrNoCase(variable, "MATCHED_VAR_NAME")) {
variableValue = transaction->m_variableMatchedVarName.resolveFirst();
}
else if (compareStrNoCase(variable, "MULTIPART_CRLF_LF_LINES")) {
variableValue = transaction->m_variableMultipartCrlfLFLines.resolveFirst();
}
else if (compareStrNoCase(variable, "MULTIPART_DATA_AFTER")) {
variableValue = transaction->m_variableMultipartDataAfter.resolveFirst();
}
else if (compareStrNoCase(variable, "MULTIPART_FILE_LIMIT_EXCEEDED")) {
variableValue = transaction->m_variableMultipartFileLimitExceeded.resolveFirst();
}
else if (compareStrNoCase(variable, "MULTIPART_STRICT_ERROR")) {
variableValue = transaction->m_variableMultipartStrictError.resolveFirst();
}
else if (compareStrNoCase(variable, "MULTIPART_HEADER_FOLDING")) {
variableValue = transaction->m_variableMultipartHeaderFolding.resolveFirst();
}
else if (compareStrNoCase(variable, "MULTIPART_INVALID_QUOTING")) {
variableValue = transaction->m_variableMultipartInvalidQuoting.resolveFirst();
}
else if (compareStrNoCase(variable, "MULTIPART_INVALID_HEADER_FOLDING")) {
variableValue = transaction->m_variableMultipartInvalidHeaderFolding.resolveFirst();
}
else if (compareStrNoCase(variable, "MULTIPART_UNMATCHED_BOUNDARY")) {
variableValue = transaction->m_variableMultipartUnmatchedBoundary.resolveFirst();
}
else if (compareStrNoCase(variable, "OUTBOUND_DATA_ERROR")) {
variableValue = transaction->m_variableOutboundDataError.resolveFirst();
}
else if (compareStrNoCase(variable, "PATH_INFO")) {
variableValue = transaction->m_variablePathInfo.resolveFirst();
}
else if (compareStrNoCase(variable, "QUERY_STRING")) {
variableValue = transaction->m_variableQueryString.resolveFirst();
}
else if (compareStrNoCase(variable, "REMOTE_ADDR")) {
variableValue = transaction->m_variableRemoteAddr.resolveFirst();
}
else if (compareStrNoCase(variable, "REMOTE_HOST")) {
variableValue = transaction->m_variableRemoteHost.resolveFirst();
}
else if (compareStrNoCase(variable, "REMOTE_PORT")) {
variableValue = transaction->m_variableRemotePort.resolveFirst();
}
else if (compareStrNoCase(variable, "REQBODY_ERROR")) {
variableValue = transaction->m_variableReqbodyError.resolveFirst();
}
else if (compareStrNoCase(variable, "REQBODY_ERROR_MSG")) {
variableValue = transaction->m_variableReqbodyErrorMsg.resolveFirst();
}
else if (compareStrNoCase(variable, "REQBODY_PROCESSOR_ERROR_MSG")) {
variableValue = transaction->m_variableReqbodyProcessorErrorMsg.resolveFirst();
}
else if (compareStrNoCase(variable, "REQBODY_PROCESSOR_ERROR")) {
variableValue = transaction->m_variableReqbodyProcessorError.resolveFirst();
}
else if (compareStrNoCase(variable, "REQBODY_PROCESSOR")) {
variableValue = transaction->m_variableReqbodyProcessor.resolveFirst();
}
else if (compareStrNoCase(variable, "REQUEST_BASENAME")) {
variableValue = transaction->m_variableRequestBasename.resolveFirst();
}
else if (compareStrNoCase(variable, "REQUEST_BODY")) {
variableValue = transaction->m_variableRequestBody.resolveFirst();
}
else if (compareStrNoCase(variable, "REQUEST_BODY_LENGTH")) {
variableValue = transaction->m_variableRequestBodyLength.resolveFirst();
}
else if (compareStrNoCase(variable, "REQUEST_FILENAME")) {
variableValue = transaction->m_variableRequestFilename.resolveFirst();
}
else if (compareStrNoCase(variable, "REQUEST_LINE")) {
variableValue = transaction->m_variableRequestLine.resolveFirst();
}
else if (compareStrNoCase(variable, "REQUEST_METHOD")) {
variableValue = transaction->m_variableRequestMethod.resolveFirst();
}
else if (compareStrNoCase(variable, "REQUEST_PROTOCOL")) {
variableValue = transaction->m_variableRequestProtocol.resolveFirst();
}
else if (compareStrNoCase(variable, "REQUEST_URI")) {
variableValue = transaction->m_variableRequestURI.resolveFirst();
}
else if (compareStrNoCase(variable, "REQUEST_URI_RAW")) {
variableValue = transaction->m_variableRequestURIRaw.resolveFirst();
}
else if (compareStrNoCase(variable, "RESOURCE")) {
variableValue = transaction->m_variableResource.resolveFirst();
}
else if (compareStrNoCase(variable, "RESPONSE_BODY")) {
variableValue = transaction->m_variableResponseBody.resolveFirst();
}
else if (compareStrNoCase(variable, "RESPONSE_CONTENT_LENGTH")) {
variableValue = transaction->m_variableResponseContentLength.resolveFirst();
}
else if (compareStrNoCase(variable, "RESPONSE_PROTOCOL")) {
variableValue = transaction->m_variableResponseProtocol.resolveFirst();
}
else if (compareStrNoCase(variable, "RESPONSE_STATUS")) {
variableValue = transaction->m_variableResponseStatus.resolveFirst();
}
else if (compareStrNoCase(variable, "SERVER_ADDR")) {
variableValue = transaction->m_variableServerAddr.resolveFirst();
}
else if (compareStrNoCase(variable, "SERVER_NAME")) {
variableValue = transaction->m_variableServerName.resolveFirst();
}
else if (compareStrNoCase(variable, "SERVER_PORT")) {
variableValue = transaction->m_variableServerPort.resolveFirst();
}
else if (compareStrNoCase(variable, "SESSIONID")) {
variableValue = transaction->m_variableSessionID.resolveFirst();
}
else if (compareStrNoCase(variable, "UNIQUE_ID")) {
variableValue = transaction->m_variableUniqueID.resolveFirst();
}
else if (compareStrNoCase(variable, "URLENCODED_ERROR")) {
variableValue = transaction->m_variableUrlEncodedError.resolveFirst();
}
else if (compareStrNoCase(variable, "USERID")) {
variableValue = transaction->m_variableUserID.resolveFirst();
if (comp(variable, "RESPONSE_CONTENT_TYPE")) {
vv = t->m_variableResponseContentType.resolveFirst();
} else if (comp(variable, "ARGS_COMBINED_SIZE")) {
vv = t->m_variableARGScombinedSize.resolveFirst();
} else if (comp(variable, "AUTH_TYPE")) {
vv = t->m_variableAuthType.resolveFirst();
} else if (comp(variable, "FILES_COMBINED_SIZE")) {
vv = t->m_variableFilesCombinedSize.resolveFirst();
} else if (comp(variable, "FULL_REQUEST")) {
vv = t->m_variableFullRequest.resolveFirst();
} else if (comp(variable, "FULL_REQUEST_LENGTH")) {
vv = t->m_variableFullRequestLength.resolveFirst();
} else if (comp(variable, "INBOUND_DATA_ERROR")) {
vv = t->m_variableInboundDataError.resolveFirst();
} else if (comp(variable, "MATCHED_VAR")) {
vv = t->m_variableMatchedVar.resolveFirst();
} else if (comp(variable, "MATCHED_VAR_NAME")) {
vv = t->m_variableMatchedVarName.resolveFirst();
} else if (comp(variable, "MULTIPART_CRLF_LF_LINES")) {
vv = t->m_variableMultipartCrlfLFLines.resolveFirst();
} else if (comp(variable, "MULTIPART_DATA_AFTER")) {
vv = t->m_variableMultipartDataAfter.resolveFirst();
} else if (comp(variable, "MULTIPART_FILE_LIMIT_EXCEEDED")) {
vv = t->m_variableMultipartFileLimitExceeded.resolveFirst();
} else if (comp(variable, "MULTIPART_STRICT_ERROR")) {
vv = t->m_variableMultipartStrictError.resolveFirst();
} else if (comp(variable, "MULTIPART_HEADER_FOLDING")) {
vv = t->m_variableMultipartHeaderFolding.resolveFirst();
} else if (comp(variable, "MULTIPART_INVALID_QUOTING")) {
vv = t->m_variableMultipartInvalidQuoting.resolveFirst();
} else if (comp(variable, "MULTIPART_INVALID_HEADER_FOLDING")) {
vv = t->m_variableMultipartInvalidHeaderFolding.resolveFirst();
} else if (comp(variable, "MULTIPART_UNMATCHED_BOUNDARY")) {
vv = t->m_variableMultipartUnmatchedBoundary.resolveFirst();
} else if (comp(variable, "OUTBOUND_DATA_ERROR")) {
vv = t->m_variableOutboundDataError.resolveFirst();
} else if (comp(variable, "PATH_INFO")) {
vv = t->m_variablePathInfo.resolveFirst();
} else if (comp(variable, "QUERY_STRING")) {
vv = t->m_variableQueryString.resolveFirst();
} else if (comp(variable, "REMOTE_ADDR")) {
vv = t->m_variableRemoteAddr.resolveFirst();
} else if (comp(variable, "REMOTE_HOST")) {
vv = t->m_variableRemoteHost.resolveFirst();
} else if (comp(variable, "REMOTE_PORT")) {
vv = t->m_variableRemotePort.resolveFirst();
} else if (comp(variable, "REQBODY_ERROR")) {
vv = t->m_variableReqbodyError.resolveFirst();
} else if (comp(variable, "REQBODY_ERROR_MSG")) {
vv = t->m_variableReqbodyErrorMsg.resolveFirst();
} else if (comp(variable, "REQBODY_PROCESSOR_ERROR_MSG")) {
vv = t->m_variableReqbodyProcessorErrorMsg.resolveFirst();
} else if (comp(variable, "REQBODY_PROCESSOR_ERROR")) {
vv = t->m_variableReqbodyProcessorError.resolveFirst();
} else if (comp(variable, "REQBODY_PROCESSOR")) {
vv = t->m_variableReqbodyProcessor.resolveFirst();
} else if (comp(variable, "REQUEST_BASENAME")) {
vv = t->m_variableRequestBasename.resolveFirst();
} else if (comp(variable, "REQUEST_BODY")) {
vv = t->m_variableRequestBody.resolveFirst();
} else if (comp(variable, "REQUEST_BODY_LENGTH")) {
vv = t->m_variableRequestBodyLength.resolveFirst();
} else if (comp(variable, "REQUEST_FILENAME")) {
vv = t->m_variableRequestFilename.resolveFirst();
} else if (comp(variable, "REQUEST_LINE")) {
vv = t->m_variableRequestLine.resolveFirst();
} else if (comp(variable, "REQUEST_METHOD")) {
vv = t->m_variableRequestMethod.resolveFirst();
} else if (comp(variable, "REQUEST_PROTOCOL")) {
vv = t->m_variableRequestProtocol.resolveFirst();
} else if (comp(variable, "REQUEST_URI")) {
vv = t->m_variableRequestURI.resolveFirst();
} else if (comp(variable, "REQUEST_URI_RAW")) {
vv = t->m_variableRequestURIRaw.resolveFirst();
} else if (comp(variable, "RESOURCE")) {
vv = t->m_variableResource.resolveFirst();
} else if (comp(variable, "RESPONSE_BODY")) {
vv = t->m_variableResponseBody.resolveFirst();
} else if (comp(variable, "RESPONSE_CONTENT_LENGTH")) {
vv = t->m_variableResponseContentLength.resolveFirst();
} else if (comp(variable, "RESPONSE_PROTOCOL")) {
vv = t->m_variableResponseProtocol.resolveFirst();
} else if (comp(variable, "RESPONSE_STATUS")) {
vv = t->m_variableResponseStatus.resolveFirst();
} else if (comp(variable, "SERVER_ADDR")) {
vv = t->m_variableServerAddr.resolveFirst();
} else if (comp(variable, "SERVER_NAME")) {
vv = t->m_variableServerName.resolveFirst();
} else if (comp(variable, "SERVER_PORT")) {
vv = t->m_variableServerPort.resolveFirst();
} else if (comp(variable, "SESSIONID")) {
vv = t->m_variableSessionID.resolveFirst();
} else if (comp(variable, "UNIQUE_ID")) {
vv = t->m_variableUniqueID.resolveFirst();
} else if (comp(variable, "URLENCODED_ERROR")) {
vv = t->m_variableUrlEncodedError.resolveFirst();
} else if (comp(variable, "USERID")) {
vv = t->m_variableUserID.resolveFirst();
} else {
variableValue = transaction->m_collections.resolveFirst(
variable);
vv = t->m_collections.resolveFirst(variable);
}
} else {
std::string col = std::string(variable, 0, collection);
std::string var = std::string(variable, collection + 1,
variable.length() - (collection + 1));
if (compareStrNoCase(col, "ARGS")) {
variableValue = transaction->m_variableArgs.resolveFirst(var);
}
else if (compareStrNoCase(variable, "ARGS_NAMES")) {
variableValue = transaction->m_variableArgsNames.resolveFirst(var);
}
else if (compareStrNoCase(variable, "ARGS_GET_NAMES")) {
variableValue = transaction->m_variableArgsGetNames.resolveFirst(var);
}
else if (compareStrNoCase(variable, "ARGS_POST_NAMES")) {
variableValue = transaction->m_variableArgsPostNames.resolveFirst(var);
}
else if (compareStrNoCase(col, "RULE")) {
variableValue = transaction->m_variableRule.resolveFirst(var);
}
else if (compareStrNoCase(col, "ARGS_GET")) {
variableValue = transaction->m_variableArgsGet.resolveFirst(var);
}
else if (compareStrNoCase(col, "ARGS_POST")) {
variableValue = transaction->m_variableArgsPost.resolveFirst(var);
}
else if (compareStrNoCase(col, "FILES_SIZES")) {
variableValue = transaction->m_variableFilesSizes.resolveFirst(var);
}
else if (compareStrNoCase(col, "FILES_NAMES")) {
variableValue = transaction->m_variableFilesNames.resolveFirst(var);
}
else if (compareStrNoCase(col, "FILES_TMP_CONTENT")) {
variableValue = transaction->m_variableFilesTmpContent.resolveFirst(var);
}
else if (compareStrNoCase(col, "MULTIPART_FILENAME")) {
variableValue = transaction->m_variableMultiPartFileName.resolveFirst(var);
}
else if (compareStrNoCase(col, "MULTIPART_NAME")) {
variableValue = transaction->m_variableMultiPartName.resolveFirst(var);
}
else if (compareStrNoCase(col, "MATCHED_VARS_NAMES")) {
variableValue = transaction->m_variableMatchedVarsNames.resolveFirst(var);
}
else if (compareStrNoCase(col, "MATCHED_VARS")) {
variableValue = transaction->m_variableMatchedVars.resolveFirst(var);
}
else if (compareStrNoCase(col, "FILES")) {
variableValue = transaction->m_variableFiles.resolveFirst(var);
}
else if (compareStrNoCase(col, "REQUEST_COOKIES")) {
variableValue = transaction->m_variableRequestCookies.resolveFirst(var);
}
else if (compareStrNoCase(col, "REQUEST_HEADERS")) {
variableValue = transaction->m_variableRequestHeaders.resolveFirst(var);
}
else if (compareStrNoCase(variable, "REQUEST_HEADERS_NAMES")) {
variableValue = transaction->m_variableRequestHeadersNames.resolveFirst(var);
}
else if (compareStrNoCase(col, "RESPONSE_HEADERS")) {
variableValue = transaction->m_variableResponseHeaders.resolveFirst(var);
}
else if (compareStrNoCase(variable, "RESPONSE_HEADERS_NAMES")) {
variableValue = transaction->m_variableResponseHeadersNames.resolveFirst(var);
}
else if (compareStrNoCase(col, "GEO")) {
variableValue = transaction->m_variableGeo.resolveFirst(var);
}
else if (compareStrNoCase(col, "REQUEST_COOKIES_NAMES")) {
variableValue = transaction->m_variableRequestCookiesNames.resolveFirst(var);
}
else if (compareStrNoCase(col, "FILES_TMPNAMES")) {
variableValue = transaction->m_variableFilesTmpNames.resolveFirst(var);
if (comp(col, "ARGS")) {
vv = t->m_variableArgs.resolveFirst(var);
} else if (comp(variable, "ARGS_NAMES")) {
vv = t->m_variableArgsNames.resolveFirst(var);
} else if (comp(variable, "ARGS_GET_NAMES")) {
vv = t->m_variableArgsGetNames.resolveFirst(var);
} else if (comp(variable, "ARGS_POST_NAMES")) {
vv = t->m_variableArgsPostNames.resolveFirst(var);
} else if (comp(col, "RULE")) {
vv = t->m_variableRule.resolveFirst(var);
} else if (comp(col, "ARGS_GET")) {
vv = t->m_variableArgsGet.resolveFirst(var);
} else if (comp(col, "ARGS_POST")) {
vv = t->m_variableArgsPost.resolveFirst(var);
} else if (comp(col, "FILES_SIZES")) {
vv = t->m_variableFilesSizes.resolveFirst(var);
} else if (comp(col, "FILES_NAMES")) {
vv = t->m_variableFilesNames.resolveFirst(var);
} else if (comp(col, "FILES_TMP_CONTENT")) {
vv = t->m_variableFilesTmpContent.resolveFirst(var);
} else if (comp(col, "MULTIPART_FILENAME")) {
vv = t->m_variableMultiPartFileName.resolveFirst(var);
} else if (comp(col, "MULTIPART_NAME")) {
vv = t->m_variableMultiPartName.resolveFirst(var);
} else if (comp(col, "MATCHED_VARS_NAMES")) {
vv = t->m_variableMatchedVarsNames.resolveFirst(var);
} else if (comp(col, "MATCHED_VARS")) {
vv = t->m_variableMatchedVars.resolveFirst(var);
} else if (comp(col, "FILES")) {
vv = t->m_variableFiles.resolveFirst(var);
} else if (comp(col, "REQUEST_COOKIES")) {
vv = t->m_variableRequestCookies.resolveFirst(var);
} else if (comp(col, "REQUEST_HEADERS")) {
vv = t->m_variableRequestHeaders.resolveFirst(var);
} else if (comp(variable, "REQUEST_HEADERS_NAMES")) {
vv = t->m_variableRequestHeadersNames.resolveFirst(var);
} else if (comp(col, "RESPONSE_HEADERS")) {
vv = t->m_variableResponseHeaders.resolveFirst(var);
} else if (comp(variable, "RESPONSE_HEADERS_NAMES")) {
vv = t->m_variableResponseHeadersNames.resolveFirst(var);
} else if (comp(col, "GEO")) {
vv = t->m_variableGeo.resolveFirst(var);
} else if (comp(col, "REQUEST_COOKIES_NAMES")) {
vv = t->m_variableRequestCookiesNames.resolveFirst(var);
} else if (comp(col, "FILES_TMPNAMES")) {
vv = t->m_variableFilesTmpNames.resolveFirst(var);
} else {
variableValue = transaction->m_collections.resolveFirst(col,
var);
vv = t->m_collections.resolveFirst(col, var);
}
}
return std::string(*variableValue.get());
return std::string(*vv.get());
}
std::string m_name;
@@ -575,10 +433,10 @@ class VariableModificatorExclusion : public Variable {
m_isExclusion = true;
}
void evaluate(Transaction *transaction,
void evaluate(Transaction *t,
Rule *rule,
std::vector<const collection::Variable *> *l) {
m_var->evaluate(transaction, rule, l);
m_var->evaluate(t, rule, l);
}
std::unique_ptr<Variable> m_var;
@@ -593,14 +451,14 @@ class VariableModificatorCount : public Variable {
m_isCount = true;
}
void evaluate(Transaction *transaction,
void evaluate(Transaction *t,
Rule *rule,
std::vector<const collection::Variable *> *l) {
std::vector<const collection::Variable *> reslIn;
collection::Variable *val = NULL;
int count = 0;
m_var->evaluate(transaction, rule, &reslIn);
m_var->evaluate(t, rule, &reslIn);
for (const collection::Variable *a : reslIn) {
count++;
delete a;

View File

@@ -32,7 +32,7 @@ namespace Variables {
class WebAppId : public Variable {
public:
explicit WebAppId()
WebAppId()
: Variable("WEBAPPID") { }
void evaluate(Transaction *transaction,