Showing 102 of 102 total issues
Method azureIterator.Next
has 11 return statements (exceeds 4 allowed). Open
Open
func (a *azureIterator) Next() (key vault.StoredKey, err error) {
if a.done {
return nil, vault.ErrDone
}
Function NewServeCommand
has 11 return statements (exceeds 4 allowed). Open
Open
func NewServeCommand(c *Context) *cobra.Command {
var noList bool
serveCmd := cobra.Command{
Use: "serve",
Method Vault.Import
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (v *Vault) Import(ctx context.Context, priv crypt.PrivateKey, opt utils.Options) (vault.StoredKey, error) {
keyName, ok, err := opt.GetString("name")
if err != nil {
return nil, fmt.Errorf("(Azure/%s): %w", v.config.Vault, err)
}
Function NewGenKeyCommand
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func NewGenKeyCommand() *cobra.Command {
var (
keyType string
num int
)
Method App.GetAppVersion
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (a *App) GetAppVersion() (*Version, error) {
res, err := a.Exchange(&APDUCommand{
Cla: claGlobal,
Ins: insVersion,
})
Method Vault.Import
has 9 return statements (exceeds 4 allowed). Open
Open
func (v *Vault) Import(ctx context.Context, priv crypt.PrivateKey, opt utils.Options) (vault.StoredKey, error) {
keyName, ok, err := opt.GetString("name")
if err != nil {
return nil, fmt.Errorf("(Azure/%s): %w", v.config.Vault, err)
}
Method JWT.Authenticate
has 8 return statements (exceeds 4 allowed). Open
Open
func (j *JWT) Authenticate(user string, token string) (string, error) {
var tok *jwt.Token
var err error
ud, ok := j.GetUserData(user)
if ok {
Method Vault.SignMessage
has 8 return statements (exceeds 4 allowed). Open
Open
func (v *Vault) SignMessage(ctx context.Context, message []byte, key vault.StoredKey) (crypt.Signature, error) {
digest := crypt.DigestFunc(message)
azureKey, ok := key.(*azureKey)
if !ok {
return nil, errors.Wrap(fmt.Errorf("(Azure/%s): not a Azure key: %T", v.config.Vault, key), http.StatusBadRequest)
Function NewImportCommand
has 8 return statements (exceeds 4 allowed). Open
Open
func NewImportCommand(c *Context) *cobra.Command {
var (
vaultName string
password string
opt string
Method Vault.request
has 7 return statements (exceeds 4 allowed). Open
Open
func (v *Vault) request(ctx context.Context, client *http.Client, method, url string, body io.Reader, result interface{}) (status int, err error) {
req, err := http.NewRequestWithContext(ctx, method, url, body)
if err != nil {
return status, err
}
Function NewAuthRequestCommand
has 7 return statements (exceeds 4 allowed). Open
Open
func NewAuthRequestCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "authenticate <secret key> <request pkh> <request body>",
Short: "Authenticate (sign) a sign request",
Args: cobra.ExactArgs(3),
Method JWK.PublicKey
has 7 return statements (exceeds 4 allowed). Open
Open
func (j *JWK) PublicKey() (crypto.PublicKey, error) {
switch j.KeyType {
case "EC", "EC-HSM":
pub, err := j.ecPublicKey()
if err != nil {
Method HSM.Import
has 7 return statements (exceeds 4 allowed). Open
Open
func (h *HSM) Import(ctx context.Context, pk crypt.PrivateKey, opt utils.Options) (vault.StoredKey, error) {
typ, alg, caps, p, err := getPrivateKeyData(pk)
if err != nil {
return nil, fmt.Errorf("(YubiHSM/%s): %w", h.conf.id(), err)
}
Method usbHIDRoundTripper.Ping
has 7 return statements (exceeds 4 allowed). Open
Open
func (u *usbHIDRoundTripper) Ping() error {
if err := u.writeCommand(cmdPing, nil); err != nil {
return err
}
ch, cmd, data, err := u.readCommand()
Avoid deeply nested control flow statements. Open
Open
if err = openDev(attempt == 1); err != nil {
r.err <- err
break
}
Method yubihsmStoredKeysIterator.Next
has 7 return statements (exceeds 4 allowed). Open
Open
func (y *yubihsmStoredKeysIterator) Next() (key vault.StoredKey, err error) {
if y.objects == nil {
y.objects, err = y.hsm.listObjects(commands.NewObjectTypeOption(commands.ObjectTypeAsymmetricKey))
if err != nil {
return nil, fmt.Errorf("(YubiHSM/%s): %w", y.hsm.conf.id(), err)
Avoid deeply nested control flow statements. Open
Open
if err == iterator.Done {
c.keyIter = nil
return nil, vault.ErrDone
} else {
return nil, fmt.Errorf("(CloudKMS/%s) ListCryptoKeys: %w", c.vault.config.keyRingName(), err)
Function parsePublicKey
has 7 return statements (exceeds 4 allowed). Open
Open
func parsePublicKey(r *commands.GetPubKeyResponse) (crypt.PublicKey, bool, error) {
switch r.Algorithm {
case commands.AlgorithmP256, commands.AlgorithmSecp256k1:
var curve elliptic.Curve
switch r.Algorithm {
Method Signatory.Import
has 7 return statements (exceeds 4 allowed). Open
Open
func (s *Signatory) Import(ctx context.Context, importerName string, secretKey string, passCB func() ([]byte, error), opt utils.Options) (*PublicKey, error) {
v, ok := s.vaults[importerName]
if !ok {
return nil, fmt.Errorf("import: vault %s is not found", importerName)
}
Method HSM.GetPublicKey
has 7 return statements (exceeds 4 allowed). Open
Open
func (h *HSM) GetPublicKey(ctx context.Context, keyID string) (vault.StoredKey, error) {
id, err := strconv.ParseUint(keyID, 16, 16)
if err != nil {
return nil, fmt.Errorf("(YubiHSM/%s): %w", h.conf.id(), err)
}