Skip to content

Commit 99171e5

Browse files
authored
Merge pull request #449 from github/enterprise-3.8-backport-443-kyfast-create-current-encryption-key-backup-3.7.0+
Backport 443 for 3.8: Kyfast create current encryption key backup 3.7.0+
2 parents c216f2f + dd16a26 commit 99171e5

File tree

2 files changed

+67
-16
lines changed

2 files changed

+67
-16
lines changed

share/github-backup-utils/ghe-backup-settings

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ backup-secret "password pepper" "password-pepper" "secrets.github.user-password-
7979
backup-secret "kredz.credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hmac-secret"
8080
backup-secret "kredz.varz HMAC key" "kredz-varz-hmac" "secrets.kredz.varz-hmac-secret"
8181

82-
# backup encryption keying material for GHES 3.7.0 onwards
82+
# backup encryption keying material and create backup value current encryption for GHES 3.7.0 onwards
83+
# this is for forwards compatibility with GHES 3.8.0 onwards
8384
if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.7.0)" ]; then
8485
backup-secret "encrypted column encryption keying material" "encrypted-column-encryption-keying-material" "secrets.github.encrypted-column-keying-material"
8586
fi
8687

87-
# backup current encryption key for GHES 3.8.0 onwards
8888
if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" ]; then
89-
backup-secret "encrypted column current encryption key" "encrypted-column-current-encryption-key" "secrets.github.encrypted-column-current-encryption-key"
89+
cat "$GHE_SNAPSHOT_DIR/encrypted-column-encryption-keying-material" | sed 's:.*;::' > "$GHE_SNAPSHOT_DIR/encrypted-column-current-encryption-key"
9090
fi
9191

9292
# Backup argon secrets for multiuser from ghes version 3.8 onwards

test/test-ghe-backup.sh

Lines changed: 64 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ begin_test "ghe-backup does not take backup of encrypted column encryption keyin
554554
)
555555
end_test
556556

557-
begin_test "ghe-backup takes backup of encrypted column encryption keying material for versions 3.7.0+"
557+
begin_test "ghe-backup takes backup of encrypted column encryption keying material and create encrypted column current encryption key for versions 3.7.0+"
558558
(
559559
set -e
560560

@@ -597,27 +597,61 @@ begin_test "ghe-backup takes backup of encrypted column encryption keying materi
597597
)
598598
end_test
599599

600-
begin_test "ghe-backup does not take backup of encrypted column current encryption key for versions below 3.8.0"
600+
begin_test "ghe-backup takes backup of encrypted column encryption keying material and encrypted column current encryption key for versions 3.8.0+"
601601
(
602-
GHE_REMOTE_VERSION=2.1.10 ghe-backup -v | grep -q "encrypted column current encryption key not set" && exit 1
603-
[ ! -f "$GHE_DATA_DIR/current/encrypted-column-current-encryption-key" ]
602+
set -e
603+
604+
required_secrets=(
605+
"secrets.github.encrypted-column-keying-material"
606+
)
607+
608+
for secret in "${required_secrets[@]}"; do
609+
ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret" "foo"
610+
done
611+
612+
# GHES version 3.8.0
613+
GHE_REMOTE_VERSION=3.8.0
614+
export GHE_REMOTE_VERSION
615+
616+
ghe-backup
617+
618+
required_files=(
619+
"encrypted-column-encryption-keying-material"
620+
"encrypted-column-current-encryption-key"
621+
)
622+
623+
for file in "${required_files[@]}"; do
624+
[ "$(cat "$GHE_DATA_DIR/current/$file")" = "foo" ]
625+
done
626+
627+
# GHES version 3.9.0
628+
GHE_REMOTE_VERSION=3.9.0
629+
export GHE_REMOTE_VERSION
604630

605-
GHE_REMOTE_VERSION=3.7.0 ghe-backup -v | grep -q "encrypted column current encryption key not set" && exit 1
606-
[ ! -f "$GHE_DATA_DIR/current/encrypted-column-current-encryption-key" ]
631+
ghe-backup
632+
633+
required_files=(
634+
"encrypted-column-current-encryption-key"
635+
)
636+
637+
for file in "${required_files[@]}"; do
638+
[ "$(cat "$GHE_DATA_DIR/current/$file")" = "foo" ]
639+
done
607640

608641
)
609642
end_test
610643

611-
begin_test "ghe-backup takes backup of encrypted column current encryption key for versions 3.8.0+"
644+
begin_test "ghe-backup takes backup of encrypted column encryption keying material and encrypted column current encryption key accounting for multiple encryption keying materials for versions 3.7.0+"
612645
(
613646
set -e
614647

615648
required_secrets=(
616-
"secrets.github.encrypted-column-current-encryption-key"
649+
"secrets.github.encrypted-column-keying-material"
617650
)
618651

619652
for secret in "${required_secrets[@]}"; do
620-
ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret" "foo"
653+
echo "ghe-config '$secret' 'foo;bar'" |
654+
ghe-ssh "$GHE_HOSTNAME" -- /bin/bash
621655
done
622656

623657
# GHES version 3.8.0
@@ -627,25 +661,42 @@ begin_test "ghe-backup takes backup of encrypted column current encryption key f
627661
ghe-backup
628662

629663
required_files=(
630-
"encrypted-column-current-encryption-key"
664+
"encrypted-column-encryption-keying-material"
631665
)
632666

633667
for file in "${required_files[@]}"; do
634-
[ "$(cat "$GHE_DATA_DIR/current/$file")" = "foo" ]
668+
[ "$(cat "$GHE_DATA_DIR/current/$file")" = "foo;bar" ]
635669
done
636670

671+
required_files_current_encryption_key=(
672+
"encrypted-column-current-encryption-key"
673+
)
674+
675+
for file in "${required_files_current_encryption_key[@]}"; do
676+
[ "$(cat "$GHE_DATA_DIR/current/$file")" = "bar" ]
677+
done
678+
679+
637680
# GHES version 3.9.0
638681
GHE_REMOTE_VERSION=3.9.0
639682
export GHE_REMOTE_VERSION
640683

641684
ghe-backup
642685

643686
required_files=(
644-
"encrypted-column-current-encryption-key"
687+
"encrypted-column-encryption-keying-material"
645688
)
646689

647690
for file in "${required_files[@]}"; do
648-
[ "$(cat "$GHE_DATA_DIR/current/$file")" = "foo" ]
691+
[ "$(cat "$GHE_DATA_DIR/current/$file")" = "foo;bar" ]
692+
done
693+
694+
required_files_current_encryption_key=(
695+
"encrypted-column-current-encryption-key"
696+
)
697+
698+
for file in "${required_files_current_encryption_key[@]}"; do
699+
[ "$(cat "$GHE_DATA_DIR/current/$file")" = "bar" ]
649700
done
650701

651702
)

0 commit comments

Comments
 (0)