@@ -231,6 +231,7 @@ func NewServer(cfg Config) (*Server, error) {
|
||||
}
|
||||
|
||||
_, err := cfg.Trust.GetByDomainName(ctx, host)
|
||||
|
||||
return err == nil
|
||||
},
|
||||
func(ctx context.Context, host string) bool {
|
||||
|
||||
@@ -58,13 +58,16 @@ func NewAPIKeyMiddleware(svc *iam.Service, tokenSecret string) func(next http.Ha
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
apiKey, err := svc.APIKeyService.GetAPIKey(ctx, keyID)
|
||||
if err != nil {
|
||||
var errPersonalAPIKeyNotFound *iam.ErrPersonalAPIKeyNotFound
|
||||
var errPersonalAPIKeyExpired *iam.ErrPersonalAPIKeyExpired
|
||||
var (
|
||||
errPersonalAPIKeyNotFound *iam.ErrPersonalAPIKeyNotFound
|
||||
errPersonalAPIKeyExpired *iam.ErrPersonalAPIKeyExpired
|
||||
)
|
||||
|
||||
if errors.As(err, &errPersonalAPIKeyNotFound) || errors.As(err, &errPersonalAPIKeyExpired) {
|
||||
next.ServeHTTP(w, r)
|
||||
|
||||
@@ -42,6 +42,7 @@ func NewIdentityPresenceMiddleware() func(next http.Handler) http.Handler {
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ func NewSessionMiddleware(svc *iam.Service, cookieConfig securecookie.Config) fu
|
||||
if err != nil {
|
||||
securecookie.Clear(w, cookieConfig)
|
||||
next.ServeHTTP(w, r)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -60,17 +61,21 @@ func NewSessionMiddleware(svc *iam.Service, cookieConfig securecookie.Config) fu
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
session, err := svc.SessionService.GetSession(ctx, sessionID)
|
||||
if err != nil {
|
||||
var errSessionNotFound *iam.ErrSessionNotFound
|
||||
var errSessionExpired *iam.ErrSessionExpired
|
||||
var (
|
||||
errSessionNotFound *iam.ErrSessionNotFound
|
||||
errSessionExpired *iam.ErrSessionExpired
|
||||
)
|
||||
|
||||
if errors.As(err, &errSessionNotFound) || errors.As(err, &errSessionExpired) {
|
||||
securecookie.Clear(w, cookieConfig)
|
||||
next.ServeHTTP(w, r)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -83,6 +88,7 @@ func NewSessionMiddleware(svc *iam.Service, cookieConfig securecookie.Config) fu
|
||||
if errors.As(err, &errIdentityNotFound) {
|
||||
securecookie.Clear(w, cookieConfig)
|
||||
next.ServeHTTP(w, r)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -94,6 +94,7 @@ func NewAuthorizeFunc(
|
||||
}
|
||||
|
||||
logger.ErrorCtx(ctx, "cannot authorize", log.Error(err))
|
||||
|
||||
return gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -36,11 +36,13 @@ func Extract(r *http.Request) string {
|
||||
if i := strings.LastIndexByte(xff, ','); i != -1 {
|
||||
xff = xff[i+1:]
|
||||
}
|
||||
|
||||
xff = strings.TrimSpace(xff)
|
||||
|
||||
if ip, _, err := net.SplitHostPort(xff); err == nil {
|
||||
return ip
|
||||
}
|
||||
|
||||
return xff
|
||||
}
|
||||
|
||||
@@ -77,6 +79,7 @@ func parseForwardedFor(header string) string {
|
||||
if ip, _, err := net.SplitHostPort(val); err == nil {
|
||||
return ip
|
||||
}
|
||||
|
||||
return val
|
||||
}
|
||||
|
||||
|
||||
@@ -119,6 +119,7 @@ func TestExtract(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
r := httptest.NewRequest("GET", "/", nil)
|
||||
|
||||
r.RemoteAddr = tt.remoteAddr
|
||||
for k, v := range tt.headers {
|
||||
r.Header.Set(k, v)
|
||||
|
||||
@@ -42,6 +42,7 @@ func NewCompliancePagePresenceMiddleware() func(next http.Handler) http.Handler
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ func NewIDMiddleware(trustSvc *trust.Service, baseURL string) func(next http.Han
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -68,6 +69,7 @@ func NewIDMiddleware(trustSvc *trust.Service, baseURL string) func(next http.Han
|
||||
|
||||
ctx = context.WithValue(ctx, compliancePageKey, compliancePage)
|
||||
next.ServeHTTP(w, r.WithContext(ctx))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -87,6 +89,7 @@ func NewIDMiddleware(trustSvc *trust.Service, baseURL string) func(next http.Han
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -97,6 +100,7 @@ func NewIDMiddleware(trustSvc *trust.Service, baseURL string) func(next http.Han
|
||||
if compliancePage.Active {
|
||||
ctx = context.WithValue(ctx, compliancePageKey, compliancePage)
|
||||
next.ServeHTTP(w, r.WithContext(ctx))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ func NewMemberProvisioningMiddleware(trustSvc *trust.Service, logger *log.Logger
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ func NewSNIMiddleware(trustSvc *trust.Service) func(next http.Handler) http.Hand
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -72,6 +73,7 @@ func NewSNIMiddleware(trustSvc *trust.Service) func(next http.Handler) http.Hand
|
||||
if compliancePage.Active {
|
||||
ctx = context.WithValue(ctx, compliancePageKey, compliancePage)
|
||||
next.ServeHTTP(w, r.WithContext(ctx))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -119,6 +119,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewPersonalAPIKey(personalAPIKey), nil
|
||||
}
|
||||
case coredata.SCIMConfigurationEntityType:
|
||||
@@ -128,6 +129,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewSCIMConfiguration(scimConfiguration), nil
|
||||
}
|
||||
case coredata.SCIMEventEntityType:
|
||||
@@ -137,6 +139,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewSCIMEvent(scimEvent), nil
|
||||
}
|
||||
default:
|
||||
@@ -174,6 +177,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load node", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -44,5 +44,6 @@ func NewGraphQLHandler(svc *iam.Service, logger *log.Logger, baseURL *baseurl.Ba
|
||||
|
||||
es := schema.NewExecutableSchema(config)
|
||||
gqlh := gqlutils.NewHandler(es, logger)
|
||||
|
||||
return gqlh
|
||||
}
|
||||
|
||||
@@ -168,9 +168,11 @@ func (r *identityResolver) SsoLoginURL(ctx context.Context, obj *types.Identity)
|
||||
r.logger.ErrorCtx(ctx, "cannot find SAML config")
|
||||
return nil, gqlutils.NotFoundf(ctx, "cannot find SAML config")
|
||||
}
|
||||
|
||||
samlConfig := samlConfigs[0]
|
||||
|
||||
loginURL := r.SSOLoginURL(samlConfig.ID)
|
||||
|
||||
return &loginURL, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -36,8 +36,10 @@ func (r *mutationResolver) InviteUser(ctx context.Context, input types.InviteUse
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
var errOrganizationNotFound *iam.ErrOrganizationNotFound
|
||||
var errUserAlreadyExists *iam.ErrUserAlreadyExists
|
||||
var (
|
||||
errOrganizationNotFound *iam.ErrOrganizationNotFound
|
||||
errUserAlreadyExists *iam.ErrUserAlreadyExists
|
||||
)
|
||||
|
||||
if errors.As(err, &errOrganizationNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
@@ -48,6 +50,7 @@ func (r *mutationResolver) InviteUser(ctx context.Context, input types.InviteUse
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot invite user", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ func (r *membershipResolver) LastSession(ctx context.Context, obj *types.Members
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get active session for membership", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -89,6 +89,7 @@ func toOAuth2Error(err error) *oauth2server.OAuth2Error {
|
||||
if oauthErr, ok := errors.AsType[*oauth2server.OAuth2Error](err); ok {
|
||||
return oauthErr
|
||||
}
|
||||
|
||||
return oauth2server.NewError(oauth2server.ErrServerError, oauth2server.WithDescription("internal error"))
|
||||
}
|
||||
}
|
||||
@@ -108,12 +109,15 @@ func redirectWithError(w http.ResponseWriter, r *http.Request, redirectURI, stat
|
||||
|
||||
q := u.Query()
|
||||
q.Set("error", oauthErr.ErrorCode())
|
||||
|
||||
if desc := oauthErr.Description(); desc != "" {
|
||||
q.Set("error_description", desc)
|
||||
}
|
||||
|
||||
if state != "" {
|
||||
q.Set("state", state)
|
||||
}
|
||||
|
||||
u.RawQuery = q.Encode()
|
||||
|
||||
http.Redirect(w, r, u.String(), http.StatusFound)
|
||||
|
||||
@@ -98,6 +98,7 @@ func (h *OAuth2Handler) BearerTokenMiddleware(next http.Handler) http.Handler {
|
||||
if err != nil {
|
||||
w.Header().Set("WWW-Authenticate", `Bearer error="invalid_token"`)
|
||||
http.Error(w, "unauthorized", http.StatusUnauthorized)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -105,6 +106,7 @@ func (h *OAuth2Handler) BearerTokenMiddleware(next http.Handler) http.Handler {
|
||||
if err != nil {
|
||||
w.Header().Set("WWW-Authenticate", `Bearer error="invalid_token"`)
|
||||
http.Error(w, "unauthorized", http.StatusUnauthorized)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -160,6 +162,7 @@ func (h *OAuth2Handler) AuthorizeHandler(w http.ResponseWriter, r *http.Request)
|
||||
WithQuery("continue", continueURL).
|
||||
MustString()
|
||||
http.Redirect(w, r, loginURL, http.StatusFound)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -170,6 +173,7 @@ func (h *OAuth2Handler) AuthorizeHandler(w http.ResponseWriter, r *http.Request)
|
||||
}
|
||||
|
||||
session := authn.SessionFromContext(r.Context())
|
||||
|
||||
authTime := time.Now()
|
||||
if session != nil {
|
||||
authTime = session.CreatedAt
|
||||
@@ -197,12 +201,14 @@ func (h *OAuth2Handler) AuthorizeHandler(w http.ResponseWriter, r *http.Request)
|
||||
WithQuery("consent_id", consentErr.ConsentID.String()).
|
||||
MustString()
|
||||
http.Redirect(w, r, consentURL, http.StatusFound)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
oauthErr := toOAuth2Error(err)
|
||||
h.handleAuthorizeError(w, r, oauthErr, in.RedirectURI, in.State)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -282,6 +288,7 @@ func (h *OAuth2Handler) RevokeHandler(w http.ResponseWriter, r *http.Request) {
|
||||
h.logger.ErrorCtx(r.Context(), "cannot revoke token", log.Error(err))
|
||||
w.Header().Set("Retry-After", "30")
|
||||
w.WriteHeader(http.StatusServiceUnavailable)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -340,21 +347,26 @@ func (h *OAuth2Handler) RegisterHandler(w http.ResponseWriter, r *http.Request)
|
||||
r,
|
||||
oauth2server.NewError(oauth2server.ErrInvalidRequest, oauth2server.WithDescription("invalid JSON body")),
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if len(in.GrantTypes) == 0 {
|
||||
in.GrantTypes = []coredata.OAuth2GrantType{coredata.OAuth2GrantTypeAuthorizationCode}
|
||||
}
|
||||
|
||||
if len(in.ResponseTypes) == 0 {
|
||||
in.ResponseTypes = []coredata.OAuth2ResponseType{coredata.OAuth2ResponseTypeCode}
|
||||
}
|
||||
|
||||
if in.TokenEndpointAuthMethod == "" {
|
||||
in.TokenEndpointAuthMethod = coredata.OAuth2ClientTokenEndpointAuthMethodClientSecretBasic
|
||||
}
|
||||
|
||||
if in.Visibility == "" {
|
||||
in.Visibility = coredata.OAuth2ClientVisibilityPrivate
|
||||
}
|
||||
|
||||
if len(in.Scopes) == 0 {
|
||||
in.Scopes = coredata.OAuth2Scopes{
|
||||
coredata.OAuth2ScopeOpenID,
|
||||
@@ -539,9 +551,11 @@ func redirectWithCode(w http.ResponseWriter, r *http.Request, redirectURI, code,
|
||||
u, _ := url.Parse(redirectURI)
|
||||
q := u.Query()
|
||||
q.Set("code", code)
|
||||
|
||||
if state != "" {
|
||||
q.Set("state", state)
|
||||
}
|
||||
|
||||
u.RawQuery = q.Encode()
|
||||
|
||||
http.Redirect(w, r, u.String(), http.StatusFound)
|
||||
|
||||
@@ -50,6 +50,7 @@ func (r *mutationResolver) AuthorizeDevice(ctx context.Context, input types.Auth
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot authorize device", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -89,12 +90,15 @@ func (r *mutationResolver) ApproveConsent(ctx context.Context, input types.Appro
|
||||
q := u.Query()
|
||||
q.Set("error", "access_denied")
|
||||
q.Set("error_description", "user denied the request")
|
||||
|
||||
if result.State != "" {
|
||||
q.Set("state", result.State)
|
||||
}
|
||||
|
||||
u.RawQuery = q.Encode()
|
||||
|
||||
redirectURL := u.String()
|
||||
|
||||
return &types.ApproveConsentPayload{
|
||||
RedirectURL: &redirectURL,
|
||||
}, nil
|
||||
@@ -109,12 +113,15 @@ func (r *mutationResolver) ApproveConsent(ctx context.Context, input types.Appro
|
||||
u, _ := url.Parse(result.RedirectURI)
|
||||
q := u.Query()
|
||||
q.Set("code", result.Code)
|
||||
|
||||
if result.State != "" {
|
||||
q.Set("state", result.State)
|
||||
}
|
||||
|
||||
u.RawQuery = q.Encode()
|
||||
|
||||
redirectURL := u.String()
|
||||
|
||||
return &types.ApproveConsentPayload{
|
||||
RedirectURL: &redirectURL,
|
||||
}, nil
|
||||
|
||||
@@ -81,6 +81,7 @@ func (h *OIDCHandler) LoginHandler(w http.ResponseWriter, r *http.Request) {
|
||||
if err != nil {
|
||||
h.logger.ErrorCtx(ctx, "cannot initiate OIDC login", log.Error(err))
|
||||
httpserver.RenderError(w, http.StatusInternalServerError, errors.New("internal server error"))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -105,6 +106,7 @@ func (h *OIDCHandler) CallbackHandler(w http.ResponseWriter, r *http.Request) {
|
||||
log.String("error_description", r.URL.Query().Get("error_description")),
|
||||
)
|
||||
httpserver.RenderError(w, http.StatusUnauthorized, errors.New("authentication failed"))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -120,6 +122,7 @@ func (h *OIDCHandler) CallbackHandler(w http.ResponseWriter, r *http.Request) {
|
||||
if err != nil {
|
||||
h.logger.ErrorCtx(ctx, "cannot handle OIDC callback", log.Error(err))
|
||||
httpserver.RenderError(w, http.StatusUnauthorized, errors.New("authentication failed"))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -131,6 +134,7 @@ func (h *OIDCHandler) CallbackHandler(w http.ResponseWriter, r *http.Request) {
|
||||
if err != nil {
|
||||
h.logger.ErrorCtx(ctx, "cannot open root session", log.Error(err))
|
||||
httpserver.RenderError(w, http.StatusInternalServerError, errors.New("internal server error"))
|
||||
|
||||
return
|
||||
}
|
||||
case rootSession.IdentityID != identity.ID:
|
||||
@@ -138,6 +142,7 @@ func (h *OIDCHandler) CallbackHandler(w http.ResponseWriter, r *http.Request) {
|
||||
if err != nil {
|
||||
h.logger.ErrorCtx(ctx, "cannot close session", log.Error(err))
|
||||
httpserver.RenderError(w, http.StatusInternalServerError, errors.New("internal server error"))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -145,6 +150,7 @@ func (h *OIDCHandler) CallbackHandler(w http.ResponseWriter, r *http.Request) {
|
||||
if err != nil {
|
||||
h.logger.ErrorCtx(ctx, "cannot open root session", log.Error(err))
|
||||
httpserver.RenderError(w, http.StatusInternalServerError, errors.New("internal server error"))
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ func (r *mutationResolver) CreateOrganization(ctx context.Context, input types.C
|
||||
Size: input.HorizontalLogoFile.Size,
|
||||
}
|
||||
}
|
||||
|
||||
organization, profile, err := r.iam.OrganizationService.CreateOrganization(
|
||||
ctx,
|
||||
identity.ID,
|
||||
@@ -71,6 +72,7 @@ func (r *mutationResolver) CreateOrganization(ctx context.Context, input types.C
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -267,6 +269,7 @@ func (r *organizationResolver) ScimConfiguration(ctx context.Context, obj *types
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get scim configuration", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -307,16 +310,20 @@ func (r *organizationResolver) AuditLogEntries(ctx context.Context, obj *types.O
|
||||
c := cursor.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
coredataFilter := coredata.NewAuditLogEntryFilter()
|
||||
|
||||
if filter != nil {
|
||||
if filter.Action != nil {
|
||||
coredataFilter.WithAction(*filter.Action)
|
||||
}
|
||||
|
||||
if filter.ActorID != nil {
|
||||
coredataFilter.WithActorID(*filter.ActorID)
|
||||
}
|
||||
|
||||
if filter.ResourceType != nil {
|
||||
coredataFilter.WithResourceType(*filter.ResourceType)
|
||||
}
|
||||
|
||||
if filter.ResourceID != nil {
|
||||
coredataFilter.WithResourceID(*filter.ResourceID)
|
||||
}
|
||||
@@ -347,6 +354,7 @@ func (r *organizationResolver) Viewer(ctx context.Context, obj *types.Organizati
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get profile", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -99,6 +99,7 @@ func (r *personalAPIKeyConnectionResolver) TotalCount(ctx context.Context, obj *
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver", log.Any("resolver", obj.Resolver))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ func (r *mutationResolver) CreateUser(ctx context.Context, input types.CreateUse
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create user", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -66,7 +67,6 @@ func (r *mutationResolver) DeactivateUser(ctx context.Context, input types.Deact
|
||||
input.ProfileID,
|
||||
coredata.ProfileStateInactive,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot deactivate profile", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -113,8 +113,10 @@ func (r *mutationResolver) RemoveUser(ctx context.Context, input types.RemoveUse
|
||||
|
||||
err := r.iam.OrganizationService.RemoveUser(ctx, input.OrganizationID, input.ProfileID)
|
||||
if err != nil {
|
||||
var errManagedBySCIM *iam.ErrUserManagedBySCIM
|
||||
var errLastActiveOwner *iam.ErrLastActiveOwner
|
||||
var (
|
||||
errManagedBySCIM *iam.ErrUserManagedBySCIM
|
||||
errLastActiveOwner *iam.ErrLastActiveOwner
|
||||
)
|
||||
|
||||
if errors.As(err, &errManagedBySCIM) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
@@ -125,6 +127,7 @@ func (r *mutationResolver) RemoveUser(ctx context.Context, input types.RemoveUse
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot remove user from organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -150,6 +153,7 @@ func (r *profileResolver) Identity(ctx context.Context, obj *types.Profile) (*ty
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get identity", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -170,6 +174,7 @@ func (r *profileResolver) Organization(ctx context.Context, obj *types.Profile)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -190,6 +195,7 @@ func (r *profileResolver) Membership(ctx context.Context, obj *types.Profile) (*
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get membership", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -232,6 +238,7 @@ func (r *profileConnectionResolver) TotalCount(ctx context.Context, obj *types.P
|
||||
r.logger.ErrorCtx(ctx, "cannot count profiles", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return &count, nil
|
||||
case *organizationResolver:
|
||||
count, err := r.iam.OrganizationService.CountProfiles(ctx, obj.ParentID, obj.Filters)
|
||||
@@ -239,10 +246,12 @@ func (r *profileConnectionResolver) TotalCount(ctx context.Context, obj *types.P
|
||||
r.logger.ErrorCtx(ctx, "cannot count profiles", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return &count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver", log.Any("resolver", obj.Resolver))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -100,9 +100,9 @@ func (h *SAMLHandler) ConsumeHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
continueURL := "/organizations/" + membership.OrganizationID.String()
|
||||
|
||||
if len(relayState) > gid.EncodedGIDSize {
|
||||
unescapedContinueURL, err := url.QueryUnescape(relayState[gid.EncodedGIDSize:])
|
||||
|
||||
if err != nil {
|
||||
h.logger.WarnCtx(ctx, "cannot unescape continue URL from RelayState", log.Error(err))
|
||||
} else {
|
||||
@@ -118,6 +118,7 @@ func (h *SAMLHandler) ConsumeHandler(w http.ResponseWriter, r *http.Request) {
|
||||
if err != nil {
|
||||
h.logger.ErrorCtx(ctx, "cannot open root session", log.Error(err))
|
||||
h.renderInternalServerError(w)
|
||||
|
||||
return
|
||||
}
|
||||
case rootSession.IdentityID != user.ID:
|
||||
@@ -125,6 +126,7 @@ func (h *SAMLHandler) ConsumeHandler(w http.ResponseWriter, r *http.Request) {
|
||||
if err != nil {
|
||||
h.logger.ErrorCtx(ctx, "cannot close session", log.Error(err))
|
||||
h.renderInternalServerError(w)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -132,6 +134,7 @@ func (h *SAMLHandler) ConsumeHandler(w http.ResponseWriter, r *http.Request) {
|
||||
if err != nil {
|
||||
h.logger.ErrorCtx(ctx, "cannot open root session", log.Error(err))
|
||||
h.renderInternalServerError(w)
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -140,6 +143,7 @@ func (h *SAMLHandler) ConsumeHandler(w http.ResponseWriter, r *http.Request) {
|
||||
if err != nil {
|
||||
h.logger.ErrorCtx(ctx, "cannot open SAML child session", log.Error(err))
|
||||
h.renderInternalServerError(w)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@ func (r *mutationResolver) CreateSAMLConfiguration(ctx context.Context, input ty
|
||||
input.OrganizationID,
|
||||
req,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
var errSAMLConfigurationEmailDomainAlreadyExists *iam.ErrSAMLConfigurationEmailDomainAlreadyExists
|
||||
if errors.As(err, &errSAMLConfigurationEmailDomainAlreadyExists) {
|
||||
@@ -51,6 +50,7 @@ func (r *mutationResolver) CreateSAMLConfiguration(ctx context.Context, input ty
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create saml configuration", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -133,10 +133,12 @@ func (r *sAMLConfigurationConnectionResolver) TotalCount(ctx context.Context, ob
|
||||
r.logger.ErrorCtx(ctx, "cannot count saml configurations", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return &count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver", log.Any("resolver", obj.Resolver))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -139,6 +139,7 @@ func (h *SCIMHandler) BearerTokenMiddleware(next http.Handler) http.Handler {
|
||||
|
||||
h.logger.ErrorCtx(r.Context(), "SCIM token validation error", log.Error(err))
|
||||
httpserver.RenderError(w, http.StatusInternalServerError, errors.New("internal server error"))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -157,13 +158,17 @@ func (rc *scimRequestContext) logAndWrapError(err error, logMsg string) error {
|
||||
if scimErr.Status == http.StatusNotFound {
|
||||
userName = ""
|
||||
}
|
||||
|
||||
rc.handler.handler.iam.SCIMService.LogEvent(rc.ctx, rc.config, rc.method, rc.path, userName, rc.ipAddress, scimErr.Status, &errMsg)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
rc.handler.handler.logger.ErrorCtx(rc.ctx, logMsg, log.Error(err))
|
||||
|
||||
errMsg := "internal server error"
|
||||
rc.handler.handler.iam.SCIMService.LogEvent(rc.ctx, rc.config, rc.method, rc.path, rc.userName, rc.ipAddress, 500, &errMsg)
|
||||
|
||||
return scimerrors.ScimErrorInternal
|
||||
}
|
||||
|
||||
@@ -236,6 +241,7 @@ func (h *scimResourceHandler) GetAll(r *http.Request, params scim.ListRequestPar
|
||||
}
|
||||
|
||||
var filterExpr scimfilter.Expression
|
||||
|
||||
if params.FilterValidator != nil {
|
||||
if err := params.FilterValidator.Validate(); err != nil {
|
||||
return scim.Page{}, rc.logAndWrapError(scimerrors.ScimErrorBadRequest(err.Error()), "invalid filter")
|
||||
@@ -250,6 +256,7 @@ func (h *scimResourceHandler) GetAll(r *http.Request, params scim.ListRequestPar
|
||||
}
|
||||
|
||||
rc.logSuccess(200)
|
||||
|
||||
return scim.Page{
|
||||
TotalResults: totalCount,
|
||||
Resources: resources,
|
||||
|
||||
@@ -44,6 +44,7 @@ func (r *mutationResolver) CreateSCIMConfiguration(ctx context.Context, input ty
|
||||
r.logger.ErrorCtx(ctx, "cannot create scim bridge", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
bridge = types.NewSCIMBridge(scimBridge)
|
||||
}
|
||||
|
||||
@@ -188,6 +189,7 @@ func (r *sCIMConfigurationResolver) Organization(ctx context.Context, obj *types
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization for scim configuration", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -212,6 +214,7 @@ func (r *sCIMConfigurationResolver) Bridge(ctx context.Context, obj *types.SCIMC
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get scim bridge", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -267,10 +270,12 @@ func (r *sCIMEventConnectionResolver) TotalCount(ctx context.Context, obj *types
|
||||
r.logger.ErrorCtx(ctx, "cannot count scim events", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return &count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver", log.Any("resolver", obj.Resolver))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ func (r *mutationResolver) SignIn(ctx context.Context, input types.SignInInput)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot check credentials", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -46,6 +47,7 @@ func (r *mutationResolver) SignIn(ctx context.Context, input types.SignInInput)
|
||||
switch {
|
||||
case session == nil:
|
||||
var err error
|
||||
|
||||
session, err = r.iam.AuthService.OpenSessionWithPassword(
|
||||
ctx,
|
||||
identity.ID,
|
||||
@@ -75,17 +77,21 @@ func (r *mutationResolver) SignIn(ctx context.Context, input types.SignInInput)
|
||||
|
||||
if input.OrganizationID != nil {
|
||||
var err error
|
||||
|
||||
_, _, err = r.iam.SessionService.OpenPasswordChildSessionForOrganization(ctx, session.ID, *input.OrganizationID)
|
||||
if err != nil {
|
||||
// Here session middleware already took care of expired/nil root session so we only handle membership related errors
|
||||
var errMembershipNotFound *iam.ErrMembershipNotFound
|
||||
var errUserInactive *iam.ErrUserInactive
|
||||
var (
|
||||
errMembershipNotFound *iam.ErrMembershipNotFound
|
||||
errUserInactive *iam.ErrUserInactive
|
||||
)
|
||||
|
||||
if errors.As(err, &errMembershipNotFound) || errors.As(err, &errUserInactive) {
|
||||
return nil, gqlutils.Forbiddenf(ctx, "forbidden")
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot assume organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
}
|
||||
@@ -118,6 +124,7 @@ func (r *mutationResolver) SignUp(ctx context.Context, input types.SignUpInput)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create identity with password", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -141,6 +148,7 @@ func (r *mutationResolver) SignOut(ctx context.Context) (*types.SignOutPayload,
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot close session", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -163,7 +171,6 @@ func (r *mutationResolver) ActivateAccount(ctx context.Context, input types.Acti
|
||||
r.logger.ErrorCtx(ctx, "cannot close session", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
w := gqlutils.HTTPResponseWriterFromContext(ctx)
|
||||
@@ -196,10 +203,12 @@ func (r *mutationResolver) ActivateAccount(ctx context.Context, input types.Acti
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot activate account from invitation", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
var ssoLoginURL *string
|
||||
|
||||
samlConfigs, err := r.iam.AccountService.ListSAMLConfigurationsForEmail(ctx, user.EmailAddress)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot list saml configurations", log.Error(err))
|
||||
@@ -223,6 +232,7 @@ func (r *mutationResolver) ActivateAccount(ctx context.Context, input types.Acti
|
||||
}
|
||||
|
||||
var createPasswordToken *string
|
||||
|
||||
if identity.HashedPassword == nil {
|
||||
token, err := r.iam.AuthService.GetResetPasswordToken(ctx, identity.EmailAddress)
|
||||
if err != nil {
|
||||
@@ -272,6 +282,7 @@ func (r *mutationResolver) ResetPassword(ctx context.Context, input types.ResetP
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot reset password", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -307,6 +318,7 @@ func (r *mutationResolver) VerifyEmail(ctx context.Context, input types.VerifyEm
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot verify email", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -344,6 +356,7 @@ func (r *mutationResolver) ChangePassword(ctx context.Context, input types.Chang
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot change password", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -379,6 +392,7 @@ func (r *mutationResolver) ChangeEmail(ctx context.Context, input types.ChangeEm
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot change email", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -447,6 +461,7 @@ func (r *mutationResolver) RevokeSession(ctx context.Context, input types.Revoke
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot revoke session", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -506,6 +521,7 @@ func (r *sessionConnectionResolver) TotalCount(ctx context.Context, obj *types.S
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver", log.Any("resolver", obj.Resolver))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ func parseScopes(s string) (coredata.OAuth2Scopes, error) {
|
||||
if err := scopes.UnmarshalText([]byte(s)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return scopes, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
|
||||
func NewPageInfo[T page.Paginable[O], O page.OrderField](p *page.Page[T, O]) *PageInfo {
|
||||
data := pageinfo.NewPageInfo(p)
|
||||
|
||||
return &PageInfo{
|
||||
HasNextPage: data.HasNextPage,
|
||||
HasPreviousPage: data.HasPreviousPage,
|
||||
|
||||
@@ -34,6 +34,7 @@ func (r *accessEntryResolver) Campaign(ctx context.Context, obj *types.AccessEnt
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot get access review campaign: %w", err))
|
||||
}
|
||||
|
||||
@@ -53,6 +54,7 @@ func (r *accessEntryResolver) AccessSource(ctx context.Context, obj *types.Acces
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot get access source: %w", err))
|
||||
}
|
||||
|
||||
@@ -96,12 +98,15 @@ func (r *accessEntryConnectionResolver) TotalCount(ctx context.Context, obj *typ
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot count access entries: %w", err))
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
count, err := r.accessReview.Entries(scope).CountForCampaignID(ctx, obj.ParentID, obj.Filter)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot count access entries: %w", err))
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
@@ -248,6 +253,7 @@ func (r *accessReviewCampaignResolver) Entries(ctx context.Context, obj *types.A
|
||||
} else {
|
||||
p, err = r.accessReview.Entries(scope).ListForCampaignID(ctx, obj.ID, cursor, filter)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list access entries: %w", err))
|
||||
}
|
||||
@@ -302,6 +308,7 @@ func (r *accessReviewCampaignConnectionResolver) TotalCount(ctx context.Context,
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot count access review campaigns: %w", err))
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
@@ -335,6 +342,7 @@ func (r *accessReviewCampaignScopeSourceResolver) Entries(ctx context.Context, o
|
||||
}
|
||||
|
||||
sourceID := obj.ID
|
||||
|
||||
return types.NewAccessEntryConnection(p, r, obj.CampaignID, &sourceID, filter), nil
|
||||
}
|
||||
|
||||
@@ -372,6 +380,7 @@ func (r *accessSourceResolver) Connector(ctx context.Context, obj *types.AccessS
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot get connector: %w", err))
|
||||
}
|
||||
|
||||
@@ -395,6 +404,7 @@ func (r *accessSourceResolver) ProviderOrganizations(ctx context.Context, obj *t
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return []*types.ProviderOrganization{}, nil
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("cannot get connector HTTP client: %w", err)
|
||||
}
|
||||
|
||||
@@ -412,6 +422,7 @@ func (r *accessSourceResolver) ProviderOrganizations(ctx context.Context, obj *t
|
||||
for i, o := range orgs {
|
||||
result[i] = &types.ProviderOrganization{Slug: o.Slug, DisplayName: o.DisplayName}
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -437,6 +448,7 @@ func (r *accessSourceResolver) NeedsConfiguration(ctx context.Context, obj *type
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot get connector: %w", err))
|
||||
}
|
||||
|
||||
@@ -444,6 +456,7 @@ func (r *accessSourceResolver) NeedsConfiguration(ctx context.Context, obj *type
|
||||
if !ok || !cfg.NeedsPicker {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
return cfg.SelectedSlug(dbConnector) == "", nil
|
||||
}
|
||||
|
||||
@@ -460,6 +473,7 @@ func (r *accessSourceResolver) ConnectionStatus(ctx context.Context, obj *types.
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return types.AccessSourceConnectionStatusNotApplicable, nil
|
||||
}
|
||||
|
||||
return types.AccessSourceConnectionStatusDisconnected, nil
|
||||
}
|
||||
|
||||
@@ -495,6 +509,7 @@ func (r *accessSourceResolver) SelectedOrganization(ctx context.Context, obj *ty
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot get connector: %w", err))
|
||||
}
|
||||
|
||||
@@ -502,10 +517,12 @@ func (r *accessSourceResolver) SelectedOrganization(ctx context.Context, obj *ty
|
||||
if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
slug := cfg.SelectedSlug(dbConnector)
|
||||
if slug == "" {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return &slug, nil
|
||||
}
|
||||
|
||||
@@ -524,6 +541,7 @@ func (r *accessSourceConnectionResolver) TotalCount(ctx context.Context, obj *ty
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot count access sources: %w", err))
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
@@ -568,9 +586,11 @@ func (r *mutationResolver) UpdateAccessSource(ctx context.Context, input types.U
|
||||
if input.Name.IsSet() {
|
||||
req.Name = input.Name.Value()
|
||||
}
|
||||
|
||||
if input.ConnectorID.IsSet() {
|
||||
req.ConnectorID = gqlutils.UnwrapOmittable(input.ConnectorID)
|
||||
}
|
||||
|
||||
if input.CSVData.IsSet() {
|
||||
req.CsvData = gqlutils.UnwrapOmittable(input.CSVData)
|
||||
}
|
||||
@@ -580,6 +600,7 @@ func (r *mutationResolver) UpdateAccessSource(ctx context.Context, input types.U
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot update access source: %w", err))
|
||||
}
|
||||
|
||||
@@ -600,6 +621,7 @@ func (r *mutationResolver) DeleteAccessSource(ctx context.Context, input types.D
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot delete access source: %w", err))
|
||||
}
|
||||
|
||||
@@ -627,6 +649,7 @@ func (r *mutationResolver) ConfigureAccessSource(ctx context.Context, input type
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot configure access source: %w", err))
|
||||
}
|
||||
|
||||
@@ -678,9 +701,11 @@ func (r *mutationResolver) UpdateAccessReviewCampaign(ctx context.Context, input
|
||||
if input.Name.IsSet() {
|
||||
req.Name = input.Name.Value()
|
||||
}
|
||||
|
||||
if input.Description.IsSet() {
|
||||
req.Description = input.Description.Value()
|
||||
}
|
||||
|
||||
if input.FrameworkControls.IsSet() {
|
||||
controls := input.FrameworkControls.Value()
|
||||
req.FrameworkControls = &controls
|
||||
@@ -691,6 +716,7 @@ func (r *mutationResolver) UpdateAccessReviewCampaign(ctx context.Context, input
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot update access review campaign: %w", err))
|
||||
}
|
||||
|
||||
@@ -711,6 +737,7 @@ func (r *mutationResolver) DeleteAccessReviewCampaign(ctx context.Context, input
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot delete access review campaign: %w", err))
|
||||
}
|
||||
|
||||
@@ -850,6 +877,7 @@ func (r *mutationResolver) RecordAccessEntryDecision(ctx context.Context, input
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot record access entry decision: %w", err))
|
||||
}
|
||||
|
||||
@@ -893,6 +921,7 @@ func (r *mutationResolver) RecordAccessEntryDecisions(ctx context.Context, input
|
||||
decisions := make([]accessreview.RecordAccessEntryDecisionRequest, len(input.Decisions))
|
||||
for i, d := range input.Decisions {
|
||||
var decidedByID *gid.GID
|
||||
|
||||
organizationID, err := r.accessReview.ResolveEntryOrganizationID(ctx, d.AccessEntryID)
|
||||
if err == nil {
|
||||
if cached, ok := profileCache[organizationID]; ok {
|
||||
@@ -902,6 +931,7 @@ func (r *mutationResolver) RecordAccessEntryDecisions(ctx context.Context, input
|
||||
if err == nil {
|
||||
decidedByID = &profile.ID
|
||||
}
|
||||
|
||||
profileCache[organizationID] = decidedByID
|
||||
}
|
||||
}
|
||||
@@ -919,6 +949,7 @@ func (r *mutationResolver) RecordAccessEntryDecisions(ctx context.Context, input
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot record access entry decisions: %w", err))
|
||||
}
|
||||
|
||||
@@ -949,6 +980,7 @@ func (r *mutationResolver) FlagAccessEntry(ctx context.Context, input types.Flag
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot flag access entry: %w", err))
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ func (r *assetResolver) Owner(ctx context.Context, obj *types.Asset) (*types.Pro
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get owner", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -84,7 +85,6 @@ func (r *assetResolver) Organization(ctx context.Context, obj *types.Asset) (*ty
|
||||
|
||||
asset, err := prb.Assets.Get(ctx, obj.ID)
|
||||
if err != nil {
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load audit", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
@@ -96,6 +96,7 @@ func (r *assetResolver) Organization(ctx context.Context, obj *types.Asset) (*ty
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -122,10 +123,12 @@ func (r *assetConnectionResolver) TotalCount(ctx context.Context, obj *types.Ass
|
||||
r.logger.ErrorCtx(ctx, "cannot count assets", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -194,6 +197,7 @@ func (r *datumResolver) Organization(ctx context.Context, obj *types.Datum) (*ty
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -220,10 +224,12 @@ func (r *datumConnectionResolver) TotalCount(ctx context.Context, obj *types.Dat
|
||||
r.logger.ErrorCtx(ctx, "cannot count data", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -247,12 +253,13 @@ func (r *mutationResolver) CreateAsset(ctx context.Context, input types.CreateAs
|
||||
ThirdPartyIDs: input.ThirdPartyIds,
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create asset", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -285,7 +292,9 @@ func (r *mutationResolver) UpdateAsset(ctx context.Context, input types.UpdateAs
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update asset", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -331,12 +340,13 @@ func (r *mutationResolver) CreateDatum(ctx context.Context, input types.CreateDa
|
||||
ThirdPartyIDs: input.ThirdPartyIds,
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create datum", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -363,12 +373,13 @@ func (r *mutationResolver) UpdateDatum(ctx context.Context, input types.UpdateDa
|
||||
ThirdPartyIDs: input.ThirdPartyIds,
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update datum", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -408,10 +419,13 @@ func (r *mutationResolver) PublishDataList(ctx context.Context, input types.Publ
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
|
||||
return nil, gqlutils.Invalid(ctx, errMinor)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot publish data list", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -434,10 +448,13 @@ func (r *mutationResolver) PublishAssetList(ctx context.Context, input types.Pub
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
|
||||
return nil, gqlutils.Invalid(ctx, errMinor)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot publish asset list", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ func (r *auditResolver) Organization(ctx context.Context, obj *types.Audit) (*ty
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -60,6 +61,7 @@ func (r *auditResolver) Framework(ctx context.Context, obj *types.Audit) (*types
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load framework", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -85,6 +87,7 @@ func (r *auditResolver) Report(ctx context.Context, obj *types.Audit) (*types.Re
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load report", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -212,6 +215,7 @@ func (r *auditConnectionResolver) TotalCount(ctx context.Context, obj *types.Aud
|
||||
r.logger.ErrorCtx(ctx, "cannot count audits", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *findingResolver:
|
||||
count, err := prb.Audits.CountForFindingID(ctx, obj.ParentID)
|
||||
@@ -219,6 +223,7 @@ func (r *auditConnectionResolver) TotalCount(ctx context.Context, obj *types.Aud
|
||||
r.logger.ErrorCtx(ctx, "cannot count audits", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *controlResolver:
|
||||
count, err := prb.Audits.CountForControlID(ctx, obj.ParentID)
|
||||
@@ -226,6 +231,7 @@ func (r *auditConnectionResolver) TotalCount(ctx context.Context, obj *types.Aud
|
||||
r.logger.ErrorCtx(ctx, "cannot count audits", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
default:
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver", log.Any("resolver", obj.Resolver))
|
||||
@@ -248,6 +254,7 @@ func (r *findingResolver) Organization(ctx context.Context, obj *types.Finding)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get finding organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -303,6 +310,7 @@ func (r *findingResolver) Owner(ctx context.Context, obj *types.Finding) (*types
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get finding owner", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -328,6 +336,7 @@ func (r *findingResolver) Risk(ctx context.Context, obj *types.Finding) (*types.
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get finding risk", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -369,6 +378,7 @@ func (r *findingConnectionResolver) TotalCount(ctx context.Context, obj *types.F
|
||||
r.logger.ErrorCtx(ctx, "cannot count findings", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *auditResolver:
|
||||
count, err := prb.Findings.CountForAuditID(ctx, obj.ParentID, findingFilter)
|
||||
@@ -376,10 +386,12 @@ func (r *findingConnectionResolver) TotalCount(ctx context.Context, obj *types.F
|
||||
r.logger.ErrorCtx(ctx, "cannot count findings", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver", log.Any("resolver", obj.Resolver))
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -406,7 +418,9 @@ func (r *mutationResolver) CreateAudit(ctx context.Context, input types.CreateAu
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create audit", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -426,7 +440,9 @@ func (r *mutationResolver) CreateAudit(ctx context.Context, input types.CreateAu
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot upload audit report", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
}
|
||||
@@ -458,7 +474,9 @@ func (r *mutationResolver) UpdateAudit(ctx context.Context, input types.UpdateAu
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update audit", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -509,7 +527,9 @@ func (r *mutationResolver) UploadAuditReport(ctx context.Context, input types.Up
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot upload audit report", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -566,7 +586,9 @@ func (r *mutationResolver) CreateFinding(ctx context.Context, input types.Create
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create finding", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -603,7 +625,9 @@ func (r *mutationResolver) UpdateFinding(ctx context.Context, input types.Update
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update finding", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -684,10 +708,13 @@ func (r *mutationResolver) PublishFindingList(ctx context.Context, input types.P
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
|
||||
return nil, gqlutils.Invalid(ctx, errMinor)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot publish finding list", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewOrganization(organization), nil
|
||||
}
|
||||
case coredata.ThirdPartyEntityType:
|
||||
@@ -46,6 +47,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewThirdParty(thirdParty), nil
|
||||
}
|
||||
case coredata.FrameworkEntityType:
|
||||
@@ -55,6 +57,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewFramework(framework), nil
|
||||
}
|
||||
case coredata.MeasureEntityType:
|
||||
@@ -64,6 +67,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewMeasure(measure), nil
|
||||
}
|
||||
case coredata.TaskEntityType:
|
||||
@@ -73,6 +77,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewTask(task), nil
|
||||
}
|
||||
case coredata.EvidenceEntityType:
|
||||
@@ -82,6 +87,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewEvidence(evidence), nil
|
||||
}
|
||||
case coredata.DocumentEntityType:
|
||||
@@ -91,6 +97,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewDocument(document), nil
|
||||
}
|
||||
case coredata.ControlEntityType:
|
||||
@@ -100,6 +107,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewControl(control), nil
|
||||
}
|
||||
case coredata.RiskEntityType:
|
||||
@@ -109,6 +117,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewRisk(risk), nil
|
||||
}
|
||||
case coredata.RiskAssessmentEntityType:
|
||||
@@ -178,6 +187,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewThirdPartyComplianceReport(thirdPartyComplianceReport), nil
|
||||
}
|
||||
case coredata.ThirdPartyContactEntityType:
|
||||
@@ -187,6 +197,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewThirdPartyContact(thirdPartyContact), nil
|
||||
}
|
||||
case coredata.ThirdPartyServiceEntityType:
|
||||
@@ -196,6 +207,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewThirdPartyService(thirdPartyService), nil
|
||||
}
|
||||
case coredata.DocumentVersionEntityType:
|
||||
@@ -205,6 +217,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewDocumentVersion(documentVersion), nil
|
||||
}
|
||||
case coredata.DocumentVersionSignatureEntityType:
|
||||
@@ -214,6 +227,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewDocumentVersionSignature(documentVersionSignature), nil
|
||||
}
|
||||
case coredata.AssetEntityType:
|
||||
@@ -223,6 +237,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewAsset(asset), nil
|
||||
}
|
||||
case coredata.DatumEntityType:
|
||||
@@ -232,6 +247,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewDatum(datum), nil
|
||||
}
|
||||
case coredata.AuditEntityType:
|
||||
@@ -241,6 +257,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewAudit(audit), nil
|
||||
}
|
||||
case coredata.FindingEntityType:
|
||||
@@ -250,6 +267,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewFinding(finding), nil
|
||||
}
|
||||
case coredata.ObligationEntityType:
|
||||
@@ -259,6 +277,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewObligation(obligation), nil
|
||||
}
|
||||
case coredata.ReportEntityType:
|
||||
@@ -268,6 +287,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewReport(report), nil
|
||||
}
|
||||
case coredata.ProcessingActivityEntityType:
|
||||
@@ -277,6 +297,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewProcessingActivity(processingActivity), nil
|
||||
}
|
||||
case coredata.DataProtectionImpactAssessmentEntityType:
|
||||
@@ -287,6 +308,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewDataProtectionImpactAssessment(dpia), nil
|
||||
}
|
||||
case coredata.TransferImpactAssessmentEntityType:
|
||||
@@ -297,6 +319,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewTransferImpactAssessment(tia), nil
|
||||
}
|
||||
case coredata.TrustCenterEntityType:
|
||||
@@ -324,6 +347,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewTrustCenterAccess(trustCenterAccess), nil
|
||||
}
|
||||
case coredata.RightsRequestEntityType:
|
||||
@@ -333,6 +357,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewRightsRequest(rightsRequest), nil
|
||||
}
|
||||
case coredata.StatementOfApplicabilityEntityType:
|
||||
@@ -342,6 +367,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewStatementOfApplicability(statementOfApplicability), nil
|
||||
}
|
||||
case coredata.WebhookSubscriptionEntityType:
|
||||
@@ -351,76 +377,91 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewWebhookSubscription(wc), nil
|
||||
}
|
||||
case coredata.AccessReviewCampaignEntityType:
|
||||
action = probo.ActionAccessReviewCampaignGet
|
||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
||||
scope := coredata.NewScopeFromObjectID(id)
|
||||
|
||||
campaign, err := r.accessReview.Campaigns(scope).Get(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewAccessReviewCampaign(campaign), nil
|
||||
}
|
||||
case coredata.AccessSourceEntityType:
|
||||
action = probo.ActionAccessSourceGet
|
||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
||||
scope := coredata.NewScopeFromObjectID(id)
|
||||
|
||||
source, err := r.accessReview.Sources(scope).Get(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewAccessSource(source), nil
|
||||
}
|
||||
case coredata.AccessEntryEntityType:
|
||||
action = probo.ActionAccessEntryGet
|
||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
||||
scope := coredata.NewScopeFromObjectID(id)
|
||||
|
||||
entry, err := r.accessReview.Entries(scope).Get(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewAccessEntry(entry), nil
|
||||
}
|
||||
case coredata.CookieBannerEntityType:
|
||||
action = probo.ActionCookieBannerGet
|
||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
||||
scope := coredata.NewScopeFromObjectID(id)
|
||||
|
||||
banner, err := r.cookieBanner.GetCookieBanner(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewCookieBanner(banner), nil
|
||||
}
|
||||
case coredata.CookieCategoryEntityType:
|
||||
action = probo.ActionCookieCategoryGet
|
||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
||||
scope := coredata.NewScopeFromObjectID(id)
|
||||
|
||||
category, err := r.cookieBanner.GetCookieCategory(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewCookieCategory(category), nil
|
||||
}
|
||||
case coredata.CookieConsentRecordEntityType:
|
||||
action = probo.ActionCookieConsentRecordList
|
||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
||||
scope := coredata.NewScopeFromObjectID(id)
|
||||
|
||||
record, err := r.cookieBanner.GetCookieConsentRecord(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewCookieConsentRecord(record), nil
|
||||
}
|
||||
case coredata.CookieBannerVersionEntityType:
|
||||
action = probo.ActionCookieBannerVersionGet
|
||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
||||
scope := coredata.NewScopeFromObjectID(id)
|
||||
|
||||
version, err := r.cookieBanner.GetCookieBannerVersion(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.CookieBannerVersion{
|
||||
ID: version.ID,
|
||||
Version: version.Version,
|
||||
@@ -443,6 +484,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load node", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ func handleConnectorInitiate(
|
||||
httpserver.RenderError(w, http.StatusUnauthorized, fmt.Errorf("authentication required"))
|
||||
return
|
||||
}
|
||||
|
||||
session := authn.SessionFromContext(r.Context())
|
||||
if session == nil {
|
||||
httpserver.RenderError(w, http.StatusUnauthorized, fmt.Errorf("authentication required"))
|
||||
@@ -94,12 +95,15 @@ func handleConnectorInitiate(
|
||||
httpserver.RenderError(w, http.StatusBadRequest, fmt.Errorf("cannot reconnect: connector not found"))
|
||||
return
|
||||
}
|
||||
|
||||
if errors.Is(err, errInvalidReconnectConnector) {
|
||||
httpserver.RenderError(w, http.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
|
||||
logger.ErrorCtx(r.Context(), "cannot look up existing connector", log.Error(err))
|
||||
httpserver.RenderError(w, http.StatusInternalServerError, fmt.Errorf("internal error"))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -118,6 +122,7 @@ func handleConnectorInitiate(
|
||||
if err != nil {
|
||||
logger.ErrorCtx(r.Context(), "cannot initiate connector", log.Error(err))
|
||||
httpserver.RenderError(w, http.StatusInternalServerError, fmt.Errorf("internal error"))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -147,6 +152,7 @@ func loadExistingConnector(
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return found, nil
|
||||
}
|
||||
|
||||
@@ -158,5 +164,6 @@ func loadExistingConnector(
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return found, err
|
||||
}
|
||||
|
||||
@@ -75,5 +75,6 @@ func providerExtraSettings(provider coredata.ConnectorProvider) []*types.Connect
|
||||
if settings, ok := providerExtraSettingsMap[provider]; ok {
|
||||
return settings
|
||||
}
|
||||
|
||||
return []*types.ConnectorProviderSettingInfo{}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ func (r *connectorResolver) Oauth2Scopes(ctx context.Context, obj *types.Connect
|
||||
if scopes == nil {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
return scopes, nil
|
||||
}
|
||||
|
||||
@@ -49,26 +50,31 @@ func (r *mutationResolver) CreateAPIKeyConnector(ctx context.Context, input type
|
||||
OrganizationID: *input.TallyOrganizationID,
|
||||
}
|
||||
}
|
||||
|
||||
if input.SentryOrganizationSlug != nil {
|
||||
req.SentrySettings = &coredata.SentryConnectorSettings{
|
||||
OrganizationSlug: *input.SentryOrganizationSlug,
|
||||
}
|
||||
}
|
||||
|
||||
if input.SupabaseOrganizationSlug != nil {
|
||||
req.SupabaseSettings = &coredata.SupabaseConnectorSettings{
|
||||
OrganizationSlug: *input.SupabaseOrganizationSlug,
|
||||
}
|
||||
}
|
||||
|
||||
if input.GithubOrganization != nil {
|
||||
req.GitHubSettings = &coredata.GitHubConnectorSettings{
|
||||
Organization: *input.GithubOrganization,
|
||||
}
|
||||
}
|
||||
|
||||
if input.OnePasswordScimBridgeURL != nil {
|
||||
req.OnePasswordSettings = &coredata.OnePasswordConnectorSettings{
|
||||
SCIMBridgeURL: *input.OnePasswordScimBridgeURL,
|
||||
}
|
||||
}
|
||||
|
||||
cnnctr, err := prb.Connectors.Create(ctx, req)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
|
||||
@@ -54,6 +54,7 @@ func (r *applicabilityStatementResolver) Control(ctx context.Context, obj *types
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get control", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -80,10 +81,12 @@ func (r *applicabilityStatementConnectionResolver) TotalCount(ctx context.Contex
|
||||
r.logger.ErrorCtx(ctx, "cannot count applicability statements", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver for applicability statement connection", log.String("resolver", fmt.Sprintf("%T", obj.Resolver)))
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -102,8 +105,10 @@ func (r *controlResolver) Organization(ctx context.Context, obj *types.Control)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return types.NewOrganization(organization), nil
|
||||
}
|
||||
|
||||
@@ -161,6 +166,7 @@ func (r *controlResolver) Framework(ctx context.Context, obj *types.Control) (*t
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get framework", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -320,6 +326,7 @@ func (r *controlConnectionResolver) TotalCount(ctx context.Context, obj *types.C
|
||||
r.logger.ErrorCtx(ctx, "cannot count controls", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *frameworkResolver:
|
||||
count, err := prb.Controls.CountForFrameworkID(ctx, obj.ParentID, obj.Filters)
|
||||
@@ -327,6 +334,7 @@ func (r *controlConnectionResolver) TotalCount(ctx context.Context, obj *types.C
|
||||
r.logger.ErrorCtx(ctx, "cannot count controls", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *documentResolver:
|
||||
count, err := prb.Controls.CountForDocumentID(ctx, obj.ParentID, obj.Filters)
|
||||
@@ -334,6 +342,7 @@ func (r *controlConnectionResolver) TotalCount(ctx context.Context, obj *types.C
|
||||
r.logger.ErrorCtx(ctx, "cannot count controls", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *measureResolver:
|
||||
count, err := prb.Controls.CountForMeasureID(ctx, obj.ParentID, obj.Filters)
|
||||
@@ -341,6 +350,7 @@ func (r *controlConnectionResolver) TotalCount(ctx context.Context, obj *types.C
|
||||
r.logger.ErrorCtx(ctx, "cannot count controls", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *riskResolver:
|
||||
count, err := prb.Controls.CountForRiskID(ctx, obj.ParentID, obj.Filters)
|
||||
@@ -348,6 +358,7 @@ func (r *controlConnectionResolver) TotalCount(ctx context.Context, obj *types.C
|
||||
r.logger.ErrorCtx(ctx, "cannot count controls", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *statementOfApplicabilityResolver:
|
||||
count, err := prb.Controls.CountForStatementOfApplicabilityID(ctx, obj.ParentID, obj.Filters)
|
||||
@@ -355,10 +366,12 @@ func (r *controlConnectionResolver) TotalCount(ctx context.Context, obj *types.C
|
||||
r.logger.ErrorCtx(ctx, "cannot count controls", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -390,7 +403,9 @@ func (r *mutationResolver) CreateControl(ctx context.Context, input types.Create
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create control", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -419,7 +434,6 @@ func (r *mutationResolver) UpdateControl(ctx context.Context, input types.Update
|
||||
NotImplementedJustification: gqlutils.UnwrapOmittable(input.NotImplementedJustification),
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
@@ -428,7 +442,9 @@ func (r *mutationResolver) UpdateControl(ctx context.Context, input types.Update
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update control", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -491,6 +507,7 @@ func (r *mutationResolver) CreateControlDocumentMapping(ctx context.Context, inp
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create control document mapping", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -696,10 +713,13 @@ func (r *mutationResolver) CreateStatementOfApplicability(ctx context.Context, i
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create statement_of_applicability", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -732,10 +752,13 @@ func (r *mutationResolver) UpdateStatementOfApplicability(ctx context.Context, i
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update statement_of_applicability", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -776,10 +799,13 @@ func (r *mutationResolver) PublishStatementOfApplicability(ctx context.Context,
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
|
||||
return nil, gqlutils.Invalid(ctx, errMinor)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot publish statement of applicability", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -806,7 +832,9 @@ func (r *statementOfApplicabilityResolver) Document(ctx context.Context, obj *ty
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -826,7 +854,9 @@ func (r *statementOfApplicabilityResolver) Organization(ctx context.Context, obj
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) || errors.Is(err, dataloadgen.ErrNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -879,10 +909,12 @@ func (r *statementOfApplicabilityConnectionResolver) TotalCount(ctx context.Cont
|
||||
r.logger.ErrorCtx(ctx, "cannot count statements_of_applicability", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,9 @@ func (r *cookieBannerResolver) Organization(ctx context.Context, obj *types.Cook
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) || errors.Is(err, dataloadgen.ErrNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -124,6 +126,7 @@ func (r *cookieBannerResolver) LatestVersion(ctx context.Context, obj *types.Coo
|
||||
}
|
||||
|
||||
v := versions[0]
|
||||
|
||||
return &types.CookieBannerVersion{
|
||||
ID: v.ID,
|
||||
Version: v.Version,
|
||||
@@ -331,7 +334,9 @@ func (r *cookieCategoryResolver) CookieBanner(ctx context.Context, obj *types.Co
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) || errors.Is(err, dataloadgen.ErrNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get cookie banner", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -446,10 +451,13 @@ func (r *mutationResolver) CreateCookieBanner(ctx context.Context, input types.C
|
||||
if errors.Is(err, cookiebanner.ErrOriginAlreadyInUse) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create cookie banner", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -482,10 +490,13 @@ func (r *mutationResolver) UpdateCookieBanner(ctx context.Context, input types.U
|
||||
if errors.Is(err, cookiebanner.ErrBannerNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update cookie banner", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -507,7 +518,9 @@ func (r *mutationResolver) DeleteCookieBanner(ctx context.Context, input types.D
|
||||
if errors.Is(err, cookiebanner.ErrBannerNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot delete cookie banner", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -529,13 +542,17 @@ func (r *mutationResolver) ActivateCookieBanner(ctx context.Context, input types
|
||||
if errors.Is(err, cookiebanner.ErrBannerNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
if errors.Is(err, cookiebanner.ErrBannerAlreadyActive) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if errors.Is(err, cookiebanner.ErrOriginAlreadyInUse) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot activate cookie banner", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -557,10 +574,13 @@ func (r *mutationResolver) DeactivateCookieBanner(ctx context.Context, input typ
|
||||
if errors.Is(err, cookiebanner.ErrBannerNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
if errors.Is(err, cookiebanner.ErrBannerAlreadyInactive) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot deactivate cookie banner", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -582,7 +602,9 @@ func (r *mutationResolver) PublishCookieBannerVersion(ctx context.Context, input
|
||||
if errors.Is(err, cookiebanner.ErrNoDraftVersion) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot publish cookie banner version", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -627,13 +649,17 @@ func (r *mutationResolver) CreateCookieCategory(ctx context.Context, input types
|
||||
if errors.Is(err, cookiebanner.ErrBannerNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
if errors.Is(err, cookiebanner.ErrCategorySlugAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create cookie category", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -678,20 +704,26 @@ func (r *mutationResolver) UpdateCookieCategory(ctx context.Context, input types
|
||||
if errors.Is(err, cookiebanner.ErrCategoryNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
if errors.Is(err, cookiebanner.ErrCategorySlugAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if errors.Is(err, cookiebanner.ErrPostHogConsentKindInvalid) {
|
||||
return nil, gqlutils.Invalid(ctx, err)
|
||||
}
|
||||
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update cookie category", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
bannerScope := coredata.NewScopeFromObjectID(category.CookieBannerID)
|
||||
|
||||
banner, err := r.cookieBanner.GetCookieBanner(ctx, bannerScope, category.CookieBannerID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot get cookie banner", log.Error(err))
|
||||
@@ -717,7 +749,9 @@ func (r *mutationResolver) DeleteCookieCategory(ctx context.Context, input types
|
||||
if errors.Is(err, cookiebanner.ErrCategoryNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get cookie category", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -728,14 +762,18 @@ func (r *mutationResolver) DeleteCookieCategory(ctx context.Context, input types
|
||||
if errors.Is(err, cookiebanner.ErrCategoryNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
if errors.Is(err, cookiebanner.ErrCannotDeleteSystemCategory) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot delete cookie category", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
bannerScope := coredata.NewScopeFromObjectID(bannerID)
|
||||
|
||||
banner, err := r.cookieBanner.GetCookieBanner(ctx, bannerScope, bannerID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot get cookie banner", log.Error(err))
|
||||
@@ -768,10 +806,13 @@ func (r *mutationResolver) ReorderCookieCategory(ctx context.Context, input type
|
||||
if errors.Is(err, cookiebanner.ErrCategoryNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot reorder cookie category", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -801,10 +842,13 @@ func (r *mutationResolver) UpsertCookieBannerTranslation(ctx context.Context, in
|
||||
if errors.Is(err, cookiebanner.ErrBannerNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot upsert cookie banner translation", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -855,14 +899,18 @@ func (r *mutationResolver) CreateTrackerPattern(ctx context.Context, input types
|
||||
if errors.Is(err, cookiebanner.ErrPatternAlreadyExists) {
|
||||
return nil, gqlutils.Conflictf(ctx, "a pattern with this name already exists in this banner")
|
||||
}
|
||||
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create tracker pattern", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
bannerScope := coredata.NewScopeFromObjectID(pattern.CookieBannerID)
|
||||
|
||||
banner, err := r.cookieBanner.GetCookieBanner(ctx, bannerScope, pattern.CookieBannerID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot get cookie banner", log.Error(err))
|
||||
@@ -897,11 +945,14 @@ func (r *mutationResolver) UpdateTrackerPattern(ctx context.Context, input types
|
||||
if errors.Is(err, cookiebanner.ErrTrackerPatternNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update tracker pattern", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
bannerScope := coredata.NewScopeFromObjectID(pattern.CookieBannerID)
|
||||
|
||||
banner, err := r.cookieBanner.GetCookieBanner(ctx, bannerScope, pattern.CookieBannerID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot get cookie banner", log.Error(err))
|
||||
@@ -927,7 +978,9 @@ func (r *mutationResolver) DeleteTrackerPattern(ctx context.Context, input types
|
||||
if errors.Is(err, cookiebanner.ErrTrackerPatternNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get tracker pattern", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -937,11 +990,14 @@ func (r *mutationResolver) DeleteTrackerPattern(ctx context.Context, input types
|
||||
if errors.Is(err, cookiebanner.ErrTrackerPatternNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot delete tracker pattern", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
bannerScope := coredata.NewScopeFromObjectID(bannerID)
|
||||
|
||||
banner, err := r.cookieBanner.GetCookieBanner(ctx, bannerScope, bannerID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot get cookie banner", log.Error(err))
|
||||
@@ -1023,14 +1079,18 @@ func (r *mutationResolver) CreateTrackerResource(ctx context.Context, input type
|
||||
if errors.Is(err, cookiebanner.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflictf(ctx, "a resource with this origin and path already exists in this banner")
|
||||
}
|
||||
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create tracker resource", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
bannerScope := coredata.NewScopeFromObjectID(resource.CookieBannerID)
|
||||
|
||||
banner, err := r.cookieBanner.GetCookieBanner(ctx, bannerScope, resource.CookieBannerID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot get cookie banner", log.Error(err))
|
||||
@@ -1065,14 +1125,18 @@ func (r *mutationResolver) UpdateTrackerResource(ctx context.Context, input type
|
||||
if errors.Is(err, cookiebanner.ErrTrackerResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update tracker resource", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
bannerScope := coredata.NewScopeFromObjectID(resource.CookieBannerID)
|
||||
|
||||
banner, err := r.cookieBanner.GetCookieBanner(ctx, bannerScope, resource.CookieBannerID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot get cookie banner", log.Error(err))
|
||||
@@ -1098,7 +1162,9 @@ func (r *mutationResolver) DeleteTrackerResource(ctx context.Context, input type
|
||||
if errors.Is(err, cookiebanner.ErrTrackerResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get tracker resource", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1108,11 +1174,14 @@ func (r *mutationResolver) DeleteTrackerResource(ctx context.Context, input type
|
||||
if errors.Is(err, cookiebanner.ErrTrackerResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot delete tracker resource", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
bannerScope := coredata.NewScopeFromObjectID(bannerID)
|
||||
|
||||
banner, err := r.cookieBanner.GetCookieBanner(ctx, bannerScope, bannerID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot get cookie banner", log.Error(err))
|
||||
@@ -1180,7 +1249,9 @@ func (r *trackerPatternResolver) CookieCategory(ctx context.Context, obj *types.
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) || errors.Is(err, dataloadgen.ErrNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get cookie category", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1209,8 +1280,10 @@ func (r *trackerPatternResolver) Permission(ctx context.Context, obj *types.Trac
|
||||
func (r *trackerPatternConnectionResolver) TotalCount(ctx context.Context, obj *types.TrackerPatternConnection) (int, error) {
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
|
||||
var count int
|
||||
var err error
|
||||
var (
|
||||
count int
|
||||
err error
|
||||
)
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *cookieCategoryResolver:
|
||||
@@ -1220,6 +1293,7 @@ func (r *trackerPatternConnectionResolver) TotalCount(ctx context.Context, obj *
|
||||
if obj.Filter != nil {
|
||||
filter = filter.WithQuery(obj.Filter.Query).WithSource(obj.Filter.Source).WithTrackerType(obj.Filter.TrackerType)
|
||||
}
|
||||
|
||||
count, err = r.cookieBanner.CountUncategorisedTrackerPatterns(ctx, scope, obj.ParentID, filter)
|
||||
}
|
||||
|
||||
@@ -1244,7 +1318,9 @@ func (r *trackerResourceResolver) CookieCategory(ctx context.Context, obj *types
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) || errors.Is(err, dataloadgen.ErrNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get cookie category", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1260,8 +1336,10 @@ func (r *trackerResourceResolver) Permission(ctx context.Context, obj *types.Tra
|
||||
func (r *trackerResourceConnectionResolver) TotalCount(ctx context.Context, obj *types.TrackerResourceConnection) (int, error) {
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
|
||||
var count int
|
||||
var err error
|
||||
var (
|
||||
count int
|
||||
err error
|
||||
)
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *cookieCategoryResolver:
|
||||
@@ -1271,6 +1349,7 @@ func (r *trackerResourceConnectionResolver) TotalCount(ctx context.Context, obj
|
||||
if obj.Filter != nil {
|
||||
filter = filter.WithQuery(obj.Filter.Query).WithResourceType(obj.Filter.Type)
|
||||
}
|
||||
|
||||
count, err = r.cookieBanner.CountUncategorisedTrackerResources(ctx, scope, obj.ParentID, filter)
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,9 @@ func (r *cookieConsentRecordResolver) CookieBanner(ctx context.Context, obj *typ
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) || errors.Is(err, dataloadgen.ErrNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get cookie banner", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -53,7 +55,9 @@ func (r *cookieConsentRecordResolver) CookieBannerVersion(ctx context.Context, o
|
||||
if errors.Is(err, cookiebanner.ErrVersionNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get cookie banner version", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,9 @@ func (r *dataProtectionImpactAssessmentResolver) Organization(ctx context.Contex
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -89,10 +91,12 @@ func (r *dataProtectionImpactAssessmentConnectionResolver) TotalCount(ctx contex
|
||||
r.logger.ErrorCtx(ctx, "cannot count organization data protection impact assessments", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -122,7 +126,9 @@ func (r *mutationResolver) CreateDataProtectionImpactAssessment(ctx context.Cont
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create data protection impact assessment", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -153,7 +159,9 @@ func (r *mutationResolver) UpdateDataProtectionImpactAssessment(ctx context.Cont
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update data protection impact assessment", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -207,7 +215,9 @@ func (r *mutationResolver) CreateTransferImpactAssessment(ctx context.Context, i
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create transfer impact assessment", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -238,7 +248,9 @@ func (r *mutationResolver) UpdateTransferImpactAssessment(ctx context.Context, i
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update transfer impact assessment", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -279,10 +291,13 @@ func (r *mutationResolver) PublishDataProtectionImpactAssessmentList(ctx context
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
|
||||
return nil, gqlutils.Invalid(ctx, errMinor)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot publish data protection impact assessment list", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -305,10 +320,13 @@ func (r *mutationResolver) PublishTransferImpactAssessmentList(ctx context.Conte
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
|
||||
return nil, gqlutils.Invalid(ctx, errMinor)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot publish transfer impact assessment list", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -350,6 +368,7 @@ func (r *transferImpactAssessmentResolver) Organization(ctx context.Context, obj
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -376,10 +395,12 @@ func (r *transferImpactAssessmentConnectionResolver) TotalCount(ctx context.Cont
|
||||
r.logger.ErrorCtx(ctx, "cannot count organization transfer impact assessments", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@ func (f *batchFetcher) fetchOrganizations(ctx context.Context, keys []gid.GID) (
|
||||
for _, org := range orgs {
|
||||
result[org.ID] = org
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -117,6 +118,7 @@ func (f *batchFetcher) fetchFrameworks(ctx context.Context, keys []gid.GID) (map
|
||||
for _, v := range frameworks {
|
||||
result[v.ID] = v
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -132,6 +134,7 @@ func (f *batchFetcher) fetchControls(ctx context.Context, keys []gid.GID) (map[g
|
||||
for _, v := range controls {
|
||||
result[v.ID] = v
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -147,6 +150,7 @@ func (f *batchFetcher) fetchThirdParties(ctx context.Context, keys []gid.GID) (m
|
||||
for _, v := range thirdParties {
|
||||
result[v.ID] = v
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -162,6 +166,7 @@ func (f *batchFetcher) fetchDocuments(ctx context.Context, keys []gid.GID) (map[
|
||||
for _, v := range documents {
|
||||
result[v.ID] = v
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -177,6 +182,7 @@ func (f *batchFetcher) fetchProfiles(ctx context.Context, keys []gid.GID) (map[g
|
||||
for _, v := range profiles {
|
||||
result[v.ID] = v
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -192,6 +198,7 @@ func (f *batchFetcher) fetchRisks(ctx context.Context, keys []gid.GID) (map[gid.
|
||||
for _, v := range risks {
|
||||
result[v.ID] = v
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -207,6 +214,7 @@ func (f *batchFetcher) fetchMeasures(ctx context.Context, keys []gid.GID) (map[g
|
||||
for _, v := range measures {
|
||||
result[v.ID] = v
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -222,6 +230,7 @@ func (f *batchFetcher) fetchTasks(ctx context.Context, keys []gid.GID) (map[gid.
|
||||
for _, v := range tasks {
|
||||
result[v.ID] = v
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -237,6 +246,7 @@ func (f *batchFetcher) fetchFiles(ctx context.Context, keys []gid.GID) (map[gid.
|
||||
for _, v := range files {
|
||||
result[v.ID] = v
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -252,6 +262,7 @@ func (f *batchFetcher) fetchReports(ctx context.Context, keys []gid.GID) (map[gi
|
||||
for _, v := range reports {
|
||||
result[v.ID] = v
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -267,6 +278,7 @@ func (f *batchFetcher) fetchCookieBanners(ctx context.Context, keys []gid.GID) (
|
||||
for _, v := range banners {
|
||||
result[v.ID] = v
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -282,5 +294,6 @@ func (f *batchFetcher) fetchCookieCategories(ctx context.Context, keys []gid.GID
|
||||
for _, v := range categories {
|
||||
result[v.ID] = v
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ func (r *documentResolver) Organization(ctx context.Context, obj *types.Document
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -160,6 +161,7 @@ func (r *documentConnectionResolver) TotalCount(ctx context.Context, obj *types.
|
||||
r.logger.ErrorCtx(ctx, "cannot count controls", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *organizationResolver:
|
||||
count, err := prb.Documents.CountForOrganizationID(ctx, obj.ParentID, obj.Filters)
|
||||
@@ -167,6 +169,7 @@ func (r *documentConnectionResolver) TotalCount(ctx context.Context, obj *types.
|
||||
r.logger.ErrorCtx(ctx, "cannot count documents", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *riskResolver:
|
||||
count, err := prb.Documents.CountForRiskID(ctx, obj.ParentID, obj.Filters)
|
||||
@@ -174,6 +177,7 @@ func (r *documentConnectionResolver) TotalCount(ctx context.Context, obj *types.
|
||||
r.logger.ErrorCtx(ctx, "cannot count risks", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *measureResolver:
|
||||
count, err := prb.Documents.CountForMeasureID(ctx, obj.ParentID, obj.Filters)
|
||||
@@ -181,10 +185,12 @@ func (r *documentConnectionResolver) TotalCount(ctx context.Context, obj *types.
|
||||
r.logger.ErrorCtx(ctx, "cannot count documents", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -203,6 +209,7 @@ func (r *documentVersionResolver) Document(ctx context.Context, obj *types.Docum
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -263,16 +270,21 @@ func (r *documentVersionResolver) Signatures(ctx context.Context, obj *types.Doc
|
||||
}
|
||||
}
|
||||
|
||||
var signatureStates []coredata.DocumentVersionSignatureState
|
||||
var activeContract *bool
|
||||
var (
|
||||
signatureStates []coredata.DocumentVersionSignatureState
|
||||
activeContract *bool
|
||||
)
|
||||
|
||||
if filter != nil {
|
||||
if filter.States != nil {
|
||||
signatureStates = filter.States
|
||||
}
|
||||
|
||||
if filter.ActiveContract != nil {
|
||||
activeContract = filter.ActiveContract
|
||||
}
|
||||
}
|
||||
|
||||
signatureFilter := coredata.NewDocumentVersionSignatureFilter(signatureStates, activeContract)
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
@@ -355,6 +367,7 @@ func (r *documentVersionApprovalDecisionResolver) Quorum(ctx context.Context, ob
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get approval quorum", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -376,6 +389,7 @@ func (r *documentVersionApprovalDecisionResolver) DocumentVersion(ctx context.Co
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get approval quorum", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -386,6 +400,7 @@ func (r *documentVersionApprovalDecisionResolver) DocumentVersion(ctx context.Co
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get document version", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -405,6 +420,7 @@ func (r *documentVersionApprovalDecisionResolver) Approver(ctx context.Context,
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get approver profile", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -475,6 +491,7 @@ func (r *documentVersionApprovalQuorumResolver) DocumentVersion(ctx context.Cont
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get document version", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -504,6 +521,7 @@ func (r *documentVersionApprovalQuorumResolver) Decisions(ctx context.Context, o
|
||||
if filter != nil && filter.States != nil {
|
||||
approvalStates = filter.States
|
||||
}
|
||||
|
||||
approvalFilter := coredata.NewDocumentVersionApprovalDecisionFilter(approvalStates)
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
@@ -553,15 +571,18 @@ func (r *documentVersionConnectionResolver) TotalCount(ctx context.Context, obj
|
||||
if obj.Filters != nil {
|
||||
filter = obj.Filters
|
||||
}
|
||||
|
||||
count, err := prb.Documents.CountVersionsForDocumentID(ctx, obj.ParentID, filter)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot count document versions", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -580,6 +601,7 @@ func (r *documentVersionSignatureResolver) DocumentVersion(ctx context.Context,
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get document version", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -601,6 +623,7 @@ func (r *documentVersionSignatureResolver) SignedBy(ctx context.Context, obj *ty
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get people", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -626,15 +649,18 @@ func (r *documentVersionSignatureConnectionResolver) TotalCount(ctx context.Cont
|
||||
if obj.Filters != nil {
|
||||
filter = obj.Filters
|
||||
}
|
||||
|
||||
count, err := prb.Documents.CountSignaturesForVersionID(ctx, obj.ParentID, filter)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot count signatures", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -653,7 +679,9 @@ func (r *employeeDocumentResolver) Signed(ctx context.Context, obj *types.Employ
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot check if document is signed", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -675,7 +703,9 @@ func (r *employeeDocumentResolver) ApprovalState(ctx context.Context, obj *types
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get viewer approval state", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -706,6 +736,7 @@ func (r *employeeDocumentResolver) Versions(ctx context.Context, obj *types.Empl
|
||||
identity := authn.IdentityFromContext(ctx)
|
||||
|
||||
var filterMode coredata.EmployeeFilterMode
|
||||
|
||||
switch obj.FilterMode {
|
||||
case types.EmployeeDocumentFilterModeSignature:
|
||||
filterMode = coredata.EmployeeFilterModeSignature
|
||||
@@ -782,6 +813,7 @@ func (r *employeeDocumentVersionResolver) ApprovalDecision(ctx context.Context,
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get viewer approval decision", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -821,7 +853,9 @@ func (r *mutationResolver) CreateDocument(ctx context.Context, input types.Creat
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -856,21 +890,25 @@ func (r *mutationResolver) UpdateDocument(ctx context.Context, input types.Updat
|
||||
DefaultApproverIDs: defaultApproverIDs,
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
if errArchived, ok := errors.AsType[*probo.ErrDocumentArchived](err); ok {
|
||||
return nil, gqlutils.Conflict(ctx, errArchived)
|
||||
}
|
||||
|
||||
if errGenerated, ok := errors.AsType[*probo.ErrDocumentVersionGenerated](err); ok {
|
||||
return nil, gqlutils.Conflict(ctx, errGenerated)
|
||||
}
|
||||
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -905,13 +943,17 @@ func (r *mutationResolver) DeleteDocumentDraft(ctx context.Context, input types.
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
if errNotDeletable, ok := errors.AsType[*probo.ErrDocumentDraftNotDeletable](err); ok {
|
||||
return nil, gqlutils.Conflict(ctx, errNotDeletable)
|
||||
}
|
||||
|
||||
if errArchived, ok := errors.AsType[*probo.ErrDocumentArchived](err); ok {
|
||||
return nil, gqlutils.Conflict(ctx, errArchived)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot delete document draft", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -933,7 +975,9 @@ func (r *mutationResolver) ArchiveDocument(ctx context.Context, input types.Arch
|
||||
if errArchived, ok := errors.AsType[*probo.ErrDocumentArchived](err); ok {
|
||||
return nil, gqlutils.Conflict(ctx, errArchived)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot archive document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -955,7 +999,9 @@ func (r *mutationResolver) UnarchiveDocument(ctx context.Context, input types.Un
|
||||
if errNotArchived, ok := errors.AsType[*probo.ErrDocumentNotArchived](err); ok {
|
||||
return nil, gqlutils.Conflict(ctx, errNotArchived)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot unarchive document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -989,6 +1035,7 @@ func (r *mutationResolver) PublishDocument(ctx context.Context, input types.Publ
|
||||
if !input.Minor && len(input.ApproverIds) > 0 {
|
||||
action = probo.ActionDocumentVersionRequestApproval
|
||||
}
|
||||
|
||||
if err := r.authorize(ctx, input.DocumentID, action); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1027,6 +1074,7 @@ func (r *mutationResolver) PublishDocument(ctx context.Context, input types.Publ
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot publish document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1037,6 +1085,7 @@ func (r *mutationResolver) PublishDocument(ctx context.Context, input types.Publ
|
||||
if result.Quorum != nil {
|
||||
payload.ApprovalQuorum = types.NewDocumentVersionApprovalQuorum(result.Quorum)
|
||||
}
|
||||
|
||||
return payload, nil
|
||||
}
|
||||
|
||||
@@ -1076,6 +1125,7 @@ func (r *mutationResolver) BulkPublishDocuments(ctx context.Context, input types
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot bulk publish documents", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1118,6 +1168,7 @@ func (r *mutationResolver) VoidDocumentVersionApproval(ctx context.Context, inpu
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot void document version approval", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1256,6 +1307,7 @@ func (r *mutationResolver) GenerateDocumentChangelog(ctx context.Context, input
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot generate document changelog", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1297,6 +1349,7 @@ func (r *mutationResolver) RequestSignature(ctx context.Context, input types.Req
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot request signature", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1342,6 +1395,7 @@ func (r *mutationResolver) BulkRequestSignatures(ctx context.Context, input type
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot bulk request signatures", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1384,6 +1438,7 @@ func (r *mutationResolver) CancelSignatureRequest(ctx context.Context, input typ
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot cancel signature request", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1408,6 +1463,7 @@ func (r *mutationResolver) SignDocument(ctx context.Context, input types.SignDoc
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot sign document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1459,6 +1515,7 @@ func (r *mutationResolver) ApproveDocumentVersion(ctx context.Context, input typ
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot approve document version", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1500,6 +1557,7 @@ func (r *mutationResolver) RejectDocumentVersion(ctx context.Context, input type
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot reject document version", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1567,6 +1625,7 @@ func (r *mutationResolver) ExportEmployeeDocumentVersionPDF(ctx context.Context,
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get employee document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ func (r *evidenceResolver) File(ctx context.Context, obj *types.Evidence) (*type
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load evidence file", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -65,6 +66,7 @@ func (r *evidenceResolver) Task(ctx context.Context, obj *types.Evidence) (*type
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load task", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -86,6 +88,7 @@ func (r *evidenceResolver) Measure(ctx context.Context, obj *types.Evidence) (*t
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load measure", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -112,6 +115,7 @@ func (r *evidenceConnectionResolver) TotalCount(ctx context.Context, obj *types.
|
||||
r.logger.ErrorCtx(ctx, "cannot count measure evidence", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *taskResolver:
|
||||
count, err := prb.Evidences.CountForTaskID(ctx, obj.ParentID)
|
||||
@@ -119,10 +123,12 @@ func (r *evidenceConnectionResolver) TotalCount(ctx context.Context, obj *types.
|
||||
r.logger.ErrorCtx(ctx, "cannot count task evidence", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -169,7 +175,9 @@ func (r *mutationResolver) UploadMeasureEvidence(ctx context.Context, input type
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot upload measure evidence", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ func (r *frameworkResolver) Organization(ctx context.Context, obj *types.Framewo
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -122,10 +123,12 @@ func (r *frameworkConnectionResolver) TotalCount(ctx context.Context, obj *types
|
||||
r.logger.ErrorCtx(ctx, "cannot count frameworks", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -148,7 +151,9 @@ func (r *mutationResolver) CreateFramework(ctx context.Context, input types.Crea
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create framework", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -177,7 +182,9 @@ func (r *mutationResolver) UpdateFramework(ctx context.Context, input types.Upda
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update framework", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -207,6 +214,7 @@ func (r *mutationResolver) ImportFramework(ctx context.Context, input types.Impo
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot import framework", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -64,5 +64,6 @@ func NewGraphQLHandler(
|
||||
|
||||
es := schema.NewExecutableSchema(config)
|
||||
gqlh := gqlutils.NewHandler(es, logger)
|
||||
|
||||
return gqlh
|
||||
}
|
||||
|
||||
@@ -78,10 +78,12 @@ func (r *mailingListSubscriberConnectionResolver) TotalCount(ctx context.Context
|
||||
r.logger.ErrorCtx(ctx, "cannot count mailing list subscribers", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver for mailing list subscriber connection", log.String("resolver", fmt.Sprintf("%T", obj.Resolver)))
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -118,7 +120,9 @@ func (r *mutationResolver) CreateMailingListUpdate(ctx context.Context, input ty
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create mailing list update", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -145,13 +149,17 @@ func (r *mutationResolver) UpdateMailingListUpdate(ctx context.Context, input ty
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
if errors.Is(err, mailman.ErrMailingListUpdateAlreadySent) {
|
||||
return nil, gqlutils.Conflictf(ctx, "mailing list update can only be edited when in draft")
|
||||
}
|
||||
|
||||
if errors.Is(err, mailman.ErrMailingListUpdateNotFound) {
|
||||
return nil, gqlutils.NotFoundf(ctx, "mailing list update not found")
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update mailing list update", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -171,10 +179,13 @@ func (r *mutationResolver) SendMailingListUpdate(ctx context.Context, input type
|
||||
if errors.Is(err, mailman.ErrMailingListUpdateAlreadySent) {
|
||||
return nil, gqlutils.Conflictf(ctx, "mailing list update has already been queued for sending")
|
||||
}
|
||||
|
||||
if errors.Is(err, mailman.ErrMailingListUpdateNotFound) {
|
||||
return nil, gqlutils.NotFoundf(ctx, "mailing list update not found")
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot queue mailing list update for sending", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -193,7 +204,9 @@ func (r *mutationResolver) DeleteMailingListUpdate(ctx context.Context, input ty
|
||||
if errors.Is(err, mailman.ErrMailingListUpdateNotFound) {
|
||||
return nil, gqlutils.NotFoundf(ctx, "mailing list update not found")
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot delete mailing list update", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -238,10 +251,13 @@ func (r *mutationResolver) CreateMailingListSubscriber(ctx context.Context, inpu
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
if errors.Is(err, mailman.ErrSubscriberAlreadyExist) {
|
||||
return nil, gqlutils.Conflictf(ctx, "subscriber already exists in this mailing list")
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create mailing list subscriber", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -260,7 +276,9 @@ func (r *mutationResolver) DeleteMailingListSubscriber(ctx context.Context, inpu
|
||||
if errors.Is(err, mailman.ErrSubscriberNotFound) {
|
||||
return nil, gqlutils.NotFoundf(ctx, "mailing list subscriber not found")
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot delete mailing list subscriber", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -208,6 +208,7 @@ func (r *measureConnectionResolver) TotalCount(ctx context.Context, obj *types.M
|
||||
r.logger.ErrorCtx(ctx, "cannot count measures", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *controlResolver:
|
||||
count, err := prb.Measures.CountForControlID(ctx, obj.ParentID, obj.Filters)
|
||||
@@ -215,6 +216,7 @@ func (r *measureConnectionResolver) TotalCount(ctx context.Context, obj *types.M
|
||||
r.logger.ErrorCtx(ctx, "cannot count measures", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *riskResolver:
|
||||
count, err := prb.Measures.CountForRiskID(ctx, obj.ParentID, obj.Filters)
|
||||
@@ -222,10 +224,12 @@ func (r *measureConnectionResolver) TotalCount(ctx context.Context, obj *types.M
|
||||
r.logger.ErrorCtx(ctx, "cannot count measures", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -254,7 +258,9 @@ func (r *mutationResolver) CreateMeasure(ctx context.Context, input types.Create
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create measure", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -285,7 +291,9 @@ func (r *mutationResolver) UpdateMeasure(ctx context.Context, input types.Update
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update measure", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -358,6 +366,7 @@ func (r *mutationResolver) CreateMeasureDocumentMapping(ctx context.Context, inp
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create measure document mapping", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,9 @@ func (r *mutationResolver) CreateObligation(ctx context.Context, input types.Cre
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create obligation", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -84,7 +86,9 @@ func (r *mutationResolver) UpdateObligation(ctx context.Context, input types.Upd
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update obligation", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -125,10 +129,13 @@ func (r *mutationResolver) PublishObligationList(ctx context.Context, input type
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
|
||||
return nil, gqlutils.Invalid(ctx, errMinor)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot publish obligation list", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -153,6 +160,7 @@ func (r *obligationResolver) Organization(ctx context.Context, obj *types.Obliga
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get obligation organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -174,6 +182,7 @@ func (r *obligationResolver) Owner(ctx context.Context, obj *types.Obligation) (
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get obligation owner", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -200,6 +209,7 @@ func (r *obligationConnectionResolver) TotalCount(ctx context.Context, obj *type
|
||||
r.logger.ErrorCtx(ctx, "cannot count obligations", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *riskResolver:
|
||||
count, err := prb.Obligations.CountForRiskID(ctx, obj.ParentID)
|
||||
@@ -207,10 +217,12 @@ func (r *obligationConnectionResolver) TotalCount(ctx context.Context, obj *type
|
||||
r.logger.ErrorCtx(ctx, "cannot count risk obligations", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,9 @@ func (r *mutationResolver) UpdateOrganizationContext(ctx context.Context, input
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update organization context", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -236,6 +238,7 @@ func (r *organizationResolver) AssetListDocument(ctx context.Context, obj *types
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get asset list document ID: %w", err)
|
||||
}
|
||||
|
||||
if assetDocumentID == nil {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -290,6 +293,7 @@ func (r *organizationResolver) DataListDocument(ctx context.Context, obj *types.
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get data export document ID: %w", err)
|
||||
}
|
||||
|
||||
if dataDocumentID == nil {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -374,6 +378,7 @@ func (r *organizationResolver) FindingsDocument(ctx context.Context, obj *types.
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get finding list document ID: %w", err)
|
||||
}
|
||||
|
||||
if findingDocumentID == nil {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -452,16 +457,20 @@ func (r *organizationResolver) AuditLogEntries(ctx context.Context, obj *types.O
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
coredataFilter := coredata.NewAuditLogEntryFilter()
|
||||
|
||||
if filter != nil {
|
||||
if filter.Action != nil {
|
||||
coredataFilter.WithAction(*filter.Action)
|
||||
}
|
||||
|
||||
if filter.ActorID != nil {
|
||||
coredataFilter.WithActorID(*filter.ActorID)
|
||||
}
|
||||
|
||||
if filter.ResourceType != nil {
|
||||
coredataFilter.WithResourceType(*filter.ResourceType)
|
||||
}
|
||||
|
||||
if filter.ResourceID != nil {
|
||||
coredataFilter.WithResourceID(*filter.ResourceID)
|
||||
}
|
||||
@@ -533,6 +542,7 @@ func (r *organizationResolver) Connectors(ctx context.Context, obj *types.Organi
|
||||
filtered = append(filtered, cnnctr)
|
||||
}
|
||||
}
|
||||
|
||||
connectors = filtered
|
||||
}
|
||||
|
||||
@@ -546,12 +556,15 @@ func (r *organizationResolver) ConnectorProviderInfos(ctx context.Context, obj *
|
||||
}
|
||||
|
||||
var infos []*types.ConnectorProviderInfo
|
||||
|
||||
for _, provider := range coredata.ConnectorProviders() {
|
||||
_, oauthErr := r.connectorRegistry.Get(string(provider))
|
||||
|
||||
scopes := drivers.ProviderOAuth2Scopes(provider)
|
||||
if scopes == nil {
|
||||
scopes = []string{}
|
||||
}
|
||||
|
||||
info := &types.ConnectorProviderInfo{
|
||||
Provider: provider,
|
||||
DisplayName: providerDisplayName(provider),
|
||||
@@ -563,6 +576,7 @@ func (r *organizationResolver) ConnectorProviderInfos(ctx context.Context, obj *
|
||||
}
|
||||
infos = append(infos, info)
|
||||
}
|
||||
|
||||
return infos, nil
|
||||
}
|
||||
|
||||
@@ -675,6 +689,7 @@ func (r *organizationResolver) DataProtectionImpactAssessmentsDocument(ctx conte
|
||||
r.logger.ErrorCtx(ctx, "cannot get DPIA list document ID", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
if documentID == nil {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -684,7 +699,9 @@ func (r *organizationResolver) DataProtectionImpactAssessmentsDocument(ctx conte
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load DPIA list document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -735,6 +752,7 @@ func (r *organizationResolver) TransferImpactAssessmentsDocument(ctx context.Con
|
||||
r.logger.ErrorCtx(ctx, "cannot get TIA list document ID", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
if documentID == nil {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -744,7 +762,9 @@ func (r *organizationResolver) TransferImpactAssessmentsDocument(ctx context.Con
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load TIA list document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -872,6 +892,7 @@ func (r *organizationResolver) ObligationsDocument(ctx context.Context, obj *typ
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get obligation list document ID: %w", err)
|
||||
}
|
||||
|
||||
if obligationDocumentID == nil {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -959,6 +980,7 @@ func (r *organizationResolver) ProcessingActivitiesDocument(ctx context.Context,
|
||||
r.logger.ErrorCtx(ctx, "cannot get processing activities document ID", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
if documentID == nil {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -968,7 +990,9 @@ func (r *organizationResolver) ProcessingActivitiesDocument(ctx context.Context,
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load processing activities document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1054,6 +1078,7 @@ func (r *organizationResolver) RisksDocument(ctx context.Context, obj *types.Org
|
||||
r.logger.ErrorCtx(ctx, "cannot get risks document ID", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
if documentID == nil {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -1063,7 +1088,9 @@ func (r *organizationResolver) RisksDocument(ctx context.Context, obj *types.Org
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load risks document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1313,6 +1340,7 @@ func (r *organizationResolver) ThirdPartiesDocument(ctx context.Context, obj *ty
|
||||
r.logger.ErrorCtx(ctx, "cannot get thirdParties document ID", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
if documentID == nil {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -1322,7 +1350,9 @@ func (r *organizationResolver) ThirdPartiesDocument(ctx context.Context, obj *ty
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load thirdParties document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1382,18 +1412,22 @@ func (r *profileConnectionResolver) TotalCount(ctx context.Context, obj *types.P
|
||||
r.logger.ErrorCtx(ctx, "cannot count profiles", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *documentVersionResolver:
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
|
||||
count, err := prb.Documents.CountVersionApprovers(ctx, obj.ParentID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot count document version approvers", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver for profile connection", log.String("resolver", fmt.Sprintf("%T", obj.Resolver)))
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -137,10 +137,13 @@ func (r *mutationResolver) PublishProcessingActivityList(ctx context.Context, in
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
|
||||
return nil, gqlutils.Invalid(ctx, errMinor)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot publish processing activity list", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -165,6 +168,7 @@ func (r *processingActivityResolver) Organization(ctx context.Context, obj *type
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -190,6 +194,7 @@ func (r *processingActivityResolver) DataProtectionOfficer(ctx context.Context,
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get data protection officer", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -239,7 +244,9 @@ func (r *processingActivityResolver) DataProtectionImpactAssessment(ctx context.
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get processing activity dpia", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -259,7 +266,9 @@ func (r *processingActivityResolver) TransferImpactAssessment(ctx context.Contex
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get processing activity tia", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -286,10 +295,12 @@ func (r *processingActivityConnectionResolver) TotalCount(ctx context.Context, o
|
||||
r.logger.ErrorCtx(ctx, "cannot count organization processing activities", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -33,12 +33,14 @@ func probeConnection(ctx context.Context, httpClient *http.Client, probeURL stri
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot create probe request: %w", err)
|
||||
}
|
||||
|
||||
req.Header.Set("Accept", "application/json")
|
||||
|
||||
resp, err := httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("probe request failed: %w", err)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
_, _ = io.Copy(io.Discard, resp.Body)
|
||||
_ = resp.Body.Close()
|
||||
|
||||
@@ -162,6 +162,7 @@ func handleConnectorComplete(
|
||||
if err != nil {
|
||||
logger.ErrorCtx(r.Context(), "cannot complete connector", log.Error(err))
|
||||
httpserver.RenderError(w, http.StatusInternalServerError, fmt.Errorf("internal error"))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -196,6 +197,7 @@ func handleConnectorComplete(
|
||||
if err != nil {
|
||||
logger.ErrorCtx(r.Context(), "cannot reconnect connector", log.Error(err))
|
||||
httpserver.RenderError(w, http.StatusInternalServerError, fmt.Errorf("internal error"))
|
||||
|
||||
return
|
||||
}
|
||||
} else {
|
||||
@@ -218,6 +220,7 @@ func handleConnectorComplete(
|
||||
// token response body.
|
||||
subdomain = state.ProviderMetadata["subdomain"]
|
||||
}
|
||||
|
||||
// The subdomain comes from an attacker-influenceable
|
||||
// callback parameter; refuse anything that isn't a valid
|
||||
// DNS label so it cannot be smuggled into URLs or logs.
|
||||
@@ -225,8 +228,10 @@ func handleConnectorComplete(
|
||||
logger.WarnCtx(r.Context(), "rejecting invalid pagerduty subdomain",
|
||||
log.String("provider", string(connectorProvider)),
|
||||
)
|
||||
|
||||
subdomain = ""
|
||||
}
|
||||
|
||||
if subdomain != "" {
|
||||
createReq.PagerDutySettings = &coredata.PagerDutyConnectorSettings{
|
||||
Subdomain: subdomain,
|
||||
@@ -250,6 +255,7 @@ func handleConnectorComplete(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if teamID != "" {
|
||||
createReq.VercelSettings = &coredata.VercelConnectorSettings{
|
||||
TeamID: teamID,
|
||||
@@ -261,6 +267,7 @@ func handleConnectorComplete(
|
||||
if err != nil {
|
||||
logger.ErrorCtx(r.Context(), "cannot create connector", log.Error(err))
|
||||
httpserver.RenderError(w, http.StatusInternalServerError, fmt.Errorf("internal error"))
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -273,8 +280,10 @@ func handleConnectorComplete(
|
||||
parsedURL, err := url.Parse(redirectURL)
|
||||
if err != nil {
|
||||
logger.ErrorCtx(r.Context(), "cannot parse redirect URL", log.Error(err))
|
||||
|
||||
parsedURL, _ = url.Parse(baseURL.WithPath("/organizations/" + organizationID.String()).MustString())
|
||||
}
|
||||
|
||||
q := parsedURL.Query()
|
||||
q.Set("connector_id", cnnctr.ID.String())
|
||||
q.Set("provider", string(connectorProvider))
|
||||
@@ -296,11 +305,13 @@ func handleConnectorOAuth2Error(
|
||||
|
||||
provider := "unknown"
|
||||
redirectURL := baseURL.String()
|
||||
|
||||
if stateToken := query.Get("state"); stateToken != "" {
|
||||
if payload, err := connector.DecodeOAuth2StatePayload(stateToken); err == nil {
|
||||
if payload.Data.Provider != "" {
|
||||
provider = payload.Data.Provider
|
||||
}
|
||||
|
||||
if payload.Data.ContinueURL != "" {
|
||||
redirectURL = payload.Data.ContinueURL
|
||||
}
|
||||
@@ -331,6 +342,7 @@ func isValidPagerDutySubdomain(s string) bool {
|
||||
if s == "" || len(s) > 63 {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, c := range s {
|
||||
switch {
|
||||
case c >= 'a' && c <= 'z':
|
||||
@@ -341,6 +353,7 @@ func isValidPagerDutySubdomain(s string) bool {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,9 @@ func (r *mutationResolver) CreateRightsRequest(ctx context.Context, input types.
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create rights request", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -76,7 +78,9 @@ func (r *mutationResolver) UpdateRightsRequest(ctx context.Context, input types.
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update rights request", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -123,7 +127,9 @@ func (r *rightsRequestResolver) Organization(ctx context.Context, obj *types.Rig
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,9 @@ func (r *mutationResolver) CreateRisk(ctx context.Context, input types.CreateRis
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create risk", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -91,7 +93,9 @@ func (r *mutationResolver) UpdateRisk(ctx context.Context, input types.UpdateRis
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update risk", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -252,10 +256,13 @@ func (r *mutationResolver) PublishRiskList(ctx context.Context, input types.Publ
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
|
||||
return nil, gqlutils.Invalid(ctx, errMinor)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot publish risk list", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -284,6 +291,7 @@ func (r *riskResolver) Owner(ctx context.Context, obj *types.Risk) (*types.Profi
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get owner", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -305,6 +313,7 @@ func (r *riskResolver) Organization(ctx context.Context, obj *types.Risk) (*type
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -404,6 +413,7 @@ func (r *riskResolver) Controls(ctx context.Context, obj *types.Risk, first *int
|
||||
}
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
var filters = coredata.NewControlFilter(nil)
|
||||
if filter != nil {
|
||||
filters = coredata.NewControlFilter(filter.Query)
|
||||
@@ -490,6 +500,7 @@ func (r *riskConnectionResolver) TotalCount(ctx context.Context, obj *types.Risk
|
||||
r.logger.ErrorCtx(ctx, "cannot count risks", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *organizationResolver:
|
||||
count, err := prb.Risks.CountForOrganizationID(ctx, obj.ParentID, obj.Filters)
|
||||
@@ -497,6 +508,7 @@ func (r *riskConnectionResolver) TotalCount(ctx context.Context, obj *types.Risk
|
||||
r.logger.ErrorCtx(ctx, "cannot count risks", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *riskAssessmentScenarioResolver:
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
@@ -509,6 +521,7 @@ func (r *riskConnectionResolver) TotalCount(ctx context.Context, obj *types.Risk
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,9 @@ func (r *mutationResolver) CreateTask(ctx context.Context, input types.CreateTas
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create task", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -87,7 +89,9 @@ func (r *mutationResolver) UpdateTask(ctx context.Context, input types.UpdateTas
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update task", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -134,6 +138,7 @@ func (r *taskResolver) AssignedTo(ctx context.Context, obj *types.Task) (*types.
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get assigned to", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -155,6 +160,7 @@ func (r *taskResolver) Organization(ctx context.Context, obj *types.Task) (*type
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -180,6 +186,7 @@ func (r *taskResolver) Measure(ctx context.Context, obj *types.Task) (*types.Mea
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get measure", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -206,6 +213,7 @@ func (r *taskResolver) Evidences(ctx context.Context, obj *types.Task, first *in
|
||||
}
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
page, err := prb.Evidences.ListForTaskID(ctx, obj.ID, cursor)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot list task evidences", log.Error(err))
|
||||
@@ -235,6 +243,7 @@ func (r *taskConnectionResolver) TotalCount(ctx context.Context, obj *types.Task
|
||||
r.logger.ErrorCtx(ctx, "cannot count tasks", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *organizationResolver:
|
||||
count, err := prb.Tasks.CountForOrganizationID(ctx, obj.ParentID)
|
||||
@@ -242,10 +251,12 @@ func (r *taskConnectionResolver) TotalCount(ctx context.Context, obj *types.Task
|
||||
r.logger.ErrorCtx(ctx, "cannot count tasks", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -66,9 +66,12 @@ func (r *mutationResolver) CreateThirdParty(ctx context.Context, input types.Cre
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create thirdParty", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return &types.CreateThirdPartyPayload{
|
||||
ThirdPartyEdge: types.NewThirdPartyEdge(thirdParty, coredata.ThirdPartyOrderFieldName),
|
||||
}, nil
|
||||
@@ -112,7 +115,9 @@ func (r *mutationResolver) UpdateThirdParty(ctx context.Context, input types.Upd
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update thirdParty", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -161,7 +166,9 @@ func (r *mutationResolver) CreateThirdPartyContact(ctx context.Context, input ty
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create thirdParty contact", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -191,7 +198,9 @@ func (r *mutationResolver) UpdateThirdPartyContact(ctx context.Context, input ty
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update thirdParty contact", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -238,7 +247,9 @@ func (r *mutationResolver) CreateThirdPartyService(ctx context.Context, input ty
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create thirdParty service", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -266,7 +277,9 @@ func (r *mutationResolver) UpdateThirdPartyService(ctx context.Context, input ty
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update thirdParty service", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -316,7 +329,9 @@ func (r *mutationResolver) UploadThirdPartyComplianceReport(ctx context.Context,
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot upload thirdParty compliance report", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -366,7 +381,9 @@ func (r *mutationResolver) UploadThirdPartyBusinessAssociateAgreement(ctx contex
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot upload thirdParty business associate agreement", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -395,7 +412,9 @@ func (r *mutationResolver) UpdateThirdPartyBusinessAssociateAgreement(ctx contex
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update thirdParty business associate agreement", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -445,7 +464,9 @@ func (r *mutationResolver) UploadThirdPartyDataPrivacyAgreement(ctx context.Cont
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot upload thirdParty data privacy agreement", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -474,7 +495,9 @@ func (r *mutationResolver) UpdateThirdPartyDataPrivacyAgreement(ctx context.Cont
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update thirdParty data privacy agreement", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -524,7 +547,9 @@ func (r *mutationResolver) CreateThirdPartyRiskAssessment(ctx context.Context, i
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create thirdParty risk assessment", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -555,6 +580,7 @@ func (r *mutationResolver) AssessThirdParty(ctx context.Context, input types.Ass
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot assess thirdParty", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -578,10 +604,13 @@ func (r *mutationResolver) PublishThirdPartyList(ctx context.Context, input type
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
|
||||
return nil, gqlutils.Invalid(ctx, errMinor)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot publish thirdParty list", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -606,6 +635,7 @@ func (r *thirdPartyResolver) Organization(ctx context.Context, obj *types.ThirdP
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -657,6 +687,7 @@ func (r *thirdPartyResolver) BusinessAssociateAgreement(ctx context.Context, obj
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get thirdParty business associate agreement", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -678,6 +709,7 @@ func (r *thirdPartyResolver) DataPrivacyAgreement(ctx context.Context, obj *type
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get thirdParty data privacy agreement", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -793,6 +825,7 @@ func (r *thirdPartyResolver) BusinessOwner(ctx context.Context, obj *types.Third
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get business owner", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -818,6 +851,7 @@ func (r *thirdPartyResolver) SecurityOwner(ctx context.Context, obj *types.Third
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get security owner", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -886,6 +920,7 @@ func (r *thirdPartyComplianceReportResolver) ThirdParty(ctx context.Context, obj
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get thirdParty", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -917,6 +952,7 @@ func (r *thirdPartyComplianceReportResolver) File(ctx context.Context, obj *type
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load evidence file", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -943,6 +979,7 @@ func (r *thirdPartyConnectionResolver) TotalCount(ctx context.Context, obj *type
|
||||
r.logger.ErrorCtx(ctx, "cannot count thirdParties", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *assetResolver:
|
||||
count, err := prb.ThirdParties.CountForAssetID(ctx, obj.ParentID)
|
||||
@@ -950,6 +987,7 @@ func (r *thirdPartyConnectionResolver) TotalCount(ctx context.Context, obj *type
|
||||
r.logger.ErrorCtx(ctx, "cannot count thirdParties", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *datumResolver:
|
||||
count, err := prb.ThirdParties.CountForDatumID(ctx, obj.ParentID)
|
||||
@@ -957,10 +995,12 @@ func (r *thirdPartyConnectionResolver) TotalCount(ctx context.Context, obj *type
|
||||
r.logger.ErrorCtx(ctx, "cannot count thirdParties", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -986,6 +1026,7 @@ func (r *thirdPartyContactResolver) ThirdParty(ctx context.Context, obj *types.T
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get thirdParty", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1012,6 +1053,7 @@ func (r *thirdPartyDataPrivacyAgreementResolver) ThirdParty(ctx context.Context,
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get thirdParty", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1055,6 +1097,7 @@ func (r *thirdPartyRiskAssessmentResolver) ThirdParty(ctx context.Context, obj *
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get thirdParty", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1081,6 +1124,7 @@ func (r *thirdPartyServiceResolver) ThirdParty(ctx context.Context, obj *types.T
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get thirdParty", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ func (r *complianceFrameworkResolver) Framework(ctx context.Context, obj *types.
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load framework", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -75,7 +76,9 @@ func (r *mutationResolver) UpdateTrustCenter(ctx context.Context, input types.Up
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update trust center", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -104,7 +107,9 @@ func (r *mutationResolver) UploadTrustCenterNda(ctx context.Context, input types
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot upload trust center NDA", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -148,6 +153,7 @@ func (r *mutationResolver) UpdateTrustCenterBrand(ctx context.Context, input typ
|
||||
logoFile := input.LogoFile.Value()
|
||||
if logoFile == nil {
|
||||
var nilFile *probo.FileUpload
|
||||
|
||||
req.LogoFile = &nilFile
|
||||
} else {
|
||||
fileUpload := &probo.FileUpload{
|
||||
@@ -164,6 +170,7 @@ func (r *mutationResolver) UpdateTrustCenterBrand(ctx context.Context, input typ
|
||||
darkLogoFile := input.DarkLogoFile.Value()
|
||||
if darkLogoFile == nil {
|
||||
var nilFile *probo.FileUpload
|
||||
|
||||
req.DarkLogoFile = &nilFile
|
||||
} else {
|
||||
fileUpload := &probo.FileUpload{
|
||||
@@ -181,7 +188,9 @@ func (r *mutationResolver) UpdateTrustCenterBrand(ctx context.Context, input typ
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update trust center brand", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -198,27 +207,33 @@ func (r *mutationResolver) UpdateTrustCenterAccess(ctx context.Context, input ty
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
|
||||
var documentAccesses []probo.UpdateTrustCenterDocumentAccessRequest
|
||||
var reportAccesses []probo.UpdateTrustCenterDocumentAccessRequest
|
||||
var fileAccesses []probo.UpdateTrustCenterDocumentAccessRequest
|
||||
var (
|
||||
documentAccesses []probo.UpdateTrustCenterDocumentAccessRequest
|
||||
reportAccesses []probo.UpdateTrustCenterDocumentAccessRequest
|
||||
fileAccesses []probo.UpdateTrustCenterDocumentAccessRequest
|
||||
)
|
||||
|
||||
for _, documentAccess := range input.Documents {
|
||||
documentAccesses = append(documentAccesses, probo.UpdateTrustCenterDocumentAccessRequest{
|
||||
ID: documentAccess.ID,
|
||||
Status: documentAccess.Status,
|
||||
})
|
||||
}
|
||||
|
||||
for _, reportAccess := range input.Reports {
|
||||
reportAccesses = append(reportAccesses, probo.UpdateTrustCenterDocumentAccessRequest{
|
||||
ID: reportAccess.ID,
|
||||
Status: reportAccess.Status,
|
||||
})
|
||||
}
|
||||
|
||||
for _, fileAccess := range input.TrustCenterFiles {
|
||||
fileAccesses = append(fileAccesses, probo.UpdateTrustCenterDocumentAccessRequest{
|
||||
ID: fileAccess.ID,
|
||||
Status: fileAccess.Status,
|
||||
})
|
||||
}
|
||||
|
||||
access, err := prb.TrustCenterAccesses.Update(
|
||||
ctx,
|
||||
&probo.UpdateTrustCenterAccessRequest{
|
||||
@@ -232,7 +247,9 @@ func (r *mutationResolver) UpdateTrustCenterAccess(ctx context.Context, input ty
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update trust center access", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -287,7 +304,9 @@ func (r *mutationResolver) CreateTrustCenterReference(ctx context.Context, input
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create trust center reference", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -326,7 +345,9 @@ func (r *mutationResolver) UpdateTrustCenterReference(ctx context.Context, input
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update trust center reference", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -373,7 +394,9 @@ func (r *mutationResolver) CreateComplianceFramework(ctx context.Context, input
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create compliance framework", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -398,7 +421,9 @@ func (r *mutationResolver) UpdateComplianceFramework(ctx context.Context, input
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update compliance framework", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -425,7 +450,9 @@ func (r *mutationResolver) DeleteComplianceFramework(ctx context.Context, input
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot delete compliance framework", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -454,7 +481,9 @@ func (r *mutationResolver) CreateComplianceExternalURL(ctx context.Context, inpu
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create compliance external URL", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -481,7 +510,9 @@ func (r *mutationResolver) UpdateComplianceExternalURL(ctx context.Context, inpu
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update compliance external URL", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -502,7 +533,9 @@ func (r *mutationResolver) DeleteComplianceExternalURL(ctx context.Context, inpu
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot delete compliance external URL", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -538,7 +571,9 @@ func (r *mutationResolver) CreateTrustCenterFile(ctx context.Context, input type
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create trust center file", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -568,7 +603,9 @@ func (r *mutationResolver) UpdateTrustCenterFile(ctx context.Context, input type
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update trust center file", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -634,7 +671,9 @@ func (r *mutationResolver) CreateCustomDomain(ctx context.Context, input types.C
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create custom domain", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -753,6 +792,7 @@ func (r *trustCenterResolver) Organization(ctx context.Context, obj *types.Trust
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -956,6 +996,7 @@ func (r *trustCenterAccessResolver) ActiveCount(ctx context.Context, obj *types.
|
||||
if err := r.authorize(ctx, obj.ID, probo.ActionTrustCenterAccessGet); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
count, err := prb.TrustCenterAccesses.CountActiveDocumentAccesses(ctx, obj.ID)
|
||||
@@ -980,6 +1021,7 @@ func (r *trustCenterAccessResolver) Profile(ctx context.Context, obj *types.Trus
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get profile", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1040,6 +1082,7 @@ func (r *trustCenterDocumentAccessResolver) Document(ctx context.Context, obj *t
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1143,6 +1186,7 @@ func (r *trustCenterFileResolver) Organization(ctx context.Context, obj *types.T
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1167,6 +1211,7 @@ func (r *trustCenterFileConnectionResolver) TotalCount(ctx context.Context, obj
|
||||
r.logger.ErrorCtx(ctx, "cannot count trust center files", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -108,9 +108,13 @@ func NewAccessReviewCampaignScopeSource(
|
||||
status := coredata.AccessReviewCampaignSourceFetchStatusQueued
|
||||
fetchedAccountsCount := 0
|
||||
attemptCount := 0
|
||||
var lastError *string
|
||||
var fetchStartedAt *time.Time
|
||||
var fetchCompletedAt *time.Time
|
||||
|
||||
var (
|
||||
lastError *string
|
||||
fetchStartedAt *time.Time
|
||||
fetchCompletedAt *time.Time
|
||||
)
|
||||
|
||||
if fetch != nil {
|
||||
status = fetch.Status
|
||||
fetchedAccountsCount = fetch.FetchedAccountsCount
|
||||
|
||||
@@ -33,13 +33,16 @@ func TestNewAccessReviewCampaignScopeSource_DefaultFetchState(t *testing.T) {
|
||||
}
|
||||
|
||||
campaignID := gid.New(tenantID, coredata.AccessReviewCampaignEntityType)
|
||||
|
||||
got := NewAccessReviewCampaignScopeSource(campaignID, source, nil)
|
||||
if got.FetchStatus != coredata.AccessReviewCampaignSourceFetchStatusQueued {
|
||||
t.Fatalf("fetch status = %q, want QUEUED", got.FetchStatus)
|
||||
}
|
||||
|
||||
if got.FetchedAccountsCount != 0 {
|
||||
t.Fatalf("fetched accounts count = %d, want 0", got.FetchedAccountsCount)
|
||||
}
|
||||
|
||||
if got.AttemptCount != 0 {
|
||||
t.Fatalf("attempt count = %d, want 0", got.AttemptCount)
|
||||
}
|
||||
@@ -66,16 +69,20 @@ func TestNewAccessReviewCampaignScopeSource_UsesFetchState(t *testing.T) {
|
||||
}
|
||||
|
||||
campaignID := gid.New(tenantID, coredata.AccessReviewCampaignEntityType)
|
||||
|
||||
got := NewAccessReviewCampaignScopeSource(campaignID, source, fetch)
|
||||
if got.FetchStatus != coredata.AccessReviewCampaignSourceFetchStatusFailed {
|
||||
t.Fatalf("fetch status = %q, want FAILED", got.FetchStatus)
|
||||
}
|
||||
|
||||
if got.FetchedAccountsCount != 42 {
|
||||
t.Fatalf("fetched accounts count = %d, want 42", got.FetchedAccountsCount)
|
||||
}
|
||||
|
||||
if got.AttemptCount != 3 {
|
||||
t.Fatalf("attempt count = %d, want 3", got.AttemptCount)
|
||||
}
|
||||
|
||||
if got.LastError == nil || *got.LastError != errMsg {
|
||||
t.Fatalf("last error = %v, want %q", got.LastError, errMsg)
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ func NewComplianceExternalURLConnection(
|
||||
for i := range edges {
|
||||
edges[i] = NewComplianceExternalURLEdge(p.Data[i], p.Cursor.OrderBy.Field)
|
||||
}
|
||||
|
||||
return &ComplianceExternalURLConnection{
|
||||
Edges: edges,
|
||||
PageInfo: NewPageInfo(p),
|
||||
|
||||
@@ -65,6 +65,7 @@ func NewCookieCategory(c *coredata.CookieCategory) *CookieCategory {
|
||||
if gcmConsentTypes == nil {
|
||||
gcmConsentTypes = []string{}
|
||||
}
|
||||
|
||||
return &CookieCategory{
|
||||
ID: c.ID,
|
||||
CookieBanner: &CookieBanner{
|
||||
|
||||
@@ -62,6 +62,7 @@ func NewEvidenceEdge(e *coredata.Evidence, orderBy coredata.EvidenceOrderField)
|
||||
|
||||
func NewEvidence(e *coredata.Evidence) *Evidence {
|
||||
var urlPtr *string = nil
|
||||
|
||||
if e.URL != "" {
|
||||
urlCopy := e.URL
|
||||
urlPtr = &urlCopy
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
|
||||
func NewPageInfo[T page.Paginable[O], O page.OrderField](p *page.Page[T, O]) *PageInfo {
|
||||
data := pageinfo.NewPageInfo(p)
|
||||
|
||||
return &PageInfo{
|
||||
HasNextPage: data.HasNextPage,
|
||||
HasPreviousPage: data.HasPreviousPage,
|
||||
|
||||
@@ -51,6 +51,7 @@ func NewSlackConnection(c *coredata.Connector) *SlackConnection {
|
||||
if settings.Channel != "" {
|
||||
conn.Channel = &settings.Channel
|
||||
}
|
||||
|
||||
if settings.ChannelID != "" {
|
||||
conn.ChannelID = &settings.ChannelID
|
||||
}
|
||||
|
||||
@@ -113,5 +113,6 @@ func NewThirdPartySubprocessors(sps []probo.Subprocessor) []*ThirdPartySubproces
|
||||
Purpose: sp.Purpose,
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ func NewTrackerPatternConnectionWithFilter(
|
||||
) *TrackerPatternConnection {
|
||||
conn := NewTrackerPatternConnection(p, parentType, parentID)
|
||||
conn.Filter = filter
|
||||
|
||||
return conn
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ func NewTrackerResourceConnectionWithFilter(
|
||||
) *TrackerResourceConnection {
|
||||
conn := NewTrackerResourceConnection(p, parentType, parentID)
|
||||
conn.Filter = filter
|
||||
|
||||
return conn
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ func NewWebhookEventEdge(we *coredata.WebhookEvent, orderBy coredata.WebhookEven
|
||||
|
||||
func NewWebhookEvent(we *coredata.WebhookEvent) *WebhookEvent {
|
||||
var response *string
|
||||
|
||||
if len(we.Response) > 0 {
|
||||
s := string(we.Response)
|
||||
response = &s
|
||||
|
||||
@@ -79,6 +79,7 @@ func (r *viewerResolver) SignableDocument(ctx context.Context, obj *types.Viewer
|
||||
identity := authn.IdentityFromContext(ctx)
|
||||
|
||||
documentFilter := coredata.NewDocumentFilter(nil).WithEmployeeIdentityID(&identity.ID, coredata.EmployeeFilterModeSignature)
|
||||
|
||||
document, err := prb.Documents.GetWithFilter(ctx, id, documentFilter)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
@@ -86,6 +87,7 @@ func (r *viewerResolver) SignableDocument(ctx context.Context, obj *types.Viewer
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get signable document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -158,6 +160,7 @@ func (r *viewerResolver) ApprovableDocument(ctx context.Context, obj *types.View
|
||||
identity := authn.IdentityFromContext(ctx)
|
||||
|
||||
documentFilter := coredata.NewDocumentFilter(nil).WithEmployeeIdentityID(&identity.ID, coredata.EmployeeFilterModeApproval)
|
||||
|
||||
document, err := prb.Documents.GetWithFilter(ctx, id, documentFilter)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
@@ -165,6 +168,7 @@ func (r *viewerResolver) ApprovableDocument(ctx context.Context, obj *types.View
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get approvable document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,9 @@ func (r *mutationResolver) CreateWebhookSubscription(ctx context.Context, input
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create webhook subscription", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -71,7 +73,9 @@ func (r *mutationResolver) UpdateWebhookSubscription(ctx context.Context, input
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update webhook subscription", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -131,6 +135,7 @@ func (r *webhookSubscriptionResolver) Organization(ctx context.Context, obj *typ
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -204,10 +209,12 @@ func (r *webhookSubscriptionConnectionResolver) TotalCount(ctx context.Context,
|
||||
r.logger.ErrorCtx(ctx, "cannot count webhook subscriptions", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver for webhook subscription connection", log.String("resolver", fmt.Sprintf("%T", obj.Resolver)))
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -53,8 +53,10 @@ func newCORSMiddleware(logger *log.Logger, cookieBannerSvc *cookiebanner.Service
|
||||
jsonutil.RenderForbidden(w)
|
||||
return
|
||||
}
|
||||
|
||||
logger.ErrorCtx(r.Context(), "cannot load cookie banner for CORS check", log.Error(err))
|
||||
jsonutil.RenderInternalServerError(w)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -88,12 +88,15 @@ func (h *Handler) handleGetConfig(w http.ResponseWriter, r *http.Request) {
|
||||
jsonutil.RenderNotFound(w, fmt.Errorf("banner not found"))
|
||||
return
|
||||
}
|
||||
|
||||
if errors.Is(err, cookiebanner.ErrNoPublishedVersion) {
|
||||
jsonutil.RenderNotFound(w, fmt.Errorf("no published version"))
|
||||
return
|
||||
}
|
||||
|
||||
h.logger.ErrorCtx(r.Context(), "cannot get banner config", log.Error(err), log.String("sdk_version", sdkVersion))
|
||||
jsonutil.RenderInternalServerError(w)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -111,6 +114,7 @@ func (h *Handler) resolveCountryCode(r *http.Request) *coredata.CountryCode {
|
||||
log.Error(err),
|
||||
log.String("sdk_version", sdkVersionFromContext(r.Context())),
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -140,10 +144,12 @@ func (h *Handler) handleGetConsent(w http.ResponseWriter, r *http.Request) {
|
||||
jsonutil.RenderNotFound(w, fmt.Errorf("banner not found"))
|
||||
return
|
||||
}
|
||||
|
||||
if errors.Is(err, cookiebanner.ErrConsentNotFound) {
|
||||
jsonutil.RenderNotFound(w, fmt.Errorf("consent not found"))
|
||||
return
|
||||
}
|
||||
|
||||
h.logger.ErrorCtx(
|
||||
r.Context(),
|
||||
"cannot get visitor consent",
|
||||
@@ -151,6 +157,7 @@ func (h *Handler) handleGetConsent(w http.ResponseWriter, r *http.Request) {
|
||||
log.String("sdk_version", sdkVersionFromContext(r.Context())),
|
||||
)
|
||||
jsonutil.RenderInternalServerError(w)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -221,12 +228,15 @@ func (h *Handler) handlePostConsent(w http.ResponseWriter, r *http.Request) {
|
||||
jsonutil.RenderNotFound(w, fmt.Errorf("banner not found"))
|
||||
return
|
||||
}
|
||||
|
||||
if errors.Is(err, cookiebanner.ErrVersionNotFound) || errors.Is(err, cookiebanner.ErrVersionNotPublished) {
|
||||
jsonutil.RenderBadRequest(w, fmt.Errorf("invalid version"))
|
||||
return
|
||||
}
|
||||
|
||||
h.logger.ErrorCtx(r.Context(), "cannot record consent", log.Error(err), log.String("sdk_version", sdkVersion))
|
||||
jsonutil.RenderInternalServerError(w)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -266,20 +276,25 @@ func sanitizeInitiatorURL(raw *string) *string {
|
||||
if raw == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
s := strings.TrimSpace(*raw)
|
||||
if s == "" || len(s) > maxInitiatorURLLength {
|
||||
return nil
|
||||
}
|
||||
|
||||
u, err := url.Parse(s)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if u.Scheme != "http" && u.Scheme != "https" {
|
||||
return nil
|
||||
}
|
||||
|
||||
if u.Host == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &s
|
||||
}
|
||||
|
||||
@@ -314,6 +329,7 @@ func (h *Handler) handleReportDetectedCookies(w http.ResponseWriter, r *http.Req
|
||||
}
|
||||
|
||||
var source coredata.CookieSource
|
||||
|
||||
switch strings.TrimSpace(c.Source) {
|
||||
case "pre-existing":
|
||||
source = coredata.CookieSourcePreExisting
|
||||
@@ -356,6 +372,7 @@ func (h *Handler) handleReportDetectedCookies(w http.ResponseWriter, r *http.Req
|
||||
log.String("sdk_version", sdkVersionFromContext(r.Context())),
|
||||
)
|
||||
jsonutil.RenderInternalServerError(w)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -415,6 +432,7 @@ func (h *Handler) handleReportDetectedTrackers(w http.ResponseWriter, r *http.Re
|
||||
}
|
||||
|
||||
var source coredata.CookieSource
|
||||
|
||||
switch strings.TrimSpace(c.Source) {
|
||||
case "pre-existing":
|
||||
source = coredata.CookieSourcePreExisting
|
||||
@@ -442,6 +460,7 @@ func (h *Handler) handleReportDetectedTrackers(w http.ResponseWriter, r *http.Re
|
||||
}
|
||||
|
||||
var storageType coredata.TrackerType
|
||||
|
||||
switch strings.TrimSpace(s.StorageType) {
|
||||
case "local_storage":
|
||||
storageType = coredata.TrackerTypeLocalStorage
|
||||
@@ -476,6 +495,7 @@ func (h *Handler) handleReportDetectedTrackers(w http.ResponseWriter, r *http.Re
|
||||
}
|
||||
|
||||
var resourceType coredata.TrackerResourceType
|
||||
|
||||
switch strings.TrimSpace(res.ResourceType) {
|
||||
case "script":
|
||||
resourceType = coredata.TrackerResourceTypeScript
|
||||
@@ -521,6 +541,7 @@ func (h *Handler) handleReportDetectedTrackers(w http.ResponseWriter, r *http.Re
|
||||
|
||||
h.logger.ErrorCtx(r.Context(), "cannot report detected trackers", log.Error(err), log.String("sdk_version", sdkVersionFromContext(r.Context())))
|
||||
jsonutil.RenderInternalServerError(w)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ func (h *Handler) handleGetPublicFile(w http.ResponseWriter, r *http.Request) {
|
||||
log.String("file_id", fileIDStr),
|
||||
)
|
||||
http.Error(w, "internal server error", http.StatusInternalServerError)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,6 @@ func LoggingMiddleware(logger *log.Logger) func(mcp.MethodHandler) mcp.MethodHan
|
||||
log.Error(err),
|
||||
)
|
||||
} else {
|
||||
|
||||
logger.InfoCtx(
|
||||
ctx,
|
||||
fmt.Sprintf("mcp %q method completed", method),
|
||||
|
||||
@@ -88,5 +88,6 @@ func sanitizeError(ctx context.Context, logger *log.Logger, err error) error {
|
||||
}
|
||||
|
||||
logger.ErrorCtx(ctx, "internal error in MCP tool handler", log.Error(err))
|
||||
|
||||
return fmt.Errorf("internal server error")
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ func RequireAPIKeyHandler(
|
||||
) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
correlationID := r.Header.Get("X-Request-ID")
|
||||
if correlationID == "" {
|
||||
correlationID = r.Header.Get("X-Correlation-ID")
|
||||
@@ -43,10 +44,12 @@ func RequireAPIKeyHandler(
|
||||
)
|
||||
|
||||
apiKey := authn.APIKeyFromContext(ctx)
|
||||
|
||||
identity := authn.IdentityFromContext(ctx)
|
||||
if identity == nil {
|
||||
w.Header().Set("WWW-Authenticate", "Bearer")
|
||||
httpserver.RenderError(w, http.StatusUnauthorized, errors.New("authentication required"))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,7 @@ func (r *Resolver) AddThirdPartyTool(ctx context.Context, req *mcp.CallToolReque
|
||||
svc := r.ProboService(ctx, input.OrganizationID)
|
||||
|
||||
var category *coredata.ThirdPartyCategory
|
||||
|
||||
if input.Category != nil {
|
||||
cat := coredata.ThirdPartyCategory(*input.Category)
|
||||
category = &cat
|
||||
@@ -211,6 +212,7 @@ func (r *Resolver) UpdateThirdPartyTool(ctx context.Context, req *mcp.CallToolRe
|
||||
}
|
||||
|
||||
var category *coredata.ThirdPartyCategory
|
||||
|
||||
if input.Category != nil {
|
||||
cat := coredata.ThirdPartyCategory(*input.Category)
|
||||
category = &cat
|
||||
@@ -1403,14 +1405,17 @@ func (r *Resolver) ListControlsTool(ctx context.Context, req *mcp.CallToolReques
|
||||
controlFilter = coredata.NewControlFilter(input.Filter.Query)
|
||||
}
|
||||
|
||||
var controlPage *page.Page[*coredata.Control, coredata.ControlOrderField]
|
||||
var err error
|
||||
var (
|
||||
controlPage *page.Page[*coredata.Control, coredata.ControlOrderField]
|
||||
err error
|
||||
)
|
||||
|
||||
if input.Filter != nil && input.Filter.FrameworkID != nil {
|
||||
controlPage, err = prb.Controls.ListForFrameworkID(ctx, *input.Filter.FrameworkID, cursor, controlFilter)
|
||||
} else {
|
||||
controlPage, err = prb.Controls.ListForOrganizationID(ctx, input.OrganizationID, cursor, controlFilter)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list organization controls: %w", err))
|
||||
}
|
||||
@@ -1465,6 +1470,7 @@ func (r *Resolver) UpdateControlTool(ctx context.Context, req *mcp.CallToolReque
|
||||
svc := r.ProboService(ctx, input.ID)
|
||||
|
||||
var maturityLevel *coredata.ControlMaturityLevel
|
||||
|
||||
if input.MaturityLevel != nil {
|
||||
v := coredata.ControlMaturityLevel(*input.MaturityLevel)
|
||||
maturityLevel = &v
|
||||
@@ -1497,21 +1503,25 @@ func (r *Resolver) LinkControlTool(ctx context.Context, req *mcp.CallToolRequest
|
||||
switch input.ResourceID.EntityType() {
|
||||
case coredata.MeasureEntityType:
|
||||
r.MustAuthorize(ctx, input.ControlID, probo.ActionControlMeasureMappingCreate)
|
||||
|
||||
if _, _, err := svc.Controls.CreateMeasureMapping(ctx, input.ControlID, input.ResourceID); err != nil {
|
||||
return nil, types.LinkControlOutput{}, fmt.Errorf("failed to link control to measure: %w", err)
|
||||
}
|
||||
case coredata.DocumentEntityType:
|
||||
r.MustAuthorize(ctx, input.ControlID, probo.ActionControlDocumentMappingCreate)
|
||||
|
||||
if _, _, err := svc.Controls.CreateDocumentMapping(ctx, input.ControlID, input.ResourceID); err != nil {
|
||||
return nil, types.LinkControlOutput{}, fmt.Errorf("failed to link control to document: %w", err)
|
||||
}
|
||||
case coredata.AuditEntityType:
|
||||
r.MustAuthorize(ctx, input.ControlID, probo.ActionControlAuditMappingCreate)
|
||||
|
||||
if _, _, err := svc.Controls.CreateAuditMapping(ctx, input.ControlID, input.ResourceID); err != nil {
|
||||
return nil, types.LinkControlOutput{}, fmt.Errorf("failed to link control to audit: %w", err)
|
||||
}
|
||||
case coredata.ObligationEntityType:
|
||||
r.MustAuthorize(ctx, input.ControlID, probo.ActionControlObligationMappingCreate)
|
||||
|
||||
if _, _, err := svc.Controls.CreateObligationMapping(ctx, input.ControlID, input.ResourceID); err != nil {
|
||||
return nil, types.LinkControlOutput{}, fmt.Errorf("failed to link control to obligation: %w", err)
|
||||
}
|
||||
@@ -1528,21 +1538,25 @@ func (r *Resolver) UnlinkControlTool(ctx context.Context, req *mcp.CallToolReque
|
||||
switch input.ResourceID.EntityType() {
|
||||
case coredata.MeasureEntityType:
|
||||
r.MustAuthorize(ctx, input.ControlID, probo.ActionControlMeasureMappingDelete)
|
||||
|
||||
if _, _, err := svc.Controls.DeleteMeasureMapping(ctx, input.ControlID, input.ResourceID); err != nil {
|
||||
return nil, types.UnlinkControlOutput{}, fmt.Errorf("failed to unlink control from measure: %w", err)
|
||||
}
|
||||
case coredata.DocumentEntityType:
|
||||
r.MustAuthorize(ctx, input.ControlID, probo.ActionControlDocumentMappingDelete)
|
||||
|
||||
if _, _, err := svc.Controls.DeleteDocumentMapping(ctx, input.ControlID, input.ResourceID); err != nil {
|
||||
return nil, types.UnlinkControlOutput{}, fmt.Errorf("failed to unlink control from document: %w", err)
|
||||
}
|
||||
case coredata.AuditEntityType:
|
||||
r.MustAuthorize(ctx, input.ControlID, probo.ActionControlAuditMappingDelete)
|
||||
|
||||
if _, _, err := svc.Controls.DeleteAuditMapping(ctx, input.ControlID, input.ResourceID); err != nil {
|
||||
return nil, types.UnlinkControlOutput{}, fmt.Errorf("failed to unlink control from audit: %w", err)
|
||||
}
|
||||
case coredata.ObligationEntityType:
|
||||
r.MustAuthorize(ctx, input.ControlID, probo.ActionControlObligationMappingDelete)
|
||||
|
||||
if _, _, err := svc.Controls.DeleteObligationMapping(ctx, input.ControlID, input.ResourceID); err != nil {
|
||||
return nil, types.UnlinkControlOutput{}, fmt.Errorf("failed to unlink control from obligation: %w", err)
|
||||
}
|
||||
@@ -1689,16 +1703,19 @@ func (r *Resolver) LinkRiskTool(ctx context.Context, req *mcp.CallToolRequest, i
|
||||
switch input.ResourceID.EntityType() {
|
||||
case coredata.DocumentEntityType:
|
||||
r.MustAuthorize(ctx, input.RiskID, probo.ActionRiskDocumentMappingCreate)
|
||||
|
||||
if _, _, err := svc.Risks.CreateDocumentMapping(ctx, input.RiskID, input.ResourceID); err != nil {
|
||||
return nil, types.LinkRiskOutput{}, fmt.Errorf("failed to link risk to document: %w", err)
|
||||
}
|
||||
case coredata.MeasureEntityType:
|
||||
r.MustAuthorize(ctx, input.RiskID, probo.ActionRiskMeasureMappingCreate)
|
||||
|
||||
if _, _, err := svc.Risks.CreateMeasureMapping(ctx, input.RiskID, input.ResourceID); err != nil {
|
||||
return nil, types.LinkRiskOutput{}, fmt.Errorf("failed to link risk to measure: %w", err)
|
||||
}
|
||||
case coredata.ObligationEntityType:
|
||||
r.MustAuthorize(ctx, input.RiskID, probo.ActionRiskObligationMappingCreate)
|
||||
|
||||
if _, _, err := svc.Risks.CreateObligationMapping(ctx, input.RiskID, input.ResourceID); err != nil {
|
||||
return nil, types.LinkRiskOutput{}, fmt.Errorf("failed to link risk to obligation: %w", err)
|
||||
}
|
||||
@@ -1715,16 +1732,19 @@ func (r *Resolver) UnlinkRiskTool(ctx context.Context, req *mcp.CallToolRequest,
|
||||
switch input.ResourceID.EntityType() {
|
||||
case coredata.DocumentEntityType:
|
||||
r.MustAuthorize(ctx, input.RiskID, probo.ActionRiskDocumentMappingDelete)
|
||||
|
||||
if _, _, err := svc.Risks.DeleteDocumentMapping(ctx, input.RiskID, input.ResourceID); err != nil {
|
||||
return nil, types.UnlinkRiskOutput{}, fmt.Errorf("failed to unlink risk from document: %w", err)
|
||||
}
|
||||
case coredata.MeasureEntityType:
|
||||
r.MustAuthorize(ctx, input.RiskID, probo.ActionRiskMeasureMappingDelete)
|
||||
|
||||
if _, _, err := svc.Risks.DeleteMeasureMapping(ctx, input.RiskID, input.ResourceID); err != nil {
|
||||
return nil, types.UnlinkRiskOutput{}, fmt.Errorf("failed to unlink risk from measure: %w", err)
|
||||
}
|
||||
case coredata.ObligationEntityType:
|
||||
r.MustAuthorize(ctx, input.RiskID, probo.ActionRiskObligationMappingDelete)
|
||||
|
||||
if _, _, err := svc.Risks.DeleteObligationMapping(ctx, input.RiskID, input.ResourceID); err != nil {
|
||||
return nil, types.UnlinkRiskOutput{}, fmt.Errorf("failed to unlink risk from obligation: %w", err)
|
||||
}
|
||||
@@ -1770,6 +1790,7 @@ func (r *Resolver) GetTaskTool(ctx context.Context, req *mcp.CallToolRequest, in
|
||||
if err != nil {
|
||||
return nil, types.GetTaskOutput{}, fmt.Errorf("failed to get task: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.GetTaskOutput{
|
||||
Task: types.NewTask(task),
|
||||
}, nil
|
||||
@@ -1801,6 +1822,7 @@ func (r *Resolver) AddTaskTool(ctx context.Context, req *mcp.CallToolRequest, in
|
||||
if err != nil {
|
||||
return nil, types.AddTaskOutput{}, fmt.Errorf("failed to create task: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.AddTaskOutput{
|
||||
Task: types.NewTask(task),
|
||||
}, nil
|
||||
@@ -1829,6 +1851,7 @@ func (r *Resolver) UpdateTaskTool(ctx context.Context, req *mcp.CallToolRequest,
|
||||
if err != nil {
|
||||
return nil, types.UpdateTaskOutput{}, fmt.Errorf("failed to update task: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.UpdateTaskOutput{
|
||||
Task: types.NewTask(task),
|
||||
}, nil
|
||||
@@ -1858,6 +1881,7 @@ func (r *Resolver) UnassignTaskTool(ctx context.Context, req *mcp.CallToolReques
|
||||
if err != nil {
|
||||
return nil, types.UnassignTaskOutput{}, fmt.Errorf("failed to unassign task: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.UnassignTaskOutput{
|
||||
Task: types.NewTask(task),
|
||||
}, nil
|
||||
@@ -1898,6 +1922,7 @@ func (r *Resolver) ListDocumentsTool(ctx context.Context, req *mcp.CallToolReque
|
||||
|
||||
documentFilter := coredata.NewDocumentFilter(nil).
|
||||
WithStatus([]coredata.DocumentStatus{coredata.DocumentStatusActive})
|
||||
|
||||
if input.Filter != nil {
|
||||
var query *string
|
||||
if input.Filter.Query != nil && *input.Filter.Query != "" {
|
||||
@@ -1983,11 +2008,13 @@ func (r *Resolver) UpdateDocumentTool(ctx context.Context, req *mcp.CallToolRequ
|
||||
}
|
||||
|
||||
var content *string
|
||||
|
||||
if input.Content != nil {
|
||||
c, err := markdownToProseMirrorJSON(*input.Content)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot convert markdown to prosemirror: %w", err))
|
||||
}
|
||||
|
||||
content = &c
|
||||
}
|
||||
|
||||
@@ -2081,16 +2108,21 @@ func (r *Resolver) ListDocumentVersionSignaturesTool(ctx context.Context, req *m
|
||||
|
||||
cursor := types.NewCursor(input.Size, input.Cursor, pageOrderBy)
|
||||
|
||||
var signatureStates []coredata.DocumentVersionSignatureState
|
||||
var activeContract *bool
|
||||
var (
|
||||
signatureStates []coredata.DocumentVersionSignatureState
|
||||
activeContract *bool
|
||||
)
|
||||
|
||||
if input.Filter != nil {
|
||||
if input.Filter.States != nil {
|
||||
signatureStates = input.Filter.States
|
||||
}
|
||||
|
||||
if input.Filter.ActiveContract != nil {
|
||||
activeContract = input.Filter.ActiveContract
|
||||
}
|
||||
}
|
||||
|
||||
signatureFilter := coredata.NewDocumentVersionSignatureFilter(signatureStates, activeContract)
|
||||
|
||||
page, err := prb.Documents.ListSignatures(ctx, input.DocumentVersionID, cursor, signatureFilter)
|
||||
@@ -2301,16 +2333,19 @@ func (r *Resolver) LinkMeasureTool(ctx context.Context, req *mcp.CallToolRequest
|
||||
switch input.ResourceID.EntityType() {
|
||||
case coredata.ControlEntityType:
|
||||
r.MustAuthorize(ctx, input.MeasureID, probo.ActionControlMeasureMappingCreate)
|
||||
|
||||
if _, _, err := svc.Controls.CreateMeasureMapping(ctx, input.ResourceID, input.MeasureID); err != nil {
|
||||
return nil, types.LinkMeasureOutput{}, fmt.Errorf("failed to link measure to control: %w", err)
|
||||
}
|
||||
case coredata.RiskEntityType:
|
||||
r.MustAuthorize(ctx, input.MeasureID, probo.ActionRiskMeasureMappingCreate)
|
||||
|
||||
if _, _, err := svc.Risks.CreateMeasureMapping(ctx, input.ResourceID, input.MeasureID); err != nil {
|
||||
return nil, types.LinkMeasureOutput{}, fmt.Errorf("failed to link measure to risk: %w", err)
|
||||
}
|
||||
case coredata.DocumentEntityType:
|
||||
r.MustAuthorize(ctx, input.MeasureID, probo.ActionMeasureDocumentMappingCreate)
|
||||
|
||||
if _, _, err := svc.Measures.CreateDocumentMapping(ctx, input.MeasureID, input.ResourceID); err != nil {
|
||||
return nil, types.LinkMeasureOutput{}, fmt.Errorf("failed to link measure to document: %w", err)
|
||||
}
|
||||
@@ -2327,16 +2362,19 @@ func (r *Resolver) UnlinkMeasureTool(ctx context.Context, req *mcp.CallToolReque
|
||||
switch input.ResourceID.EntityType() {
|
||||
case coredata.ControlEntityType:
|
||||
r.MustAuthorize(ctx, input.MeasureID, probo.ActionControlMeasureMappingDelete)
|
||||
|
||||
if _, _, err := svc.Controls.DeleteMeasureMapping(ctx, input.ResourceID, input.MeasureID); err != nil {
|
||||
return nil, types.UnlinkMeasureOutput{}, fmt.Errorf("failed to unlink measure from control: %w", err)
|
||||
}
|
||||
case coredata.RiskEntityType:
|
||||
r.MustAuthorize(ctx, input.MeasureID, probo.ActionRiskMeasureMappingDelete)
|
||||
|
||||
if _, _, err := svc.Risks.DeleteMeasureMapping(ctx, input.ResourceID, input.MeasureID); err != nil {
|
||||
return nil, types.UnlinkMeasureOutput{}, fmt.Errorf("failed to unlink measure from risk: %w", err)
|
||||
}
|
||||
case coredata.DocumentEntityType:
|
||||
r.MustAuthorize(ctx, input.MeasureID, probo.ActionMeasureDocumentMappingDelete)
|
||||
|
||||
if _, _, err := svc.Measures.DeleteDocumentMapping(ctx, input.MeasureID, input.ResourceID); err != nil {
|
||||
return nil, types.UnlinkMeasureOutput{}, fmt.Errorf("failed to unlink measure from document: %w", err)
|
||||
}
|
||||
@@ -2360,6 +2398,7 @@ func (r *Resolver) ListUsersTool(ctx context.Context, req *mcp.CallToolRequest,
|
||||
Direction: input.OrderBy.Direction,
|
||||
}
|
||||
}
|
||||
|
||||
cursor := types.NewCursor(input.Size, input.Cursor, pageOrderBy)
|
||||
|
||||
filter := coredata.NewMembershipProfileFilter(nil).WithMembership()
|
||||
@@ -2379,11 +2418,14 @@ func (r *Resolver) ListUsersTool(ctx context.Context, req *mcp.CallToolRequest,
|
||||
for _, p := range pageResult.Data {
|
||||
users = append(users, types.NewProfile(p))
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(pageResult.Data) > 0 && pageResult.Cursor != nil {
|
||||
cursorKey := pageResult.Data[len(pageResult.Data)-1].CursorKey(pageResult.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
}
|
||||
|
||||
return nil, types.ListUsersOutput{
|
||||
Users: users,
|
||||
NextCursor: nextCursor,
|
||||
@@ -2397,9 +2439,12 @@ func (r *Resolver) GetUserTool(ctx context.Context, req *mcp.CallToolRequest, in
|
||||
if errors.As(err, &errNotFound) {
|
||||
return nil, types.GetUserOutput{}, fmt.Errorf("user not found: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.GetUserOutput{}, fmt.Errorf("get user: %w", err)
|
||||
}
|
||||
|
||||
r.MustAuthorize(ctx, profile.OrganizationID, iam.ActionMembershipProfileGet)
|
||||
|
||||
return nil, types.GetUserOutput{User: types.NewProfile(profile)}, nil
|
||||
}
|
||||
|
||||
@@ -2410,9 +2455,11 @@ func (r *Resolver) CreateUserTool(ctx context.Context, req *mcp.CallToolRequest,
|
||||
if input.ContractStartDate != nil {
|
||||
contractStart = &input.ContractStartDate
|
||||
}
|
||||
|
||||
if input.ContractEndDate != nil {
|
||||
contractEnd = &input.ContractEndDate
|
||||
}
|
||||
|
||||
profile, err := r.iamSvc.OrganizationService.CreateUser(ctx, &iam.CreateUserRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
EmailAddress: input.EmailAddress,
|
||||
@@ -2429,8 +2476,10 @@ func (r *Resolver) CreateUserTool(ctx context.Context, req *mcp.CallToolRequest,
|
||||
if errors.As(err, &errAlreadyExists) {
|
||||
return nil, types.CreateUserOutput{}, fmt.Errorf("user with email already exists: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.CreateUserOutput{}, fmt.Errorf("create user: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.CreateUserOutput{User: types.NewProfile(profile)}, nil
|
||||
}
|
||||
|
||||
@@ -2442,16 +2491,22 @@ func (r *Resolver) InviteUserTool(ctx context.Context, req *mcp.CallToolRequest,
|
||||
ProfileID: input.ProfileID,
|
||||
})
|
||||
if err != nil {
|
||||
var errOrgNotFound *iam.ErrOrganizationNotFound
|
||||
var errUserExists *iam.ErrUserAlreadyExists
|
||||
var (
|
||||
errOrgNotFound *iam.ErrOrganizationNotFound
|
||||
errUserExists *iam.ErrUserAlreadyExists
|
||||
)
|
||||
|
||||
if errors.As(err, &errOrgNotFound) {
|
||||
return nil, types.InviteUserOutput{}, fmt.Errorf("organization not found: %w", err)
|
||||
}
|
||||
|
||||
if errors.As(err, &errUserExists) {
|
||||
return nil, types.InviteUserOutput{}, fmt.Errorf("user already in organization: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.InviteUserOutput{}, fmt.Errorf("invite user: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.InviteUserOutput{InvitationID: invitation.ID}, nil
|
||||
}
|
||||
|
||||
@@ -2462,17 +2517,21 @@ func (r *Resolver) UpdateUserTool(ctx context.Context, req *mcp.CallToolRequest,
|
||||
if input.AdditionalEmailAddresses != nil {
|
||||
additionalEmails = *input.AdditionalEmailAddresses
|
||||
}
|
||||
|
||||
var position *string
|
||||
if p := UnwrapOmittable(input.Position); p != nil {
|
||||
position = *p
|
||||
}
|
||||
|
||||
var contractStart, contractEnd **time.Time
|
||||
if p := UnwrapOmittable(input.ContractStartDate); p != nil {
|
||||
contractStart = p
|
||||
}
|
||||
|
||||
if p := UnwrapOmittable(input.ContractEndDate); p != nil {
|
||||
contractEnd = p
|
||||
}
|
||||
|
||||
profile, err := r.iamSvc.OrganizationService.UpdateUser(ctx, &iam.UpdateUserRequest{
|
||||
ID: input.ID,
|
||||
FullName: input.FullName,
|
||||
@@ -2485,11 +2544,13 @@ func (r *Resolver) UpdateUserTool(ctx context.Context, req *mcp.CallToolRequest,
|
||||
if err != nil {
|
||||
return nil, types.UpdateUserOutput{}, fmt.Errorf("update user: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.UpdateUserOutput{User: types.NewProfile(profile)}, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) UpdateMembershipTool(ctx context.Context, req *mcp.CallToolRequest, input *types.UpdateMembershipInput) (*mcp.CallToolResult, types.UpdateMembershipOutput, error) {
|
||||
r.MustAuthorize(ctx, input.MembershipID, iam.ActionMembershipUpdate)
|
||||
|
||||
if input.Role == coredata.MembershipRoleOwner {
|
||||
r.MustAuthorize(ctx, input.MembershipID, iam.ActionMembershipRoleSetOwner)
|
||||
}
|
||||
@@ -2498,6 +2559,7 @@ func (r *Resolver) UpdateMembershipTool(ctx context.Context, req *mcp.CallToolRe
|
||||
if err != nil {
|
||||
return nil, types.UpdateMembershipOutput{}, fmt.Errorf("update membership: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.UpdateMembershipOutput{
|
||||
Membership: &types.Membership{
|
||||
ID: membership.ID,
|
||||
@@ -2512,16 +2574,22 @@ func (r *Resolver) RemoveUserTool(ctx context.Context, req *mcp.CallToolRequest,
|
||||
|
||||
err := r.iamSvc.OrganizationService.RemoveUser(ctx, input.OrganizationID, input.ProfileID)
|
||||
if err != nil {
|
||||
var errManagedBySCIM *iam.ErrUserManagedBySCIM
|
||||
var errLastOwner *iam.ErrLastActiveOwner
|
||||
var (
|
||||
errManagedBySCIM *iam.ErrUserManagedBySCIM
|
||||
errLastOwner *iam.ErrLastActiveOwner
|
||||
)
|
||||
|
||||
if errors.As(err, &errManagedBySCIM) {
|
||||
return nil, types.RemoveUserOutput{}, fmt.Errorf("user is managed by SCIM and cannot be removed: %w", err)
|
||||
}
|
||||
|
||||
if errors.As(err, &errLastOwner) {
|
||||
return nil, types.RemoveUserOutput{}, fmt.Errorf("cannot remove last active owner: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.RemoveUserOutput{}, fmt.Errorf("remove user: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.RemoveUserOutput{DeletedUserID: input.ProfileID}, nil
|
||||
}
|
||||
|
||||
@@ -2932,6 +3000,7 @@ func (r *Resolver) ListAccessEntriesTool(ctx context.Context, req *mcp.CallToolR
|
||||
|
||||
if input.AccessSourceID != nil {
|
||||
var err error
|
||||
|
||||
p, err = r.accessReview.Entries(scope).ListForCampaignIDAndSourceID(
|
||||
ctx,
|
||||
input.CampaignID,
|
||||
@@ -2944,6 +3013,7 @@ func (r *Resolver) ListAccessEntriesTool(ctx context.Context, req *mcp.CallToolR
|
||||
}
|
||||
} else {
|
||||
var err error
|
||||
|
||||
p, err = r.accessReview.Entries(scope).ListForCampaignID(ctx, input.CampaignID, cursor, filter)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list access entries: %w", err))
|
||||
@@ -3039,6 +3109,7 @@ func (r *Resolver) RecordAccessEntryDecisionsTool(ctx context.Context, req *mcp.
|
||||
decisions := make([]accessreview.RecordAccessEntryDecisionRequest, len(input.Decisions))
|
||||
for i, d := range input.Decisions {
|
||||
var decidedByID *gid.GID
|
||||
|
||||
organizationID, err := r.accessReview.ResolveEntryOrganizationID(ctx, d.AccessEntryID)
|
||||
if err == nil {
|
||||
if cached, ok := profileCache[organizationID]; ok {
|
||||
@@ -3048,6 +3119,7 @@ func (r *Resolver) RecordAccessEntryDecisionsTool(ctx context.Context, req *mcp.
|
||||
if err == nil {
|
||||
decidedByID = &profile.ID
|
||||
}
|
||||
|
||||
profileCache[organizationID] = decidedByID
|
||||
}
|
||||
}
|
||||
@@ -3161,10 +3233,12 @@ func (r *Resolver) UpdateAccessSourceTool(ctx context.Context, req *mcp.CallTool
|
||||
if err != nil {
|
||||
return nil, types.UpdateAccessSourceOutput{}, fmt.Errorf("cannot parse connector_id: %w", err)
|
||||
}
|
||||
|
||||
idPtr := &id
|
||||
updateReq.ConnectorID = &idPtr
|
||||
} else {
|
||||
var nilGID *gid.GID
|
||||
|
||||
updateReq.ConnectorID = &nilGID
|
||||
}
|
||||
}
|
||||
@@ -3248,6 +3322,7 @@ func (r *Resolver) UpdateAccessReviewCampaignTool(ctx context.Context, req *mcp.
|
||||
controls = append(controls, s)
|
||||
}
|
||||
}
|
||||
|
||||
updateReq.FrameworkControls = &controls
|
||||
} else {
|
||||
empty := []string{}
|
||||
@@ -3485,16 +3560,20 @@ func (r *Resolver) ListAuditLogEntriesTool(ctx context.Context, req *mcp.CallToo
|
||||
cursor := types.NewCursor(input.Size, input.Cursor, pageOrderBy)
|
||||
|
||||
filter := coredata.NewAuditLogEntryFilter()
|
||||
|
||||
if input.Filter != nil {
|
||||
if input.Filter.Action != nil {
|
||||
filter.WithAction(*input.Filter.Action)
|
||||
}
|
||||
|
||||
if input.Filter.ActorID != nil {
|
||||
filter.WithActorID(*input.Filter.ActorID)
|
||||
}
|
||||
|
||||
if input.Filter.ResourceType != nil {
|
||||
filter.WithResourceType(*input.Filter.ResourceType)
|
||||
}
|
||||
|
||||
if input.Filter.ResourceID != nil {
|
||||
filter.WithResourceID(*input.Filter.ResourceID)
|
||||
}
|
||||
@@ -3784,6 +3863,7 @@ func (r *Resolver) ListDocumentVersionApprovalDecisionsTool(ctx context.Context,
|
||||
if input.Filter != nil {
|
||||
states = input.Filter.States
|
||||
}
|
||||
|
||||
filter := coredata.NewDocumentVersionApprovalDecisionFilter(states)
|
||||
|
||||
p, err := svc.DocumentApprovals.ListDecisions(ctx, input.QuorumID, cursor, filter)
|
||||
@@ -3917,6 +3997,7 @@ func (r *Resolver) UpdateThirdPartyContactTool(ctx context.Context, req *mcp.Cal
|
||||
if err != nil {
|
||||
return nil, types.UpdateThirdPartyContactOutput{}, fmt.Errorf("invalid email address: %w", err)
|
||||
}
|
||||
|
||||
emailPtr := &emailAddr
|
||||
updateReq.Email = &emailPtr
|
||||
}
|
||||
@@ -4262,6 +4343,7 @@ func (r *Resolver) UpdateTrustCenterTool(ctx context.Context, req *mcp.CallToolR
|
||||
if active := UnwrapOmittable(input.Active); active != nil {
|
||||
updateReq.Active = *active
|
||||
}
|
||||
|
||||
if sei := UnwrapOmittable(input.SearchEngineIndexing); sei != nil {
|
||||
updateReq.SearchEngineIndexing = *sei
|
||||
}
|
||||
@@ -4344,9 +4426,11 @@ func (r *Resolver) UpdateTrustCenterReferenceTool(ctx context.Context, req *mcp.
|
||||
if name := UnwrapOmittable(input.Name); name != nil {
|
||||
updateRefReq.Name = *name
|
||||
}
|
||||
|
||||
if websiteURL := UnwrapOmittable(input.WebsiteURL); websiteURL != nil {
|
||||
updateRefReq.WebsiteURL = *websiteURL
|
||||
}
|
||||
|
||||
if rank := UnwrapOmittable(input.Rank); rank != nil {
|
||||
updateRefReq.Rank = *rank
|
||||
}
|
||||
@@ -4406,6 +4490,7 @@ func (r *Resolver) ListTrustCenterFilesTool(ctx context.Context, req *mcp.CallTo
|
||||
if err != nil {
|
||||
return nil, types.ListTrustCenterFilesOutput{}, fmt.Errorf("cannot generate file URL: %w", err)
|
||||
}
|
||||
|
||||
files = append(files, types.NewTrustCenterFile(f, fileURL))
|
||||
}
|
||||
|
||||
@@ -4491,9 +4576,11 @@ func (r *Resolver) UpdateComplianceExternalURLTool(ctx context.Context, req *mcp
|
||||
if name := UnwrapOmittable(input.Name); name != nil && *name != nil {
|
||||
updateURLReq.Name = **name
|
||||
}
|
||||
|
||||
if u := UnwrapOmittable(input.URL); u != nil && *u != nil {
|
||||
updateURLReq.URL = **u
|
||||
}
|
||||
|
||||
if rank := UnwrapOmittable(input.Rank); rank != nil {
|
||||
updateURLReq.Rank = *rank
|
||||
}
|
||||
@@ -4692,27 +4779,33 @@ func (r *Resolver) ListCookieBannersTool(ctx context.Context, req *mcp.CallToolR
|
||||
r.MustAuthorize(ctx, input.OrganizationID, probo.ActionCookieBannerList)
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
cursor := types.NewCursor(input.Size, input.Cursor, page.OrderBy[coredata.CookieBannerOrderField]{Field: coredata.CookieBannerOrderFieldCreatedAt, Direction: page.OrderDirectionDesc})
|
||||
|
||||
banners, err := r.cookieBanner.ListCookieBannersForOrganization(ctx, scope, input.OrganizationID, cursor, coredata.NewCookieBannerFilter(nil))
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list cookie banners: %w", err))
|
||||
}
|
||||
|
||||
p := page.NewPage(banners, cursor)
|
||||
|
||||
return nil, types.NewListCookieBannersOutput(p), nil
|
||||
}
|
||||
|
||||
func (r *Resolver) GetCookieBannerTool(ctx context.Context, req *mcp.CallToolRequest, input *types.GetCookieBannerInput) (*mcp.CallToolResult, types.GetCookieBannerOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionCookieBannerGet)
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
|
||||
banner, err := r.cookieBanner.GetCookieBanner(ctx, scope, input.ID)
|
||||
if err != nil {
|
||||
return nil, types.GetCookieBannerOutput{}, fmt.Errorf("cannot get cookie banner: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.GetCookieBannerOutput{CookieBanner: types.NewCookieBanner(banner)}, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) AddCookieBannerTool(ctx context.Context, req *mcp.CallToolRequest, input *types.AddCookieBannerInput) (*mcp.CallToolResult, types.AddCookieBannerOutput, error) {
|
||||
r.MustAuthorize(ctx, input.OrganizationID, probo.ActionCookieBannerCreate)
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
|
||||
banner, err := r.cookieBanner.CreateCookieBanner(ctx, scope, cookiebanner.CreateCookieBannerRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
Name: input.Name,
|
||||
@@ -4724,6 +4817,7 @@ func (r *Resolver) AddCookieBannerTool(ctx context.Context, req *mcp.CallToolReq
|
||||
if err != nil {
|
||||
return nil, types.AddCookieBannerOutput{}, fmt.Errorf("cannot create cookie banner: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.AddCookieBannerOutput{CookieBanner: types.NewCookieBanner(banner)}, nil
|
||||
}
|
||||
|
||||
@@ -4735,15 +4829,19 @@ func (r *Resolver) UpdateCookieBannerTool(ctx context.Context, req *mcp.CallTool
|
||||
if v := UnwrapOmittable(input.Name); v != nil && *v != nil {
|
||||
updateReq.Name = *v
|
||||
}
|
||||
|
||||
if v := UnwrapOmittable(input.PrivacyPolicyURL); v != nil && *v != nil {
|
||||
updateReq.PrivacyPolicyURL = *v
|
||||
}
|
||||
|
||||
if v := UnwrapOmittable(input.CookiePolicyURL); v != nil && *v != nil {
|
||||
updateReq.CookiePolicyURL = *v
|
||||
}
|
||||
|
||||
if v := UnwrapOmittable(input.ConsentExpiryDays); v != nil && *v != nil {
|
||||
updateReq.ConsentExpiryDays = *v
|
||||
}
|
||||
|
||||
if v := UnwrapOmittable(input.DefaultLanguage); v != nil && *v != nil {
|
||||
updateReq.DefaultLanguage = *v
|
||||
}
|
||||
@@ -4752,35 +4850,42 @@ func (r *Resolver) UpdateCookieBannerTool(ctx context.Context, req *mcp.CallTool
|
||||
if err != nil {
|
||||
return nil, types.UpdateCookieBannerOutput{}, fmt.Errorf("cannot update cookie banner: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.UpdateCookieBannerOutput{CookieBanner: types.NewCookieBanner(banner)}, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) DeleteCookieBannerTool(ctx context.Context, req *mcp.CallToolRequest, input *types.DeleteCookieBannerInput) (*mcp.CallToolResult, types.DeleteCookieBannerOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionCookieBannerDelete)
|
||||
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
if err := r.cookieBanner.DeleteCookieBanner(ctx, scope, input.ID); err != nil {
|
||||
return nil, types.DeleteCookieBannerOutput{}, fmt.Errorf("cannot delete cookie banner: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.DeleteCookieBannerOutput{DeletedID: input.ID}, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) ActivateCookieBannerTool(ctx context.Context, req *mcp.CallToolRequest, input *types.ActivateCookieBannerInput) (*mcp.CallToolResult, types.ActivateCookieBannerOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionCookieBannerActivate)
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
|
||||
banner, err := r.cookieBanner.ActivateCookieBanner(ctx, scope, input.ID)
|
||||
if err != nil {
|
||||
return nil, types.ActivateCookieBannerOutput{}, fmt.Errorf("cannot activate cookie banner: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.ActivateCookieBannerOutput{CookieBanner: types.NewCookieBanner(banner)}, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) DeactivateCookieBannerTool(ctx context.Context, req *mcp.CallToolRequest, input *types.DeactivateCookieBannerInput) (*mcp.CallToolResult, types.DeactivateCookieBannerOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionCookieBannerDeactivate)
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
|
||||
banner, err := r.cookieBanner.DeactivateCookieBanner(ctx, scope, input.ID)
|
||||
if err != nil {
|
||||
return nil, types.DeactivateCookieBannerOutput{}, fmt.Errorf("cannot deactivate cookie banner: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.DeactivateCookieBannerOutput{CookieBanner: types.NewCookieBanner(banner)}, nil
|
||||
}
|
||||
|
||||
@@ -4788,27 +4893,33 @@ func (r *Resolver) ListCookieCategoriesTool(ctx context.Context, req *mcp.CallTo
|
||||
r.MustAuthorize(ctx, input.CookieBannerID, probo.ActionCookieCategoryList)
|
||||
scope := coredata.NewScopeFromObjectID(input.CookieBannerID)
|
||||
cursor := types.NewCursor(input.Size, input.Cursor, page.OrderBy[coredata.CookieCategoryOrderField]{Field: coredata.CookieCategoryOrderFieldRank, Direction: page.OrderDirectionAsc})
|
||||
|
||||
categories, err := r.cookieBanner.ListCookieCategoriesForBanner(ctx, scope, input.CookieBannerID, cursor)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list cookie categories: %w", err))
|
||||
}
|
||||
|
||||
p := page.NewPage(categories, cursor)
|
||||
|
||||
return nil, types.NewListCookieCategoriesOutput(p), nil
|
||||
}
|
||||
|
||||
func (r *Resolver) GetCookieCategoryTool(ctx context.Context, req *mcp.CallToolRequest, input *types.GetCookieCategoryInput) (*mcp.CallToolResult, types.GetCookieCategoryOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionCookieCategoryGet)
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
|
||||
category, err := r.cookieBanner.GetCookieCategory(ctx, scope, input.ID)
|
||||
if err != nil {
|
||||
return nil, types.GetCookieCategoryOutput{}, fmt.Errorf("cannot get cookie category: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.GetCookieCategoryOutput{CookieCategory: types.NewCookieCategory(category)}, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) AddCookieCategoryTool(ctx context.Context, req *mcp.CallToolRequest, input *types.AddCookieCategoryInput) (*mcp.CallToolResult, types.AddCookieCategoryOutput, error) {
|
||||
r.MustAuthorize(ctx, input.CookieBannerID, probo.ActionCookieCategoryCreate)
|
||||
scope := coredata.NewScopeFromObjectID(input.CookieBannerID)
|
||||
|
||||
category, err := r.cookieBanner.CreateCookieCategory(ctx, scope, cookiebanner.CreateCookieCategoryRequest{
|
||||
CookieBannerID: input.CookieBannerID,
|
||||
Name: input.Name,
|
||||
@@ -4819,41 +4930,50 @@ func (r *Resolver) AddCookieCategoryTool(ctx context.Context, req *mcp.CallToolR
|
||||
if err != nil {
|
||||
return nil, types.AddCookieCategoryOutput{}, fmt.Errorf("cannot create cookie category: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.AddCookieCategoryOutput{CookieCategory: types.NewCookieCategory(category)}, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) UpdateCookieCategoryTool(ctx context.Context, req *mcp.CallToolRequest, input *types.UpdateCookieCategoryInput) (*mcp.CallToolResult, types.UpdateCookieCategoryOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionCookieCategoryUpdate)
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
|
||||
updateReq := cookiebanner.UpdateCookieCategoryRequest{CookieCategoryID: input.ID}
|
||||
if v := UnwrapOmittable(input.Name); v != nil && *v != nil {
|
||||
updateReq.Name = *v
|
||||
}
|
||||
|
||||
if v := UnwrapOmittable(input.Slug); v != nil && *v != nil {
|
||||
updateReq.Slug = *v
|
||||
}
|
||||
|
||||
if v := UnwrapOmittable(input.Description); v != nil && *v != nil {
|
||||
updateReq.Description = *v
|
||||
}
|
||||
|
||||
category, err := r.cookieBanner.UpdateCookieCategory(ctx, scope, updateReq)
|
||||
if err != nil {
|
||||
return nil, types.UpdateCookieCategoryOutput{}, fmt.Errorf("cannot update cookie category: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.UpdateCookieCategoryOutput{CookieCategory: types.NewCookieCategory(category)}, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) DeleteCookieCategoryTool(ctx context.Context, req *mcp.CallToolRequest, input *types.DeleteCookieCategoryInput) (*mcp.CallToolResult, types.DeleteCookieCategoryOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionCookieCategoryDelete)
|
||||
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
if err := r.cookieBanner.DeleteCookieCategory(ctx, scope, input.ID); err != nil {
|
||||
return nil, types.DeleteCookieCategoryOutput{}, fmt.Errorf("cannot delete cookie category: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.DeleteCookieCategoryOutput{DeletedID: input.ID}, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) ReorderCookieCategoryTool(ctx context.Context, req *mcp.CallToolRequest, input *types.ReorderCookieCategoryInput) (*mcp.CallToolResult, types.ReorderCookieCategoryOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionCookieCategoryUpdate)
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
|
||||
_, err := r.cookieBanner.ReorderCookieCategory(ctx, scope, cookiebanner.ReorderCookieCategoryRequest{
|
||||
CookieCategoryID: input.ID,
|
||||
Rank: input.Rank,
|
||||
@@ -4861,10 +4981,12 @@ func (r *Resolver) ReorderCookieCategoryTool(ctx context.Context, req *mcp.CallT
|
||||
if err != nil {
|
||||
return nil, types.ReorderCookieCategoryOutput{}, fmt.Errorf("cannot reorder cookie category: %w", err)
|
||||
}
|
||||
|
||||
category, err := r.cookieBanner.GetCookieCategory(ctx, scope, input.ID)
|
||||
if err != nil {
|
||||
return nil, types.ReorderCookieCategoryOutput{}, fmt.Errorf("cannot get cookie category: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.ReorderCookieCategoryOutput{CookieCategory: types.NewCookieCategory(category)}, nil
|
||||
}
|
||||
|
||||
@@ -4872,27 +4994,33 @@ func (r *Resolver) ListTrackerPatternsTool(ctx context.Context, req *mcp.CallToo
|
||||
r.MustAuthorize(ctx, input.CookieCategoryID, probo.ActionTrackerPatternList)
|
||||
scope := coredata.NewScopeFromObjectID(input.CookieCategoryID)
|
||||
cursor := types.NewCursor(input.Size, input.Cursor, page.OrderBy[coredata.TrackerPatternOrderField]{Field: coredata.TrackerPatternOrderFieldCreatedAt, Direction: page.OrderDirectionAsc})
|
||||
|
||||
patterns, err := r.cookieBanner.ListTrackerPatternsForCategory(ctx, scope, input.CookieCategoryID, cursor)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list tracker patterns: %w", err))
|
||||
}
|
||||
|
||||
p := page.NewPage(patterns, cursor)
|
||||
|
||||
return nil, types.NewListTrackerPatternsOutput(p), nil
|
||||
}
|
||||
|
||||
func (r *Resolver) GetTrackerPatternTool(ctx context.Context, req *mcp.CallToolRequest, input *types.GetTrackerPatternInput) (*mcp.CallToolResult, types.GetTrackerPatternOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionTrackerPatternGet)
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
|
||||
pattern, err := r.cookieBanner.GetTrackerPattern(ctx, scope, input.ID)
|
||||
if err != nil {
|
||||
return nil, types.GetTrackerPatternOutput{}, fmt.Errorf("cannot get tracker pattern: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.GetTrackerPatternOutput{TrackerPattern: types.NewTrackerPattern(pattern)}, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) AddTrackerPatternTool(ctx context.Context, req *mcp.CallToolRequest, input *types.AddTrackerPatternInput) (*mcp.CallToolResult, types.AddTrackerPatternOutput, error) {
|
||||
r.MustAuthorize(ctx, input.CookieCategoryID, probo.ActionTrackerPatternCreate)
|
||||
scope := coredata.NewScopeFromObjectID(input.CookieCategoryID)
|
||||
|
||||
pattern, err := r.cookieBanner.CreateTrackerPattern(ctx, scope, cookiebanner.CreateTrackerPatternRequest{
|
||||
CookieCategoryID: input.CookieCategoryID,
|
||||
TrackerType: coredata.TrackerType(input.TrackerType),
|
||||
@@ -4905,42 +5033,51 @@ func (r *Resolver) AddTrackerPatternTool(ctx context.Context, req *mcp.CallToolR
|
||||
if err != nil {
|
||||
return nil, types.AddTrackerPatternOutput{}, fmt.Errorf("cannot create tracker pattern: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.AddTrackerPatternOutput{TrackerPattern: types.NewTrackerPattern(pattern)}, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) UpdateTrackerPatternTool(ctx context.Context, req *mcp.CallToolRequest, input *types.UpdateTrackerPatternInput) (*mcp.CallToolResult, types.UpdateTrackerPatternOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionTrackerPatternUpdate)
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
|
||||
updateReq := cookiebanner.UpdateTrackerPatternRequest{TrackerPatternID: input.ID}
|
||||
if input.MaxAgeSeconds.IsSet() {
|
||||
val, _ := input.MaxAgeSeconds.Value()
|
||||
updateReq.MaxAgeSeconds = &val
|
||||
}
|
||||
|
||||
if v := UnwrapOmittable(input.Description); v != nil && *v != nil {
|
||||
updateReq.Description = *v
|
||||
}
|
||||
|
||||
if v := UnwrapOmittable(input.Excluded); v != nil && *v != nil {
|
||||
updateReq.Excluded = *v
|
||||
}
|
||||
|
||||
pattern, err := r.cookieBanner.UpdateTrackerPattern(ctx, scope, updateReq)
|
||||
if err != nil {
|
||||
return nil, types.UpdateTrackerPatternOutput{}, fmt.Errorf("cannot update tracker pattern: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.UpdateTrackerPatternOutput{TrackerPattern: types.NewTrackerPattern(pattern)}, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) DeleteTrackerPatternTool(ctx context.Context, req *mcp.CallToolRequest, input *types.DeleteTrackerPatternInput) (*mcp.CallToolResult, types.DeleteTrackerPatternOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionTrackerPatternDelete)
|
||||
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
if err := r.cookieBanner.DeleteTrackerPattern(ctx, scope, input.ID); err != nil {
|
||||
return nil, types.DeleteTrackerPatternOutput{}, fmt.Errorf("cannot delete tracker pattern: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.DeleteTrackerPatternOutput{DeletedID: input.ID}, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) MoveTrackerPatternToCategoryTool(ctx context.Context, req *mcp.CallToolRequest, input *types.MoveTrackerPatternToCategoryInput) (*mcp.CallToolResult, types.MoveTrackerPatternToCategoryOutput, error) {
|
||||
r.MustAuthorize(ctx, input.TrackerPatternID, probo.ActionTrackerPatternUpdate)
|
||||
scope := coredata.NewScopeFromObjectID(input.TrackerPatternID)
|
||||
|
||||
result, err := r.cookieBanner.MoveTrackerPatternToCategory(ctx, scope, cookiebanner.MoveTrackerPatternToCategoryRequest{
|
||||
TrackerPatternID: input.TrackerPatternID,
|
||||
TargetCookieCategoryID: input.TargetCookieCategoryID,
|
||||
@@ -4948,16 +5085,19 @@ func (r *Resolver) MoveTrackerPatternToCategoryTool(ctx context.Context, req *mc
|
||||
if err != nil {
|
||||
return nil, types.MoveTrackerPatternToCategoryOutput{}, fmt.Errorf("cannot move tracker pattern: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.MoveTrackerPatternToCategoryOutput{TrackerPattern: types.NewTrackerPattern(result.TrackerPattern)}, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) PublishCookieBannerVersionTool(ctx context.Context, req *mcp.CallToolRequest, input *types.PublishCookieBannerVersionInput) (*mcp.CallToolResult, types.PublishCookieBannerVersionOutput, error) {
|
||||
r.MustAuthorize(ctx, input.CookieBannerID, probo.ActionCookieBannerVersionPublish)
|
||||
scope := coredata.NewScopeFromObjectID(input.CookieBannerID)
|
||||
|
||||
version, err := r.cookieBanner.PublishCookieBannerVersion(ctx, scope, input.CookieBannerID)
|
||||
if err != nil {
|
||||
return nil, types.PublishCookieBannerVersionOutput{}, fmt.Errorf("cannot publish cookie banner version: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.PublishCookieBannerVersionOutput{CookieBannerVersion: types.NewCookieBannerVersion(version)}, nil
|
||||
}
|
||||
|
||||
@@ -4965,17 +5105,21 @@ func (r *Resolver) ListCookieBannerVersionsTool(ctx context.Context, req *mcp.Ca
|
||||
r.MustAuthorize(ctx, input.CookieBannerID, probo.ActionCookieBannerVersionList)
|
||||
scope := coredata.NewScopeFromObjectID(input.CookieBannerID)
|
||||
cursor := types.NewCursor(input.Size, input.Cursor, page.OrderBy[coredata.CookieBannerVersionOrderField]{Field: coredata.CookieBannerVersionOrderFieldCreatedAt, Direction: page.OrderDirectionDesc})
|
||||
|
||||
versions, err := r.cookieBanner.ListCookieBannerVersionsForBanner(ctx, scope, input.CookieBannerID, cursor)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list cookie banner versions: %w", err))
|
||||
}
|
||||
|
||||
p := page.NewPage(versions, cursor)
|
||||
|
||||
return nil, types.NewListCookieBannerVersionsOutput(p), nil
|
||||
}
|
||||
|
||||
func (r *Resolver) UpsertCookieBannerTranslationTool(ctx context.Context, req *mcp.CallToolRequest, input *types.UpsertCookieBannerTranslationInput) (*mcp.CallToolResult, types.UpsertCookieBannerTranslationOutput, error) {
|
||||
r.MustAuthorize(ctx, input.CookieBannerID, probo.ActionCookieBannerUpdate)
|
||||
scope := coredata.NewScopeFromObjectID(input.CookieBannerID)
|
||||
|
||||
translation, err := r.cookieBanner.UpsertCookieBannerTranslation(ctx, scope, cookiebanner.UpsertCookieBannerTranslationRequest{
|
||||
CookieBannerID: input.CookieBannerID,
|
||||
Language: input.Language,
|
||||
@@ -4984,6 +5128,7 @@ func (r *Resolver) UpsertCookieBannerTranslationTool(ctx context.Context, req *m
|
||||
if err != nil {
|
||||
return nil, types.UpsertCookieBannerTranslationOutput{}, fmt.Errorf("cannot upsert cookie banner translation: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.UpsertCookieBannerTranslationOutput{CookieBannerTranslation: types.NewCookieBannerTranslation(translation)}, nil
|
||||
}
|
||||
|
||||
@@ -4993,27 +5138,33 @@ func (r *Resolver) ListCookieConsentRecordsTool(ctx context.Context, req *mcp.Ca
|
||||
cursor := types.NewCursor(input.Size, input.Cursor, page.OrderBy[coredata.CookieConsentRecordOrderField]{Field: coredata.CookieConsentRecordOrderFieldCreatedAt, Direction: page.OrderDirectionDesc})
|
||||
|
||||
var action *coredata.CookieConsentAction
|
||||
|
||||
if input.Action != nil {
|
||||
a := coredata.CookieConsentAction(*input.Action)
|
||||
action = &a
|
||||
}
|
||||
|
||||
filter := coredata.NewCookieConsentRecordFilter(action, input.VisitorID, input.Version)
|
||||
|
||||
records, err := r.cookieBanner.ListCookieConsentRecordsForBanner(ctx, scope, input.CookieBannerID, cursor, filter)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list cookie consent records: %w", err))
|
||||
}
|
||||
|
||||
p := page.NewPage(records, cursor)
|
||||
|
||||
return nil, types.NewListCookieConsentRecordsOutput(p), nil
|
||||
}
|
||||
|
||||
func (r *Resolver) GetCookieConsentRecordTool(ctx context.Context, req *mcp.CallToolRequest, input *types.GetCookieConsentRecordInput) (*mcp.CallToolResult, types.GetCookieConsentRecordOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionCookieConsentRecordList)
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
|
||||
record, err := r.cookieBanner.GetCookieConsentRecord(ctx, scope, input.ID)
|
||||
if err != nil {
|
||||
return nil, types.GetCookieConsentRecordOutput{}, fmt.Errorf("cannot get cookie consent record: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.GetCookieConsentRecordOutput{CookieConsentRecord: types.NewCookieConsentRecord(record)}, nil
|
||||
}
|
||||
|
||||
@@ -5042,6 +5193,7 @@ func (r *Resolver) GetSCIMConfigurationTool(ctx context.Context, req *mcp.CallTo
|
||||
if errors.As(err, &errNotFound) {
|
||||
return nil, types.GetSCIMConfigurationOutput{}, fmt.Errorf("SCIM configuration not found")
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot get SCIM configuration: %w", err))
|
||||
}
|
||||
|
||||
@@ -5066,6 +5218,7 @@ func (r *Resolver) CreateSCIMConfigurationTool(ctx context.Context, req *mcp.Cal
|
||||
if err != nil {
|
||||
return nil, types.CreateSCIMConfigurationOutput{}, fmt.Errorf("cannot create SCIM bridge: %w", err)
|
||||
}
|
||||
|
||||
output.ScimBridge = types.NewSCIMBridge(bridge)
|
||||
}
|
||||
|
||||
@@ -5106,6 +5259,7 @@ func (r *Resolver) GetSCIMBridgeTool(ctx context.Context, req *mcp.CallToolReque
|
||||
if errors.As(err, &errNotFound) {
|
||||
return nil, types.GetSCIMBridgeOutput{}, fmt.Errorf("SCIM bridge %s not found", input.ID)
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot get SCIM bridge: %w", err))
|
||||
}
|
||||
|
||||
@@ -5152,6 +5306,7 @@ func (r *Resolver) PublishDocumentTool(ctx context.Context, req *mcp.CallToolReq
|
||||
if !input.Minor && len(input.ApproverIds) > 0 {
|
||||
action = probo.ActionDocumentVersionRequestApproval
|
||||
}
|
||||
|
||||
r.MustAuthorize(ctx, input.DocumentID, action)
|
||||
|
||||
svc := r.ProboService(ctx, input.DocumentID)
|
||||
@@ -5173,6 +5328,7 @@ func (r *Resolver) PublishDocumentTool(ctx context.Context, req *mcp.CallToolReq
|
||||
if result.Quorum != nil {
|
||||
output.ApprovalQuorum = types.NewDocumentVersionApprovalQuorum(result.Quorum)
|
||||
}
|
||||
|
||||
return nil, output, nil
|
||||
}
|
||||
|
||||
@@ -5180,31 +5336,38 @@ func (r *Resolver) ListTrackerResourcesTool(ctx context.Context, req *mcp.CallTo
|
||||
r.MustAuthorize(ctx, input.CookieCategoryID, probo.ActionTrackerResourceList)
|
||||
scope := coredata.NewScopeFromObjectID(input.CookieCategoryID)
|
||||
cursor := types.NewCursor(input.Size, input.Cursor, page.OrderBy[coredata.TrackerResourceOrderField]{Field: coredata.TrackerResourceOrderFieldCreatedAt, Direction: page.OrderDirectionAsc})
|
||||
|
||||
resources, err := r.cookieBanner.ListTrackerResourcesForCategory(ctx, scope, input.CookieCategoryID, cursor)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list tracker resources: %w", err))
|
||||
}
|
||||
|
||||
p := page.NewPage(resources, cursor)
|
||||
|
||||
return nil, types.NewListTrackerResourcesOutput(p), nil
|
||||
}
|
||||
|
||||
func (r *Resolver) GetTrackerResourceTool(ctx context.Context, req *mcp.CallToolRequest, input *types.GetTrackerResourceInput) (*mcp.CallToolResult, types.GetTrackerResourceOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionTrackerResourceGet)
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
|
||||
resource, err := r.cookieBanner.GetTrackerResource(ctx, scope, input.ID)
|
||||
if err != nil {
|
||||
return nil, types.GetTrackerResourceOutput{}, fmt.Errorf("cannot get tracker resource: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.GetTrackerResourceOutput{TrackerResource: types.NewTrackerResource(resource)}, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) AddTrackerResourceTool(ctx context.Context, req *mcp.CallToolRequest, input *types.AddTrackerResourceInput) (*mcp.CallToolResult, types.AddTrackerResourceOutput, error) {
|
||||
r.MustAuthorize(ctx, input.CookieCategoryID, probo.ActionTrackerResourceCreate)
|
||||
scope := coredata.NewScopeFromObjectID(input.CookieCategoryID)
|
||||
|
||||
description := ""
|
||||
if input.Description != nil {
|
||||
description = *input.Description
|
||||
}
|
||||
|
||||
resource, err := r.cookieBanner.CreateTrackerResource(ctx, scope, cookiebanner.CreateTrackerResourceRequest{
|
||||
CookieCategoryID: input.CookieCategoryID,
|
||||
ResourceType: coredata.TrackerResourceType(input.ResourceType),
|
||||
@@ -5216,41 +5379,50 @@ func (r *Resolver) AddTrackerResourceTool(ctx context.Context, req *mcp.CallTool
|
||||
if err != nil {
|
||||
return nil, types.AddTrackerResourceOutput{}, fmt.Errorf("cannot create tracker resource: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.AddTrackerResourceOutput{TrackerResource: types.NewTrackerResource(resource)}, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) UpdateTrackerResourceTool(ctx context.Context, req *mcp.CallToolRequest, input *types.UpdateTrackerResourceInput) (*mcp.CallToolResult, types.UpdateTrackerResourceOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionTrackerResourceUpdate)
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
|
||||
updateReq := cookiebanner.UpdateTrackerResourceRequest{TrackerResourceID: input.ID}
|
||||
if v := UnwrapOmittable(input.DisplayName); v != nil && *v != nil {
|
||||
updateReq.DisplayName = *v
|
||||
}
|
||||
|
||||
if v := UnwrapOmittable(input.Description); v != nil && *v != nil {
|
||||
updateReq.Description = *v
|
||||
}
|
||||
|
||||
if v := UnwrapOmittable(input.Excluded); v != nil && *v != nil {
|
||||
updateReq.Excluded = *v
|
||||
}
|
||||
|
||||
resource, err := r.cookieBanner.UpdateTrackerResource(ctx, scope, updateReq)
|
||||
if err != nil {
|
||||
return nil, types.UpdateTrackerResourceOutput{}, fmt.Errorf("cannot update tracker resource: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.UpdateTrackerResourceOutput{TrackerResource: types.NewTrackerResource(resource)}, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) DeleteTrackerResourceTool(ctx context.Context, req *mcp.CallToolRequest, input *types.DeleteTrackerResourceInput) (*mcp.CallToolResult, types.DeleteTrackerResourceOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionTrackerResourceDelete)
|
||||
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
if err := r.cookieBanner.DeleteTrackerResource(ctx, scope, input.ID); err != nil {
|
||||
return nil, types.DeleteTrackerResourceOutput{}, fmt.Errorf("cannot delete tracker resource: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.DeleteTrackerResourceOutput{DeletedID: input.ID}, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) MoveTrackerResourceToCategoryTool(ctx context.Context, req *mcp.CallToolRequest, input *types.MoveTrackerResourceToCategoryInput) (*mcp.CallToolResult, types.MoveTrackerResourceToCategoryOutput, error) {
|
||||
r.MustAuthorize(ctx, input.TrackerResourceID, probo.ActionTrackerResourceUpdate)
|
||||
scope := coredata.NewScopeFromObjectID(input.TrackerResourceID)
|
||||
|
||||
result, err := r.cookieBanner.MoveTrackerResourceToCategory(ctx, scope, cookiebanner.MoveTrackerResourceToCategoryRequest{
|
||||
TrackerResourceID: input.TrackerResourceID,
|
||||
TargetCookieCategoryID: input.TargetCookieCategoryID,
|
||||
@@ -5258,5 +5430,6 @@ func (r *Resolver) MoveTrackerResourceToCategoryTool(ctx context.Context, req *m
|
||||
if err != nil {
|
||||
return nil, types.MoveTrackerResourceToCategoryOutput{}, fmt.Errorf("cannot move tracker resource: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.MoveTrackerResourceToCategoryOutput{TrackerResource: types.NewTrackerResource(result.TrackerResource)}, nil
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ func NewListAccessSourcesOutput(
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(p.Data) > 0 {
|
||||
cursorKey := p.Data[len(p.Data)-1].CursorKey(p.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
@@ -105,6 +106,7 @@ func NewListAccessReviewCampaignsOutput(
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(p.Data) > 0 {
|
||||
cursorKey := p.Data[len(p.Data)-1].CursorKey(p.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
@@ -125,6 +127,7 @@ func NewListAccessEntriesOutput(
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(p.Data) > 0 {
|
||||
cursorKey := p.Data[len(p.Data)-1].CursorKey(p.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
|
||||
@@ -40,6 +40,7 @@ func NewListAssetsOutput(assetPage *page.Page[*coredata.Asset, coredata.AssetOrd
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(assetPage.Data) > 0 {
|
||||
cursorKey := assetPage.Data[len(assetPage.Data)-1].CursorKey(assetPage.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
|
||||
@@ -49,6 +49,7 @@ func NewListControlAuditsOutput(auditPage *page.Page[*coredata.Audit, coredata.A
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(auditPage.Data) > 0 {
|
||||
cursorKey := auditPage.Data[len(auditPage.Data)-1].CursorKey(auditPage.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
@@ -67,6 +68,7 @@ func NewListAuditsOutput(auditPage *page.Page[*coredata.Audit, coredata.AuditOrd
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(auditPage.Data) > 0 {
|
||||
cursorKey := auditPage.Data[len(auditPage.Data)-1].CursorKey(auditPage.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
@@ -85,6 +87,7 @@ func NewListFindingAuditsOutput(auditPage *page.Page[*coredata.Audit, coredata.A
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(auditPage.Data) > 0 {
|
||||
cursorKey := auditPage.Data[len(auditPage.Data)-1].CursorKey(auditPage.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
|
||||
@@ -50,6 +50,7 @@ func NewListAuditLogEntriesOutput(p *page.Page[*coredata.AuditLogEntry, coredata
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(p.Data) > 0 {
|
||||
cursorKey := p.Data[len(p.Data)-1].CursorKey(p.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
|
||||
@@ -37,6 +37,7 @@ func NewListComplianceExternalURLsOutput(p *page.Page[*coredata.ComplianceExtern
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(p.Data) > 0 {
|
||||
cursorKey := p.Data[len(p.Data)-1].CursorKey(p.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
|
||||
@@ -41,6 +41,7 @@ func NewListMeasureControlsOutput(controlPage *page.Page[*coredata.Control, core
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(controlPage.Data) > 0 {
|
||||
cursorKey := controlPage.Data[len(controlPage.Data)-1].CursorKey(controlPage.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
@@ -59,6 +60,7 @@ func NewListControlsOutput(controlPage *page.Page[*coredata.Control, coredata.Co
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(controlPage.Data) > 0 {
|
||||
cursorKey := controlPage.Data[len(controlPage.Data)-1].CursorKey(controlPage.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
|
||||
@@ -43,6 +43,7 @@ func NewListCookieBannersOutput(p *page.Page[*coredata.CookieBanner, coredata.Co
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(p.Data) > 0 {
|
||||
cursorKey := p.Data[len(p.Data)-1].CursorKey(p.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
|
||||
@@ -37,6 +37,7 @@ func NewListCookieBannerVersionsOutput(p *page.Page[*coredata.CookieBannerVersio
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(p.Data) > 0 {
|
||||
cursorKey := p.Data[len(p.Data)-1].CursorKey(p.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
|
||||
@@ -45,6 +45,7 @@ func NewListCookieCategoriesOutput(p *page.Page[*coredata.CookieCategory, coreda
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(p.Data) > 0 {
|
||||
cursorKey := p.Data[len(p.Data)-1].CursorKey(p.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
|
||||
@@ -48,6 +48,7 @@ func NewListCookieConsentRecordsOutput(p *page.Page[*coredata.CookieConsentRecor
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(p.Data) > 0 {
|
||||
cursorKey := p.Data[len(p.Data)-1].CursorKey(p.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
|
||||
@@ -42,11 +42,14 @@ func NewListDataProtectionImpactAssessmentsOutput(
|
||||
for _, v := range pg.Data {
|
||||
items = append(items, NewDataProtectionImpactAssessment(v))
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(pg.Data) > 0 {
|
||||
cursorKey := pg.Data[len(pg.Data)-1].CursorKey(pg.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
}
|
||||
|
||||
return ListDataProtectionImpactAssessmentsOutput{
|
||||
NextCursor: nextCursor,
|
||||
DataProtectionImpactAssessments: items,
|
||||
|
||||
@@ -38,6 +38,7 @@ func NewListDataOutput(datumPage *page.Page[*coredata.Datum, coredata.DatumOrder
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(datumPage.Data) > 0 {
|
||||
cursorKey := datumPage.Data[len(datumPage.Data)-1].CursorKey(datumPage.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
|
||||
@@ -63,6 +63,7 @@ func NewListControlDocumentsOutput(documentPage *page.Page[*coredata.Document, c
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(documentPage.Data) > 0 {
|
||||
cursorKey := documentPage.Data[len(documentPage.Data)-1].CursorKey(documentPage.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
@@ -81,6 +82,7 @@ func NewListMeasureDocumentsOutput(documentPage *page.Page[*coredata.Document, c
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(documentPage.Data) > 0 {
|
||||
cursorKey := documentPage.Data[len(documentPage.Data)-1].CursorKey(documentPage.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
@@ -99,6 +101,7 @@ func NewListDocumentsOutput(documentPage *page.Page[*coredata.Document, coredata
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(documentPage.Data) > 0 {
|
||||
cursorKey := documentPage.Data[len(documentPage.Data)-1].CursorKey(documentPage.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
@@ -148,6 +151,7 @@ func NewListDocumentVersionsOutput(versionPage *page.Page[*coredata.DocumentVers
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(versionPage.Data) > 0 {
|
||||
cursorKey := versionPage.Data[len(versionPage.Data)-1].CursorKey(versionPage.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
@@ -180,6 +184,7 @@ func NewListDocumentVersionSignaturesOutput(signaturePage *page.Page[*coredata.D
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(signaturePage.Data) > 0 {
|
||||
cursorKey := signaturePage.Data[len(signaturePage.Data)-1].CursorKey(signaturePage.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
@@ -209,6 +214,7 @@ func NewListDocumentVersionApprovalQuorumsOutput(quorumPage *page.Page[*coredata
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(quorumPage.Data) > 0 {
|
||||
cursorKey := quorumPage.Data[len(quorumPage.Data)-1].CursorKey(quorumPage.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
@@ -241,6 +247,7 @@ func NewListDocumentVersionApprovalDecisionsOutput(decisionPage *page.Page[*core
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(decisionPage.Data) > 0 {
|
||||
cursorKey := decisionPage.Data[len(decisionPage.Data)-1].CursorKey(decisionPage.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
|
||||
@@ -42,6 +42,7 @@ func NewListMeasureEvidencesOutput(evidencePage *page.Page[*coredata.Evidence, c
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(evidencePage.Data) > 0 {
|
||||
cursorKey := evidencePage.Data[len(evidencePage.Data)-1].CursorKey(evidencePage.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
|
||||
@@ -50,6 +50,7 @@ func NewListFindingsOutput(findingPage *page.Page[*coredata.Finding, coredata.Fi
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(findingPage.Data) > 0 {
|
||||
cursorKey := findingPage.Data[len(findingPage.Data)-1].CursorKey(findingPage.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
|
||||
@@ -37,6 +37,7 @@ func NewListFrameworksOutput(frameworkPage *page.Page[*coredata.Framework, cored
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(frameworkPage.Data) > 0 {
|
||||
cursorKey := frameworkPage.Data[len(frameworkPage.Data)-1].CursorKey(frameworkPage.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
|
||||
@@ -38,6 +38,7 @@ func NewListControlMeasuresOutput(measurePage *page.Page[*coredata.Measure, core
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(measurePage.Data) > 0 {
|
||||
cursorKey := measurePage.Data[len(measurePage.Data)-1].CursorKey(measurePage.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
@@ -56,6 +57,7 @@ func NewListMeasuresOutput(measurePage *page.Page[*coredata.Measure, coredata.Me
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(measurePage.Data) > 0 {
|
||||
cursorKey := measurePage.Data[len(measurePage.Data)-1].CursorKey(measurePage.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
|
||||
@@ -47,6 +47,7 @@ func NewListObligationsOutput(obligationPage *page.Page[*coredata.Obligation, co
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(obligationPage.Data) > 0 {
|
||||
cursorKey := obligationPage.Data[len(obligationPage.Data)-1].CursorKey(obligationPage.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
@@ -65,6 +66,7 @@ func NewListControlObligationsOutput(obligationPage *page.Page[*coredata.Obligat
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(obligationPage.Data) > 0 {
|
||||
cursorKey := obligationPage.Data[len(obligationPage.Data)-1].CursorKey(obligationPage.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
@@ -83,6 +85,7 @@ func NewListRiskObligationsOutput(obligationPage *page.Page[*coredata.Obligation
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(obligationPage.Data) > 0 {
|
||||
cursorKey := obligationPage.Data[len(obligationPage.Data)-1].CursorKey(obligationPage.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
|
||||
@@ -51,11 +51,14 @@ func NewListProcessingActivitiesOutput(pg *page.Page[*coredata.ProcessingActivit
|
||||
for _, v := range pg.Data {
|
||||
items = append(items, NewProcessingActivity(v))
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(pg.Data) > 0 {
|
||||
cursorKey := pg.Data[len(pg.Data)-1].CursorKey(pg.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
}
|
||||
|
||||
return ListProcessingActivitiesOutput{
|
||||
NextCursor: nextCursor,
|
||||
ProcessingActivities: items,
|
||||
|
||||
@@ -47,6 +47,7 @@ func NewListRightsRequestsOutput(rightsRequestPage *page.Page[*coredata.RightsRe
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(rightsRequestPage.Data) > 0 {
|
||||
cursorKey := rightsRequestPage.Data[len(rightsRequestPage.Data)-1].CursorKey(rightsRequestPage.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
|
||||
@@ -47,6 +47,7 @@ func NewListMeasureRisksOutput(riskPage *page.Page[*coredata.Risk, coredata.Risk
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(riskPage.Data) > 0 {
|
||||
cursorKey := riskPage.Data[len(riskPage.Data)-1].CursorKey(riskPage.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
@@ -65,6 +66,7 @@ func NewListRisksOutput(riskPage *page.Page[*coredata.Risk, coredata.RiskOrderFi
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(riskPage.Data) > 0 {
|
||||
cursorKey := riskPage.Data[len(riskPage.Data)-1].CursorKey(riskPage.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
|
||||
@@ -68,6 +68,7 @@ func NewListSCIMEventsOutput(p *page.Page[*coredata.SCIMEvent, coredata.SCIMEven
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(p.Data) > 0 {
|
||||
cursorKey := p.Data[len(p.Data)-1].CursorKey(p.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user