[MXS-2859] Strings with newlines break configuration serialization Created: 2020-01-29  Updated: 2020-02-03  Resolved: 2020-02-03

Status: Closed
Project: MariaDB MaxScale
Component/s: Core
Affects Version/s: 2.3.16, 2.4.6
Fix Version/s: 2.3.17, 2.4.7, 2.5.0

Type: Bug Priority: Minor
Reporter: Petko Vasilev (Inactive) Assignee: markus makela
Resolution: Fixed Votes: 0
Labels: None


 Description   

The REST API does not validate the input string in a way that would prevent it from breaking the configuration serialization. Strings with an embedded newlines must be rejected.


Original description:

The following regex

(?x) start #comment
end

is a valid regex with comments enabled.
It should match "startend"
The Maxscale REST API allows creating of such regexes and they function as expected, but the resulting .cnf file ine "/var/lib/maxscale/maxscale/cnf.d/" is invalid, as it contains a new line.

[replication_filter]
type=filter
module=binlogfilter
match=(?#test1)(?x) start #comment
end
exclude=something
rewrite_src=something
rewrite_dest=something

The REST API returns the following JSON for this filter

            "parameters": {
                "match": "(?x) start #comment\nend",
                "exclude": "something",
                "rewrite_src": "something",
                "rewrite_dest": "something"
            }

The discrepancy between the json and .cnf representations means that after a maxscale restart the .cnf will be loaded and maxscale will crash as this is not a valid .cnf file



 Comments   
Comment by markus makela [ 2020-01-30 ]

We'd recommend either converting explicit newlines into escaped form (\n) or using the newline characer class (\R). For more information, refer to the PCRE2 syntax: https://www.pcre.org/current/doc/html/pcre2syntax.html#SEC4

For the time being, regular expressions with explicit newlines should be rejected.

Generated at Thu Feb 08 04:17:12 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.