Custom command options for MongoDB hook #837 #1041

Merged
witten merged 3 commits from gautamaggarwal2810/borgmatic:main into main 2025-03-26 05:27:04 +00:00
Contributor

Fixes #837.Successfully ran unit tests locally.Please review and suggest changes.

Fixes #837.Successfully ran unit tests locally.Please review and suggest changes.
gautamaggarwal2810 added 2 commits 2025-03-24 04:05:26 +00:00
witten reviewed 2025-03-24 19:44:17 +00:00
witten left a comment
Owner

Looking good! Mostly minor comments.

Looking good! Mostly minor comments.
@@ -684,0 +715,4 @@
dry_run=False,
) == [process]
def test_build_dump_command_prevents_shell_injection():
Owner

Do you think it's worth having a test like this for the restore command as well?

Do you think it's worth having a test like this for the restore command as well?
@@ -684,0 +717,4 @@
def test_build_dump_command_prevents_shell_injection():
database = {
'name': 'testdb; rm -rf /', # Malicious input
Owner

It's not a concern here, but generally I try not to include real malicious commands even in tests—on the off chance that something is broken and they actually get executed!

It's not a concern here, but generally I try not to include real malicious commands even in tests—on the off chance that something is broken and they actually get executed!
@@ -684,0 +729,4 @@
dump_filename = '/path/to/dump'
dump_format = 'archive'
from borgmatic.hooks.data_source.mongodb import build_dump_command, build_restore_command # Import the functions
Owner

You shouldn't need to do this here (or at all) if you instead use module.build_dump_command() and module.build_restore_command().

You shouldn't need to do this here (or at all) if you instead use `module.build_dump_command()` and `module.build_restore_command()`.
witten marked this conversation as resolved
gautamaggarwal2810 added 1 commit 2025-03-25 04:52:11 +00:00
Author
Contributor

Thank you for the feedback! I’ve applied all the suggested changes in the latest commit, including:

  • Added unit test test_build_restore_command_prevents_shell_injection( ).
  • Used module.build_dump_command( ) instead of importing the command.

Please let me know if there’s anything else I should adjust or improve.
All unit tests ran successfully.

Thank you for the feedback! I’ve applied all the suggested changes in the latest commit, including: - Added unit test test_build_restore_command_prevents_shell_injection( ). - Used module.build_dump_command( ) instead of importing the command. Please let me know if there’s anything else I should adjust or improve. All unit tests ran successfully.
Owner

As far as I'm concerned, this looks set to merge! Please take off the "WIP" prefix when you are ready.

As far as I'm concerned, this looks set to merge! Please take off the "WIP" prefix when you are ready.
gautamaggarwal2810 changed title from WIP: Custom command options for MongoDB hook #837 to Custom command options for MongoDB hook #837 2025-03-26 04:45:34 +00:00
witten merged commit 76f7c53a1c into main 2025-03-26 05:27:04 +00:00
Owner

Thanks!!

Thanks!!
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#1041