Skip to content
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

Fix database quoting problem in collector 'info_schema.tables' #908

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

oblitorum
Copy link

In collector/info_schema_tables.go, the SQL it uses to retrieves the table meta data is

SELECT
	TABLE_SCHEMA,
	...
FROM information_schema.tables
WHERE TABLE_SCHEMA = '%s'

Which could cause a problem if the schema contains the single quote character ' (It's indeed a vaild character in database/table name), we should use the placeholder ? and pass the schema as an argument to db.QueryContext(...) to avoid this kind of problem. Also to avoid the SQL injection problem as user can pass anything to --collect.info_schema.tables.databases in reality (accidentally or on purpose).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant