Showing 91 of 102 total issues
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)
}
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),
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)
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 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 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 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 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()
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)
}
Avoid deeply nested control flow statements. Open
Open
if err = openDev(attempt == 1); err != nil {
r.err <- err
break
}
Avoid deeply nested control flow statements. Open
Open
if err != nil {
if attempt == 1 {
r.err <- err
} else {
attempt = attempt + 1
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 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)
Function validateSecretAndPass
has 6 return statements (exceeds 4 allowed). Open
Open
func validateSecretAndPass(secret []string) error {
var length int = 16
var stype string = "password"
for _, s := range secret {
// Check length
Function wrapPrivateKey
has 6 return statements (exceeds 4 allowed). Open
Open
func wrapPrivateKey(pubKey *rsa.PublicKey, priv crypt.PrivateKey) ([]byte, error) {
pkcs8Key, err := cryptoutils.MarshalPKCS8PrivateKey(priv)
if err != nil {
return nil, err
}
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
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 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