Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions global-settings/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ One entry per released `VERSION`, newest first. The heading is the version numbe

Versions 1.0.0 to 1.3.0 were released from the now archived `ConductionNL/claude-code-config` repository, and their date is the day they reached that repository's `main`. A few versions reached `main` together with the next one instead of on their own; their entry says so, and carries the date they reached `main`. Numbers that `main` never carried (1.5.0, 1.5.2, 1.5.3, 2.4.3) are listed under a `###` heading with a note on where their changes went. The update notice reads only `##` headings, so it skips them.

## 2.8.1 β€” 2026-11-12

A read-only command is no longer blocked as a clock change when another command on the same line has a `-s` flag, as in `curl -s … ; date -u`; only the arguments of `date` itself are checked.

## 2.8.0 β€” 2026-10-02

The update notice is now short at session start and says in one sentence what each pending version adds. Ask Claude how to update for the full steps, or for the details of the changes with links to the pull requests.
Expand Down
2 changes: 1 addition & 1 deletion global-settings/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.8.0
2.8.1
17 changes: 16 additions & 1 deletion global-settings/block-write-commands.sh
Original file line number Diff line number Diff line change
Expand Up @@ -584,8 +584,23 @@ if echo "$cmd" | grep -qE '(^|[;&|]\s*)env\b'; then
fi

# ── date (HARD BLOCK: modifying system time β€” no legitimate use case) ─────────
# Only the arguments of a `date` invocation are inspected, so another command's
# `-s` (as in `curl -s x; date -u`) is not mistaken for `date -s`. The segment
# ends at a real separator only: `;`, `&&`, `||`, `|`, `|&`, a lone `&` or a
# newline. It does NOT end at a quoted string, an escaped character (`\;`, `\"`),
# or a redirection operator (`2>&1`, `&>`, `>|`, `<&`); a quote that is never
# closed runs to the end of the line (fail closed). The two sed steps below
# blank out escapes and redirections so the segment grep only sees real separators.
if echo "$cmd" | grep -qE '(^|[;&|]\s*)date\b'; then
if echo "$cmd" | grep -qE '(^|\s)(-s\s|--set[[:space:]=])'; then
_q="'"; _dq='"'
_norm=$(echo "$cmd" | sed -E -e 's/\\./xx/g' -e 's/[0-9]*(>&|<&|&>>|&>|>\|)/RR/g')
_date_segments=$(echo "$_norm" | grep -oE "(^|[;&|][[:space:]]*)date\b([^;&|${_dq}${_q}]|${_dq}[^${_dq}]*${_dq}|${_q}[^${_q}]*${_q}|${_dq}[^${_dq}]*\$|${_q}[^${_q}]*\$)*")
# A command or process substitution can hold its own `;` or `|`, which the
# segment grep cannot follow: with one on the line, the whole line counts.
if echo "$cmd" | grep -qE '\$\(|`|[<>]\('; then
_date_segments="$_norm"
fi
if echo "$_date_segments" | grep -qE '(^|\s)(-s\s|--set[[:space:]=])'; then
hard_deny "Blocked: date -s / --set modifies the system clock. This is never allowed."
fi
fi
Expand Down
39 changes: 39 additions & 0 deletions global-settings/tests/test-block-write-commands.sh
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,45 @@ done
add_ask "order v2.7.3: two asks" "rm build.log && npm install"
add_ask "order v2.7.3: three asks" "gh pr create --title t --body b; docker compose up -d && echo x > out.txt"

# ── date -s: only the arguments of `date` itself count ────────────────────────
# Another command's `-s` / `--set` on the same line (curl -s, sort -s, grep -s)
# is not a clock change. Every real `date -s` / `--set` form stays hard-denied.
add_allow "date: plain" "date"
add_allow "date: -u +%s" "date -u +%s"
add_allow "date: +%F" "date +%F"
add_allow "date: curl -s before it" "curl -s x; date -u"
add_allow "date: curl -s -o, date, docker exec tail" "curl -s -o /dev/null http://x/; date -u +%FT%T; docker exec c sh -c 'tail -n 4 f'"
add_allow "date: grep -s after it" "date -u; grep -s x f"
add_allow "date: sort -s after a pipe" "ls | sort -s"
add_allow "date: piped into a -s command" "date -u | sort -s"
add_allow "date: quoted ; in -d is not the end" "date -d 'a;b' +%s"
add_deny "date: -s quoted value" 'date -s "2020-01-01"'
add_deny "date: --set=" 'date --set="2020-01-01"'
add_deny "date: --set <value>" "date --set 2020-01-01"
add_deny "date: -u -s" "date -u -s 2020-01-01"
add_deny "date: after ;" "foo; date -s x"
add_deny "date: after &&" "true && date -s x"
add_deny "date: after a pipe" "echo x | date -s x"
add_deny "date: after a harmless date" "date -u; date -s x"
add_deny "date: after curl -s" "curl -s x; date -s x"
add_deny "date: -s behind a quoted ;" "date -d 'a;b' -s now"
# A redirection, an escape or an open quote does not end the inspected segment.
add_allow "date: redirection then ; then curl -s" "date -u 2>/dev/null; curl -s x"
add_allow "date: 2>&1 piped into sort -s" "date -u 2>&1 | sort -s"
add_deny "date: -s behind 2>&1" "date -u 2>&1 -s 2020-01-01"
add_deny "date: -s behind &>" "date -u &>/dev/null -s 2020-01-01"
add_deny "date: -s behind >|" 'date >|/tmp/x -s 2020-01-01'
add_deny "date: -s behind an escaped ;" 'date +a\;b -s 2020-01-01'
add_deny "date: -s behind an escaped \"" 'date +\" -s 2020-01-01'
add_deny "date: -s behind an escaped '" "date +\\' -s 2020-01-01"
add_deny "date: -s inside an unclosed quote" 'date -d "a -s now'
# A substitution can hold its own separator; with one on the line the whole line counts.
add_deny "date: -s behind a \$( ; ) substitution" 'date $(echo +%F; true) -s 2020-01-01'
add_deny "date: -s behind a backtick substitution" 'date `echo +%F; true` -s 2020-01-01'
add_deny "date: -s behind a \$( | ) substitution" 'date $(echo a | cat) -s 2020-01-01'
add_deny "date: -s behind a process substitution" 'date <(echo a; echo b) -s 2020-01-01'
add_allow "date: substitution on the line, no -s" 'date -d "$(echo now)" +%s; curl x'

# ── v2.7.3 git push: `push` must end the word ─────────────────────────────────
add_allow "push v2.7.3: git push-notes is another command" "git push-notes"
add_allow "push v2.7.3: -C repo push-notes (asks, no deny)" "git -C repo push-notes"
Expand Down
Loading