-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MySQL: sanitize identifiers #197
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #197 +/- ##
=======================================
Coverage 64.50% 64.50%
=======================================
Files 104 104
Lines 5665 5666 +1
=======================================
+ Hits 3654 3655 +1
Misses 1693 1693
Partials 318 318 ☔ View full report in Codecov by Sentry. |
@@ -72,7 +75,7 @@ func (sqlFormatter) GetPlaceholder(_ int) string { | |||
} | |||
|
|||
func (sqlFormatter) SanitiseIdentifier(ident string) string { | |||
return ident |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Есть ли гарантия, что в имени нет перевода строки? Или мы не боимся его? А бекслеш боимся?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Есть ли гарантия, что в имени нет перевода строки?
Нет, гарантий нет. Это пользовательский ввод. Если YQL не валидирует и не отфильтровывает его как-либо, то это дойдёт до коннектора.
А бекслеш боимся?
Это сложный вопрос. Я руководствовался вот этой функцией - здесь написано, что практически любой символ в MySQL может использоваться для идентификатора поля. Поэтому берётся идентификатор и оборачивается просто в бектики. Я лишь добавил экранирование самих бектиков.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Также там приводится пример функции для проверки валидности идентификаторов. Можно портировать её на Go. Но не уверен, насколько это правильно, ведь для других клиентов мы не занимаемся такой глубокой валидацией ввода, даже сибы на ревью PG/CH не предлагали этого делать. Мне кажется, база должна сама это отсечь.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
стремная часть. хорошо бы однажды ее перепроверить
No description provided.