From a434fe763790e8089e5ad0b0eccceddd937e10b4 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 6 Mar 2018 20:01:18 -0600 Subject: register additional gob types to support arrays and dicts in post props (#8412) --- plugin/rpcplugin/api.go | 2 ++ plugin/rpcplugin/api_test.go | 43 ++++++++++++++++++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 5 deletions(-) (limited to 'plugin/rpcplugin') diff --git a/plugin/rpcplugin/api.go b/plugin/rpcplugin/api.go index 5b5b11a62..d87f65b55 100644 --- a/plugin/rpcplugin/api.go +++ b/plugin/rpcplugin/api.go @@ -610,4 +610,6 @@ func ConnectAPI(conn io.ReadWriteCloser, muxer *Muxer) *RemoteAPI { func init() { gob.Register([]*model.SlackAttachment{}) + gob.Register([]interface{}{}) + gob.Register(map[string]interface{}{}) } diff --git a/plugin/rpcplugin/api_test.go b/plugin/rpcplugin/api_test.go index 145ec9005..7fe7a0ff9 100644 --- a/plugin/rpcplugin/api_test.go +++ b/plugin/rpcplugin/api_test.go @@ -72,11 +72,6 @@ func TestAPI(t *testing.T) { testPost := &model.Post{ Message: "hello", - Props: map[string]interface{}{ - "attachments": []*model.SlackAttachment{ - &model.SlackAttachment{}, - }, - }, } testAPIRPC(&api, func(remote plugin.API) { @@ -244,3 +239,41 @@ func TestAPI(t *testing.T) { assert.Nil(t, err) }) } + +func TestAPI_GobRegistration(t *testing.T) { + keyValueStore := &plugintest.KeyValueStore{} + api := plugintest.API{Store: keyValueStore} + defer api.AssertExpectations(t) + + testAPIRPC(&api, func(remote plugin.API) { + api.On("CreatePost", mock.AnythingOfType("*model.Post")).Return(func(p *model.Post) (*model.Post, *model.AppError) { + p.Id = "thepostid" + return p, nil + }).Once() + _, err := remote.CreatePost(&model.Post{ + Message: "hello", + Props: map[string]interface{}{ + "attachments": []*model.SlackAttachment{ + &model.SlackAttachment{ + Actions: []*model.PostAction{ + &model.PostAction{ + Integration: &model.PostActionIntegration{ + Context: map[string]interface{}{ + "foo": "bar", + "foos": []interface{}{"bar", "baz", 1, 2}, + "foo_map": map[string]interface{}{ + "1": "bar", + "2": 2, + }, + }, + }, + }, + }, + Timestamp: 1, + }, + }, + }, + }) + require.Nil(t, err) + }) +} -- cgit v1.2.3-1-g7c22 From e4ddad16bfe15ac1c1b6a0334df084bbb334d4e3 Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 7 Mar 2018 12:43:26 -0600 Subject: plugin sandbox fixes (#8418) --- plugin/rpcplugin/sandbox/sandbox_linux.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'plugin/rpcplugin') diff --git a/plugin/rpcplugin/sandbox/sandbox_linux.go b/plugin/rpcplugin/sandbox/sandbox_linux.go index dad485f68..4ade00cf2 100644 --- a/plugin/rpcplugin/sandbox/sandbox_linux.go +++ b/plugin/rpcplugin/sandbox/sandbox_linux.go @@ -267,7 +267,7 @@ func pivotRoot(newRoot string) error { func dropInheritableCapabilities() error { type capHeader struct { version uint32 - pid int + pid int32 } type capData struct { @@ -425,6 +425,15 @@ func checkSupportInNamespace() error { return errors.Wrapf(err, "unable to enable seccomp filter") } + if f, err := os.Create(os.DevNull); err != nil { + return errors.Wrapf(err, "unable to open os.DevNull") + } else { + defer f.Close() + if _, err = f.Write([]byte("foo")); err != nil { + return errors.Wrapf(err, "unable to write to os.DevNull") + } + } + return nil } -- cgit v1.2.3-1-g7c22