From d9cb3583f593936752279c35031323ceae64b99b Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Sun, 20 Oct 2019 22:03:42 +0100 Subject: [PATCH 1/3] Ensure defaultGPGSettings not nil --- models/gpg_key.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/gpg_key.go b/models/gpg_key.go index 9b690475bd52a..9caaa8f95fe9a 100644 --- a/models/gpg_key.go +++ b/models/gpg_key.go @@ -682,7 +682,7 @@ func ParseCommitWithSignature(c *git.Commit) *CommitVerification { defaultGPGSettings, err := c.GetRepositoryDefaultPublicGPGKey(false) if err != nil { log.Error("Error getting default public gpg key: %v", err) - } else if defaultGPGSettings.Sign { + } else if defaultGPGSettings != nil && defaultGPGSettings.Sign { if commitVerification := verifyWithGPGSettings(defaultGPGSettings, sig, c.Signature.Payload, committer, keyID); commitVerification != nil { if commitVerification.Reason == BadSignature { defaultReason = BadSignature From 9f2e8e6a58e4c1872016f7a17f43fb76ec7bd030 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Sun, 20 Oct 2019 22:12:10 +0100 Subject: [PATCH 2/3] Ensure that coerced commits gain a reference to the repo --- modules/git/commit_info.go | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/git/commit_info.go b/modules/git/commit_info.go index d8bf88a47cd43..e74ddbfb053fa 100644 --- a/modules/git/commit_info.go +++ b/modules/git/commit_info.go @@ -72,6 +72,7 @@ func (tes Entries) GetCommitsInfo(commit *Commit, treePath string, cache LastCom treeCommit = commit } else if rev, ok := revs[""]; ok { treeCommit = convertCommit(rev) + treeCommit.repo = commit.repo } return commitsInfo, treeCommit, nil } From 068d6f17c780f514f63fb0a0bc291d8760e8d89d Mon Sep 17 00:00:00 2001 From: zeripath Date: Sun, 20 Oct 2019 22:48:30 +0100 Subject: [PATCH 3/3] Add warning if trying to get defaultgpgsetting on an unattached commit --- models/gpg_key.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/models/gpg_key.go b/models/gpg_key.go index 9caaa8f95fe9a..58eaa61e223e1 100644 --- a/models/gpg_key.go +++ b/models/gpg_key.go @@ -682,7 +682,9 @@ func ParseCommitWithSignature(c *git.Commit) *CommitVerification { defaultGPGSettings, err := c.GetRepositoryDefaultPublicGPGKey(false) if err != nil { log.Error("Error getting default public gpg key: %v", err) - } else if defaultGPGSettings != nil && defaultGPGSettings.Sign { + } else if defaultGPGSettings == nil { + log.Warn("Unable to get defaultGPGSettings for unattached commit: %s", c.ID.String()) + } else if defaultGPGSettings.Sign { if commitVerification := verifyWithGPGSettings(defaultGPGSettings, sig, c.Signature.Payload, committer, keyID); commitVerification != nil { if commitVerification.Reason == BadSignature { defaultReason = BadSignature