fix(cron): skip non-script files in lifecycle guard script walk - #78108
fix(cron): skip non-script files in lifecycle guard script walk#78108jiangjingzwd wants to merge 1 commit into
Conversation
Context: the merged fix (#77332 / c98ed22 + 037825c) does not fully close #76762For maintainers reviewing this PR, there is important follow-up evidence on #76762 after it was closed on 2026-08-03: AndrewRahman's comment (2026-08-03 09:38 UTC, after the issue was closed) shows the crash still reproduces on a gateway including both Root cause of the residual gap (from their analysis, which I verified against the current main):
This is why CI doesn't catch it either: tests call How this PR differsThis PR removes the entire crash class rather than patching the instance: Test suite: 83 passed in 1.02s. The new test asserts a This is complementary to (and strictly more root-cause than) the merged fix — happy to rebase or adjust if maintainers prefer a narrower diff. |
|
The binary false-positive class this PR targets is resolved on main: |
Summary
Follow-up to #76762 / #77332. The lifecycle guard's referenced-script walk
(
_iter_referenced_shell_scripts) yields every token containing/asa "referenced shell script", then reads and scans its bytes. For absolute
paths to non-scripts (binaries like
/usr/bin/python3, logs, data files)this is wasted I/O and a false-positive source — and it was the original
crash vector behind #76762.
This PR narrows the walk to files that actually look like shell scripts:
.sh/.bash/.zsh), or#!shebangNon-regular/unreadable paths fall through to the legacy scan so the
existing fails-closed behaviour (
_read_referenced_script) is preserved.Changes
cron/lifecycle_guard.py: add_looks_like_shell_script()and apply itin
_iter_referenced_shell_scriptstests/hermes_cli/test_gateway_restart_loop.py: new testtest_absolute_path_extensionless_non_script_is_not_walkedasserting a.txtfile is not walked while an extensionless shebang script still isTest
Closes #76762 (completes the second proposed fix from the issue)