Commit Graph

984 Commits

Author SHA1 Message Date
b15a460416 MXS-1659 Do not include C++ headers from C header 2018-02-08 12:45:18 +02:00
ea58b16a7a Add missing include for vector
The vector header was not included in dbfwfilter.hh.
2018-01-30 19:14:28 +02:00
c7474e439e Print new parameters during diagnostics
Also, copy using strdup instead since config_copy_string()
returns null for empty strings.
2018-01-30 18:40:33 +02:00
0db538db9a MXS-1583 Treat independent 'users' line in OR-fashion
If there are several 'users' lines in a rule file, for a particular
user, the rules each matching line will be checked independently
until a rule match is found.

That is, the rules of each 'users' line are treated in an OR-fashion
with respect to each other.
2018-01-29 15:25:21 +02:00
7c7190e0c4 Fix index overflow in masking filter 2018-01-19 09:55:20 +02:00
beac04b8e7 MXS-1616 Also use 'value' in partial matching
As you can create regular expressions that have a fixed length,
e.g. "....$", it makes perfect sense to replace using 'value' if
the length of the string matches exactly.
2018-01-18 09:48:38 +02:00
c02da103d7 MXS-1615 Fix access of wrong argument
- Wrong argument accessed at command invocation. In debug mode
  leads to crash, in release mode probably leads to crash.
- Log result of reload.
2018-01-17 13:59:00 +02:00
1d211ecee2 MXS-1511: QLA-Filter replace newlines in SQL-queries with custom strings
The config parameter 'newline_replacement' (defaults to 1 space " ") now defines
what to write to the log file when the sql-query has a newline sequence (\n, \r or
\r\n). If 'newline_replacement' is the empty string "", no replacing is done and
newlines are printed to file.

Also, adds the config parameter 'separator', which defines the string
printed between elements. Default value is ",".
2018-01-16 14:25:19 +02:00
14f1bbed51 NamedServerFilter: Deprecate message for legacy parameter use 2018-01-15 15:30:38 +02:00
224f918845 MXS-1592 Make all modules lowercase
Make all modules lowercase and make module loading case
insensitive. Further, make command invocation case insensitive,
as far as the module name is conserned.
2018-01-03 14:57:18 +02:00
9689271a34 MXS-1541: Use session ID in topfilter
The topfilter now uses the session ID as the filename suffix.
2018-01-03 08:56:41 +02:00
cf29430476 Merge branch '2.1' into 2.2 2018-01-02 09:31:07 +02:00
95983ddaf4 Fix unit test failures
When the unit tests were run without installing the libraries in their
final locations, the loading of the modules would fail. Using locations
relative to the build directory allows unit testing without having to
install the libraries.
2017-12-29 10:09:16 +02:00
cf627203cb Fix issues revealed on CentOS6 2017-12-02 13:42:15 +02:00
481892b452 MXS-1512 Add test case for cache options
Here's now tested that the cache properly deals with the configuration
setting "cache_in_transactions" and the current transaction state.
2017-11-29 12:41:34 +02:00
b225eeff2c MXS-1512 Allow autocommit and trx state to be set for a session
When mocking you want to be able to set explicitly how a filter
session should see the current context.
2017-11-29 12:41:34 +02:00
02cf284b61 MXS-1512 Add mock Backend class that can generate resultsets 2017-11-29 12:41:34 +02:00
6d66ffe9f7 Use FilterModule::ConfigParameters in test_dbfwfilter 2017-11-29 12:41:34 +02:00
9aa4a2d1ff MXS-1512 Create parameters object from default parameters 2017-11-29 12:41:34 +02:00
7ae2acecf7 MXS-1512 Take module object type as template argument
Makes it possible to move the module object pointer into the
SpecificModule template.
2017-11-29 12:41:34 +02:00
e0818fdbeb Fix include path error 2017-11-23 12:55:24 +02:00
396b81f336 Fix in-source builds
The internal header directory conflicted with in-source builds causing a
build failure. This is fixed by renaming the internal header directory to
something other than maxscale.

The renaming pointed out a few problems in a couple of source files that
appeared to include internal headers when the headers were in fact public
headers.

Fixed maxctrl in-source builds by making the copying of the sources
optional.
2017-11-22 18:40:18 +02:00
c38fbd0b74 Move utility and mock classes to .../filter/test
The utility and mock classes created for the testing of dbfwfilter
will be used for testing certain aspects of the cache filter.
Consequently better to move them somewhere outside dbfwfilter.
Sofar they will be built separately for each filter.
2017-11-22 10:00:34 +02:00
bc7209c04e cache: Update test-program due to qc-changes
In 2.2 it is no longer possible to know where a particular column
appears. Hence the result when a column appears amongst the selected
columns and the where-clause must be the same.
2017-11-20 15:21:46 +02:00
fc8c25803a cache: Perform thread initialization in test program 2017-11-20 15:19:54 +02:00
cd89b976a9 cache: Fix iteration of rules
Incrementation of index ended up outside iteration block at
earlier refactoring.
2017-11-20 15:18:17 +02:00
604502e1cb MXS-1461 Template Module -> class Module + template SpecificModule 2017-11-20 13:14:02 +02:00
25e288b571 MXS-1461 Add firewall test cases 2017-11-20 13:14:02 +02:00
8abe5a659e MXS-1461 Allow user and host to be exluded in test cases 2017-11-20 13:14:02 +02:00
a596e1a77c MXS-1461 Move client data to Client
The user and host are now in Client.
2017-11-20 13:14:02 +02:00
083c3bcad7 MXS-1461 Rename Upstream to Client 2017-11-20 13:14:02 +02:00
a35a4c7e9f MXS-1461 Modify mock classes 2017-11-20 13:14:02 +02:00
8fba2a8049 MXS-1461 Add local firewall filter tests
Only two now, more to be added.
2017-11-20 13:14:02 +02:00
da989d636e MXS-1461 Add TempFile
Class for creating a temporary file.
2017-11-20 13:14:02 +02:00
edb271fa8e MXS-1461 Modify some mock-classes 2017-11-20 13:14:02 +02:00
843c9b0ce1 MXS-1461 Add mock Upstream class
Upstream can be used as the upstream filter of a filter to
be tested.
2017-11-20 13:14:02 +02:00
8aeb49cffa MXS-1461 Add FilterModule class 2017-11-20 13:14:02 +02:00
815da1b7ad MXS-1461 Add mock RouterSession 2017-11-20 13:14:02 +02:00
1edccba885 MXS-1461 Add mock Backend class 2017-11-20 13:14:02 +02:00
d2c80d2e91 MXS-1461 Add QueryClassifierModule 2017-11-20 13:14:02 +02:00
531a8bafbd MXS-1461 Add mock classes Session and Dcb 2017-11-20 13:14:02 +02:00
65cf491350 MXS-1461 Add general purpose mocking functions 2017-11-20 13:14:02 +02:00
e434c7ec66 MXS-1461 Add template Module
This is the first in a series of commits that introduce components
that allow filters to be tested without MaxScale or backends.
Obviously the environment is not suited for all cases, but allow e.g.
the behaviour of the firewall filter to be tested in isolation.

The environment consists of helper classes loading and manipulating
modules and filters and mock-classes that provide the needed
scaffolding around a filter.

Currently all components exist under the test directory of the firewall
filter, but once proven they can be moved to a more general purpose
location.
2017-11-20 13:14:02 +02:00
204fa17322 MXS-1519 Prevent "inheritance" of fw rules
By using an the value of a global incremented integer as the
initial version number of a Dbfw instance it is ensured that every
such instance does not "inherit" any rules from a previous instance
that happened to exist in the same place as the new instance to be
created.
2017-11-20 10:11:23 +02:00
decd5578bc MXS-1525 Check exact match first when checking host
Given a rule like

  ...
  users %@127.0.0.1 match any rules ...

the code started with %@127.0.0.%, which meant that the exact
match rule would be missed.
2017-11-16 14:09:28 +02:00
11a240cb15 MXS-1519 Use fw instance specific rules and users
The rules and users need to be distinct not only for each thread
but for each instance and thread.
2017-11-16 14:06:50 +02:00
032b2f3846 MXS-1333: QLAFilter, add option to log execution time
Adds an option 'reply_time' to log_data. When enabled, query execution time
in milliseconds is logged. Execution time is measured as the time between
routeQuery and the first clientReply.
2017-11-15 16:56:39 +02:00
9d686c4c41 MXS-1461 Create error message only when blocking
Only if the filter is in blocking mode, will a match cause an error
to be returned. Thus, no point in creating the error message unless
the filter is in blocking mode.
2017-11-14 13:03:07 +02:00
ea0f8978b2 MXS-1461 Update log messages of firewall rules
Whether or not a match causes the query to be blocked or to be allowed
depends on whether the filter is in white-listing or black-listing mode,
so better if the text is neutral.
2017-11-14 13:03:07 +02:00
3eba77f43e MXS-1461 Implement not_function
If the instance represents `not_function` then it is a match if the
used function is not found amongst the listed functions.
2017-11-14 13:03:07 +02:00