mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-11-22 05:49:23 +08:00
* Stop forced pushes and file reads through the git allow rules Tag mode lets Claude run its push wrapper and git commit without asking, and both accepted more than a normal commit and push. - The push wrapper rejects a ref starting with +, which git treats as a forced update. - A new commit wrapper replaces the git commit allow rule. It accepts only a literal message and basic flags, so no flag can read a file into a commit. Co-authored-by: mhegazy <[email protected]> * Keep deny rules working with the git wrappers Deny rules match command text, so denying git commit or git push no longer blocked the wrappers that run them. The commit wrapper also stops offering to rewrite a commit, because a pushed one could not be published again. Co-authored-by: mhegazy <[email protected]> * Read deny rules the same way the CLI receives them Unquoted rules, the equals form and mid-word wildcards all reached the CLI but were missed when carrying deny rules over to the git wrappers, so those workflows could still commit and push. Co-authored-by: mhegazy <[email protected]> * Only let the push wrapper update the session's own branch (#2008) * Only let the push wrapper update the session's own branch The wrapper accepted any valid branch name, so a prompt-injected session could update main or another person's branch once it moved that branch locally. It now pushes only to the branch the run was set up on. Co-authored-by: mhegazy <[email protected]> * Repair the tag mode tests after merging The merge left the test file's two new test groups interleaved, so it did not parse. Co-authored-by: mhegazy <[email protected]> --------- Co-authored-by: Claude <[email protected]> * Note the pr-N branch for fork pull requests in the push docs On a pull request from a fork, the session's branch is pr-N in the base repository, not the pull request's own branch. A pull request opened from the default branch can also update that branch, so branch protection still matters. --------- Co-authored-by: Claude <[email protected]>
54 lines
1.2 KiB
Bash
Executable File
54 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Wrapper around `git commit` that only allows a literal message. Without it, an
|
|
# allow rule for `git commit` also permits flags that make git read a file into
|
|
# the commit, such as -F .git/config, which a later push would then publish.
|
|
#
|
|
# Usage:
|
|
# git-commit.sh -m "<message>" [-m "<message>"] [-a] [--allow-empty] [-- <paths>]
|
|
|
|
has_message=false
|
|
expect_message=false
|
|
paths_only=false
|
|
|
|
for arg in "$@"; do
|
|
if [[ "$expect_message" == true ]]; then
|
|
expect_message=false
|
|
has_message=true
|
|
continue
|
|
fi
|
|
if [[ "$paths_only" == true ]]; then
|
|
continue
|
|
fi
|
|
case "$arg" in
|
|
-m | --message | -am)
|
|
expect_message=true
|
|
;;
|
|
--message=*)
|
|
has_message=true
|
|
;;
|
|
-a | --all | --allow-empty | -q | --quiet | -s | --signoff)
|
|
;;
|
|
--)
|
|
paths_only=true
|
|
;;
|
|
-*)
|
|
echo "Error: only -m with a literal message and basic commit flags are allowed (got: $arg)" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if [[ "$expect_message" == true ]]; then
|
|
echo "Error: -m needs a message" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ "$has_message" != true ]]; then
|
|
echo "Error: a message is required, with -m" >&2
|
|
exit 1
|
|
fi
|
|
|
|
exec git commit "$@"
|