서명 된 git 커밋 확인 중?
최신 버전 git
에서는 PGP 키로 개별 커밋 (태그 외에도)에 서명 할 수 있습니다.
git commit -m "some message" -S
다음 옵션 을 git log
사용하여 의 출력에 이러한 서명을 표시 할 수 있습니다 --show-signature
.
$ git log --show-signature
commit 93bd0a7529ef347f8dbca7efde43f7e99ab89515
gpg: Signature made Fri 28 Jun 2013 02:28:41 PM EDT using RSA key ID AC1964A8
gpg: Good signature from "Lars Kellogg-Stedman <lars@seas.harvard.edu>"
Author: Lars Kellogg-Stedman <lars@seas.harvard.edu>
Date: Fri Jun 28 14:28:41 2013 -0400
this is a test
그러나 주어진 커밋에서 서명을 프로그래밍 방식으로 확인하는 방법이 git log
있습니까? git tag -v
주어진 커밋에 유효한 서명이 있는지 여부를 나타내는 종료 코드를 제공하는 커밋에 해당하는 것을 찾고 있습니다.
내가했던 것처럼 이런 경우에 누군가가 검색 엔진을 통해 해당 페이지로 온다 : 질문이 게시 된 이후 새로운 도구가 2 년 만에 가능하게되었습니다이이 작업에 대한 자식 명령은 지금 : git verify-commit
및 git verify-tag
커밋을 확인하는 데 사용할 수 있으며, 태그.
참고 : 최대 2.5 이눔 아,하기 git verify-commit
와 git verify-tag
만 사람이 읽을 수있는 메시지가 표시됩니다.
검사를 자동화하려면 git 2.6+ (2015 년 3 분기)가 다른 출력을 추가합니다.
참조 e18443e 커밋 , aeff29d 커밋 , ca194d5 커밋 , 434060e을 커밋 , 8e98e5f 커밋 , a4cc18f 커밋 , d66aeff 커밋 에 의해 (2015년 6월 21일를) 브라이언 m. 칼슨 ( bk2204
) .
(Merged by Junio C gitster
Hamano -- in commit ba12cb2 , 03 Aug 2015)
verify-tag
/verify-commit
: 원시 gpg 상태 정보를 인쇄하는 옵션 추가
verify-tag
/verify-commit
는 기본적으로 표준 오류에 대해 사람이 읽을 수있는 출력을 표시합니다.
그러나 컴퓨터에서 읽을 수있는 원시 gpg 상태 정보에 액세스하여 서명 정책의 자동화 된 구현을 허용하는 것도 유용 할 수 있습니다 .사람이 읽을 수있는 형식 대신 표준 오류에 대한 gpg 상태 정보를 생성 하는
--raw
옵션 을 추가verify-tag
합니다.
을 더한:
verify-tag
서명은 양호하지만 키를 신뢰할 수없는 경우 성공적으로 종료됩니다.verify-commit
성공적으로 종료됩니다.
이러한 행동의 차이는 예상치 못한 원치 않는 것입니다. 이전에 존재
했기 때문에 share 의 동작verify-tag
을 갖도록 실패한 테스트를 추가하십시오 .verify-commit
verify-tag
git 2.9 (2016 년 6 월) git merge doc 업데이트 :
Keller Fuchs (``)의 commit 05a5869 (2016 년 5 월 13 일)를 참조하십시오 . 도움 : Junio C Hamano ( ) . (Merged by Junio C Hamano -- in commit be6ec17 , 17 May 2016)gitster
gitster
--verify-signatures:
--no-verify-signatures:
병합되는 사이드 브랜치의 팁 커밋이 유효한 키, 즉 유효한 uid가있는
키로 서명되었는지 확인합니다. 기본 신뢰 모델에서 이는 서명 키가 신뢰할 수있는 키에 의해 서명되었음을 의미합니다. 사이드 브랜치의 팁 커밋이 유효한 키로 서명되지 않은 경우 병합이 중단 됩니다.
Git 2.10 업데이트 (2016 년 3 분기)
Linus Torvalds ( )의 commit b624a3e (2016 년 8 월 16 일)를 참조하십시오 . (가 합병 - Junio C 하마노 - 에 83d9eb0 커밋 2016 19 팔월)torvalds
gitster
gpg-interface
: pgp 서명을 확인할 때 "긴"키 형식 출력 선호"
git log --show-signature
"및 PGP 서명의 확인 상태를 표시하는 기타 명령은 이제 32 비트 키 ID가 지난 세기이므로 더 긴 키 ID를 표시합니다.Linus의 원본은 과거에 갇혀 있던 바이너리 배포자가 이전 코드베이스로 가져 가고자하는 경우를 대비하여 유지 관리 트랙에 적용되도록 리베이스되었습니다.
Git 2.11+ (2016 년 4 분기)는 훨씬 더 정확할 것입니다.
Michael J Gruber ( )의 commit 661a180 (2016 년 10 월 12 일)을 참조하십시오 . (의해 병합 - Junio C 하마노 - 에 56d268b 커밋 2,016 26 10 월)mjg
gitster
"
%G?
"프리티 형식 지정자에 표시된 GPG 확인 상태 는 만료 된 키로 만든 서명, 해지 된 키로 만든 서명 등을 구분할만큼 풍부하지
않았습니다 . 이를 표현하기 위해 새 출력 문자가 할당되었습니다 .gpg2
doc/DETAILS
에 따르면 :각 서명 코드의 하나를 들어
GOODSIG
,BADSIG
,EXPSIG
,EXPKEYSIG
,REVKEYSIG
또는ERRSIG
배출된다.
이제 git pretty-format
문서 에는 다음이 포함됩니다.
- '
%G?
': 표시
- "
G
"(유효한) 서명의 경우- "
B
"은 (는) 잘못된 서명입니다.- "
U
"의 유효성을 알 수없는 양호한 서명의 경우- "
X
" for a good signature that has expired,- "
Y
" for a good signature made by an expired key,- "
R
" for a good signature made by a revoked key,- "
E
" if the signature cannot be checked (e.g. missing key) and "N" for no signature
Git 2.12 (Q1 2017) "git tag
" and "git verify-tag
" learned to put GPG verification status in their "--format=<placeholders>
" output format.
See commit 4fea72f, commit 02c5433, commit ff3c8c8 (17 Jan 2017) by Santiago Torres (SantiagoTorres
).
See commit 07d347c, commit 2111aa7, commit 94240b9 (17 Jan 2017) by Lukas Puehringer (``).
(Merged by Junio C Hamano -- gitster
-- in commit 237bdd9, 31 Jan 2017)
Adding
--format
togit tag -v
mutes the default output of the GPG verification and instead prints the formatted tag object.
This allows callers to cross-check the tagname from refs/tags with the tagname from the tag object header upon GPG verification.
Git 2.16 (Q1 2018) will allow the commit signature verification to be even more automated, with the merge.verifySignatures
configuration variable.
See commit 7f8ca20, commit ca779e8 (10 Dec 2017) by Hans Jerry Illikainen (``).
(Merged by Junio C Hamano -- gitster
-- in commit 0433d53, 28 Dec 2017)
merge
: add config option forverifySignatures
git merge --verify-signatures
can be used to verify that the tip commit of the branch being merged in is properly signed, but it's cumbersome to have to specify that every time.Add a configuration option that enables this behaviour by default, which can be overridden by
--no-verify-signatures
.
The git merge
config man page now reads:
merge.verifySignatures:
If true, this is equivalent to the
--verify-signatures
command line option.
Git 2.19 (Q3 2018) is even more helpful, since "git verify-tag
" and "git verify-commit
" have been taught to use the exit status of underlying "gpg --verify
" to signal bad or untrusted signature they found.
See commit 4e5dc9c (09 Aug 2018) by Junio C Hamano (gitster
).
Helped-by: Vojtech Myslivec (VojtechMyslivec
), brian m. carlson (bk2204
), and Jeff King (peff
).
(Merged by Junio C Hamano -- gitster
-- in commit 4d34122, 20 Aug 2018)
gpg-interface
: propagate exit status fromgpg
back to the callersWhen gpg-interface API unified support for signature verification codepaths for signed tags and signed commits in mid 2015 at around v2.6.0-rc0~114, we accidentally loosened the GPG signature verification.
Before that change, signed commits were verified by looking for "
G
"ood signature from GPG, while ignoring the exit status of "gpg --verify
" process, while signed tags were verified by simply passing the exit status of"gpg --verify
" through.The unified code we currently have ignores the exit status of "
gpg --verify
" and returns successful verification when the signature matches an unexpired key regardless of the trust placed on the key (i.e. in addition to "G
"ood ones, we accept "U
"ntrusted ones).Make these commands signal failure with their exit status when underlying "
gpg --verify
" (or the custom command specified by "gpg.program
" configuration variable) does so.
This essentially changes their behaviour in a backward incompatible way to reject signatures that have been made with untrusted keys even if they correctly verify, as that is how "gpg --verify
" behaves.Note that the code still overrides a zero exit status obtained from "
gpg
" (orgpg.program
) if the output does not say the signature is good or computes correctly but made with untrusted keys, to catch a poorly written wrapper around "gpg
" the user may give us.We could exclude "
U
"ntrusted support from this fallback code, but that would be making two backward incompatible changes in a single commit, so let's avoid that for now.
A follow-up change could do so if desired.
A cursory inspection of the code suggests that there is no such direct method.
All of the tests in the git source rely on grep
ping the output of git show
(see t/t7510-signed-commit.sh for the tests).
You can customize the output using something like --pretty "%H %G?%"
to make it easy to parse.
It appears you can ask git merge
to verify a signature but again, its tests rely on grep
(see t/t7612-merge-verify-signatures.sh). It does look like an invalid signature will cause git merge
to exit with a bad signature, so you could potentially today hack around this by doing a test merge somewhere and throwing out that merge but that seems worse than just calling grep.
참고URL : https://stackoverflow.com/questions/17371955/verifying-signed-git-commits
'Nice programing' 카테고리의 다른 글
C 컴파일 오류 : "변수 크기의 개체를 초기화 할 수 없습니다." (0) | 2020.10.05 |
---|---|
git 로그 그래프 읽는 방법 (0) | 2020.10.05 |
spec / rails_helper.rb는 spec / spec_helper.rb와 어떻게 다릅니 까? (0) | 2020.10.05 |
C # 메서드 명명 규칙 : ToSomething 대 AsSomething (0) | 2020.10.05 |
이름이 같은 여러 쿠키를 처리하는 방법은 무엇입니까? (0) | 2020.10.05 |