Skip to content

Commit 6ceb461

Browse files
authored
Merge branch 'main' into bugfix/issue-33265
2 parents 2e16eb1 + 121e4c9 commit 6ceb461

Some content is hidden

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

42 files changed

+427
-217
lines changed

Makefile

Lines changed: 60 additions & 116 deletions
Large diffs are not rendered by default.

assets/go-licenses.json

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/serv.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ func fail(ctx context.Context, userMessage, logMsgFmt string, args ...any) error
104104
// There appears to be a chance to cause a zombie process and failure to read the Exit status
105105
// if nothing is outputted on stdout.
106106
_, _ = fmt.Fprintln(os.Stdout, "")
107-
_, _ = fmt.Fprintln(os.Stderr, "Gitea:", userMessage)
107+
// add extra empty lines to separate our message from other git errors to get more attention
108+
_, _ = fmt.Fprintln(os.Stderr, "error:")
109+
_, _ = fmt.Fprintln(os.Stderr, "error:", userMessage)
110+
_, _ = fmt.Fprintln(os.Stderr, "error:")
108111

109112
if logMsgFmt != "" {
110113
logMsg := fmt.Sprintf(logMsgFmt, args...)

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ require (
7878
github.com/jhillyerd/enmime v1.3.0
7979
github.com/json-iterator/go v1.1.12
8080
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
81-
github.com/keybase/go-crypto v0.0.0-20200123153347-de78d2cb44f4
8281
github.com/klauspost/compress v1.17.11
8382
github.com/klauspost/cpuid/v2 v2.2.8
8483
github.com/lib/pq v1.10.9

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,6 @@ github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNU
506506
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
507507
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
508508
github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
509-
github.com/keybase/go-crypto v0.0.0-20200123153347-de78d2cb44f4 h1:cTxwSmnaqLoo+4tLukHoB9iqHOu3LmLhRmgUxZo6Vp4=
510-
github.com/keybase/go-crypto v0.0.0-20200123153347-de78d2cb44f4/go.mod h1:ghbZscTyKdM07+Fw3KSi0hcJm+AlEUWj8QLlPtijN/M=
511509
github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
512510
github.com/klauspost/compress v1.11.4/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
513511
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=

models/activities/action.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ func (at ActionType) String() string {
7272
case ActionRenameRepo:
7373
return "rename_repo"
7474
case ActionStarRepo:
75-
return "star_repo"
75+
return "star_repo" // will not displayed in feeds.tmpl
7676
case ActionWatchRepo:
77-
return "watch_repo"
77+
return "watch_repo" // will not displayed in feeds.tmpl
7878
case ActionCommitRepo:
7979
return "commit_repo"
8080
case ActionCreateIssue:

models/asymkey/gpg_key.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
user_model "code.gitea.io/gitea/models/user"
1414
"code.gitea.io/gitea/modules/timeutil"
1515

16-
"github.com/keybase/go-crypto/openpgp"
17-
"github.com/keybase/go-crypto/openpgp/packet"
16+
"github.com/ProtonMail/go-crypto/openpgp"
17+
"github.com/ProtonMail/go-crypto/openpgp/packet"
1818
"xorm.io/builder"
1919
)
2020

@@ -141,7 +141,11 @@ func parseGPGKey(ctx context.Context, ownerID int64, e *openpgp.Entity, verified
141141
// Parse Subkeys
142142
subkeys := make([]*GPGKey, len(e.Subkeys))
143143
for i, k := range e.Subkeys {
144-
subs, err := parseSubGPGKey(ownerID, pubkey.KeyIdString(), k.PublicKey, expiry)
144+
subkeyExpiry := expiry
145+
if k.Sig.KeyLifetimeSecs != nil {
146+
subkeyExpiry = k.PublicKey.CreationTime.Add(time.Duration(*k.Sig.KeyLifetimeSecs) * time.Second)
147+
}
148+
subs, err := parseSubGPGKey(ownerID, pubkey.KeyIdString(), k.PublicKey, subkeyExpiry)
145149
if err != nil {
146150
return nil, ErrGPGKeyParsing{ParseError: err}
147151
}
@@ -156,7 +160,7 @@ func parseGPGKey(ctx context.Context, ownerID int64, e *openpgp.Entity, verified
156160

157161
emails := make([]*user_model.EmailAddress, 0, len(e.Identities))
158162
for _, ident := range e.Identities {
159-
if ident.Revocation != nil {
163+
if ident.Revoked(time.Now()) {
160164
continue
161165
}
162166
email := strings.ToLower(strings.TrimSpace(ident.UserId.Email))

models/asymkey/gpg_key_add.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"code.gitea.io/gitea/models/db"
1111
"code.gitea.io/gitea/modules/log"
1212

13-
"github.com/keybase/go-crypto/openpgp"
13+
"github.com/ProtonMail/go-crypto/openpgp"
1414
)
1515

1616
// __________________ ________ ____ __.
@@ -83,12 +83,12 @@ func AddGPGKey(ctx context.Context, ownerID int64, content, token, signature str
8383
verified := false
8484
// Handle provided signature
8585
if signature != "" {
86-
signer, err := openpgp.CheckArmoredDetachedSignature(ekeys, strings.NewReader(token), strings.NewReader(signature))
86+
signer, err := openpgp.CheckArmoredDetachedSignature(ekeys, strings.NewReader(token), strings.NewReader(signature), nil)
8787
if err != nil {
88-
signer, err = openpgp.CheckArmoredDetachedSignature(ekeys, strings.NewReader(token+"\n"), strings.NewReader(signature))
88+
signer, err = openpgp.CheckArmoredDetachedSignature(ekeys, strings.NewReader(token+"\n"), strings.NewReader(signature), nil)
8989
}
9090
if err != nil {
91-
signer, err = openpgp.CheckArmoredDetachedSignature(ekeys, strings.NewReader(token+"\r\n"), strings.NewReader(signature))
91+
signer, err = openpgp.CheckArmoredDetachedSignature(ekeys, strings.NewReader(token+"\r\n"), strings.NewReader(signature), nil)
9292
}
9393
if err != nil {
9494
log.Error("Unable to validate token signature. Error: %v", err)

models/asymkey/gpg_key_commit_verification.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"code.gitea.io/gitea/modules/log"
1717
"code.gitea.io/gitea/modules/setting"
1818

19-
"github.com/keybase/go-crypto/openpgp/packet"
19+
"github.com/ProtonMail/go-crypto/openpgp/packet"
2020
)
2121

2222
// __________________ ________ ____ __.

models/asymkey/gpg_key_common.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import (
1313
"strings"
1414
"time"
1515

16-
"github.com/keybase/go-crypto/openpgp"
17-
"github.com/keybase/go-crypto/openpgp/armor"
18-
"github.com/keybase/go-crypto/openpgp/packet"
16+
"github.com/ProtonMail/go-crypto/openpgp"
17+
"github.com/ProtonMail/go-crypto/openpgp/armor"
18+
"github.com/ProtonMail/go-crypto/openpgp/packet"
1919
)
2020

2121
// __________________ ________ ____ __.
@@ -80,20 +80,20 @@ func base64DecPubKey(content string) (*packet.PublicKey, error) {
8080
return pkey, nil
8181
}
8282

83-
// getExpiryTime extract the expire time of primary key based on sig
83+
// getExpiryTime extract the expiry time of primary key based on sig
8484
func getExpiryTime(e *openpgp.Entity) time.Time {
8585
expiry := time.Time{}
8686
// Extract self-sign for expire date based on : https://github.com/golang/crypto/blob/master/openpgp/keys.go#L165
8787
var selfSig *packet.Signature
8888
for _, ident := range e.Identities {
8989
if selfSig == nil {
9090
selfSig = ident.SelfSignature
91-
} else if ident.SelfSignature.IsPrimaryId != nil && *ident.SelfSignature.IsPrimaryId {
91+
} else if ident.SelfSignature != nil && ident.SelfSignature.IsPrimaryId != nil && *ident.SelfSignature.IsPrimaryId {
9292
selfSig = ident.SelfSignature
9393
break
9494
}
9595
}
96-
if selfSig.KeyLifetimeSecs != nil {
96+
if selfSig != nil && selfSig.KeyLifetimeSecs != nil {
9797
expiry = e.PrimaryKey.CreationTime.Add(time.Duration(*selfSig.KeyLifetimeSecs) * time.Second)
9898
}
9999
return expiry

0 commit comments

Comments
 (0)