mirror of
https://github.com/quexten/goldwarden.git
synced 2024-09-11 19:17:33 +03:00
Fix more lints found by golangci-lint's default config
This commit is contained in:
parent
1479d9f8fd
commit
17f62c130e
@ -17,7 +17,7 @@ func handleAddSSH(msg messages.IPCMessage, cfg *config.Config, vault *vault.Vaul
|
||||
req := messages.ParsePayload(msg).(messages.CreateSSHKeyRequest)
|
||||
|
||||
cipher, publicKey := ssh.NewSSHKeyCipher(req.Name, vault.Keyring)
|
||||
response, err = messages.IPCMessageFromPayload(messages.ActionResponse{
|
||||
_, err = messages.IPCMessageFromPayload(messages.ActionResponse{
|
||||
Success: true,
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -162,10 +162,10 @@ func LoginWithMasterpassword(ctx context.Context, email string, cfg *config.Conf
|
||||
return LoginResponseToken{}, crypto.MasterKey{}, "", err
|
||||
}
|
||||
} else if err != nil && strings.Contains(err.Error(), "Captcha required.") {
|
||||
notify.Notify("Goldwarden", fmt.Sprintf("Captcha required"), "", 0, func() {})
|
||||
notify.Notify("Goldwarden", "Captcha required", "", 0, func() {})
|
||||
return LoginResponseToken{}, crypto.MasterKey{}, "", fmt.Errorf("captcha required, please login via the web interface")
|
||||
} else if err != nil {
|
||||
notify.Notify("Goldwarden", fmt.Sprintf("Could not login via password: %v", err), "", 0, func() {})
|
||||
notify.Notify("Goldwarden", fmt.Sprintf("Could not login via password: %s", err.Error()), "", 0, func() {})
|
||||
return LoginResponseToken{}, crypto.MasterKey{}, "", fmt.Errorf("could not login via password: %v", err)
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
@ -105,7 +104,7 @@ func makeAuthenticatedHTTPRequest(ctx context.Context, req *http.Request, recv i
|
||||
return err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
body, err := ioutil.ReadAll(res.Body)
|
||||
body, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ func (pe *Pinentry) Get(arg keybase1.SecretEntryArg) (res *keybase1.SecretEntryR
|
||||
|
||||
func (pi *pinentryInstance) Close() {
|
||||
pi.stdin.Close()
|
||||
pi.cmd.Wait()
|
||||
_ = pi.cmd.Wait()
|
||||
}
|
||||
|
||||
type pinentryInstance struct {
|
||||
@ -123,7 +123,6 @@ func (pi *pinentryInstance) Set(cmd, val string, errp *error) {
|
||||
if string(line) != "OK" {
|
||||
*errp = fmt.Errorf("Response to " + cmd + " was " + string(line))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (pi *pinentryInstance) Init() (err error) {
|
||||
|
@ -42,50 +42,47 @@ func TypeString(textToType string) {
|
||||
var sessionHandle dbus.ObjectPath
|
||||
|
||||
for {
|
||||
select {
|
||||
case message := <-signals:
|
||||
if state == 0 {
|
||||
log.Info("Selecting Devices")
|
||||
result := message.Body[1].(map[string]dbus.Variant)
|
||||
resultSessionHandle := result["session_handle"]
|
||||
sessionHandle = dbus.ObjectPath(resultSessionHandle.String()[1 : len(resultSessionHandle.String())-1])
|
||||
res := obj.Call("org.freedesktop.portal.RemoteDesktop.SelectDevices", 0, sessionHandle, map[string]dbus.Variant{
|
||||
"types": dbus.MakeVariant(uint32(1)),
|
||||
})
|
||||
if res.Err != nil {
|
||||
log.Error("Error selecting devices: %s", res.Err.Error())
|
||||
}
|
||||
state = 1
|
||||
} else if state == 1 {
|
||||
log.Info("Starting Session")
|
||||
res := obj.Call("org.freedesktop.portal.RemoteDesktop.Start", 0, sessionHandle, "", map[string]dbus.Variant{})
|
||||
if res.Err != nil {
|
||||
log.Error("Error starting session: %s", res.Err.Error())
|
||||
}
|
||||
state = 2
|
||||
} else if state == 2 {
|
||||
log.Info("Performing Typing")
|
||||
state = 3
|
||||
time.Sleep(1000 * time.Millisecond)
|
||||
for _, char := range textToType {
|
||||
if char == '\t' {
|
||||
obj.Call("org.freedesktop.portal.RemoteDesktop.NotifyKeyboardKeycode", 0, sessionHandle, map[string]dbus.Variant{}, 15, uint32(1))
|
||||
time.Sleep(autoTypeDelay)
|
||||
obj.Call("org.freedesktop.portal.RemoteDesktop.NotifyKeyboardKeycode", 0, sessionHandle, map[string]dbus.Variant{}, 15, uint32(0))
|
||||
time.Sleep(autoTypeDelay)
|
||||
} else {
|
||||
obj.Call("org.freedesktop.portal.RemoteDesktop.NotifyKeyboardKeysym", 0, sessionHandle, map[string]dbus.Variant{}, int32(char), uint32(1))
|
||||
time.Sleep(autoTypeDelay)
|
||||
obj.Call("org.freedesktop.portal.RemoteDesktop.NotifyKeyboardKeysym", 0, sessionHandle, map[string]dbus.Variant{}, int32(char), uint32(0))
|
||||
time.Sleep(autoTypeDelay)
|
||||
}
|
||||
}
|
||||
bus.Close()
|
||||
return
|
||||
} else {
|
||||
log.Info("State 3")
|
||||
return
|
||||
message := <-signals
|
||||
switch state {
|
||||
case 0:
|
||||
log.Info("Selecting Devices")
|
||||
result := message.Body[1].(map[string]dbus.Variant)
|
||||
resultSessionHandle := result["session_handle"]
|
||||
sessionHandle = dbus.ObjectPath(resultSessionHandle.String()[1 : len(resultSessionHandle.String())-1])
|
||||
res := obj.Call("org.freedesktop.portal.RemoteDesktop.SelectDevices", 0, sessionHandle, map[string]dbus.Variant{
|
||||
"types": dbus.MakeVariant(uint32(1)),
|
||||
})
|
||||
if res.Err != nil {
|
||||
log.Error("Error selecting devices: %s", res.Err.Error())
|
||||
}
|
||||
state = 1
|
||||
case 1:
|
||||
log.Info("Starting Session")
|
||||
res := obj.Call("org.freedesktop.portal.RemoteDesktop.Start", 0, sessionHandle, "", map[string]dbus.Variant{})
|
||||
if res.Err != nil {
|
||||
log.Error("Error starting session: %s", res.Err.Error())
|
||||
}
|
||||
state = 2
|
||||
case 2:
|
||||
log.Info("Performing Typing")
|
||||
time.Sleep(1000 * time.Millisecond)
|
||||
for _, char := range textToType {
|
||||
if char == '\t' {
|
||||
obj.Call("org.freedesktop.portal.RemoteDesktop.NotifyKeyboardKeycode", 0, sessionHandle, map[string]dbus.Variant{}, 15, uint32(1))
|
||||
time.Sleep(autoTypeDelay)
|
||||
obj.Call("org.freedesktop.portal.RemoteDesktop.NotifyKeyboardKeycode", 0, sessionHandle, map[string]dbus.Variant{}, 15, uint32(0))
|
||||
time.Sleep(autoTypeDelay)
|
||||
} else {
|
||||
obj.Call("org.freedesktop.portal.RemoteDesktop.NotifyKeyboardKeysym", 0, sessionHandle, map[string]dbus.Variant{}, int32(char), uint32(1))
|
||||
time.Sleep(autoTypeDelay)
|
||||
obj.Call("org.freedesktop.portal.RemoteDesktop.NotifyKeyboardKeysym", 0, sessionHandle, map[string]dbus.Variant{}, int32(char), uint32(0))
|
||||
time.Sleep(autoTypeDelay)
|
||||
}
|
||||
}
|
||||
bus.Close()
|
||||
return
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
var loginCmd = &cobra.Command{
|
||||
Use: "login",
|
||||
Short: "Starts the login process for Bitwarden",
|
||||
Long: `Starts the login process for Bitwarden.
|
||||
Long: `Starts the login process for Bitwarden.
|
||||
You will be prompted to enter your password, and confirm your second factor if you have one.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
request := messages.DoLoginRequest{}
|
||||
@ -49,6 +49,6 @@ var loginCmd = &cobra.Command{
|
||||
func init() {
|
||||
vaultCmd.AddCommand(loginCmd)
|
||||
loginCmd.PersistentFlags().String("email", "", "")
|
||||
loginCmd.MarkFlagRequired("email")
|
||||
_ = loginCmd.MarkFlagRequired("email")
|
||||
loginCmd.PersistentFlags().Bool("passwordless", false, "")
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/icza/gox/stringsx"
|
||||
@ -17,7 +18,7 @@ var baseLoginCmd = &cobra.Command{
|
||||
Short: "Commands for managing logins.",
|
||||
Long: `Commands for managing logins.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
cmd.Help()
|
||||
_ = cmd.Help()
|
||||
},
|
||||
}
|
||||
|
||||
@ -55,7 +56,7 @@ var getLoginCmd = &cobra.Command{
|
||||
} else {
|
||||
fmt.Println(response.Result.Password)
|
||||
}
|
||||
break
|
||||
return
|
||||
case messages.ActionResponse:
|
||||
fmt.Println("Error: " + resp.(messages.ActionResponse).Message)
|
||||
return
|
||||
|
@ -54,7 +54,7 @@ var runCmd = &cobra.Command{
|
||||
command.Stdout = os.Stdout
|
||||
command.Stderr = os.Stderr
|
||||
command.Stdin = os.Stdin
|
||||
command.Run()
|
||||
_ = command.Run()
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/quexten/goldwarden/ipc/messages"
|
||||
"github.com/spf13/cobra"
|
||||
@ -12,7 +13,7 @@ var sendCmd = &cobra.Command{
|
||||
Short: "Commands for managing sends",
|
||||
Long: `Commands for managing sends.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
cmd.Help()
|
||||
_ = cmd.Help()
|
||||
},
|
||||
}
|
||||
|
||||
@ -42,7 +43,7 @@ var sendCreateCmd = &cobra.Command{
|
||||
switch result.(type) {
|
||||
case messages.CreateSendResponse:
|
||||
fmt.Println("Send created: " + result.(messages.CreateSendResponse).URL)
|
||||
break
|
||||
return
|
||||
case messages.ActionResponse:
|
||||
fmt.Println("Error: " + result.(messages.ActionResponse).Message)
|
||||
return
|
||||
|
@ -23,7 +23,7 @@ var sessionCmd = &cobra.Command{
|
||||
text = strings.TrimSuffix(text, "\n")
|
||||
args := strings.Split(text, " ")
|
||||
rootCmd.SetArgs(args)
|
||||
rootCmd.Execute()
|
||||
_ = rootCmd.Execute()
|
||||
}
|
||||
},
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ var setupCmd = &cobra.Command{
|
||||
Short: "Sets up Goldwarden integrations",
|
||||
Long: "Sets up Goldwarden integrations",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
cmd.Help()
|
||||
_ = cmd.Help()
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/atotto/clipboard"
|
||||
"github.com/quexten/goldwarden/ipc/messages"
|
||||
@ -13,7 +14,7 @@ var sshCmd = &cobra.Command{
|
||||
Short: "Commands for managing SSH keys",
|
||||
Long: `Commands for managing SSH keys.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
cmd.Help()
|
||||
_ = cmd.Help()
|
||||
},
|
||||
}
|
||||
|
||||
@ -52,7 +53,7 @@ var sshAddCmd = &cobra.Command{
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
break
|
||||
return
|
||||
case messages.ActionResponse:
|
||||
fmt.Println("Error: " + result.(messages.ActionResponse).Message)
|
||||
return
|
||||
@ -83,7 +84,7 @@ var listSSHCmd = &cobra.Command{
|
||||
for _, key := range response.Keys {
|
||||
fmt.Println(key)
|
||||
}
|
||||
break
|
||||
return
|
||||
case messages.ActionResponse:
|
||||
fmt.Println("Error: " + result.(messages.ActionResponse).Message)
|
||||
return
|
||||
@ -95,7 +96,7 @@ func init() {
|
||||
rootCmd.AddCommand(sshCmd)
|
||||
sshCmd.AddCommand(sshAddCmd)
|
||||
sshAddCmd.PersistentFlags().String("name", "", "")
|
||||
sshAddCmd.MarkFlagRequired("name")
|
||||
_ = sshAddCmd.MarkFlagRequired("name")
|
||||
sshAddCmd.PersistentFlags().Bool("clipboard", false, "Copy the public key to the clipboard")
|
||||
sshCmd.AddCommand(listSSHCmd)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user