add uuid check before insering into url

This commit is contained in:
Samuel Lorch 2022-01-21 13:46:26 +01:00
parent f3fe6eb1c5
commit f1122a019c
13 changed files with 162 additions and 12 deletions

View file

@ -3,6 +3,7 @@ package api
import (
"context"
"encoding/json"
"fmt"
)
// GPGKey is a GPGKey
@ -43,6 +44,10 @@ func (c *Client) GetGPGKeys(ctx context.Context, opts *GetGPGKeysOptions) ([]GPG
// GetGPGKey gets a Passbolt GPGKey
func (c *Client) GetGPGKey(ctx context.Context, gpgkeyID string) (*GPGKey, error) {
err := checkUUIDFormat(gpgkeyID)
if err != nil {
return nil, fmt.Errorf("Checking ID format: %w", err)
}
msg, err := c.DoCustomRequest(ctx, "GET", "/gpgkeys/"+gpgkeyID+".json", "v2", nil, nil)
if err != nil {
return nil, err