fix(cron): normalize script paths before validation (#26595)#39627
Open
rodboev wants to merge 2 commits into
Open
fix(cron): normalize script paths before validation (#26595)#39627rodboev wants to merge 2 commits into
rodboev wants to merge 2 commits into
Conversation
4234bdf to
724dfad
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cron script paths are documented as relative to
~/.hermes/scripts/, but the cron tool currently joins the raw user string directly to that directory. A user-providedscripts/check.pytherefore resolves as~/.hermes/scripts/scripts/check.py, while a missing file can be stored even though execution later fails with a script-not-found error.This normalizes script paths at the cron tool boundary, accepts one leading
scripts/prefix as user-friendly input, validates containment, verifies that the script exists before storing the job, and persists the normalized relative path. The existing-file requirement is intentional: the tool now rejects invalid cron job definitions before they are saved instead of deferring that failure until the scheduled run.Fixes #26595.
Changes
tools/cronjob_tools.py: normalize cron script paths and return the normalized storage value on create and update.tests/tools/test_cronjob_tools.py: add regression coverage forscripts/prefix normalization, Windows separator normalization, missing-file rejection, traversal and absolute-path rejection, and update clearing.Validation
script="scripts/check.py"scripts/check.py, resolving under a duplicate scripts directorycheck.pyscript="scripts\\check.py"check.pyTest plan
python -m pytest tests/tools/test_cronjob_tools.py -v --timeout=0: 72 passedscript_valueconsistency issue and adding Windows separator coverage