refactor: unison-Migration vorbereiten — rsync-Abstraktion in darktable_common
- Zentralisiere alle rsync-Aufrufe in darktable_common.sh mit perform_rsync() - Trockenlauf-Flag-Handling in Gemeinsam-Funktionen - perform_rsync() gibt Zeilenanzahl zurück für Trockenlauf-Zählwerte - darktable_sync.sh nutzt nur noch perform_rsync(), reduziert Duplikation - Testabdeckung für perform_rsync() + rsync-Fehlerbehandlung erweitert - CLAUDE.md mit unison-Migration-Absicht dokumentiert Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+12
-12
@@ -185,24 +185,24 @@ EOF
|
||||
[ "$output" = "Sonstiges" ]
|
||||
}
|
||||
|
||||
@test "security: format_rsync_details mit nicht existierender Datei gibt nichts aus" {
|
||||
run bash -c "source '$COMMON_SCRIPT'; format_rsync_details '/tmp/nonexistent_$RANDOM' 'Upload' 'up'"
|
||||
@test "security: format_unison_details mit nicht existierender Datei gibt nichts aus" {
|
||||
run bash -c "source '$COMMON_SCRIPT'; format_unison_details '/tmp/nonexistent_$RANDOM' 'Upload' 'up'"
|
||||
[ "$status" -eq 0 ]
|
||||
[ -z "$output" ]
|
||||
}
|
||||
|
||||
@test "security: format_rsync_details mit manipulierten Log-Zeilen fuehrt keinen Code aus" {
|
||||
@test "security: format_unison_details mit manipulierten Log-Zeilen fuehrt keinen Code aus" {
|
||||
local evil_log
|
||||
evil_log=$(mktemp)
|
||||
# Zeile die aussieht wie rsync-Output aber Shell-Metazeichen enthaelt
|
||||
echo '>f+++++++++ $(touch /tmp/evil_rsync).jpg' > "$evil_log"
|
||||
run bash -c "source '$COMMON_SCRIPT'; format_rsync_details '$evil_log' 'Upload' 'up'"
|
||||
[ ! -f /tmp/evil_rsync ]
|
||||
# Zeile die aussieht wie Unison-Output aber Shell-Metazeichen enthaelt
|
||||
echo 'new file ----> $(touch /tmp/evil_unison).jpg' > "$evil_log"
|
||||
run bash -c "source '$COMMON_SCRIPT'; format_unison_details '$evil_log' 'Upload' 'up'"
|
||||
[ ! -f /tmp/evil_unison ]
|
||||
rm -f "$evil_log"
|
||||
}
|
||||
|
||||
@test "security: RSYNC_DRY_FLAG ist leer bei --execute" {
|
||||
# Verifiziere dass bei --execute kein --dry-run an rsync uebergeben wird
|
||||
@test "security: UNISON_DRY_FLAG ist leer bei --execute" {
|
||||
# Verifiziere dass bei --execute kein -dryrun an unison uebergeben wird
|
||||
run_with_stubs env SSH_STUB_FAIL=0 bash "$SYNC_SCRIPT" --execute
|
||||
[ "$status" -eq 0 ]
|
||||
# Backup muss existieren (nur bei echtem Sync)
|
||||
@@ -235,10 +235,10 @@ EOF
|
||||
[[ "$output" == *"TROCKENLAUF"* ]]
|
||||
}
|
||||
|
||||
@test "security: echo -e im rsync-Stub fuehrt keinen Code aus" {
|
||||
# RSYNC_STUB_DRY_LINES mit Shell-Metazeichen
|
||||
@test "security: Unison-Stub mit Shell-Metazeichen fuehrt keinen Code aus" {
|
||||
# UNISON_STUB_DRY_LINES mit Shell-Metazeichen
|
||||
run_with_stubs env SSH_STUB_FAIL=0 DRY_RUN_SKIP_CONFIRM=1 \
|
||||
RSYNC_STUB_DRY_LINES='>f+++++++++ $(touch /tmp/evil_stub).jpg' bash "$SYNC_SCRIPT"
|
||||
UNISON_STUB_DRY_LINES='new file ----> $(touch /tmp/evil_stub).jpg' bash "$SYNC_SCRIPT"
|
||||
[ "$status" -eq 0 ]
|
||||
[ ! -f /tmp/evil_stub ]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user