mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-15 23:55:03 +03:00
71 lines
1.8 KiB
C++
71 lines
1.8 KiB
C++
/*
|
|
* 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 "variables/variable.h"
|
|
|
|
#include <iostream>
|
|
#include <string>
|
|
#include <vector>
|
|
#include <list>
|
|
|
|
#include "modsecurity/assay.h"
|
|
#include "variations/exclusion.h"
|
|
|
|
using ModSecurity::Variables::Variations::Exclusion;
|
|
|
|
namespace ModSecurity {
|
|
namespace Variables {
|
|
|
|
std::list<transaction::Variable *> *
|
|
Variable::evaluate(Assay *assay) {
|
|
std::list<transaction::Variable *> *l =
|
|
new std::list<transaction::Variable *>();
|
|
assay->m_collections.resolve(this->name, l);
|
|
return l;
|
|
}
|
|
|
|
std::string Variable::to_s(
|
|
std::vector<Variable *> *variables) {
|
|
std::string ret;
|
|
std::string except("");
|
|
for (int i = 0; i < variables->size() ; i++) {
|
|
std::string name = variables->at(i)->name;
|
|
Exclusion *e = dynamic_cast<Exclusion *>(variables->at(i));
|
|
if (e != NULL) {
|
|
if (except.empty()) {
|
|
except = except + name;
|
|
} else {
|
|
except = except + "|" + name;
|
|
}
|
|
continue;
|
|
}
|
|
|
|
if (i == 0) {
|
|
ret = ret + name;
|
|
} else {
|
|
ret = ret + "|" + name;
|
|
}
|
|
}
|
|
|
|
if (except.empty() == false) {
|
|
ret = ret + ", except for: " + except;
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
|
|
} // namespace Variables
|
|
} // namespace ModSecurity
|