992 Commits

Author SHA1 Message Date
Niclas Antti
89296ed4e4 MXS-1740 Hintfilter leaks memory
Single spot where an existing hint ptr was overwritten. Removed gwbuf_add_hint()
because it was  adding hints at the opposite end compared to functions in hint.h.
Added hint_splice() to replace.
2018-05-31 14:04:22 +03:00
Johan Wikman
5eb6718b75 MXS-1861 Detect and handle multistatement responses
Multi-statement SELECTs were properly detected and handled,
but e.g. multi-statement UPDATESs were not, with the result
that erronous warnings were logged.

Now the responses are detected and handled properly.
2018-05-14 10:15:36 +03:00
Johan Wikman
08230ef24c MXS-1830 Remove erroneous free
The libdir is set elsewhere as well, which causes the set
buffer to be freed. Consequently it cannot be freed.
2018-04-26 15:21:16 +03:00
Johan Wikman
033ef59c01 MXS-1733 Match empty values
If a table/database rule has been provided then if the resultset
does not contain table/database names, then we consider it a match
(subject to the column obviously).

Otherwise a rule like

        {
            "replace": {
                "table": "info",
                "column": "email"
            },
            "with": {
                "fill": "*"
            }
        }

could be bypassed with a statement like

    SELECT * FROM info UNION SELECT * from info

as the resultset in that case will not indicate that the column emain
is from info, which it will if the statement is

    SELECT * FROM info;
2018-03-26 10:02:57 +03:00
Markus Mäkelä
65033313a7
MXS-1701: Fix build instructions
Corrected the documentation on building from source and fixed a missing
variable check for the luafilter.
2018-03-22 13:29:28 +02:00
Markus Mäkelä
7359774ae1
MXS-1729: Allow global routeQuery to return values
The `lua_pcall` parameters were incorrect, the second number signifies the
number of parameters the function can return.
2018-03-21 14:14:04 +02:00
Johan Wikman
544e0eb60b Merge branch '2.1' into 2.2 2018-03-01 17:57:40 +02:00
Johan Wikman
b46c52d65c MXS-1684 Match space+linefeed as linefeed
A linefeed is whitespace, so given the rules

  "\n"+    return '\n'
  {SPACE}  ;

a line consisting of space followed by a linefeed, will be matched
as space and not as a linefeed and hence will cause the parser to
barf.
2018-03-01 17:57:07 +02:00
Johan Wikman
b15a460416 MXS-1659 Do not include C++ headers from C header 2018-02-08 12:45:18 +02:00
Markus Mäkelä
ea58b16a7a Add missing include for vector
The vector header was not included in dbfwfilter.hh.
2018-01-30 19:14:28 +02:00
Esa Korhonen
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
Johan Wikman
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
Johan Wikman
7c7190e0c4 Fix index overflow in masking filter 2018-01-19 09:55:20 +02:00
Johan Wikman
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
Johan Wikman
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
Esa Korhonen
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
Esa Korhonen
14f1bbed51 NamedServerFilter: Deprecate message for legacy parameter use 2018-01-15 15:30:38 +02:00
Johan Wikman
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
Markus Mäkelä
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
Markus Mäkelä
cf29430476 Merge branch '2.1' into 2.2 2018-01-02 09:31:07 +02:00
Markus Mäkelä
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
Johan Wikman
cf627203cb Fix issues revealed on CentOS6 2017-12-02 13:42:15 +02:00
Johan Wikman
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
Johan Wikman
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
Johan Wikman
02cf284b61 MXS-1512 Add mock Backend class that can generate resultsets 2017-11-29 12:41:34 +02:00
Johan Wikman
6d66ffe9f7 Use FilterModule::ConfigParameters in test_dbfwfilter 2017-11-29 12:41:34 +02:00
Johan Wikman
9aa4a2d1ff MXS-1512 Create parameters object from default parameters 2017-11-29 12:41:34 +02:00
Johan Wikman
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
Johan Wikman
e0818fdbeb Fix include path error 2017-11-23 12:55:24 +02:00
Markus Mäkelä
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
Johan Wikman
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
Johan Wikman
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
Johan Wikman
fc8c25803a cache: Perform thread initialization in test program 2017-11-20 15:19:54 +02:00
Johan Wikman
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
Johan Wikman
604502e1cb MXS-1461 Template Module -> class Module + template SpecificModule 2017-11-20 13:14:02 +02:00
Johan Wikman
25e288b571 MXS-1461 Add firewall test cases 2017-11-20 13:14:02 +02:00
Johan Wikman
8abe5a659e MXS-1461 Allow user and host to be exluded in test cases 2017-11-20 13:14:02 +02:00
Johan Wikman
a596e1a77c MXS-1461 Move client data to Client
The user and host are now in Client.
2017-11-20 13:14:02 +02:00
Johan Wikman
083c3bcad7 MXS-1461 Rename Upstream to Client 2017-11-20 13:14:02 +02:00
Johan Wikman
a35a4c7e9f MXS-1461 Modify mock classes 2017-11-20 13:14:02 +02:00
Johan Wikman
8fba2a8049 MXS-1461 Add local firewall filter tests
Only two now, more to be added.
2017-11-20 13:14:02 +02:00
Johan Wikman
da989d636e MXS-1461 Add TempFile
Class for creating a temporary file.
2017-11-20 13:14:02 +02:00
Johan Wikman
edb271fa8e MXS-1461 Modify some mock-classes 2017-11-20 13:14:02 +02:00
Johan Wikman
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
Johan Wikman
8aeb49cffa MXS-1461 Add FilterModule class 2017-11-20 13:14:02 +02:00
Johan Wikman
815da1b7ad MXS-1461 Add mock RouterSession 2017-11-20 13:14:02 +02:00
Johan Wikman
1edccba885 MXS-1461 Add mock Backend class 2017-11-20 13:14:02 +02:00
Johan Wikman
d2c80d2e91 MXS-1461 Add QueryClassifierModule 2017-11-20 13:14:02 +02:00
Johan Wikman
531a8bafbd MXS-1461 Add mock classes Session and Dcb 2017-11-20 13:14:02 +02:00
Johan Wikman
65cf491350 MXS-1461 Add general purpose mocking functions 2017-11-20 13:14:02 +02:00