fix: harden journal scanner startup
This commit is contained in:
@@ -224,11 +224,51 @@ PY2
|
||||
report_pass "journal_${name}"
|
||||
}
|
||||
|
||||
local python_bin
|
||||
python_bin=$(command -v python3) || report_fail python_missing
|
||||
|
||||
run_journal_case clean 0 $'INFO clean\n' 0 0
|
||||
run_journal_case oversized_line 2 "$(printf 'A%.0s' {1..1048577})" 0 0
|
||||
run_journal_case too_many_lines 2 "$(printf 'x\n%.0s' {1..10001})" 0 0
|
||||
run_journal_case child_failure 2 $'INFO child failure\n' 7 0
|
||||
run_journal_case actual_key_across_chunk 1 "$(printf 'A%.0s' {1..65530})REAL_SECRET_SYNTHETIC" 0 1
|
||||
|
||||
local empty_path="$temp_root/empty-path"
|
||||
mkdir -p "$empty_path"
|
||||
printf '%s' 'INFO spawn failure\n' >"$data_file"
|
||||
: >"$pid_file" "$stdout_file" "$stderr_file"
|
||||
if PATH="$empty_path" JOURNAL_DATA_FILE="$data_file" JOURNAL_PID_FILE="$pid_file" JOURNAL_EXIT=0 JOURNAL_HOLD=0 \
|
||||
"$python_bin" -c "$journal_code" synthetic-since "$key_file" "$legacy_file" >"$stdout_file" 2>"$stderr_file"; then
|
||||
actual=0
|
||||
else
|
||||
actual=$?
|
||||
fi
|
||||
[[ "$actual" -eq 2 ]] || report_fail journal_spawn_failure_status
|
||||
[[ ! -s "$stdout_file" && ! -s "$stderr_file" ]] || report_fail journal_spawn_failure_output
|
||||
[[ ! -s "$pid_file" ]] || report_fail journal_spawn_failure_child
|
||||
report_pass journal_spawn_failure
|
||||
|
||||
chmod 000 "$key_file"
|
||||
: >"$pid_file" "$stdout_file" "$stderr_file"
|
||||
if PATH="$fake_bin:$PATH" JOURNAL_DATA_FILE="$data_file" JOURNAL_PID_FILE="$pid_file" JOURNAL_EXIT=0 JOURNAL_HOLD=0 \
|
||||
"$python_bin" -c "$journal_code" synthetic-since "$key_file" "$legacy_file" >"$stdout_file" 2>"$stderr_file"; then
|
||||
actual=0
|
||||
else
|
||||
actual=$?
|
||||
fi
|
||||
chmod 0600 "$key_file"
|
||||
[[ "$actual" -eq 2 ]] || report_fail journal_key_unreadable_status
|
||||
[[ ! -s "$stdout_file" && ! -s "$stderr_file" ]] || report_fail journal_key_unreadable_output
|
||||
[[ ! -s "$pid_file" ]] || report_fail journal_key_unreadable_child
|
||||
report_pass journal_key_unreadable
|
||||
|
||||
python3 - "$key_file" <<'PY2'
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
pathlib.Path(sys.argv[1]).write_bytes(b"K" * 65_537)
|
||||
PY2
|
||||
run_journal_case long_key_across_chunks 1 "$(printf 'A%.0s' {1..65535})$(printf 'K%.0s' {1..65537})" 0 1
|
||||
}
|
||||
|
||||
exercise_journal_scanner
|
||||
|
||||
Reference in New Issue
Block a user