Fix line wrapping / code style (#837).

This commit is contained in:
2025-03-25 22:31:50 -07:00
parent 9e694e4df9
commit 23efbb8df3
2 changed files with 20 additions and 15 deletions

View File

@@ -1729,20 +1729,21 @@ properties:
mongodump_command:
type: string
description: |
Command to use instead of "mongodump". This can be used to
run a specific mongodump version (e.g., one inside a
Command to use instead of "mongodump". This can be used
to run a specific mongodump version (e.g., one inside a
running container). If you run it from within a
container, make sure to mount the path in the
"user_runtime_directory" option from the host into the
container at the same location. Defaults to "mongodump".
container at the same location. Defaults to
"mongodump".
example: docker exec mongodb_container mongodump
mongorestore_command:
type: string
description: |
Command to run when restoring a database instead
of "mongorestore". This can be used to run a specific
mongorestore version (e.g., one inside a running container).
Defaults to "mongorestore".
Command to run when restoring a database instead of
"mongorestore". This can be used to run a specific
mongorestore version (e.g., one inside a running
container). Defaults to "mongorestore".
example: docker exec mongodb_container mongorestore
description: |
List of one or more MongoDB databases to dump before creating a

View File

@@ -681,6 +681,8 @@ def test_restore_data_source_dump_without_extract_process_restores_from_disk():
},
borgmatic_runtime_directory='/run/borgmatic',
)
def test_dump_data_sources_uses_custom_mongodump_command():
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
flexmock()
@@ -714,7 +716,8 @@ def test_dump_data_sources_uses_custom_mongodump_command():
patterns=[],
dry_run=False,
) == [process]
def test_build_dump_command_prevents_shell_injection():
database = {
'name': 'testdb; rm -rf /', # Malicious input
@@ -733,8 +736,11 @@ def test_build_dump_command_prevents_shell_injection():
# Ensure the malicious input is properly escaped and does not execute
assert 'testdb; rm -rf /' not in command
assert any('testdb' in part for part in command) # Check if 'testdb' is in any part of the tuple
assert any(
'testdb' in part for part in command
) # Check if 'testdb' is in any part of the tuple
def test_restore_data_source_dump_uses_custom_mongorestore_command():
hook_config = [
{
@@ -777,7 +783,8 @@ def test_restore_data_source_dump_uses_custom_mongorestore_command():
},
borgmatic_runtime_directory='/run/borgmatic',
)
def test_build_restore_command_prevents_shell_injection():
database = {
'name': 'testdb; rm -rf /', # Malicious input
@@ -801,11 +808,8 @@ def test_build_restore_command_prevents_shell_injection():
command = module.build_restore_command(
extract_process, database, config, dump_filename, connection_params
)
# print(command)
# Ensure the malicious input is properly escaped and does not execute
assert 'rm -rf /' not in command
assert ';' not in command