gitlab から commit や秘匿情報が入ったファイルを削除する
GitHub だと https://engineering.mercari.com/blog/entry/20211207-removing-sensitive-data-from-github/ にあるようにサポートケースから対応する必要があるが、GitLab の場合、blobs の削除や commit sha のリンク自体を消すのは Settings > Repository > Repository maintenance から blobs の削除や text 置換、commit-map による履歴の更新や git gc を Repo Admin が実施することができる
https://docs.gitlab.com/user/project/repository/repository_size/#clean-up-repository
https://docs.gitlab.com/user/project/repository/repository_size/#remove-blobs
つまり、git-filter-repo や bfg 相当の処理を UI 上から実施ができるということ
main branch 等の永続ブランチの履歴の中に秘匿情報が入った場合、blobs の特定→ Remove Blobs から削除を実行することで git-filter-repo と同様関連するすべての commit sha の更新及び該当データの削除が行われる。
blobs の削除後に housekeeping タスクを実行することで、履歴改変後の orphan commit は unreachable objects となるため、これらの削除が git gc として実行される。
また、git-filter-repo 等で作成される commit-map も対応している。
開発している一時ブランチで秘匿情報が混ざった commit をしてしまった場合、 commit-map を利用してこの commit 自体を削除する事もできる
code::commit-map
0123456789abcdef.... 0000000000000000...
0 40 個の commit sha を指定することで、この commit を削除するという扱いになる
commit-map による cleanup の際に git gc --prune=30.minutes.ago が実行されるため、この commit が 30 分経過していれば blobs 含めて削除が行われる。prune=now にする方法は prune unreachable objects による実行が確実で、これも Settings > General > Advanced > Housekeeping から実行が可能。
通常の housekeeping の実行だと 2w の猶予期間が設けられる
Unreachable objects are pruned as part of scheduled housekeeping. However, you can trigger manual pruning as well. Triggering housekeeping prunes unreachable objects with a grace period of two weeks. When you manually trigger the pruning of unreachable objects, the grace period is reduced to 30 minutes.
cleanup を secrets の削除に利用するなと記載があるが開発中の一時ブランチかつ orphan commit のみに秘匿情報があるのならば git gc で unreachable が消えるので問題ないと思うのだがどうなのだろうか。やってることは blobs 削除→housekeeping(git gc) と同じに見えるが
Use this method to remove internal Git references and unreferenced objects from your repository. Do not use this method to remove sensitive data. To remove sensitive data, use the remove blobs method.
また、これらの対応を実施したら、ローカルの環境は再度 Clone しておくことで再度 Push されることは防がれる