Skip to content

Commit 1905d60

Browse files
authored
Merge branch 'main' into main
2 parents 671b457 + ff2fd08 commit 1905d60

File tree

304 files changed

+19088
-16055
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

304 files changed

+19088
-16055
lines changed

.drone.yml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -783,9 +783,6 @@ steps:
783783
from_secret: docker_password
784784
username:
785785
from_secret: docker_username
786-
environment:
787-
PLUGIN_MIRROR:
788-
from_secret: plugin_mirror
789786
when:
790787
event:
791788
exclude:
@@ -848,9 +845,6 @@ steps:
848845
from_secret: docker_password
849846
username:
850847
from_secret: docker_username
851-
environment:
852-
PLUGIN_MIRROR:
853-
from_secret: plugin_mirror
854848
when:
855849
event:
856850
exclude:
@@ -928,9 +922,6 @@ steps:
928922
from_secret: docker_password
929923
username:
930924
from_secret: docker_username
931-
environment:
932-
PLUGIN_MIRROR:
933-
from_secret: plugin_mirror
934925
when:
935926
event:
936927
exclude:
@@ -949,9 +940,6 @@ steps:
949940
from_secret: docker_password
950941
username:
951942
from_secret: docker_username
952-
environment:
953-
PLUGIN_MIRROR:
954-
from_secret: plugin_mirror
955943
when:
956944
event:
957945
exclude:
@@ -996,9 +984,6 @@ steps:
996984
from_secret: docker_password
997985
username:
998986
from_secret: docker_username
999-
environment:
1000-
PLUGIN_MIRROR:
1001-
from_secret: plugin_mirror
1002987
when:
1003988
event:
1004989
exclude:
@@ -1017,9 +1002,6 @@ steps:
10171002
from_secret: docker_password
10181003
username:
10191004
from_secret: docker_username
1020-
environment:
1021-
PLUGIN_MIRROR:
1022-
from_secret: plugin_mirror
10231005
when:
10241006
event:
10251007
exclude:

cmd/dump.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"github.com/urfave/cli"
2626
)
2727

28-
func addFile(w archiver.Writer, filePath string, absPath string, verbose bool) error {
28+
func addFile(w archiver.Writer, filePath, absPath string, verbose bool) error {
2929
if verbose {
3030
log.Info("Adding file %s\n", filePath)
3131
}
@@ -48,7 +48,7 @@ func addFile(w archiver.Writer, filePath string, absPath string, verbose bool) e
4848
})
4949
}
5050

51-
func isSubdir(upper string, lower string) (bool, error) {
51+
func isSubdir(upper, lower string) (bool, error) {
5252
if relPath, err := filepath.Rel(upper, lower); err != nil {
5353
return false, err
5454
} else if relPath == "." || !strings.HasPrefix(relPath, ".") {

docs/content/doc/usage/issue-pull-request-templates.en-us.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Inside the directory can be multiple issue templates with the form
6969
name: "Template Name"
7070
about: "This template is for testing!"
7171
title: "[TEST] "
72+
ref: "main"
7273
labels:
7374

7475
- bug
@@ -82,4 +83,4 @@ This is the template!
8283
In the above example, when a user is presented with the list of issues they can submit, this would show as `Template Name` with the description
8384
`This template is for testing!`. When submitting an issue with the above example, the issue title would be pre-populated with
8485
`[TEST] ` while the issue body would be pre-populated with `This is the template!`. The issue would also be assigned two labels,
85-
`bug` and `help needed`.
86+
`bug` and `help needed`, and the issue will have a reference to `main`.

go.mod

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ require (
1111
gitea.com/go-chi/captcha v0.0.0-20211013065431-70641c1a35d5
1212
gitea.com/go-chi/session v0.0.0-20211013065435-7d334f340c09
1313
gitea.com/lunny/levelqueue v0.4.1
14+
github.com/42wim/sshsig v0.0.0-20211121163825-841cf5bbc121
1415
github.com/Microsoft/go-winio v0.5.0 // indirect
1516
github.com/NYTimes/gziphandler v1.1.1
1617
github.com/ProtonMail/go-crypto v0.0.0-20210705153151-cc34b1f6908b // indirect
1718
github.com/PuerkitoBio/goquery v1.7.0
1819
github.com/RoaringBitmap/roaring v0.9.1 // indirect
19-
github.com/alecthomas/chroma v0.9.2
20+
github.com/alecthomas/chroma v0.9.4
2021
github.com/andybalholm/brotli v1.0.3 // indirect
2122
github.com/andybalholm/cascadia v1.2.0 // indirect
2223
github.com/blevesearch/bleve/v2 v2.0.6
@@ -121,10 +122,10 @@ require (
121122
go.uber.org/atomic v1.9.0 // indirect
122123
go.uber.org/multierr v1.7.0 // indirect
123124
go.uber.org/zap v1.19.0 // indirect
124-
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5
125-
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d
125+
golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871
126+
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2
126127
golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914
127-
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf
128+
golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1
128129
golang.org/x/text v0.3.7
129130
golang.org/x/time v0.0.0-20210611083556-38a9dc6acbc6 // indirect
130131
golang.org/x/tools v0.1.0

go.sum

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ gitea.com/lunny/levelqueue v0.4.1 h1:RZ+AFx5gBsZuyqCvofhAkPQ9uaVDPJnsULoJZIYaJNw
5454
gitea.com/lunny/levelqueue v0.4.1/go.mod h1:HBqmLbz56JWpfEGG0prskAV97ATNRoj5LDmPicD22hU=
5555
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:lSA0F4e9A2NcQSqGqTOXqu2aRi/XEQxDCBwM8yJtE6s=
5656
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:EXuID2Zs0pAQhH8yz+DNjUbjppKQzKFAn28TMYPB6IU=
57+
github.com/42wim/sshsig v0.0.0-20211121163825-841cf5bbc121 h1:r3qt8PCHnfjOv9PN3H+XXKmDA1dfFMIN1AislhlA/ps=
58+
github.com/42wim/sshsig v0.0.0-20211121163825-841cf5bbc121/go.mod h1:Ock8XgA7pvULhIaHGAk/cDnRfNrF9Jey81nPcc403iU=
5759
github.com/6543/go-version v1.3.1 h1:HvOp+Telns7HWJ2Xo/05YXQSB2bE0WmVgbHqwMPZT4U=
5860
github.com/6543/go-version v1.3.1/go.mod h1:oqFAHCwtLVUTLdhQmVZWYvaHXTdsbB4SY85at64SQEo=
5961
github.com/Azure/go-ntlmssp v0.0.0-20200615164410-66371956d46c h1:/IBSNwUN8+eKzUzbJPqhK839ygXJ82sde8x3ogr6R28=
@@ -93,17 +95,14 @@ github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk
9395
github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4=
9496
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
9597
github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM=
96-
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U=
9798
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI=
9899
github.com/alecthomas/chroma v0.7.2-0.20200305040604-4f3623dce67a/go.mod h1:fv5SzZPFJbwp2NXJWpFIX7DZS4HgV1K4ew4Pc2OZD9s=
99100
github.com/alecthomas/chroma v0.8.2/go.mod h1:sko8vR34/90zvl5QdcUdvzL3J8NKjAUx9va9jPuFNoM=
100-
github.com/alecthomas/chroma v0.9.2 h1:yU1sE2+TZbLIQPMk30SolL2Hn53SR/Pv750f7qZ/XMs=
101-
github.com/alecthomas/chroma v0.9.2/go.mod h1:eMuEnpA18XbG/WhOWtCzJHS7WqEtDAI+HxdwoW0nVSk=
102-
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 h1:JHZL0hZKJ1VENNfmXvHbgYlbUOvpzYzvy2aZU5gXVeo=
101+
github.com/alecthomas/chroma v0.9.4 h1:YL7sOAE3p8HS96T9km7RgvmsZIctqbK1qJ0b7hzed44=
102+
github.com/alecthomas/chroma v0.9.4/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s=
103103
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0=
104104
github.com/alecthomas/kong v0.2.1-0.20190708041108-0548c6b1afae/go.mod h1:+inYUSluD+p4L8KdviBSgzcqEjUQOfC5fQDRFuc36lI=
105105
github.com/alecthomas/kong v0.2.4/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE=
106-
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 h1:p9Sln00KOTlrYkxI1zYWl1QLnEqAqEARBEYa8FQnQcY=
107106
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
108107
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
109108
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
@@ -250,7 +249,6 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsr
250249
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
251250
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
252251
github.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76/go.mod h1:vYwsqCOLxGiisLwp9rITslkFNpZD5rz43tf41QFkTWY=
253-
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ=
254252
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk=
255253
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
256254
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
@@ -1259,8 +1257,9 @@ golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm
12591257
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
12601258
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
12611259
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
1262-
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ=
12631260
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
1261+
golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871 h1:/pEO3GD/ABYAjuakUS6xSEmmlyVS4kxBNkeA9tLJiTI=
1262+
golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
12641263
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
12651264
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
12661265
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -1353,8 +1352,8 @@ golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5o
13531352
golang.org/x/net v0.0.0-20210331060903-cb1fcc7394e5/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
13541353
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
13551354
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
1356-
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d h1:LO7XpTYMwTqxjLcGWPijK3vRXg1aWdlNOVOHRq45d7c=
1357-
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
1355+
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE=
1356+
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
13581357
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
13591358
golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
13601359
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -1460,8 +1459,8 @@ golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea/go.mod h1:oPkhp1MJrh7nUepCBc
14601459
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
14611460
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
14621461
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1463-
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf h1:2ucpDCmfkl8Bd/FsLtiD653Wf96cW37s+iGx93zsu4k=
1464-
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1462+
golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1 h1:kwrAHlwJ0DUBZwQ238v+Uod/3eZ8B2K5rYsUHBQvzmI=
1463+
golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
14651464
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
14661465
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
14671466
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=

integrations/api_repo_tags_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func TestAPIRepoTags(t *testing.T) {
6868
session.MakeRequest(t, req, http.StatusNotFound)
6969
}
7070

71-
func createNewTagUsingAPI(t *testing.T, session *TestSession, token string, ownerName, repoName, name, target, msg string) *api.Tag {
71+
func createNewTagUsingAPI(t *testing.T, session *TestSession, token, ownerName, repoName, name, target, msg string) *api.Tag {
7272
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/tags?token=%s", ownerName, repoName, token)
7373
req := NewRequestWithJSON(t, "POST", urlStr, &api.CreateTagOption{
7474
TagName: name,

integrations/git_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ func doBranchProtectPRMerge(baseCtx *APITestContext, dstPath string) func(t *tes
418418
}
419419
}
420420

421-
func doProtectBranch(ctx APITestContext, branch string, userToWhitelist string, unprotectedFilePatterns string) func(t *testing.T) {
421+
func doProtectBranch(ctx APITestContext, branch, userToWhitelist, unprotectedFilePatterns string) func(t *testing.T) {
422422
// We are going to just use the owner to set the protection.
423423
return func(t *testing.T) {
424424
csrf := GetCSRF(t, ctx.Session, fmt.Sprintf("/%s/%s/settings/branches", url.PathEscape(ctx.Username), url.PathEscape(ctx.Reponame)))

integrations/issue_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ func testIssueWithBean(t *testing.T, user string, repoID int64, title, content s
310310
return issueURL, issue
311311
}
312312

313-
func testIssueChangeInfo(t *testing.T, user, issueURL, info string, value string) {
313+
func testIssueChangeInfo(t *testing.T, user, issueURL, info, value string) {
314314
session := loginUser(t, user)
315315

316316
req := NewRequest(t, "GET", issueURL)

integrations/pull_merge_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,11 @@ func TestCantMergeConflict(t *testing.T) {
241241
gitRepo, err := git.OpenRepository(repo_model.RepoPath(user1.Name, repo1.Name))
242242
assert.NoError(t, err)
243243

244-
err = pull.Merge(pr, user1, gitRepo, repo_model.MergeStyleMerge, "CONFLICT")
244+
err = pull.Merge(pr, user1, gitRepo, repo_model.MergeStyleMerge, "", "CONFLICT")
245245
assert.Error(t, err, "Merge should return an error due to conflict")
246246
assert.True(t, models.IsErrMergeConflicts(err), "Merge error is not a conflict error")
247247

248-
err = pull.Merge(pr, user1, gitRepo, repo_model.MergeStyleRebase, "CONFLICT")
248+
err = pull.Merge(pr, user1, gitRepo, repo_model.MergeStyleRebase, "", "CONFLICT")
249249
assert.Error(t, err, "Merge should return an error due to conflict")
250250
assert.True(t, models.IsErrRebaseConflicts(err), "Merge error is not a conflict error")
251251
gitRepo.Close()
@@ -329,7 +329,7 @@ func TestCantMergeUnrelated(t *testing.T) {
329329
BaseBranch: "base",
330330
}).(*models.PullRequest)
331331

332-
err = pull.Merge(pr, user1, gitRepo, repo_model.MergeStyleMerge, "UNRELATED")
332+
err = pull.Merge(pr, user1, gitRepo, repo_model.MergeStyleMerge, "", "UNRELATED")
333333
assert.Error(t, err, "Merge should return an error due to unrelated")
334334
assert.True(t, models.IsErrMergeUnrelatedHistories(err), "Merge error is not a unrelated histories error")
335335
gitRepo.Close()

models/asymkey/error.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,3 +246,19 @@ func IsErrDeployKeyNameAlreadyUsed(err error) bool {
246246
func (err ErrDeployKeyNameAlreadyUsed) Error() string {
247247
return fmt.Sprintf("public key with name already exists [repo_id: %d, name: %s]", err.RepoID, err.Name)
248248
}
249+
250+
// ErrSSHInvalidTokenSignature represents a "ErrSSHInvalidTokenSignature" kind of error.
251+
type ErrSSHInvalidTokenSignature struct {
252+
Wrapped error
253+
Fingerprint string
254+
}
255+
256+
// IsErrSSHInvalidTokenSignature checks if an error is a ErrSSHInvalidTokenSignature.
257+
func IsErrSSHInvalidTokenSignature(err error) bool {
258+
_, ok := err.(ErrSSHInvalidTokenSignature)
259+
return ok
260+
}
261+
262+
func (err ErrSSHInvalidTokenSignature) Error() string {
263+
return "the provided signature does not sign the token with the provided key"
264+
}

models/asymkey/gpg_key_commit_verification.go

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ type CommitVerification struct {
4949
CommittingUser *user_model.User
5050
SigningEmail string
5151
SigningKey *GPGKey
52+
SigningSSHKey *PublicKey
5253
TrustStatus string
5354
}
5455

@@ -122,6 +123,11 @@ func ParseCommitWithSignature(c *git.Commit) *CommitVerification {
122123
}
123124
}
124125

126+
// If this a SSH signature handle it differently
127+
if strings.HasPrefix(c.Signature.Signature, "-----BEGIN SSH SIGNATURE-----") {
128+
return ParseCommitWithSSHSignature(c, committer)
129+
}
130+
125131
// Parsing signature
126132
sig, err := extractSignature(c.Signature.Signature)
127133
if err != nil { // Skipping failed to extract sign
@@ -487,28 +493,31 @@ func CalculateTrustStatus(verification *CommitVerification, repoTrustModel repo_
487493
return
488494
}
489495

490-
var isMember bool
491-
if keyMap != nil {
492-
var has bool
493-
isMember, has = (*keyMap)[verification.SigningKey.KeyID]
494-
if !has {
496+
// Check we actually have a GPG SigningKey
497+
if verification.SigningKey != nil {
498+
var isMember bool
499+
if keyMap != nil {
500+
var has bool
501+
isMember, has = (*keyMap)[verification.SigningKey.KeyID]
502+
if !has {
503+
isMember, err = isCodeReader(verification.SigningUser)
504+
(*keyMap)[verification.SigningKey.KeyID] = isMember
505+
}
506+
} else {
495507
isMember, err = isCodeReader(verification.SigningUser)
496-
(*keyMap)[verification.SigningKey.KeyID] = isMember
497508
}
498-
} else {
499-
isMember, err = isCodeReader(verification.SigningUser)
500-
}
501509

502-
if !isMember {
503-
verification.TrustStatus = "untrusted"
504-
if verification.CommittingUser.ID != verification.SigningUser.ID {
505-
// The committing user and the signing user are not the same
506-
// This should be marked as questionable unless the signing user is a collaborator/team member etc.
510+
if !isMember {
511+
verification.TrustStatus = "untrusted"
512+
if verification.CommittingUser.ID != verification.SigningUser.ID {
513+
// The committing user and the signing user are not the same
514+
// This should be marked as questionable unless the signing user is a collaborator/team member etc.
515+
verification.TrustStatus = "unmatched"
516+
}
517+
} else if repoTrustModel == repo_model.CollaboratorCommitterTrustModel && verification.CommittingUser.ID != verification.SigningUser.ID {
518+
// The committing user and the signing user are not the same and our trustmodel states that they must match
507519
verification.TrustStatus = "unmatched"
508520
}
509-
} else if repoTrustModel == repo_model.CollaboratorCommitterTrustModel && verification.CommittingUser.ID != verification.SigningUser.ID {
510-
// The committing user and the signing user are not the same and our trustmodel states that they must match
511-
verification.TrustStatus = "unmatched"
512521
}
513522

514523
return

models/asymkey/ssh_key.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ type PublicKey struct {
5050
UpdatedUnix timeutil.TimeStamp `xorm:"updated"`
5151
HasRecentActivity bool `xorm:"-"`
5252
HasUsed bool `xorm:"-"`
53+
Verified bool `xorm:"NOT NULL DEFAULT false"`
5354
}
5455

5556
func init() {

0 commit comments

Comments
 (0)