Commit Graph

50 Commits

Author SHA1 Message Date
Felipe Zimmerle
730328897d Constify Transaction on variable resolution 2020-11-16 10:01:43 -03:00
Felipe Zimmerle
44791be5e0 Adds support for string_view in Variable 2020-11-16 10:01:42 -03:00
Felipe Zimmerle
952473368a Replaces getKeyWithCollection with getName on VariableValue 2020-11-16 10:01:42 -03:00
Felipe Zimmerle
a8ba54e1ab Cosmetics: Using VariableValues instead of std::vector<...>
Making the code more readable.
2020-11-16 10:01:42 -03:00
Felipe Zimmerle
f917d07950 Refactoring on variables::Variable
Using the references on key and collection as shared pointers
2020-11-16 10:01:42 -03:00
WGH
1b13e041ce Use std::shared_ptr for variable resolution
AnchoredSetVariable::resolve is called for every rule
(see RuleWithOperator::evaluate). The previous implementation allocated
a new copy of every variable, which quickly added up. In my tests,
AnchoredSetVariable::resolve function consumed 7.8% of run time.

AnchoredSetVariable (which is a multimap) values are never changed,
only added. This means it's safe to store them in std::shared_ptr,
and make resolve return shared_ptr pointing to the same object.

Other resolve implementation could also use this optimization by not
allocating new objects, however, they are not hot spots, so this
optimization was not implemented there.

In my benchmark, this raises performance from 117 requests per second to
131 RPS, and overhead is lowered from 7.8% to 2.4%.

As a bonus, replacing plain pointer with smart pointers make code
cleaner, since using smart pointers makes manual deletes no longer necessary.

Additionally, VariableOrigin is now stored in plain std::vector,
since it's wasteful to store structure containing just two integer
values using std::list<std::unique_ptr<T>>.
2020-11-16 10:01:42 -03:00
Felipe Zimmerle
2ee9ccffa9 actions: Compute the rule association during rules load 2020-11-16 10:01:40 -03:00
Felipe Zimmerle
3fb4266ebf Adds method getVariableNames to variables 2020-11-16 10:01:39 -03:00
Felipe Zimmerle
7a48245aed Creates RuleUnconditional
Makes RuleScript child of RuleWithActions instead of Operator
2020-03-31 14:44:19 -03:00
Felipe Zimmerle
59d4268882 Refactoring: renames Rule to RuleWithOperator 2020-03-31 10:00:08 -03:00
Felipe Zimmerle
7495675d54 Refactoring: Renames Rules to RulesSet
RulesSet does not only contain rules but alse properties
2020-02-11 14:26:47 -03:00
martinhsv
1b1fdc055b Fix rule-update-target exclusions for plain (non-regex) variables 2020-02-11 09:42:37 -03:00
Felipe Zimmerle
357c140003 Changens copyright year 2020-01-31 10:32:37 -03:00
Felipe Zimmerle
fe98ce4c7d Cosmetics: address cppcheck warnings 2020-01-30 18:19:34 -03:00
Felipe Zimmerle
68ef2dece3 Cosmetics: address cppcheck warnings on src/variables 2020-01-27 09:08:31 -03:00
Felipe Zimmerle
4f13fecbaf cppcheck: make static analysis more pedantic 2020-01-22 09:16:10 -03:00
Felipe Zimmerle
86a5f471a9 Cosmetics: fixed static analysis issues. 2020-01-15 20:35:59 -03:00
Felipe Zimmerle
47dd9c5df4 Refactoring on the VariableValue class 2019-06-14 10:13:54 -03:00
Felipe Zimmerle
5472362313 Fix SecRuleUpdateTargetByTag with regular expressions 2019-05-31 01:42:47 -03:00
Felipe Zimmerle
4e76c6adf0 Renames namespace Variables to variables 2019-03-06 15:53:20 -03:00
Felipe Zimmerle
3e8e28da48 Refactoring on the RULE variable 2018-10-23 16:26:11 -03:00
Felipe Zimmerle
554251bade Refactoring on the Rule class 2018-10-23 16:26:10 -03:00
Felipe Zimmerle
98b9ae659d Having a better organization for Variables:: 2018-09-24 16:39:48 -03:00
Felipe Zimmerle
ee50fea266 Handling key exceptions on the variable itself
This is the first step towords to solve #1697
2018-09-24 16:16:30 -03:00
Felipe Zimmerle
eeec7efb68 Renames collection::Variable to VariableValue 2018-02-20 13:40:01 -03:00
Felipe Zimmerle
de7c5c89bb Using shared var for variables names 2018-02-20 13:40:01 -03:00
Felipe Zimmerle
6f7fdd9493 Using direct variable access instead m_collections 2018-02-20 13:40:01 -03:00
Felipe Zimmerle
2d892a3176 Adds support for multipart vars on the parser 2018-02-20 13:40:00 -03:00
Felipe Zimmerle
3fb71f32d8 Coding style fixes 2017-11-13 22:32:11 -03:00
Felipe Zimmerle
082a3e3287 Adds support to SecWebAppID 2017-11-08 09:33:14 -03:00
Felipe Zimmerle
a676f313c3 Initial support for Lua script engine 2017-11-05 23:30:50 -03:00
Felipe Zimmerle
7ac6bf7241 Fix memory issues while resolving variables 2017-08-27 22:06:20 -03:00
Felipe Zimmerle
003a8e8e5f Uses shared_ptr on variable names 2017-08-27 22:06:20 -03:00
Felipe Zimmerle
e1d3abc8e7 Removes memory leak on the counter variable modificator 2017-05-28 22:10:30 -03:00
Felipe Zimmerle
e95efa05cc Fix assorted memory and static analysis errors 2017-03-06 15:02:00 -03:00
Felipe Zimmerle
f2d149fc5f Extends the direct access model to other collections 2017-03-06 15:02:00 -03:00
Felipe Zimmerle
557c29fd46 Changes variables destructor to virtual
Avoid memory leak while destroying the Variable objects.
2017-03-06 15:01:51 -03:00
Felipe Zimmerle
a9e6716c6a Variables are now receiving the rule instance as parameter 2016-05-17 15:47:50 -03:00
Felipe Zimmerle
5643d2fa28 Warming up to the remote collections support
Huge refactoring to have the code in shape to later support the
remote collections with different backends.
2016-05-03 17:39:49 -03:00
Felipe Zimmerle
a51e707517 Renames class Assay to Transaction 2016-01-13 15:57:00 -03:00
Felipe Zimmerle
42ce0475b2 Coding style: changes the namespace in the comments 2015-12-10 13:20:32 -03:00
Felipe Zimmerle
b5a43871e6 Changes library namespace from ModSecurity to modsecurity 2015-12-01 10:55:59 -03:00
Felipe Zimmerle
de79848285 Code cosmetics 2015-11-18 12:59:08 -03:00
Felipe Zimmerle
5bef19aa4d Variables resolution results now stored into a std::vector instead of std::list 2015-11-04 15:51:22 -03:00
Felipe Zimmerle
2ee5d4ca8f Testing performance enhancements by enabling transformations cache
Also reduce the utilization of dynamic cast.
2015-11-04 00:28:04 -03:00
Felipe Zimmerle
e641c3cc17 Huge improve in the variables resolution time 2015-11-03 22:44:59 -03:00
Felipe Zimmerle
776502e021 Refactoring: changes ModSecurityStringVar to transaction::Variable
Having the variables and collection in place before start to implement
persistent storage.
2015-10-28 13:53:07 -03:00
Felipe Zimmerle
076a02951c Huge performance improvement: passing variables as pointers avoiding copies 2015-09-18 20:21:12 -03:00
Felipe Zimmerle
dc0b13ad74 Cosmetic: fix copyright header 2015-07-22 23:03:09 -03:00
Felipe Zimmerle
16bb253d0e Adds all variables to the 'Variables' name space 2015-07-22 22:36:30 -03:00