Fix mysql.db_remove system-database guard checking a misspelled name#69688
Open
ggiesen wants to merge 2 commits into
Open
Fix mysql.db_remove system-database guard checking a misspelled name#69688ggiesen wants to merge 2 commits into
ggiesen wants to merge 2 commits into
Conversation
The system-database guard in db_remove compared the name against the misspelled "information_scheme", so the check never matched and the real information_schema database was not protected from removal. Fixes saltstack#54938
…tabase guard The direct test verifies db_remove issues DROP DATABASE for a user database literally named information_scheme (the misspelling formerly stuck in the guard), called with just the database name and empty connection_args exactly as the production caller mysql_database.absent() does; it fails when the source fix is reverted. The inverse test guards against overcorrection by asserting databases whose names merely resemble the protected system databases (mysql_backup, information_schema_old) are still dropped, and passes with and without the fix. Claude-Session: https://claude.ai/code/session_01MF2AuQNhBZg4HDt1x6xxCu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
db_remove() in salt/modules/mysql.py guarded the system databases by comparing the name against the misspelled "information_scheme", so the guard never matched and the real information_schema database was not protected from a DROP. Changed the literal on line 1367 to "information_schema". Added test_db_remove_system_db which mocks db_exists=True and asserts db_remove returns False and never calls _connect for "mysql" and "information_schema"; verified it fails on the unpatched code and passes with the fix.
What issues does this PR fix or reference?
Fixes #54938
Previous Behavior
See #54938.
New Behavior
Fix mysql.db_remove system-database guard checking a misspelled name. Validated by a unit test proven to fail on unpatched 3006.x and pass with the fix (confirmed by adversarial review).
Merge requirements satisfied?
Commits signed with GPG?
No