Repository navigation
fix(global-settings): the clock rule only reads the arguments of date itself (v2.8.1) - #938
Merged
Merged
Conversation
… itself (v2.8.1) The rule that refuses a change of the system clock looked for the set flag anywhere on the command line. A read-only line such as `curl -s <url>; date -u` was therefore refused because of curl's own `-s`. The rule now inspects each `date` invocation up to the next `;`, `&`, `|` or newline, with quoted strings consumed whole. Every form that was refused before is still refused; `sudo date` was not covered and still is not. Adds 19 cases to the hook test suite (8691 of 8691 pass) and the 2.8.1 changelog entry. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…onger ends the inspected segment The inspected `date` segment now ends only at a real separator: `;`, `&&`, `||`, `|`, `|&`, a lone `&` or a newline. Escaped characters (`\;`, `\"`) and redirection operators (`2>&1`, `&>`, `&>>`, `>|`, `<&`) are blanked out first, and a quote that is never closed runs to the end of the line (fail closed). Adds the six refused forms as deny cases and two allow cases to the date test section. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…e count A command or process substitution can carry its own `;` or `|`, which the segment match cannot follow, so the set flag behind one slipped through. When the line holds `$(`, a backtick or `<(` / `>(`, the rule now reads the whole line, as it did before this pull request. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
WilcoLouwerse
commented
Nov 12, 2026
WilcoLouwerse
left a comment
Contributor
Author
There was a problem hiding this comment.
Verdict: APPROVE (Standard · full)
Self-review, so posted as a comment. The first commit narrowed the clock rule too far; the two follow-up commits on this branch close that, and on head 10c7ecd6 every line the rule refused on main is refused again, apart from the false positives this PR set out to remove.
🔴 Found and fixed before this verdict
- f1 — a redirection, an escape or an open quote ended the inspected part too early. On
25f77e8asix valid forms thatmainrefused passed the rule:-sbehind2>&1,&>,>|, an escaped\;, an escaped\"or\'. Fixed in 88a015c: escapes and redirection operators are blanked before the match, and a quote that is never closed runs to the end of the line. - f3 — a substitution carries its own separators. Found in the check of the f1 fix:
-sbehind$(a; b), a backtick substitution,$(a | b)or<(a; b)still passed. Fixed in 10c7ecd: with a substitution on the line, the rule reads the whole line, as onmain.
Verification, old script (origin/main) against the head, each line fed to the hook as JSON on stdin: all ten forms above are refused by both; curl -s x; date -u, date -u; grep -s x f and date -u 2>&1 | sort -s are refused by the old script and pass on the head.
🟢 Minor
- f2 — the PR title differed from the commit subject. Aligned.
- A line that holds a substitution and another command's
-sis still refused (for exampledate +%s; curl -s "$(…)"). That is the fail-closed choice of f3 and is named in the description.
Context
- Tests:
global-settings/tests/test-block-write-commands.shpasses 8705 of 8705 on the head;test-check-settings-version.sh114 of 114;bash -nclean. shellcheck was not run locally. - CI: the 28 checks on
10c7ecd6were still pending when this was posted. - Gates: the local gate run reported three failures (
coding-standard-adoption,composer-cooldown-config,adr-number-collision). All three are repository-wide and unrelated to this diff. - Not covered, as before this PR:
sudo date,$(date …), and escapes or quotes that span a newline. - Merge: needs an approving review from a colleague; this comment is not one.
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.
What
The hook rule that refuses a change of the system clock looked for the set flag anywhere on the command line. A read-only line such as
curl -s <url>; date -uwas therefore refused because of curl's own-s.The rule now inspects each
dateinvocation up to the next real command separator (;,&&,||,|,|&, a lone&, a newline).Behaviour
curl -s x; date -u,date -u; grep -s x f,date -u 2>&1 | sort -s.-s/--setform ofdateitself, also after;,&&or a pipe.2>&1,&>,>|), a quote that is never closed.$(, a backtick,<(), the whole line is read, as before. Such a line with another command's-son it is still refused.sudo datewas not covered by this rule and still is not.Verification
global-settings/tests/test-block-write-commands.sh; see the review for the suite counts on the head.tests/test-check-settings-version.shpasses 114 of 114.bash -nclean. shellcheck was not run locally (not installed); the ShellCheck job in CI covers it.Version 2.8.0 → 2.8.1 with a changelog entry.
🤖 Generated with Claude Code