[MXS-1321] Mask columns referred inside functions Created: 2017-07-20  Updated: 2017-08-22  Resolved: 2017-08-22

Status: Closed
Project: MariaDB MaxScale
Component/s: masking
Affects Version/s: 2.1.4
Fix Version/s: N/A

Type: Task Priority: Major
Reporter: Dipti Joshi (Inactive) Assignee: Massimiliano Pinto (Inactive)
Resolution: Won't Do Votes: 0
Labels: None


 Description   

Today if the mask filter is configured for a column , and the column is referred inside a function in the select projection list than, column is not masked. This should be correct

Following query
select SUBSTRING(nation_id, 1) from table_1

returns nation_id even if masking filter is set to filter nation_id

This should be fixed, that if the masked column is used inside a function in projection list, then the entire field should be masked with "X" - no partial regex masking or obfuscation should be done.



 Comments   
Comment by Massimiliano Pinto (Inactive) [ 2017-07-21 ]

-bash-4.1$ mysql -h 127.0.0.1 -P 8811 -e "select MD5(name), MAX(ssn) from test.masking"
------------------------------------------------------+

MD5(name) MAX(ssn)

------------------------------------------------------+

P;~:~7~lE_US@I's+m``~~8:]O    

------------------------------------------------------+

This can be easily done by checking also "column_def" "name", not only "column_def" "org_name", as above.

What cannot be done immediately is:

-bash-4.1$ mysql -h 127.0.0.1 -P 8811 -e "select MAX(name) AS mmm from test.masking"
-------

mmm

-------

foobar

-------

Adding a column alias with a function is something that cannot be checked in the result set but it must be done inspecting the input

Comment by Johan Wikman [ 2017-07-24 ]

Anything that cannot be performed by merely inspecting the resultset implies a massive change.

Masking the result of a statement like "select SUBSTRING(nation_id, 1) from table_1" effectively means that the parse tree of the statement must be made available to the filter, so that it can figure out whether a column to be masked (e.g. nation_id) is used as an argument to a function.

Comment by Dipti Joshi (Inactive) [ 2017-07-25 ]

johan.wikman Alternate to using parse tree of the entire SQL statement is to do regex processing of the return column name in the result set - "column_def". "name" in addition to "column_def". "org_name"
(1) if "column_def" "org_name" is masked column then mask the data for the column in the result set
(2) if "column_def". "name" matches the following regex, then mask the data for the column in the result set

[a-z]*[A-Z]*[ ]*([ ]*<<masked-column>>[ ]*[,]*.*)

This regex covers patterns of <function-name>(<column-name>, zero or more parameters)

Comment by Johan Wikman [ 2017-07-26 ]

That's a good idea, but the regex needs to be more complex than that. It would not catch e.g.

select concat("", masked_column) from tbl;

Comment by Johan Wikman [ 2017-08-22 ]

Handled by MXS-1364 and MXS-1346

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