fix some new lint warnings
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
parent
757185256c
commit
ad75543172
8 changed files with 48 additions and 64 deletions
|
@ -53,7 +53,7 @@ MacOS:
|
||||||
You will need to start a new shell for this setup to take effect.
|
You will need to start a new shell for this setup to take effect.
|
||||||
`,
|
`,
|
||||||
DisableFlagsInUseLine: true,
|
DisableFlagsInUseLine: true,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||||
return cmd.Root().GenBashCompletionV2(os.Stdout, true)
|
return cmd.Root().GenBashCompletionV2(os.Stdout, true)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ macOS:
|
||||||
You will need to start a new shell for this setup to take effect.
|
You will need to start a new shell for this setup to take effect.
|
||||||
`,
|
`,
|
||||||
DisableFlagsInUseLine: true,
|
DisableFlagsInUseLine: true,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||||
return cmd.Root().GenZshCompletion(os.Stdout)
|
return cmd.Root().GenZshCompletion(os.Stdout)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ $ sftpgo gen completion fish > ~/.config/fish/completions/sftpgo.fish
|
||||||
You will need to start a new shell for this setup to take effect.
|
You will need to start a new shell for this setup to take effect.
|
||||||
`,
|
`,
|
||||||
DisableFlagsInUseLine: true,
|
DisableFlagsInUseLine: true,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||||
return cmd.Root().GenFishCompletion(os.Stdout, true)
|
return cmd.Root().GenFishCompletion(os.Stdout, true)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ To load completions for every new session, add the output of the above command
|
||||||
to your powershell profile.
|
to your powershell profile.
|
||||||
`,
|
`,
|
||||||
DisableFlagsInUseLine: true,
|
DisableFlagsInUseLine: true,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||||
return cmd.Root().GenPowerShellCompletionWithDesc(os.Stdout)
|
return cmd.Root().GenPowerShellCompletionWithDesc(os.Stdout)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,10 +227,10 @@ func TestMain(m *testing.M) {
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
// start a test HTTP server to receive action notifications
|
// start a test HTTP server to receive action notifications
|
||||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) {
|
||||||
fmt.Fprintf(w, "OK\n")
|
fmt.Fprintf(w, "OK\n")
|
||||||
})
|
})
|
||||||
http.HandleFunc("/404", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/404", func(w http.ResponseWriter, _ *http.Request) {
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
fmt.Fprintf(w, "Not found\n")
|
fmt.Fprintf(w, "Not found\n")
|
||||||
})
|
})
|
||||||
|
@ -272,7 +272,7 @@ func TestMain(m *testing.M) {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
if err := smtpd.ListenAndServe(smtpServerAddr, func(remoteAddr net.Addr, from string, to []string, data []byte) error {
|
if err := smtpd.ListenAndServe(smtpServerAddr, func(_ net.Addr, from string, to []string, data []byte) error {
|
||||||
lastReceivedEmail.set(from, to, data)
|
lastReceivedEmail.set(from, to, data)
|
||||||
return nil
|
return nil
|
||||||
}, "SFTPGo test", "localhost"); err != nil {
|
}, "SFTPGo test", "localhost"); err != nil {
|
||||||
|
@ -7793,7 +7793,7 @@ func TestBuiltinKeyboardInteractiveAuthentication(t *testing.T) {
|
||||||
user, _, err := httpdtest.AddUser(u, http.StatusCreated)
|
user, _, err := httpdtest.AddUser(u, http.StatusCreated)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
authMethods := []ssh.AuthMethod{
|
authMethods := []ssh.AuthMethod{
|
||||||
ssh.KeyboardInteractive(func(user, instruction string, questions []string, echos []bool) ([]string, error) {
|
ssh.KeyboardInteractive(func(_, _ string, _ []string, _ []bool) ([]string, error) {
|
||||||
return []string{defaultPassword}, nil
|
return []string{defaultPassword}, nil
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
@ -7822,7 +7822,7 @@ func TestBuiltinKeyboardInteractiveAuthentication(t *testing.T) {
|
||||||
passwordAsked := false
|
passwordAsked := false
|
||||||
passcodeAsked := false
|
passcodeAsked := false
|
||||||
authMethods = []ssh.AuthMethod{
|
authMethods = []ssh.AuthMethod{
|
||||||
ssh.KeyboardInteractive(func(user, instruction string, questions []string, echos []bool) ([]string, error) {
|
ssh.KeyboardInteractive(func(_, _ string, questions []string, _ []bool) ([]string, error) {
|
||||||
var answers []string
|
var answers []string
|
||||||
if strings.HasPrefix(questions[0], "Password") {
|
if strings.HasPrefix(questions[0], "Password") {
|
||||||
answers = append(answers, defaultPassword)
|
answers = append(answers, defaultPassword)
|
||||||
|
@ -7866,7 +7866,7 @@ func TestMultiStepBuiltinKeyboardAuth(t *testing.T) {
|
||||||
// public key + password
|
// public key + password
|
||||||
authMethods := []ssh.AuthMethod{
|
authMethods := []ssh.AuthMethod{
|
||||||
ssh.PublicKeys(signer),
|
ssh.PublicKeys(signer),
|
||||||
ssh.KeyboardInteractive(func(user, instruction string, questions []string, echos []bool) ([]string, error) {
|
ssh.KeyboardInteractive(func(_, _ string, _ []string, _ []bool) ([]string, error) {
|
||||||
return []string{defaultPassword}, nil
|
return []string{defaultPassword}, nil
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
@ -7895,7 +7895,7 @@ func TestMultiStepBuiltinKeyboardAuth(t *testing.T) {
|
||||||
// public key + passcode
|
// public key + passcode
|
||||||
authMethods = []ssh.AuthMethod{
|
authMethods = []ssh.AuthMethod{
|
||||||
ssh.PublicKeys(signer),
|
ssh.PublicKeys(signer),
|
||||||
ssh.KeyboardInteractive(func(user, instruction string, questions []string, echos []bool) ([]string, error) {
|
ssh.KeyboardInteractive(func(_, _ string, _ []string, _ []bool) ([]string, error) {
|
||||||
return []string{passcode}, nil
|
return []string{passcode}, nil
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
@ -8849,9 +8849,7 @@ func getCustomAuthSftpClient(user dataprovider.User, authMethods []ssh.AuthMetho
|
||||||
var sftpClient *sftp.Client
|
var sftpClient *sftp.Client
|
||||||
config := &ssh.ClientConfig{
|
config := &ssh.ClientConfig{
|
||||||
User: user.Username,
|
User: user.Username,
|
||||||
HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error {
|
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
|
||||||
return nil
|
|
||||||
},
|
|
||||||
Auth: authMethods,
|
Auth: authMethods,
|
||||||
Timeout: 5 * time.Second,
|
Timeout: 5 * time.Second,
|
||||||
}
|
}
|
||||||
|
@ -8870,9 +8868,7 @@ func getSftpClient(user dataprovider.User) (*ssh.Client, *sftp.Client, error) {
|
||||||
var sftpClient *sftp.Client
|
var sftpClient *sftp.Client
|
||||||
config := &ssh.ClientConfig{
|
config := &ssh.ClientConfig{
|
||||||
User: user.Username,
|
User: user.Username,
|
||||||
HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error {
|
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
|
||||||
return nil
|
|
||||||
},
|
|
||||||
Timeout: 5 * time.Second,
|
Timeout: 5 * time.Second,
|
||||||
}
|
}
|
||||||
if user.Password != "" {
|
if user.Password != "" {
|
||||||
|
@ -8897,9 +8893,7 @@ func runSSHCommand(command string, user dataprovider.User) ([]byte, error) {
|
||||||
var output []byte
|
var output []byte
|
||||||
config := &ssh.ClientConfig{
|
config := &ssh.ClientConfig{
|
||||||
User: user.Username,
|
User: user.Username,
|
||||||
HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error {
|
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
|
||||||
return nil
|
|
||||||
},
|
|
||||||
Timeout: 5 * time.Second,
|
Timeout: 5 * time.Second,
|
||||||
}
|
}
|
||||||
if user.Password != "" {
|
if user.Password != "" {
|
||||||
|
|
|
@ -562,7 +562,7 @@ func (b *Binding) checkBranding() {
|
||||||
func (b *Binding) parseAllowedProxy() error {
|
func (b *Binding) parseAllowedProxy() error {
|
||||||
if filepath.IsAbs(b.Address) && len(b.ProxyAllowed) > 0 {
|
if filepath.IsAbs(b.Address) && len(b.ProxyAllowed) > 0 {
|
||||||
// unix domain socket
|
// unix domain socket
|
||||||
b.allowHeadersFrom = []func(net.IP) bool{func(ip net.IP) bool { return true }}
|
b.allowHeadersFrom = []func(net.IP) bool{func(_ net.IP) bool { return true }}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
allowedFuncs, err := util.ParseAllowedIPAndRanges(b.ProxyAllowed)
|
allowedFuncs, err := util.ParseAllowedIPAndRanges(b.ProxyAllowed)
|
||||||
|
|
|
@ -25526,7 +25526,7 @@ func getJWTWebToken(username, password string) (string, error) {
|
||||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
Timeout: 10 * time.Second,
|
Timeout: 10 * time.Second,
|
||||||
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
CheckRedirect: func(_ *http.Request, _ []*http.Request) error {
|
||||||
return http.ErrUseLastResponse
|
return http.ErrUseLastResponse
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -2168,7 +2168,7 @@ func TestRecoverer(t *testing.T) {
|
||||||
}
|
}
|
||||||
server := newHttpdServer(b, "../static", "", CorsConfig{}, "../openapi")
|
server := newHttpdServer(b, "../static", "", CorsConfig{}, "../openapi")
|
||||||
server.initializeRouter()
|
server.initializeRouter()
|
||||||
server.router.Get(recoveryPath, func(w http.ResponseWriter, r *http.Request) {
|
server.router.Get(recoveryPath, func(_ http.ResponseWriter, _ *http.Request) {
|
||||||
panic("panic")
|
panic("panic")
|
||||||
})
|
})
|
||||||
testServer := httptest.NewServer(server.router)
|
testServer := httptest.NewServer(server.router)
|
||||||
|
@ -2182,7 +2182,7 @@ func TestRecoverer(t *testing.T) {
|
||||||
|
|
||||||
server.router = chi.NewRouter()
|
server.router = chi.NewRouter()
|
||||||
server.router.Use(middleware.Recoverer)
|
server.router.Use(middleware.Recoverer)
|
||||||
server.router.Get(recoveryPath, func(w http.ResponseWriter, r *http.Request) {
|
server.router.Get(recoveryPath, func(_ http.ResponseWriter, _ *http.Request) {
|
||||||
panic("panic")
|
panic("panic")
|
||||||
})
|
})
|
||||||
testServer = httptest.NewServer(server.router)
|
testServer = httptest.NewServer(server.router)
|
||||||
|
@ -2208,7 +2208,7 @@ func TestStreamJSONArray(t *testing.T) {
|
||||||
data = append(data, i)
|
data = append(data, i)
|
||||||
}
|
}
|
||||||
|
|
||||||
dataGetter = func(limit, offset int) ([]byte, int, error) {
|
dataGetter = func(_, offset int) ([]byte, int, error) {
|
||||||
if offset >= len(data) {
|
if offset >= len(data) {
|
||||||
return nil, 0, nil
|
return nil, 0, nil
|
||||||
}
|
}
|
||||||
|
@ -3140,7 +3140,7 @@ func TestWebAdminSetupWithInstallCode(t *testing.T) {
|
||||||
err = dataprovider.Initialize(providerConf, configDir, true)
|
err = dataprovider.Initialize(providerConf, configDir, true)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
SetInstallationCodeResolver(func(defaultInstallationCode string) string {
|
SetInstallationCodeResolver(func(_ string) string {
|
||||||
return "5678"
|
return "5678"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -555,7 +555,7 @@ func (c *Configuration) configureLoginBanner(serverConfig *ssh.ServerConfig, con
|
||||||
bannerContent, err := os.ReadFile(bannerFilePath)
|
bannerContent, err := os.ReadFile(bannerFilePath)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
banner := string(bannerContent)
|
banner := string(bannerContent)
|
||||||
serverConfig.BannerCallback = func(conn ssh.ConnMetadata) string {
|
serverConfig.BannerCallback = func(_ ssh.ConnMetadata) string {
|
||||||
return banner
|
return banner
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -2331,7 +2331,7 @@ func TestMultiStepLoginKeyAndKeyInt(t *testing.T) {
|
||||||
signer, _ := ssh.ParsePrivateKey([]byte(testPrivateKey))
|
signer, _ := ssh.ParsePrivateKey([]byte(testPrivateKey))
|
||||||
authMethods := []ssh.AuthMethod{
|
authMethods := []ssh.AuthMethod{
|
||||||
ssh.PublicKeys(signer),
|
ssh.PublicKeys(signer),
|
||||||
ssh.KeyboardInteractive(func(user, instruction string, questions []string, echos []bool) ([]string, error) {
|
ssh.KeyboardInteractive(func(_, _ string, _ []string, _ []bool) ([]string, error) {
|
||||||
return []string{"1", "2"}, nil
|
return []string{"1", "2"}, nil
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
@ -2348,7 +2348,7 @@ func TestMultiStepLoginKeyAndKeyInt(t *testing.T) {
|
||||||
assert.NoError(t, checkBasicSFTP(client))
|
assert.NoError(t, checkBasicSFTP(client))
|
||||||
}
|
}
|
||||||
authMethods = []ssh.AuthMethod{
|
authMethods = []ssh.AuthMethod{
|
||||||
ssh.KeyboardInteractive(func(user, instruction string, questions []string, echos []bool) ([]string, error) {
|
ssh.KeyboardInteractive(func(_, _ string, _ []string, _ []bool) ([]string, error) {
|
||||||
return []string{"1", "2"}, nil
|
return []string{"1", "2"}, nil
|
||||||
}),
|
}),
|
||||||
ssh.PublicKeys(signer),
|
ssh.PublicKeys(signer),
|
||||||
|
@ -8226,9 +8226,7 @@ func TestOpenUnhandledChannel(t *testing.T) {
|
||||||
|
|
||||||
config := &ssh.ClientConfig{
|
config := &ssh.ClientConfig{
|
||||||
User: user.Username,
|
User: user.Username,
|
||||||
HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error {
|
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
|
||||||
return nil
|
|
||||||
},
|
|
||||||
Auth: []ssh.AuthMethod{ssh.Password(defaultPassword)},
|
Auth: []ssh.AuthMethod{ssh.Password(defaultPassword)},
|
||||||
Timeout: 5 * time.Second,
|
Timeout: 5 * time.Second,
|
||||||
}
|
}
|
||||||
|
@ -11187,9 +11185,7 @@ func runSSHCommand(command string, user dataprovider.User, usePubKey bool) ([]by
|
||||||
var output []byte
|
var output []byte
|
||||||
config := &ssh.ClientConfig{
|
config := &ssh.ClientConfig{
|
||||||
User: user.Username,
|
User: user.Username,
|
||||||
HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error {
|
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
|
||||||
return nil
|
|
||||||
},
|
|
||||||
Timeout: 5 * time.Second,
|
Timeout: 5 * time.Second,
|
||||||
}
|
}
|
||||||
if usePubKey {
|
if usePubKey {
|
||||||
|
@ -11236,9 +11232,7 @@ func getSftpClientWithAddr(user dataprovider.User, usePubKey bool, addr string)
|
||||||
var sftpClient *sftp.Client
|
var sftpClient *sftp.Client
|
||||||
config := &ssh.ClientConfig{
|
config := &ssh.ClientConfig{
|
||||||
User: user.Username,
|
User: user.Username,
|
||||||
HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error {
|
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
|
||||||
return nil
|
|
||||||
},
|
|
||||||
Timeout: 5 * time.Second,
|
Timeout: 5 * time.Second,
|
||||||
}
|
}
|
||||||
if usePubKey {
|
if usePubKey {
|
||||||
|
@ -11277,11 +11271,9 @@ func getKeyboardInteractiveSftpClient(user dataprovider.User, answers []string)
|
||||||
var sftpClient *sftp.Client
|
var sftpClient *sftp.Client
|
||||||
config := &ssh.ClientConfig{
|
config := &ssh.ClientConfig{
|
||||||
User: user.Username,
|
User: user.Username,
|
||||||
HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error {
|
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
|
||||||
return nil
|
|
||||||
},
|
|
||||||
Auth: []ssh.AuthMethod{
|
Auth: []ssh.AuthMethod{
|
||||||
ssh.KeyboardInteractive(func(user, instruction string, questions []string, echos []bool) ([]string, error) {
|
ssh.KeyboardInteractive(func(_, _ string, _ []string, _ []bool) ([]string, error) {
|
||||||
return answers, nil
|
return answers, nil
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
@ -11302,9 +11294,7 @@ func getCustomAuthSftpClient(user dataprovider.User, authMethods []ssh.AuthMetho
|
||||||
var sftpClient *sftp.Client
|
var sftpClient *sftp.Client
|
||||||
config := &ssh.ClientConfig{
|
config := &ssh.ClientConfig{
|
||||||
User: user.Username,
|
User: user.Username,
|
||||||
HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error {
|
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
|
||||||
return nil
|
|
||||||
},
|
|
||||||
Auth: authMethods,
|
Auth: authMethods,
|
||||||
Timeout: 5 * time.Second,
|
Timeout: 5 * time.Second,
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,7 +156,7 @@ type Binding struct {
|
||||||
func (b *Binding) parseAllowedProxy() error {
|
func (b *Binding) parseAllowedProxy() error {
|
||||||
if filepath.IsAbs(b.Address) && len(b.ProxyAllowed) > 0 {
|
if filepath.IsAbs(b.Address) && len(b.ProxyAllowed) > 0 {
|
||||||
// unix domain socket
|
// unix domain socket
|
||||||
b.allowHeadersFrom = []func(net.IP) bool{func(ip net.IP) bool { return true }}
|
b.allowHeadersFrom = []func(net.IP) bool{func(_ net.IP) bool { return true }}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
allowedFuncs, err := util.ParseAllowedIPAndRanges(b.ProxyAllowed)
|
allowedFuncs, err := util.ParseAllowedIPAndRanges(b.ProxyAllowed)
|
||||||
|
|
Loading…
Reference in a new issue