Add risk vendor risk assesment to n8n

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2025-12-16 15:32:08 +01:00
parent 8819933649
commit 7d58080ab4
11 changed files with 423 additions and 8 deletions

View File

@@ -461,7 +461,8 @@ var Permissions = map[uint16]map[Action][]Role{
ActionDeleteVendorDataPrivacyAgreement: EditRoles,
},
coredata.VendorRiskAssessmentEntityType: {
ActionGet: NonEmployeeRoles,
ActionGet: NonEmployeeRoles,
ActionGetVendor: NonEmployeeRoles,
},
coredata.FrameworkEntityType: {
ActionGet: NonEmployeeRoles,

View File

@@ -683,6 +683,35 @@ func (s VendorService) GetRiskAssessment(
return vendorRiskAssessment, nil
}
func (s VendorService) GetByRiskAssessmentID(
ctx context.Context,
vendorRiskAssessmentID gid.GID,
) (*coredata.Vendor, error) {
vendor := &coredata.Vendor{}
err := s.svc.pg.WithConn(
ctx,
func(conn pg.Conn) error {
vendorRiskAssessment := &coredata.VendorRiskAssessment{}
if err := vendorRiskAssessment.LoadByID(ctx, conn, s.svc.scope, vendorRiskAssessmentID); err != nil {
return fmt.Errorf("cannot load vendor risk assessment: %w", err)
}
if err := vendor.LoadByID(ctx, conn, s.svc.scope, vendorRiskAssessment.VendorID); err != nil {
return fmt.Errorf("cannot load vendor: %w", err)
}
return nil
},
)
if err != nil {
return nil, err
}
return vendor, nil
}
func (s VendorService) Assess(
ctx context.Context,
req AssessVendorRequest,

View File

@@ -7105,7 +7105,7 @@ func (r *vendorRiskAssessmentResolver) Vendor(ctx context.Context, obj *types.Ve
prb := r.ProboService(ctx, obj.ID.TenantID())
vendor, err := prb.Vendors.Get(ctx, obj.ID)
vendor, err := prb.Vendors.GetByRiskAssessmentID(ctx, obj.ID)
if err != nil {
var errNotFound *coredata.ErrVendorNotFound
if errors.As(err, &errNotFound) {