mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-11 05:06:51 +00:00
chore: Fix linter errors
This commit is contained in:
@ -56,7 +56,7 @@ linters:
|
|||||||
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code [fast: true, auto-fix: false]
|
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code [fast: true, auto-fix: false]
|
||||||
- unused # Checks Go code for unused constants, variables, functions and types [fast: false, auto-fix: false]
|
- unused # Checks Go code for unused constants, variables, functions and types [fast: false, auto-fix: false]
|
||||||
- bodyclose # checks whether HTTP response body is closed successfully [fast: true, auto-fix: false]
|
- bodyclose # checks whether HTTP response body is closed successfully [fast: true, auto-fix: false]
|
||||||
- depguard # Go linter that checks if package imports are in a list of acceptable packages [fast: true, auto-fix: false]
|
#- depguard # Go linter that checks if package imports are in a list of acceptable packages [fast: true, auto-fix: false]
|
||||||
- dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) [fast: true, auto-fix: false]
|
- dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) [fast: true, auto-fix: false]
|
||||||
- dupl # Tool for code clone detection [fast: true, auto-fix: false]
|
- dupl # Tool for code clone detection [fast: true, auto-fix: false]
|
||||||
- gochecknoglobals # Checks that no globals are present in Go code [fast: true, auto-fix: false]
|
- gochecknoglobals # Checks that no globals are present in Go code [fast: true, auto-fix: false]
|
||||||
@ -120,4 +120,4 @@ linters:
|
|||||||
# Deprecated:
|
# Deprecated:
|
||||||
# - structcheck # Finds unused struct fields [fast: true, auto-fix: false] deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.
|
# - structcheck # Finds unused struct fields [fast: true, auto-fix: false] deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.
|
||||||
# - deadcode # Finds unused code [fast: true, auto-fix: false] deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.
|
# - deadcode # Finds unused code [fast: true, auto-fix: false] deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.
|
||||||
# - varcheck # Finds unused global variables and constants [fast: true, auto-fix: false] deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.
|
# - varcheck # Finds unused global variables and constants [fast: true, auto-fix: false] deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.
|
||||||
|
|||||||
@ -43,7 +43,6 @@ Proton Mail Bridge includes the following 3rd party software:
|
|||||||
* [color](https://github.com/fatih/color) available under [license](https://github.com/fatih/color/blob/master/LICENSE)
|
* [color](https://github.com/fatih/color) available under [license](https://github.com/fatih/color/blob/master/LICENSE)
|
||||||
* [sentry-go](https://github.com/getsentry/sentry-go) available under [license](https://github.com/getsentry/sentry-go/blob/master/LICENSE)
|
* [sentry-go](https://github.com/getsentry/sentry-go) available under [license](https://github.com/getsentry/sentry-go/blob/master/LICENSE)
|
||||||
* [resty](https://github.com/go-resty/resty/v2) available under [license](https://github.com/go-resty/resty/v2/blob/master/LICENSE)
|
* [resty](https://github.com/go-resty/resty/v2) available under [license](https://github.com/go-resty/resty/v2/blob/master/LICENSE)
|
||||||
* [go-json](https://github.com/goccy/go-json) available under [license](https://github.com/goccy/go-json/blob/master/LICENSE)
|
|
||||||
* [dbus](https://github.com/godbus/dbus) available under [license](https://github.com/godbus/dbus/blob/master/LICENSE)
|
* [dbus](https://github.com/godbus/dbus) available under [license](https://github.com/godbus/dbus/blob/master/LICENSE)
|
||||||
* [mock](https://github.com/golang/mock) available under [license](https://github.com/golang/mock/blob/master/LICENSE)
|
* [mock](https://github.com/golang/mock) available under [license](https://github.com/golang/mock/blob/master/LICENSE)
|
||||||
* [go-cmp](https://github.com/google/go-cmp) available under [license](https://github.com/google/go-cmp/blob/master/LICENSE)
|
* [go-cmp](https://github.com/google/go-cmp) available under [license](https://github.com/google/go-cmp/blob/master/LICENSE)
|
||||||
@ -98,6 +97,7 @@ Proton Mail Bridge includes the following 3rd party software:
|
|||||||
* [locales](https://github.com/go-playground/locales) available under [license](https://github.com/go-playground/locales/blob/master/LICENSE)
|
* [locales](https://github.com/go-playground/locales) available under [license](https://github.com/go-playground/locales/blob/master/LICENSE)
|
||||||
* [universal-translator](https://github.com/go-playground/universal-translator) available under [license](https://github.com/go-playground/universal-translator/blob/master/LICENSE)
|
* [universal-translator](https://github.com/go-playground/universal-translator) available under [license](https://github.com/go-playground/universal-translator/blob/master/LICENSE)
|
||||||
* [validator](https://github.com/go-playground/validator/v10) available under [license](https://github.com/go-playground/validator/v10/blob/master/LICENSE)
|
* [validator](https://github.com/go-playground/validator/v10) available under [license](https://github.com/go-playground/validator/v10/blob/master/LICENSE)
|
||||||
|
* [go-json](https://github.com/goccy/go-json) available under [license](https://github.com/goccy/go-json/blob/master/LICENSE)
|
||||||
* [uuid](https://github.com/gofrs/uuid) available under [license](https://github.com/gofrs/uuid/blob/master/LICENSE)
|
* [uuid](https://github.com/gofrs/uuid) available under [license](https://github.com/gofrs/uuid/blob/master/LICENSE)
|
||||||
* [protobuf](https://github.com/golang/protobuf) available under [license](https://github.com/golang/protobuf/blob/master/LICENSE)
|
* [protobuf](https://github.com/golang/protobuf) available under [license](https://github.com/golang/protobuf/blob/master/LICENSE)
|
||||||
* [pprof](https://github.com/google/pprof) available under [license](https://github.com/google/pprof/blob/master/LICENSE)
|
* [pprof](https://github.com/google/pprof) available under [license](https://github.com/google/pprof/blob/master/LICENSE)
|
||||||
|
|||||||
2
go.mod
2
go.mod
@ -25,7 +25,6 @@ require (
|
|||||||
github.com/fatih/color v1.13.0
|
github.com/fatih/color v1.13.0
|
||||||
github.com/getsentry/sentry-go v0.15.0
|
github.com/getsentry/sentry-go v0.15.0
|
||||||
github.com/go-resty/resty/v2 v2.7.0
|
github.com/go-resty/resty/v2 v2.7.0
|
||||||
github.com/goccy/go-json v0.10.2
|
|
||||||
github.com/godbus/dbus v4.1.0+incompatible
|
github.com/godbus/dbus v4.1.0+incompatible
|
||||||
github.com/golang/mock v1.6.0
|
github.com/golang/mock v1.6.0
|
||||||
github.com/google/go-cmp v0.5.9
|
github.com/google/go-cmp v0.5.9
|
||||||
@ -83,6 +82,7 @@ require (
|
|||||||
github.com/go-playground/locales v0.14.1 // indirect
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
github.com/go-playground/validator/v10 v10.14.0 // indirect
|
github.com/go-playground/validator/v10 v10.14.0 // indirect
|
||||||
|
github.com/goccy/go-json v0.10.2 // indirect
|
||||||
github.com/gofrs/uuid v4.3.0+incompatible // indirect
|
github.com/gofrs/uuid v4.3.0+incompatible // indirect
|
||||||
github.com/golang/protobuf v1.5.2 // indirect
|
github.com/golang/protobuf v1.5.2 // indirect
|
||||||
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd // indirect
|
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd // indirect
|
||||||
|
|||||||
@ -93,6 +93,8 @@ func newProxyProvider(dialer TLSDialer, hostURL string, providers []string, pani
|
|||||||
}
|
}
|
||||||
|
|
||||||
// findReachableServer returns a working API server (either proxy or standard API).
|
// findReachableServer returns a working API server (either proxy or standard API).
|
||||||
|
//
|
||||||
|
//nolint:nakedret
|
||||||
func (p *proxyProvider) findReachableServer() (proxy string, err error) {
|
func (p *proxyProvider) findReachableServer() (proxy string, err error) {
|
||||||
logrus.Debug("Trying to find a reachable server")
|
logrus.Debug("Trying to find a reachable server")
|
||||||
|
|
||||||
@ -204,6 +206,8 @@ func (p *proxyProvider) canReach(url string) bool {
|
|||||||
// It looks up DNS TXT records for the given query URL using the given DoH provider.
|
// It looks up DNS TXT records for the given query URL using the given DoH provider.
|
||||||
// It returns a list of all found TXT records.
|
// It returns a list of all found TXT records.
|
||||||
// If the whole process takes more than proxyDoHTimeout then an error is returned.
|
// If the whole process takes more than proxyDoHTimeout then an error is returned.
|
||||||
|
//
|
||||||
|
//nolint:nakedret
|
||||||
func (p *proxyProvider) defaultDoHLookup(ctx context.Context, query, dohProvider string) (data []string, err error) {
|
func (p *proxyProvider) defaultDoHLookup(ctx context.Context, query, dohProvider string) (data []string, err error) {
|
||||||
ctx, cancel := context.WithTimeout(ctx, p.dohTimeout)
|
ctx, cancel := context.WithTimeout(ctx, p.dohTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|||||||
@ -53,7 +53,7 @@ func (s *Store) List() (userIDs []string, err error) {
|
|||||||
var allUserIDs []string
|
var allUserIDs []string
|
||||||
if allUserIDs, err = s.secrets.List(); err != nil {
|
if allUserIDs, err = s.secrets.List(); err != nil {
|
||||||
log.WithError(err).Error("Could not list credentials")
|
log.WithError(err).Error("Could not list credentials")
|
||||||
return
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
credentialList := []*Credentials{}
|
credentialList := []*Credentials{}
|
||||||
|
|||||||
@ -305,7 +305,7 @@ func (b *sendPrefsBuilder) setPGPSettings(
|
|||||||
func (b *sendPrefsBuilder) setInternalPGPSettings(
|
func (b *sendPrefsBuilder) setInternalPGPSettings(
|
||||||
vCardData *contactSettings,
|
vCardData *contactSettings,
|
||||||
apiKeys []proton.PublicKey,
|
apiKeys []proton.PublicKey,
|
||||||
) (err error) {
|
) error {
|
||||||
// We're guaranteed to get at least one valid (i.e. not expired, revoked or
|
// We're guaranteed to get at least one valid (i.e. not expired, revoked or
|
||||||
// marked as verification-only) public key from the server.
|
// marked as verification-only) public key from the server.
|
||||||
if len(apiKeys) == 0 {
|
if len(apiKeys) == 0 {
|
||||||
@ -327,7 +327,7 @@ func (b *sendPrefsBuilder) setInternalPGPSettings(
|
|||||||
|
|
||||||
sendingKey, err := pickSendingKey(vCardData, apiKeys)
|
sendingKey, err := pickSendingKey(vCardData, apiKeys)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
b.withPublicKey(sendingKey)
|
b.withPublicKey(sendingKey)
|
||||||
@ -349,7 +349,7 @@ func (b *sendPrefsBuilder) setInternalPGPSettings(
|
|||||||
// 3. If there are no pinned keys, then the client should encrypt with the
|
// 3. If there are no pinned keys, then the client should encrypt with the
|
||||||
// first valid key served by the API (in principle the server already
|
// first valid key served by the API (in principle the server already
|
||||||
// validates the keys and the first one provided should be valid).
|
// validates the keys and the first one provided should be valid).
|
||||||
func pickSendingKey(vCardData *contactSettings, rawAPIKeys []proton.PublicKey) (kr *crypto.KeyRing, err error) {
|
func pickSendingKey(vCardData *contactSettings, rawAPIKeys []proton.PublicKey) (*crypto.KeyRing, error) {
|
||||||
contactKeys := make([]*crypto.Key, len(vCardData.Keys))
|
contactKeys := make([]*crypto.Key, len(vCardData.Keys))
|
||||||
apiKeys := make([]*crypto.Key, len(rawAPIKeys))
|
apiKeys := make([]*crypto.Key, len(rawAPIKeys))
|
||||||
|
|
||||||
@ -357,8 +357,9 @@ func pickSendingKey(vCardData *contactSettings, rawAPIKeys []proton.PublicKey) (
|
|||||||
var ck *crypto.Key
|
var ck *crypto.Key
|
||||||
|
|
||||||
// Contact keys are not armored.
|
// Contact keys are not armored.
|
||||||
|
var err error
|
||||||
if ck, err = crypto.NewKey([]byte(key)); err != nil {
|
if ck, err = crypto.NewKey([]byte(key)); err != nil {
|
||||||
return
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
contactKeys[i] = ck
|
contactKeys[i] = ck
|
||||||
@ -368,8 +369,9 @@ func pickSendingKey(vCardData *contactSettings, rawAPIKeys []proton.PublicKey) (
|
|||||||
var ck *crypto.Key
|
var ck *crypto.Key
|
||||||
|
|
||||||
// API keys are armored.
|
// API keys are armored.
|
||||||
|
var err error
|
||||||
if ck, err = crypto.NewKeyFromArmored(key.PublicKey); err != nil {
|
if ck, err = crypto.NewKeyFromArmored(key.PublicKey); err != nil {
|
||||||
return
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
apiKeys[i] = ck
|
apiKeys[i] = ck
|
||||||
@ -416,7 +418,7 @@ func matchFingerprints(a, b []*crypto.Key) (res []*crypto.Key) {
|
|||||||
func (b *sendPrefsBuilder) setExternalPGPSettingsWithWKDKeys(
|
func (b *sendPrefsBuilder) setExternalPGPSettingsWithWKDKeys(
|
||||||
vCardData *contactSettings,
|
vCardData *contactSettings,
|
||||||
apiKeys []proton.PublicKey,
|
apiKeys []proton.PublicKey,
|
||||||
) (err error) {
|
) error {
|
||||||
// We're guaranteed to get at least one valid (i.e. not expired, revoked or
|
// We're guaranteed to get at least one valid (i.e. not expired, revoked or
|
||||||
// marked as verification-only) public key from the server.
|
// marked as verification-only) public key from the server.
|
||||||
if len(apiKeys) == 0 {
|
if len(apiKeys) == 0 {
|
||||||
@ -445,7 +447,7 @@ func (b *sendPrefsBuilder) setExternalPGPSettingsWithWKDKeys(
|
|||||||
|
|
||||||
sendingKey, err := pickSendingKey(vCardData, apiKeys)
|
sendingKey, err := pickSendingKey(vCardData, apiKeys)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
b.withPublicKey(sendingKey)
|
b.withPublicKey(sendingKey)
|
||||||
@ -455,7 +457,7 @@ func (b *sendPrefsBuilder) setExternalPGPSettingsWithWKDKeys(
|
|||||||
|
|
||||||
func (b *sendPrefsBuilder) setExternalPGPSettingsWithoutWKDKeys(
|
func (b *sendPrefsBuilder) setExternalPGPSettingsWithoutWKDKeys(
|
||||||
vCardData *contactSettings,
|
vCardData *contactSettings,
|
||||||
) (err error) {
|
) error {
|
||||||
b.withEncrypt(vCardData.Encrypt)
|
b.withEncrypt(vCardData.Encrypt)
|
||||||
|
|
||||||
if vCardData.SignIsSet {
|
if vCardData.SignIsSet {
|
||||||
@ -487,17 +489,20 @@ func (b *sendPrefsBuilder) setExternalPGPSettingsWithoutWKDKeys(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(vCardData.Keys) > 0 {
|
if len(vCardData.Keys) > 0 {
|
||||||
var key *crypto.Key
|
var (
|
||||||
|
key *crypto.Key
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
// Contact keys are not armored.
|
// Contact keys are not armored.
|
||||||
if key, err = crypto.NewKey([]byte(vCardData.Keys[0])); err != nil {
|
if key, err = crypto.NewKey([]byte(vCardData.Keys[0])); err != nil {
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var kr *crypto.KeyRing
|
var kr *crypto.KeyRing
|
||||||
|
|
||||||
if kr, err = crypto.NewKeyRing(key); err != nil {
|
if kr, err = crypto.NewKeyRing(key); err != nil {
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
b.withPublicKey(kr)
|
b.withPublicKey(kr)
|
||||||
|
|||||||
@ -18,10 +18,9 @@
|
|||||||
package tests
|
package tests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/goccy/go-json"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_IsSub(t *testing.T) {
|
func Test_IsSub(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user