summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Pasquier <spasquier@mirantis.com>2016-02-18 09:53:34 +0100
committerSimon Pasquier <spasquier@mirantis.com>2016-02-22 15:41:37 +0100
commit24839424158c24b36e0961c7b5c36891f0e50a9e (patch)
tree217435ce9dd997c783634682d7c199bf6d65681a
parent9316c2a2d8fc0000fee05e2e9e0b3106a44c90bf (diff)
Catch buffer exceptions in the Lua sandboxes0.7-eol
This change ensures that the notification and rabbitmq decoders won't crash when they process excessive payload. Change-Id: I67e2dd8a03bdce4b7e72e1f981e61f518bc8778e Closes-Bug: #1504141
Notes
Notes (review): Code-Review+1: Guillaume Thouvenin <gthouvenin@mirantis.com> Code-Review+2: Simon Pasquier <spasquier@mirantis.com> Workflow+1: Simon Pasquier <spasquier@mirantis.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Wed, 11 May 2016 07:11:22 +0000 Reviewed-on: https://review.openstack.org/281699 Project: openstack/fuel-plugin-lma-collector Branch: refs/heads/stable/0.7
-rw-r--r--deployment_scripts/puppet/modules/lma_collector/files/plugins/decoders/notification.lua11
-rw-r--r--deployment_scripts/puppet/modules/lma_collector/files/plugins/decoders/rabbitmq.lua2
2 files changed, 10 insertions, 3 deletions
diff --git a/deployment_scripts/puppet/modules/lma_collector/files/plugins/decoders/notification.lua b/deployment_scripts/puppet/modules/lma_collector/files/plugins/decoders/notification.lua
index de2a052..e5fb571 100644
--- a/deployment_scripts/puppet/modules/lma_collector/files/plugins/decoders/notification.lua
+++ b/deployment_scripts/puppet/modules/lma_collector/files/plugins/decoders/notification.lua
@@ -106,6 +106,10 @@ local include_full_notification = read_config("include_full_notification") or fa
106 106
107function process_message () 107function process_message ()
108 local data = read_message("Payload") 108 local data = read_message("Payload")
109 if string.len(data) > 63000 then
110 -- See bug #1504141
111 return -1
112 end
109 local ok, notif = pcall(cjson.decode, data) 113 local ok, notif = pcall(cjson.decode, data)
110 if not ok then 114 if not ok then
111 return -1 115 return -1
@@ -114,7 +118,10 @@ function process_message ()
114 if include_full_notification then 118 if include_full_notification then
115 msg.Payload = data 119 msg.Payload = data
116 else 120 else
117 msg.Payload = cjson.encode(notif.payload) 121 ok, msg.Payload = pcall(cjson.encode, notif.payload)
122 if not ok then
123 msg.Payload = nil
124 end
118 end 125 end
119 126
120 msg.Fields = {} 127 msg.Fields = {}
@@ -144,6 +151,6 @@ function process_message ()
144 end 151 end
145 utils.inject_tags(msg) 152 utils.inject_tags(msg)
146 153
147 inject_message(msg) 154 pcall(inject_message, msg)
148 return 0 155 return 0
149end 156end
diff --git a/deployment_scripts/puppet/modules/lma_collector/files/plugins/decoders/rabbitmq.lua b/deployment_scripts/puppet/modules/lma_collector/files/plugins/decoders/rabbitmq.lua
index 51c7be5..e98e7c8 100644
--- a/deployment_scripts/puppet/modules/lma_collector/files/plugins/decoders/rabbitmq.lua
+++ b/deployment_scripts/puppet/modules/lma_collector/files/plugins/decoders/rabbitmq.lua
@@ -67,6 +67,6 @@ function process_message ()
67 msg.Fields.programname = 'rabbitmq' 67 msg.Fields.programname = 'rabbitmq'
68 utils.inject_tags(msg) 68 utils.inject_tags(msg)
69 69
70 inject_message(msg) 70 pcall(inject_message, msg)
71 return 0 71 return 0
72end 72end