mysqldump-php icon indicating copy to clipboard operation
mysqldump-php copied to clipboard

skip-definer doesn't work for views with SQL SECURITY INVOKER

Open dweingart opened this issue 3 years ago • 3 comments

The regex pattern defined in line 1904 (inside TypeAdapterMysql::create_view) fails if the view definition contains "SQL SECURITY INVOKER" instead of "SQL SECURITY DEFINER".

Changing the regex as follows fixes the bug:

Line 1904 before:

.self::DEFINER_RE.'(?:\s+SQL SECURITY DEFINER|INVOKER)?)?\s+(VIEW .+)$/',

Line 1904 after:

.self::DEFINER_RE.'(?:\s+SQL SECURITY (?:DEFINER|INVOKER))?)?\s+(VIEW .+)$/',

The DEFINER|INVOKER alternation needs to be in its own non-capturing group.

dweingart avatar Dec 30 '21 23:12 dweingart

@dweingart Do you plan to create a PR?

amenk avatar Jan 17 '22 14:01 amenk

We are working on a PR

amenk avatar Jan 17 '22 15:01 amenk

Even with the Fix, we still see some definers (we are using smilesa/gdpr-dump)

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `view_abrechnung_letzter_monat` 

with skip-definer: true

This happens only for one view

amenk avatar Feb 04 '22 09:02 amenk