Skip to content

Commit ac0bb2c

Browse files
authored
Fix unsafe repository error (#65)
Mark the repository as safe. It should be ok to do so in the action context because the vulnerability affects "multi-user shared machines" and this is a single-user Docker image. Details of why this is needed CVE-2022-24765: https://github.blog/2022-04-12-git-security-vulnerability-announced/ I will keep monitoring if there could be any problems and get in touch in you have more information.
1 parent 483689a commit ac0bb2c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM alpine:latest
22

3-
RUN apk add --no-cache git
3+
RUN apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main git
44

55
COPY entrypoint.sh /entrypoint.sh
66

entrypoint.sh

+8
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ fi
2828

2929
CLONE_DIR=$(mktemp -d)
3030

31+
echo "[+] Git version"
32+
git --version
33+
3134
echo "[+] Cloning destination git repository $DESTINATION_REPOSITORY_NAME"
3235
# Setup git
3336
git config --global user.email "$USER_EMAIL"
@@ -97,6 +100,11 @@ ORIGIN_COMMIT="https://$GITHUB_SERVER/$GITHUB_REPOSITORY/commit/$GITHUB_SHA"
97100
COMMIT_MESSAGE="${COMMIT_MESSAGE/ORIGIN_COMMIT/$ORIGIN_COMMIT}"
98101
COMMIT_MESSAGE="${COMMIT_MESSAGE/\$GITHUB_REF/$GITHUB_REF}"
99102

103+
echo "[+] Set directory is safe ($CLONE_DIR)"
104+
# Related to https://github.com/cpina/github-action-push-to-another-repository/issues/64 and https://github.com/cpina/github-action-push-to-another-repository/issues/64
105+
# TODO: review before releasing it as a version
106+
git config --global --add safe.directory "$CLONE_DIR"
107+
100108
echo "[+] Adding git commit"
101109
git add .
102110

0 commit comments

Comments
 (0)