Showing 91 of 102 total issues
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)
}
Avoid deeply nested control flow statements. Open
Open
if err != nil {
if attempt == 1 {
r.err <- err
} else {
attempt = attempt + 1
Avoid deeply nested control flow statements. Open
Open
if u == "" {
a.done = true
return nil, vault.ErrDone
}
Avoid deeply nested control flow statements. Open
Open
if err != nil {
return nil, fmt.Errorf("(Azure/%s): %w", a.v.config.Vault, err)
}
Method Server.authenticateSignRequest
has 7 return statements (exceeds 4 allowed). Open
Open
func (s *Server) authenticateSignRequest(req *signatory.SignRequest, r *http.Request) error {
v := r.FormValue("authentication")
if v == "" {
return errors.Wrap(stderr.New("missing authentication signature field"), http.StatusUnauthorized)
}
Avoid deeply nested control flow statements. Open
Open
if status != 0 {
err = errors.Wrap(err, status)
}
Method usbHIDRoundTripper.readCommand
has 6 return statements (exceeds 4 allowed). Open
Open
func (u *usbHIDRoundTripper) readCommand() (channel uint16, cmd uint8, data []byte, err error) {
var (
dataLen int
idx uint16
)
Method cloudKMSIterator.Next
has 6 return statements (exceeds 4 allowed). Open
Open
func (c *cloudKMSIterator) Next() (vault.StoredKey, error) {
if c.keyIter == nil {
return nil, vault.ErrDone
}
Method usbHIDRoundTripper.Exchange
has 6 return statements (exceeds 4 allowed). Open
Open
func (u *usbHIDRoundTripper) Exchange(req *APDUCommand) (*APDUResponse, error) {
//fmt.Printf("%#v\n", req)
r := req.Bytes()
if err := u.writeCommand(cmdAPDU, r); err != nil {
return nil, err
Function parseKeyID
has 6 return statements (exceeds 4 allowed). Open
Open
func parseKeyID(s string) (*keyID, error) {
p := strings.SplitN(s, "/", 2)
if len(p) != 2 {
return nil, fmt.Errorf("error parsing key id: %s", s)
}
Method Config.jwtTokenSource
has 6 return statements (exceeds 4 allowed). Open
Open
func (c *Config) jwtTokenSource(ctx context.Context, scopes []string) (oauth2.TokenSource, error) {
var (
pk interface{}
thumbprint []byte
err error
Method Server.signHandler
has 6 return statements (exceeds 4 allowed). Open
Open
func (s *Server) signHandler(w http.ResponseWriter, r *http.Request) {
pkh, err := b58.ParsePublicKeyHash([]byte(mux.Vars(r)["key"]))
if err != nil {
tezosJSONError(w, errors.Wrap(err, http.StatusBadRequest))
return