Add wsl linter and fix

Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
Émile Ré
2026-05-19 14:51:08 +04:00
parent eedfdcecc8
commit 9156d6a16a
882 changed files with 6068 additions and 574 deletions

View File

@@ -69,6 +69,7 @@ func (r *mutationResolver) VerifyMagicLink(ctx context.Context, input types.Veri
}
r.logger.ErrorCtx(ctx, "cannot get magic link email", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
@@ -77,6 +78,7 @@ func (r *mutationResolver) VerifyMagicLink(ctx context.Context, input types.Veri
switch {
case session == nil:
var err error
identity, session, continueURL, err = r.iam.AuthService.OpenSessionWithMagicLink(ctx, input.Token)
if err != nil {
var errExpiredToken *iam.ErrExpiredToken
@@ -90,6 +92,7 @@ func (r *mutationResolver) VerifyMagicLink(ctx context.Context, input types.Veri
}
r.logger.ErrorCtx(ctx, "cannot open session with magic link", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
case identity.EmailAddress != email:
@@ -99,6 +102,7 @@ func (r *mutationResolver) VerifyMagicLink(ctx context.Context, input types.Veri
}
var err error
identity, session, continueURL, err = r.iam.AuthService.OpenSessionWithMagicLink(ctx, input.Token)
if err != nil {
var errExpiredToken *iam.ErrExpiredToken
@@ -112,6 +116,7 @@ func (r *mutationResolver) VerifyMagicLink(ctx context.Context, input types.Veri
}
r.logger.ErrorCtx(ctx, "cannot open session with magic link", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
}

View File

@@ -50,6 +50,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
return types.NewOrganization(organization), nil
case coredata.DocumentEntityType:
@@ -60,12 +61,16 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
if errors.Is(err, trust.ErrDocumentNotFound) || errors.Is(err, trust.ErrDocumentNotVisible) || errors.Is(err, coredata.ErrResourceNotFound) {
return nil, gqlutils.NotFoundf(ctx, "node %q not found", id)
}
if _, ok := errors.AsType[*trust.ErrDocumentArchived](err); ok {
return nil, gqlutils.NotFoundf(ctx, "node %q not found", id)
}
r.logger.ErrorCtx(ctx, "cannot get document", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
return types.NewDocument(document), nil
case coredata.FrameworkEntityType:
@@ -74,6 +79,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
r.logger.ErrorCtx(ctx, "cannot get framework", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
return types.NewFramework(framework), nil
case coredata.ReportEntityType:
@@ -84,9 +90,12 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
if errors.Is(err, trust.ErrReportNotFound) || errors.Is(err, coredata.ErrResourceNotFound) {
return nil, gqlutils.NotFoundf(ctx, "node %q not found", id)
}
r.logger.ErrorCtx(ctx, "cannot get report", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
return types.NewReport(report), nil
case coredata.AuditEntityType:
@@ -95,6 +104,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
r.logger.ErrorCtx(ctx, "cannot get audit", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
return types.NewAudit(audit), nil
case coredata.ThirdPartyEntityType:
@@ -103,6 +113,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
r.logger.ErrorCtx(ctx, "cannot get thirdParty", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
return types.NewSubprocessor(thirdParty), nil
case coredata.TrustCenterEntityType:
@@ -111,6 +122,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
r.logger.ErrorCtx(ctx, "cannot get trust center", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
return types.NewTrustCenter(trustCenter), nil
case coredata.TrustCenterReferenceEntityType:
@@ -119,6 +131,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
r.logger.ErrorCtx(ctx, "cannot get trust center reference", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
return types.NewTrustCenterReference(reference), nil
case coredata.TrustCenterFileEntityType:
@@ -129,7 +142,9 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
if errors.Is(err, trust.ErrTrustCenterFileNotFound) || errors.Is(err, trust.ErrTrustCenterFileNotVisible) {
return nil, gqlutils.NotFoundf(ctx, "node %q not found", id)
}
r.logger.ErrorCtx(ctx, "cannot get trust center file", log.Error(err))
return nil, gqlutils.Internal(ctx)
}

View File

@@ -39,10 +39,13 @@ func (r *mutationResolver) SubscribeToMailingList(ctx context.Context) (*types.S
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, "already subscribed to this mailing list")
}
r.logger.ErrorCtx(ctx, "cannot subscribe to mailing list", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
@@ -65,6 +68,7 @@ func (r *mutationResolver) UnsubscribeFromMailingList(ctx context.Context) (*typ
r.logger.ErrorCtx(ctx, "cannot get mailing list subscription", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
if subscriber == nil {
return nil, gqlutils.NotFoundf(ctx, "not subscribed to this mailing list")
}
@@ -73,7 +77,9 @@ func (r *mutationResolver) UnsubscribeFromMailingList(ctx context.Context) (*typ
if errors.Is(err, mailman.ErrSubscriberNotFound) {
return nil, gqlutils.NotFoundf(ctx, "not subscribed to this mailing list")
}
r.logger.ErrorCtx(ctx, "cannot unsubscribe from mailing list", log.Error(err))
return nil, gqlutils.Internal(ctx)
}

View File

@@ -97,6 +97,7 @@ func NewMux(
r.Method(http.MethodGet, "/session-transfer", sessionTransferHandler)
graphqlHandler := NewGraphQLHandler(iamSvc, trustSvc, esignSvc, mailmanSvc, logger, baseURL, cookieConfig, tokenSecret)
r.Group(
func(r chi.Router) {
r.Use(authn.NewSessionMiddleware(iamSvc, cookieConfig))

View File

@@ -63,6 +63,7 @@ func (h *SessionTransferHandler) ServeHTTP(w http.ResponseWriter, r *http.Reques
if err != nil {
h.logger.WarnCtx(ctx, "invalid session transfer token", log.Error(err))
httpserver.RenderError(w, http.StatusBadRequest, errors.New("invalid or expired token"))
return
}
@@ -81,6 +82,7 @@ func (h *SessionTransferHandler) ServeHTTP(w http.ResponseWriter, r *http.Reques
if err != nil {
h.logger.ErrorCtx(ctx, "cannot get session for transfer", log.Error(err))
httpserver.RenderError(w, http.StatusBadRequest, errors.New("invalid or expired token"))
return
}

View File

@@ -91,10 +91,13 @@ func (r *documentResolver) IsUserAuthorized(ctx context.Context, obj *types.Docu
if errors.Is(err, trust.ErrDocumentNotFound) || errors.Is(err, trust.ErrDocumentNotVisible) || errors.Is(err, coredata.ErrResourceNotFound) {
return false, gqlutils.NotFoundf(ctx, "document %q not found", obj.ID)
}
if _, ok := errors.AsType[*trust.ErrDocumentArchived](err); ok {
return false, gqlutils.NotFoundf(ctx, "document %q not found", obj.ID)
}
r.logger.ErrorCtx(ctx, "cannot load document", log.Error(err))
return false, gqlutils.Internal(ctx)
}
@@ -122,6 +125,7 @@ func (r *documentResolver) IsUserAuthorized(ctx context.Context, obj *types.Docu
}
r.logger.ErrorCtx(ctx, "cannot check document access", log.Error(err))
return false, gqlutils.Internal(ctx)
}
@@ -156,6 +160,7 @@ func (r *documentResolver) Access(ctx context.Context, obj *types.Document) (*ty
}
r.logger.ErrorCtx(ctx, "cannot get document access", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
@@ -222,10 +227,13 @@ func (r *mutationResolver) ExportDocumentPDF(ctx context.Context, input types.Ex
if errors.Is(err, trust.ErrDocumentNotFound) || errors.Is(err, trust.ErrDocumentNotVisible) || errors.Is(err, coredata.ErrResourceNotFound) {
return nil, gqlutils.NotFoundf(ctx, "document %q not found", input.DocumentID)
}
if _, ok := errors.AsType[*trust.ErrDocumentArchived](err); ok {
return nil, gqlutils.NotFoundf(ctx, "document %q not found", input.DocumentID)
}
r.logger.ErrorCtx(ctx, "cannot load document", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
@@ -335,7 +343,9 @@ func (r *mutationResolver) ExportTrustCenterFile(ctx context.Context, input type
if errors.Is(err, trust.ErrTrustCenterFileNotFound) || errors.Is(err, trust.ErrTrustCenterFileNotVisible) {
return nil, gqlutils.NotFoundf(ctx, "trust center file %q not found", input.TrustCenterFileID)
}
r.logger.ErrorCtx(ctx, "cannot load trust center file", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
@@ -390,12 +400,16 @@ func (r *mutationResolver) RequestDocumentAccess(ctx context.Context, input type
if errors.Is(err, trust.ErrDocumentNotFound) || errors.Is(err, trust.ErrDocumentNotVisible) || errors.Is(err, coredata.ErrResourceNotFound) {
return nil, gqlutils.NotFoundf(ctx, "document %q not found", input.DocumentID)
}
if _, ok := errors.AsType[*trust.ErrDocumentArchived](err); ok {
return nil, gqlutils.NotFoundf(ctx, "document %q not found", input.DocumentID)
}
r.logger.ErrorCtx(ctx, "cannot load document", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
if document.TrustCenterVisibility == coredata.TrustCenterVisibilityPublic {
return nil, gqlutils.Invalidf(
ctx,
@@ -479,7 +493,9 @@ func (r *mutationResolver) RequestTrustCenterFileAccess(ctx context.Context, inp
if errors.Is(err, trust.ErrTrustCenterFileNotFound) || errors.Is(err, trust.ErrTrustCenterFileNotVisible) {
return nil, gqlutils.NotFoundf(ctx, "trust center file %q not found", input.TrustCenterFileID)
}
r.logger.ErrorCtx(ctx, "cannot load trust center file", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
@@ -549,6 +565,7 @@ func (r *reportResolver) IsUserAuthorized(ctx context.Context, obj *types.Report
}
r.logger.ErrorCtx(ctx, "cannot check report access", log.Error(err))
return false, gqlutils.Internal(ctx)
}
@@ -583,6 +600,7 @@ func (r *reportResolver) Access(ctx context.Context, obj *types.Report) (*types.
}
r.logger.ErrorCtx(ctx, "cannot get audit report access", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
@@ -603,10 +621,12 @@ func (r *subprocessorConnectionResolver) TotalCount(ctx context.Context, obj *ty
r.logger.ErrorCtx(ctx, "cannot count subprocessors", log.Error(err))
return 0, gqlutils.Internal(ctx)
}
return count, nil
}
r.logger.ErrorCtx(ctx, "not implemented: TotalCount for parent type")
return 0, gqlutils.Internal(ctx)
}
@@ -638,6 +658,7 @@ func (r *trustCenterResolver) NonDisclosureAgreement(ctx context.Context, obj *t
r.logger.ErrorCtx(ctx, "cannot load NDA file", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
if file == nil {
return nil, nil
}
@@ -767,6 +788,7 @@ func (r *trustCenterResolver) TrustCenterFiles(ctx context.Context, obj *types.T
coredata.TrustCenterVisibilityPrivate,
),
)
trustCenterFilePage, err := trustService.TrustCenterFiles.ListForOrganizationId(ctx, obj.Organization.ID, cursor, filter)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot list public trust center files", log.Error(err))
@@ -854,7 +876,9 @@ func (r *trustCenterFileResolver) IsUserAuthorized(ctx context.Context, obj *typ
if errors.Is(err, trust.ErrTrustCenterFileNotFound) || errors.Is(err, trust.ErrTrustCenterFileNotVisible) {
return false, gqlutils.NotFoundf(ctx, "trust center file %q not found", obj.ID)
}
r.logger.ErrorCtx(ctx, "cannot load trust center file", log.Error(err))
return false, gqlutils.Internal(ctx)
}
@@ -881,6 +905,7 @@ func (r *trustCenterFileResolver) IsUserAuthorized(ctx context.Context, obj *typ
}
r.logger.ErrorCtx(ctx, "cannot check trust center file access", log.Error(err))
return false, gqlutils.Internal(ctx)
}
@@ -915,6 +940,7 @@ func (r *trustCenterFileResolver) Access(ctx context.Context, obj *types.TrustCe
}
r.logger.ErrorCtx(ctx, "cannot get file access", log.Error(err))
return nil, gqlutils.Internal(ctx)
}

View File

@@ -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,