Refactor corredor service, add supprot for iterators
This commit is contained in:
@@ -398,6 +398,7 @@ type ServerScript struct {
|
||||
UpdatedAt string `protobuf:"bytes,12,opt,name=updatedAt,proto3" json:"updatedAt,omitempty"`
|
||||
Security *Security `protobuf:"bytes,13,opt,name=security,proto3" json:"security,omitempty"`
|
||||
Triggers []*Trigger `protobuf:"bytes,14,rep,name=triggers,proto3" json:"triggers,omitempty"`
|
||||
Iterator *Iterator `protobuf:"bytes,11,opt,name=iterator,proto3" json:"iterator,omitempty"`
|
||||
Errors []string `protobuf:"bytes,15,rep,name=errors,proto3" json:"errors,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
@@ -471,6 +472,13 @@ func (m *ServerScript) GetTriggers() []*Trigger {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ServerScript) GetIterator() *Iterator {
|
||||
if m != nil {
|
||||
return m.Iterator
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ServerScript) GetErrors() []string {
|
||||
if m != nil {
|
||||
return m.Errors
|
||||
@@ -699,6 +707,85 @@ func (m *Trigger) GetConstraints() []*TConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
type Iterator struct {
|
||||
EventType string `protobuf:"bytes,1,opt,name=eventType,proto3" json:"eventType,omitempty"`
|
||||
ResourceType string `protobuf:"bytes,2,opt,name=resourceType,proto3" json:"resourceType,omitempty"`
|
||||
Deferred []string `protobuf:"bytes,3,rep,name=deferred,proto3" json:"deferred,omitempty"`
|
||||
Filter map[string]string `protobuf:"bytes,4,rep,name=filter,proto3" json:"filter,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||
Action string `protobuf:"bytes,5,opt,name=action,proto3" json:"action,omitempty"`
|
||||
UiProps []*TUIProp `protobuf:"bytes,14,rep,name=uiProps,proto3" json:"uiProps,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *Iterator) Reset() { *m = Iterator{} }
|
||||
func (m *Iterator) String() string { return proto.CompactTextString(m) }
|
||||
func (*Iterator) ProtoMessage() {}
|
||||
func (*Iterator) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_c06bb92bf45e37e2, []int{12}
|
||||
}
|
||||
|
||||
func (m *Iterator) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_Iterator.Unmarshal(m, b)
|
||||
}
|
||||
func (m *Iterator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_Iterator.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *Iterator) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Iterator.Merge(m, src)
|
||||
}
|
||||
func (m *Iterator) XXX_Size() int {
|
||||
return xxx_messageInfo_Iterator.Size(m)
|
||||
}
|
||||
func (m *Iterator) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Iterator.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Iterator proto.InternalMessageInfo
|
||||
|
||||
func (m *Iterator) GetEventType() string {
|
||||
if m != nil {
|
||||
return m.EventType
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Iterator) GetResourceType() string {
|
||||
if m != nil {
|
||||
return m.ResourceType
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Iterator) GetDeferred() []string {
|
||||
if m != nil {
|
||||
return m.Deferred
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Iterator) GetFilter() map[string]string {
|
||||
if m != nil {
|
||||
return m.Filter
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Iterator) GetAction() string {
|
||||
if m != nil {
|
||||
return m.Action
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Iterator) GetUiProps() []*TUIProp {
|
||||
if m != nil {
|
||||
return m.UiProps
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type TConstraint struct {
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Op string `protobuf:"bytes,2,opt,name=op,proto3" json:"op,omitempty"`
|
||||
@@ -712,7 +799,7 @@ func (m *TConstraint) Reset() { *m = TConstraint{} }
|
||||
func (m *TConstraint) String() string { return proto.CompactTextString(m) }
|
||||
func (*TConstraint) ProtoMessage() {}
|
||||
func (*TConstraint) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_c06bb92bf45e37e2, []int{12}
|
||||
return fileDescriptor_c06bb92bf45e37e2, []int{13}
|
||||
}
|
||||
|
||||
func (m *TConstraint) XXX_Unmarshal(b []byte) error {
|
||||
@@ -766,7 +853,7 @@ func (m *TUIProp) Reset() { *m = TUIProp{} }
|
||||
func (m *TUIProp) String() string { return proto.CompactTextString(m) }
|
||||
func (*TUIProp) ProtoMessage() {}
|
||||
func (*TUIProp) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_c06bb92bf45e37e2, []int{13}
|
||||
return fileDescriptor_c06bb92bf45e37e2, []int{14}
|
||||
}
|
||||
|
||||
func (m *TUIProp) XXX_Unmarshal(b []byte) error {
|
||||
@@ -814,7 +901,7 @@ func (m *Bundle) Reset() { *m = Bundle{} }
|
||||
func (m *Bundle) String() string { return proto.CompactTextString(m) }
|
||||
func (*Bundle) ProtoMessage() {}
|
||||
func (*Bundle) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_c06bb92bf45e37e2, []int{14}
|
||||
return fileDescriptor_c06bb92bf45e37e2, []int{15}
|
||||
}
|
||||
|
||||
func (m *Bundle) XXX_Unmarshal(b []byte) error {
|
||||
@@ -871,6 +958,8 @@ func init() {
|
||||
proto.RegisterType((*ClientScript)(nil), "corredor.ClientScript")
|
||||
proto.RegisterType((*Security)(nil), "corredor.Security")
|
||||
proto.RegisterType((*Trigger)(nil), "corredor.Trigger")
|
||||
proto.RegisterType((*Iterator)(nil), "corredor.Iterator")
|
||||
proto.RegisterMapType((map[string]string)(nil), "corredor.Iterator.FilterEntry")
|
||||
proto.RegisterType((*TConstraint)(nil), "corredor.TConstraint")
|
||||
proto.RegisterType((*TUIProp)(nil), "corredor.TUIProp")
|
||||
proto.RegisterType((*Bundle)(nil), "corredor.Bundle")
|
||||
@@ -879,53 +968,58 @@ func init() {
|
||||
func init() { proto.RegisterFile("service-corredor.proto", fileDescriptor_c06bb92bf45e37e2) }
|
||||
|
||||
var fileDescriptor_c06bb92bf45e37e2 = []byte{
|
||||
// 725 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0xcd, 0x6e, 0xd3, 0x4e,
|
||||
0x10, 0x97, 0x93, 0x34, 0x1f, 0xe3, 0xa4, 0xff, 0xfe, 0x57, 0x6d, 0x6a, 0x45, 0x08, 0xc2, 0xc2,
|
||||
0x21, 0x02, 0x35, 0x42, 0xa9, 0x50, 0xa1, 0x70, 0x69, 0x4b, 0x85, 0x40, 0x45, 0x42, 0x6e, 0x79,
|
||||
0x00, 0xd7, 0x1e, 0x45, 0x16, 0xc6, 0xeb, 0xee, 0xae, 0x03, 0x79, 0x00, 0x4e, 0x1c, 0x38, 0x71,
|
||||
0xea, 0x73, 0xf0, 0x5c, 0xbc, 0x02, 0xf2, 0x7a, 0xed, 0x6c, 0xeb, 0xa4, 0x02, 0x09, 0x21, 0x6e,
|
||||
0xf3, 0xf1, 0x9b, 0x4f, 0xcf, 0xcc, 0x1a, 0xfa, 0x02, 0xf9, 0x2c, 0xf4, 0x71, 0xc7, 0x67, 0x9c,
|
||||
0x63, 0xc0, 0xf8, 0x38, 0xe1, 0x4c, 0x32, 0xd2, 0x2e, 0x78, 0xfa, 0xd5, 0x02, 0xfb, 0xf8, 0x13,
|
||||
0xfa, 0x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||
0xa1, 0xa4, 0xc2, 0xb1, 0x54, 0x23, 0xfa, 0x8b, 0x46, 0x98, 0x46, 0x6e, 0x01, 0xa3, 0x5f, 0x2c,
|
||||
0xd8, 0x3e, 0x8a, 0x42, 0x8c, 0xe5, 0x5f, 0xac, 0x81, 0xf4, 0xa1, 0x79, 0x9e, 0xc6, 0x41, 0x84,
|
||||
0x4e, 0x43, 0x59, 0x6b, 0x2e, 0xab, 0xad, 0x9a, 0xcc, 0x2f, 0xd4, 0x66, 0x1a, 0x2d, 0x6a, 0xbb,
|
||||
0x07, 0xbd, 0x43, 0xe5, 0xf7, 0x86, 0xc9, 0xa5, 0xcf, 0x61, 0xbd, 0x00, 0xe9, 0x40, 0x0f, 0xa0,
|
||||
0x95, 0xa7, 0x53, 0x04, 0xda, 0x58, 0x04, 0xd2, 0xd0, 0x02, 0x40, 0x7f, 0x58, 0xd0, 0x35, 0x1b,
|
||||
0xbb, 0x74, 0x39, 0x36, 0x61, 0x2d, 0xf2, 0xce, 0x31, 0x2a, 0x06, 0x48, 0x31, 0x64, 0x08, 0x76,
|
||||
0x80, 0x79, 0xaa, 0x21, 0x8b, 0x9d, 0xba, 0xd2, 0x99, 0x22, 0x72, 0x0b, 0x3a, 0x69, 0x12, 0x78,
|
||||
0x12, 0x83, 0x03, 0xe9, 0x74, 0x95, 0x7e, 0x21, 0x20, 0x63, 0x68, 0x0b, 0xf4, 0x53, 0x1e, 0xca,
|
||||
0xb9, 0xd3, 0x1b, 0x5a, 0x23, 0x7b, 0x42, 0xcc, 0x8f, 0x9d, 0x6b, 0xdc, 0x12, 0x43, 0x76, 0xa0,
|
||||
0x2d, 0x79, 0x38, 0x9d, 0x22, 0x17, 0xce, 0xba, 0xaa, 0xeb, 0xff, 0x05, 0xfe, 0x2c, 0xd7, 0xb8,
|
||||
0x25, 0x24, 0xfb, 0x44, 0xc8, 0x39, 0xe3, 0xc2, 0xf9, 0x4f, 0x7d, 0x3e, 0xcd, 0xd1, 0xcb, 0x1a,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d, 0xc8, 0x63, 0x68, 0x64,
|
||||
0x4f, 0x09, 0xd9, 0x5a, 0xfa, 0xb6, 0x0d, 0xfa, 0xcb, 0x5f, 0x1c, 0xf2, 0x06, 0x1a, 0xd9, 0x15,
|
||||
0x23, 0x77, 0x97, 0x1f, 0x62, 0xe3, 0xdc, 0x0e, 0xe8, 0x4d, 0x90, 0xdc, 0xdd, 0xe4, 0xd2, 0x82,
|
||||
0x9e, 0xb9, 0x7d, 0x82, 0x3c, 0x2b, 0xeb, 0xdd, 0xae, 0x9c, 0x29, 0xed, 0xd8, 0xa9, 0x2a, 0x56,
|
||||
0x67, 0xb7, 0xe2, 0x31, 0x30, 0xb3, 0x5b, 0x75, 0xa2, 0x27, 0x1d, 0x68, 0x9d, 0x4a, 0xc6, 0xbd,
|
||||
0x29, 0x9e, 0x37, 0xd5, 0x5f, 0xc4, 0xee, 0xcf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd6, 0x7e, 0x48,
|
||||
0x92, 0x5f, 0x08, 0x00, 0x00,
|
||||
// 813 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0x4f, 0x6f, 0xeb, 0x44,
|
||||
0x10, 0x97, 0x9d, 0xff, 0xe3, 0xa4, 0x3c, 0x56, 0x7d, 0xa9, 0x15, 0xa1, 0x47, 0x30, 0x1c, 0x22,
|
||||
0xd0, 0x8b, 0x50, 0x2a, 0x78, 0x50, 0xb8, 0xb4, 0xa5, 0xa0, 0xa2, 0x22, 0x21, 0xb7, 0x7c, 0x00,
|
||||
0xd7, 0x9e, 0x46, 0x16, 0xc6, 0xeb, 0xee, 0xae, 0x03, 0xf9, 0x00, 0x9c, 0x38, 0x70, 0xe2, 0xd4,
|
||||
0x03, 0x7c, 0x09, 0xbe, 0x1f, 0xda, 0x3f, 0x76, 0xb6, 0x75, 0x52, 0xb5, 0x12, 0x82, 0xdb, 0xce,
|
||||
0xcc, 0x6f, 0xfe, 0xee, 0xcc, 0xce, 0xc2, 0x98, 0x23, 0x5b, 0xa5, 0x31, 0xbe, 0x8e, 0x29, 0x63,
|
||||
0x98, 0x50, 0x36, 0x2f, 0x18, 0x15, 0x94, 0xf4, 0x2b, 0x3a, 0xf8, 0xdd, 0x01, 0xef, 0xec, 0x17,
|
||||
0x8c, 0x43, 0xbc, 0x2d, 0x91, 0x0b, 0x42, 0xa0, 0x9d, 0x47, 0x3f, 0xa1, 0xef, 0x4c, 0x9d, 0xd9,
|
||||
0x20, 0x54, 0x67, 0x72, 0x08, 0xed, 0x88, 0x2d, 0xb9, 0xef, 0x4e, 0x5b, 0x33, 0x6f, 0xf1, 0xee,
|
||||
0xbc, 0x36, 0x66, 0x29, 0xce, 0x8f, 0xd9, 0x92, 0x9f, 0xe5, 0x82, 0xad, 0x43, 0x05, 0x9e, 0xbc,
|
||||
0x81, 0x41, 0xcd, 0x22, 0x2f, 0xa0, 0xf5, 0x23, 0xae, 0x8d, 0x51, 0x79, 0x24, 0xfb, 0xd0, 0x59,
|
||||
0x45, 0x59, 0x89, 0xbe, 0xab, 0x78, 0x9a, 0x38, 0x72, 0x3f, 0x73, 0x82, 0x5f, 0x1d, 0x18, 0x6a,
|
||||
0xc3, 0xbc, 0xa0, 0x39, 0x47, 0x72, 0x04, 0x5d, 0x86, 0xbc, 0xcc, 0x84, 0x09, 0x20, 0x78, 0x18,
|
||||
0x80, 0xc6, 0xcd, 0x43, 0x05, 0xd2, 0x31, 0x18, 0x8d, 0xc9, 0xe7, 0xe0, 0x59, 0xec, 0x67, 0xc5,
|
||||
0xc1, 0xe1, 0xe0, 0x12, 0xd9, 0x0a, 0xd9, 0x65, 0xcc, 0xd2, 0x42, 0x5c, 0xa4, 0x5c, 0x54, 0x45,
|
||||
0xda, 0x87, 0xce, 0x6d, 0x89, 0xac, 0x32, 0xa4, 0x09, 0x12, 0xc0, 0x90, 0x21, 0xa7, 0x25, 0x8b,
|
||||
0xf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0x29, 0xc4,
|
||||
0x86, 0xf1, 0xa4, 0xb7, 0x67, 0x02, 0xfd, 0x04, 0x6f, 0x50, 0x7a, 0x35, 0xf5, 0xa9, 0x69, 0xf2,
|
||||
0x29, 0x74, 0x6f, 0xd2, 0x4c, 0x20, 0xf3, 0xdb, 0x2a, 0xbc, 0x57, 0xcd, 0x96, 0x9e, 0x7f, 0xad,
|
||||
0x00, 0x66, 0x47, 0x68, 0xb4, 0xbc, 0xbe, 0x28, 0x56, 0x4d, 0xd8, 0xd1, 0x7d, 0xa6, 0xa9, 0x67,
|
||||
0x15, 0x48, 0x2e, 0x1a, 0xcb, 0xf6, 0xb3, 0x16, 0xcd, 0x37, 0xe0, 0x59, 0xe5, 0xdb, 0x3a, 0x42,
|
||||
0x7b, 0xe0, 0xd2, 0xc2, 0x68, 0xba, 0xb4, 0xd8, 0x18, 0x33, 0x3d, 0xa2, 0x88, 0xe0, 0x10, 0x7a,
|
||||
0x26, 0xae, 0x5d, 0x73, 0xd8, 0x8c, 0x20, 0xf8, 0x0a, 0xba, 0x27, 0xf5, 0x5c, 0x35, 0x74, 0xaa,
|
||||
0x59, 0x73, 0xad, 0x59, 0x23, 0xd0, 0x8e, 0x69, 0x82, 0x66, 0x64, 0xd5, 0x79, 0xf1, 0x87, 0x03,
|
||||
0x23, 0xfb, 0xa9, 0xe4, 0xe4, 0x13, 0x68, 0xcb, 0xed, 0x4c, 0x5e, 0x6e, 0xfd, 0x2e, 0x4c, 0xc6,
|
||||
0xdb, 0x97, 0x38, 0xf9, 0x0e, 0xda, 0x72, 0x31, 0x90, 0xf7, 0xb6, 0xef, 0x36, 0x6b, 0x83, 0x4d,
|
||||
0x82, 0xc7, 0x20, 0xda, 0xdc, 0xe2, 0xce, 0x81, 0x91, 0xfd, 0x40, 0x71, 0xf2, 0x45, 0x9d, 0xef,
|
||||
0x41, 0xe3, 0xe5, 0x37, 0x86, 0xfd, 0xa6, 0x60, 0x77, 0x74, 0x3b, 0xf6, 0xab, 0x1d, 0xdd, 0xae,
|
||||
0xad, 0xb7, 0x18, 0x40, 0xef, 0x52, 0x50, 0x16, 0x2d, 0xf1, 0xba, 0xab, 0x3e, 0x66, 0x87, 0xff,
|
||||
0x04, 0x00, 0x00, 0xff, 0xff, 0xb5, 0xf8, 0x81, 0x52, 0xb2, 0x09, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
|
||||
+252
-66
@@ -10,6 +10,7 @@ import (
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/pkg/app/options"
|
||||
@@ -20,6 +21,10 @@ import (
|
||||
)
|
||||
|
||||
type (
|
||||
// IteratorResourceFinder acts as a middleware that converts
|
||||
// iteration request to appropriate resource iterator (eg: Record Finder)
|
||||
IteratorResourceFinder func(ctx context.Context, f map[string]string, h eventbus.HandlerFn, action string) error
|
||||
|
||||
service struct {
|
||||
// stores corredor connection options
|
||||
// for when we're doing lazy setup
|
||||
@@ -49,6 +54,9 @@ type (
|
||||
eventRegistry eventRegistry
|
||||
authTokenMaker authTokenMaker
|
||||
|
||||
// map[resource-type]
|
||||
iteratorProviders map[string]IteratorResourceFinder
|
||||
|
||||
// Services to help with script security
|
||||
// we'll find users (runAs) and roles (allow, deny) for
|
||||
users userFinder
|
||||
@@ -74,6 +82,10 @@ type (
|
||||
Unregister(ptrs ...uintptr)
|
||||
}
|
||||
|
||||
iteratorRegistry interface {
|
||||
Exec(ctx context.Context, resourceType string, f map[string]string, action string) error
|
||||
}
|
||||
|
||||
userFinder interface {
|
||||
FindByAny(interface{}) (*types.User, error)
|
||||
}
|
||||
@@ -91,11 +103,33 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
const onManualEventType = "onManual"
|
||||
const (
|
||||
onManualEventType = "onManual"
|
||||
onIterationEventType = "onIteration"
|
||||
onIntervalEventType = "onInterval"
|
||||
onTimestampEventType = "onTimestamp"
|
||||
)
|
||||
|
||||
var (
|
||||
// Global corredor service
|
||||
gCorredor *service
|
||||
|
||||
// List of event types that can be used as iteration
|
||||
// initiator
|
||||
//
|
||||
// These events will fetch resources from registered services
|
||||
// according to the given filter and call accompanying script
|
||||
// for each
|
||||
iteratorCompatibleEventTypes = map[string]bool{
|
||||
onManualEventType: true,
|
||||
onIntervalEventType: true,
|
||||
onTimestampEventType: true,
|
||||
}
|
||||
|
||||
explicitEventTypes = []string{
|
||||
onManualEventType,
|
||||
onIterationEventType,
|
||||
}
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -106,7 +140,7 @@ func Service() *service {
|
||||
return gCorredor
|
||||
}
|
||||
|
||||
// Start connects to Corredor & initialize service
|
||||
// Setup start connects to Corredor & initialize service
|
||||
func Setup(logger *zap.Logger, opt options.CorredorOpt) (err error) {
|
||||
if gCorredor != nil {
|
||||
// Prevent multiple initializations
|
||||
@@ -125,6 +159,8 @@ func NewService(logger *zap.Logger, opt options.CorredorOpt) *service {
|
||||
registered: make(map[string][]uintptr),
|
||||
explicit: make(map[string]map[string]bool),
|
||||
|
||||
iteratorProviders: make(map[string]IteratorResourceFinder),
|
||||
|
||||
authTokenMaker: auth.DefaultJwtHandler,
|
||||
eventRegistry: eventbus.Service(),
|
||||
permissions: permissions.RuleSet{},
|
||||
@@ -239,6 +275,64 @@ func (svc service) makeScriptFilter(ctx context.Context, f Filter) func(s *Scrip
|
||||
}
|
||||
}
|
||||
|
||||
func (svc service) ExecIterator(ctx context.Context, scriptName string) error {
|
||||
var (
|
||||
script *Script
|
||||
runAs string
|
||||
)
|
||||
|
||||
if script = svc.sScripts.FindByName(scriptName); script == nil {
|
||||
return errors.Errorf("nonexistent script (%q)", scriptName)
|
||||
}
|
||||
|
||||
if !svc.canExec(ctx, scriptName) {
|
||||
return errors.Errorf("permission to execute %s denied", scriptName)
|
||||
}
|
||||
|
||||
if script.Iterator == nil {
|
||||
return errors.Errorf("not an itrator script")
|
||||
}
|
||||
|
||||
if finder, ok := svc.iteratorProviders[script.Iterator.ResourceType]; !ok {
|
||||
return errors.Errorf("unknown resource finder: %s", script.Iterator.ResourceType)
|
||||
} else {
|
||||
if script.Security != nil {
|
||||
runAs = script.Security.RunAs
|
||||
}
|
||||
|
||||
if runAs != "" {
|
||||
if !svc.opt.RunAsEnabled {
|
||||
return errors.New("could not make runner context, run-as disabled")
|
||||
}
|
||||
|
||||
// Run this iterator as defined user
|
||||
definer, err := svc.users.FindByAny(runAs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ctx = auth.SetIdentityToContext(ctx, definer)
|
||||
}
|
||||
|
||||
return finder(
|
||||
ctx,
|
||||
script.Iterator.Filter,
|
||||
func(ctx context.Context, ev eventbus.Event) error {
|
||||
// iteration handler/callback
|
||||
//
|
||||
// this function is called on every iteration, for
|
||||
// every resource found by iterator
|
||||
return svc.exec(ctx, scriptName, runAs, ev.(ScriptArgs))
|
||||
},
|
||||
script.Iterator.Action,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func (svc *service) RegisterIteratorProvider(resourceType string, irf IteratorResourceFinder) {
|
||||
svc.iteratorProviders[resourceType] = irf
|
||||
}
|
||||
|
||||
// Exec verifies permissions, event and script and sends exec request to corredor
|
||||
func (svc service) Exec(ctx context.Context, scriptName string, args ScriptArgs) (err error) {
|
||||
if !svc.opt.Enabled {
|
||||
@@ -324,30 +418,6 @@ func (svc *service) loadServerScripts(ctx context.Context) {
|
||||
|
||||
// Registers Corredor scripts to eventbus and list of manual scripts
|
||||
func (svc *service) registerServerScripts(ss ...*ServerScript) {
|
||||
var (
|
||||
permRuleGenerator = func(script string, access permissions.Access, roles ...string) (permissions.RuleSet, error) {
|
||||
out := make([]*permissions.Rule, len(roles))
|
||||
for i, role := range roles {
|
||||
if r, err := svc.roles.FindByAny(role); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
out[i] = &permissions.Rule{
|
||||
RoleID: r.ID,
|
||||
Resource: permissions.Resource(script),
|
||||
Operation: permOpExec,
|
||||
Access: access,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
u *types.User
|
||||
err error
|
||||
runAs = ""
|
||||
)
|
||||
|
||||
svc.sScripts = make([]*Script, 0, len(ss))
|
||||
|
||||
// Remove all previously registered triggers
|
||||
@@ -365,13 +435,6 @@ func (svc *service) registerServerScripts(ss ...*ServerScript) {
|
||||
svc.permissions = permissions.RuleSet{}
|
||||
|
||||
for _, script := range ss {
|
||||
var (
|
||||
// collectors for allow&deny rules
|
||||
// we'll merge
|
||||
allow = permissions.RuleSet{}
|
||||
deny = permissions.RuleSet{}
|
||||
)
|
||||
|
||||
if nil != svc.sScripts.FindByName(script.Name) {
|
||||
// Do not allow duplicated scripts
|
||||
continue
|
||||
@@ -383,44 +446,36 @@ func (svc *service) registerServerScripts(ss ...*ServerScript) {
|
||||
Description: script.Description,
|
||||
Errors: script.Errors,
|
||||
Triggers: script.Triggers,
|
||||
Security: &ScriptSecurity{Security: script.Security},
|
||||
Iterator: script.Iterator,
|
||||
}
|
||||
|
||||
scriptErrPush := func(err error, msg string) {
|
||||
s.Errors = append(s.Errors, errors.Wrap(err, msg).Error())
|
||||
// Corredor can (by design) serve us script with errors (load, parse time) and
|
||||
// they need to be ignored by security, trigger, iterator handlers
|
||||
if len(s.Errors) == 0 {
|
||||
if sec, rr, err := svc.serverScriptSecurity(script); err != nil {
|
||||
s.Errors = append(s.Errors, err.Error())
|
||||
} else {
|
||||
s.Security = sec
|
||||
svc.permissions = append(svc.permissions, rr...)
|
||||
}
|
||||
|
||||
if s.Iterator != nil {
|
||||
// process iterator and register (deferred) event handlers
|
||||
if ptrs, err := svc.processIterator(s); err != nil {
|
||||
s.Errors = append(s.Errors, err.Error())
|
||||
} else if ptrs > 0 {
|
||||
svc.registered[script.Name] = []uintptr{ptrs}
|
||||
}
|
||||
} else {
|
||||
if manual := mapExplicitTriggers(script); len(manual) > 0 {
|
||||
svc.explicit[script.Name] = manual
|
||||
}
|
||||
|
||||
svc.registered[script.Name] = svc.registerTriggers(script)
|
||||
}
|
||||
}
|
||||
|
||||
if len(s.Errors) == 0 {
|
||||
if manual := mapExplicitTriggers(script); len(manual) > 0 {
|
||||
if script.Security != nil {
|
||||
runAs = script.Security.RunAs
|
||||
|
||||
if runAs != "" {
|
||||
// Prefetch run-as user
|
||||
if u, err = svc.users.FindByAny(runAs); err != nil {
|
||||
scriptErrPush(err, "could not load run-as user security info")
|
||||
} else {
|
||||
s.Security.runAs = u.ID
|
||||
}
|
||||
}
|
||||
|
||||
if allow, err = permRuleGenerator(script.Name, permissions.Allow, script.Security.Allow...); err != nil {
|
||||
scriptErrPush(err, "could not load allow role security info")
|
||||
}
|
||||
|
||||
if deny, err = permRuleGenerator(script.Name, permissions.Deny, script.Security.Deny...); err != nil {
|
||||
scriptErrPush(err, "could not load deny role security info")
|
||||
}
|
||||
|
||||
svc.permissions = append(svc.permissions, allow...)
|
||||
svc.permissions = append(svc.permissions, deny...)
|
||||
}
|
||||
|
||||
svc.explicit[script.Name] = manual
|
||||
}
|
||||
|
||||
svc.registered[script.Name] = svc.registerTriggers(script)
|
||||
|
||||
svc.log.Debug(
|
||||
"script registered",
|
||||
zap.String("script", s.Name),
|
||||
@@ -434,9 +489,82 @@ func (svc *service) registerServerScripts(ss ...*ServerScript) {
|
||||
zap.Strings("errors", s.Errors),
|
||||
)
|
||||
}
|
||||
|
||||
// Even if there are errors, we'll append the scripts
|
||||
// because we need to serve them as a list for script management
|
||||
svc.sScripts = append(svc.sScripts, s)
|
||||
}
|
||||
}
|
||||
|
||||
// Registers scheduled and manual iterators
|
||||
//
|
||||
// scheduled iterators
|
||||
// registered on eventbus as onInterval or onTimestamp
|
||||
// and triggered by/from scheduler
|
||||
//
|
||||
// manual iterators
|
||||
// can be invoked via API
|
||||
func (svc *service) processIterator(script *Script) (ptr uintptr, err error) {
|
||||
var (
|
||||
log = svc.log.With(zap.String("script", script.Name))
|
||||
i = script.Iterator
|
||||
|
||||
service string
|
||||
)
|
||||
|
||||
if i == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if i.ResourceType == "" {
|
||||
return 0, errors.Errorf("iterator resourceType not defined")
|
||||
}
|
||||
|
||||
log.Info(
|
||||
"registering iterator",
|
||||
zap.String("action", i.Action),
|
||||
zap.Any("filter", i.Filter),
|
||||
zap.String("eventType", i.EventType),
|
||||
zap.String("resourceType", i.ResourceType),
|
||||
zap.Strings("deferred", i.Deferred),
|
||||
)
|
||||
|
||||
switch i.EventType {
|
||||
case onManualEventType:
|
||||
// nothing special here with manual iterators...
|
||||
return
|
||||
case onIntervalEventType, onTimestampEventType:
|
||||
if len(i.Deferred) == 0 {
|
||||
return 0, errors.Errorf("missing specification for interval/timestamp events")
|
||||
}
|
||||
|
||||
if script.Security == nil {
|
||||
return 0, errors.Errorf("can not schedule iterator without security descriptor")
|
||||
}
|
||||
|
||||
if p := strings.Index(i.ResourceType, ":"); p > 0 {
|
||||
service = i.ResourceType[0:p]
|
||||
} else {
|
||||
service = i.ResourceType
|
||||
}
|
||||
|
||||
// Generate event handler for onInterval or onTimestamp event
|
||||
// with deferred param as constraint
|
||||
return svc.eventRegistry.Register(
|
||||
func(ctx context.Context, ev eventbus.Event) error {
|
||||
return svc.ExecIterator(ctx, script.Name)
|
||||
},
|
||||
eventbus.On(i.EventType),
|
||||
eventbus.For(service),
|
||||
eventbus.Constraint(eventbus.MustMakeConstraint("", "", i.Deferred...)),
|
||||
), nil
|
||||
default:
|
||||
return 0, errors.Errorf("incompatible event type (%s) for iterator", i.EventType)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Creates handler function for eventbus subsystem
|
||||
func (svc *service) registerTriggers(script *ServerScript) []uintptr {
|
||||
var (
|
||||
@@ -719,6 +847,64 @@ func (svc *service) registerClientScripts(ss ...*ClientScript) {
|
||||
}
|
||||
}
|
||||
|
||||
// processes server script security definition
|
||||
//
|
||||
// Checks and preloads sser and roles (if defined)
|
||||
//
|
||||
func (svc *service) serverScriptSecurity(script *ServerScript) (sec *ScriptSecurity, rr permissions.RuleSet, err error) {
|
||||
if script.Security == nil {
|
||||
return
|
||||
}
|
||||
|
||||
var (
|
||||
// collectors for allow&deny rules
|
||||
// we'll merge
|
||||
allow = permissions.RuleSet{}
|
||||
deny = permissions.RuleSet{}
|
||||
|
||||
permRuleGenerator = func(script string, access permissions.Access, roles ...string) (permissions.RuleSet, error) {
|
||||
out := make([]*permissions.Rule, len(roles))
|
||||
for i, role := range roles {
|
||||
if r, err := svc.roles.FindByAny(role); err != nil {
|
||||
return nil, errors.Wrapf(err, "could not load security role: %s", role)
|
||||
} else {
|
||||
out[i] = &permissions.Rule{
|
||||
RoleID: r.ID,
|
||||
Resource: permissions.Resource(script),
|
||||
Operation: permOpExec,
|
||||
Access: access,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
)
|
||||
|
||||
sec = &ScriptSecurity{Security: script.Security}
|
||||
|
||||
if sec.RunAs != "" {
|
||||
// Prefetch run-as user
|
||||
if _, err = svc.users.FindByAny(sec.RunAs); err != nil {
|
||||
err = errors.Wrap(err, "could not load security (run-as) user")
|
||||
return
|
||||
//} else {
|
||||
// s.Security.runAs = u.ID
|
||||
}
|
||||
}
|
||||
|
||||
if allow, err = permRuleGenerator(script.Name, permissions.Allow, script.Security.Allow...); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if deny, err = permRuleGenerator(script.Name, permissions.Deny, script.Security.Deny...); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
rr = append(allow, deny...)
|
||||
return
|
||||
}
|
||||
|
||||
func (svc *service) GetBundle(ctx context.Context, name, bType string) *Bundle {
|
||||
if !svc.opt.Enabled {
|
||||
return nil
|
||||
|
||||
@@ -25,6 +25,7 @@ type (
|
||||
Description string `json:"description"`
|
||||
Errors []string `json:"errors,omitempty"`
|
||||
Triggers []*Trigger `json:"triggers"`
|
||||
Iterator *Iterator `json:"iterator"`
|
||||
Security *ScriptSecurity `json:"security"`
|
||||
|
||||
// If bundle or type is set, consider
|
||||
|
||||
Reference in New Issue
Block a user