Skip to content

Commit e43047f

Browse files
committed
🔒 Truncate encoded data URIs in REST API debug logs for polling failures and invalid URLs
Prevent leaking large base64 payloads in audit logs and system chat logs by routing polling conditions failed entries and invalid URL debug output through truncateEncodedData(), matching the behavior already applied to regular requests.
1 parent a9e9776 commit e43047f

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

‎lhc_web/lib/core/lhgenericbot/actionTypes/lhgenericbotactionrestapi.php‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public static function process($chat, $action, $trigger, $params)
176176
}
177177

178178
erLhcoreClassLog::write(
179-
json_encode([
179+
json_encode(self::truncateEncodedData([
180180
'name' => '(polling conditions failed) [' . $restAPI->name . '] [' . $i . '] tries' . (isset($method['name']) ? $method['name'] : 'unknwon_name'),
181181
'method_name' => $method['name'],
182182
'trigger' => (isset($params['current_trigger']) && is_object($params['current_trigger']) ? 'B['. $params['current_trigger']->bot_id .'] T['.$params['current_trigger']->id . '] ' . $params['current_trigger']->name : null),
@@ -192,7 +192,7 @@ public static function process($chat, $action, $trigger, $params)
192192
'http_error' => $response['http_error'],
193193
'msg_id' => (isset($params['msg']) && is_object($params['msg'])) ? $params['msg']->id : 0,
194194
'msg_text' => '-',
195-
], JSON_PRETTY_PRINT | JSON_PARTIAL_OUTPUT_ON_ERROR),
195+
]), JSON_PRETTY_PRINT | JSON_PARTIAL_OUTPUT_ON_ERROR),
196196
ezcLog::SUCCESS_AUDIT,
197197
array(
198198
'source' => 'Bot',
@@ -217,7 +217,7 @@ public static function process($chat, $action, $trigger, $params)
217217
$msgLog->time = time();
218218
$msgLog->meta_msg = json_encode(['content' => ['html' => [
219219
'debug' => true,
220-
'content' => json_encode([
220+
'content' => json_encode(self::truncateEncodedData([
221221
'name' => '[' . $restAPI->name . '] ' . (isset($method['name']) ? $method['name'] : 'unknwon_name'),
222222
'method_name' => $method['name'],
223223
'trigger' => (isset($params['current_trigger']) && is_object($params['current_trigger']) ? 'B['. $params['current_trigger']->bot_id .'] T['.$params['current_trigger']->id . '] ' . $params['current_trigger']->name : null),
@@ -234,7 +234,7 @@ public static function process($chat, $action, $trigger, $params)
234234
'msg_id' => (isset($params['msg']) && is_object($params['msg'])) ? $params['msg']->id : 0,
235235
'msg_text' => '-',
236236
'line' => __LINE__,
237-
],JSON_PRETTY_PRINT | JSON_PARTIAL_OUTPUT_ON_ERROR)]]]);
237+
]),JSON_PRETTY_PRINT | JSON_PARTIAL_OUTPUT_ON_ERROR)]]]);
238238
$msgLog->msg = '(polling conditions failed) [' . $restAPI->name . '] [' . $i . ' tries] [i]'.(isset($method['name']) ? $method['name'] : 'unknown_name').'[/i]';
239239

240240
$statusWorkflow = erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.log_msg', array(
@@ -1373,7 +1373,7 @@ public static function makeRequest($host, $methodSettings, $paramsCustomer)
13731373

13741374
if (isset($paramsCustomer['rest_api']->configuration_array['log_audit']) && $paramsCustomer['rest_api']->configuration_array['log_audit']) {
13751375
erLhcoreClassLog::write(
1376-
json_encode([
1376+
json_encode(self::truncateEncodedData([
13771377
'name' => '[' . $paramsCustomer['rest_api']->name . '] ' . (isset($methodSettings['name']) ? $methodSettings['name'] : 'unknwon_name'),
13781378
'method_name' => $methodSettings['name'],
13791379
'trigger' => (isset($paramsCustomer['params']['current_trigger']) && is_object($paramsCustomer['params']['current_trigger']) ? 'B['. $paramsCustomer['params']['current_trigger']->bot_id .'] T['.$paramsCustomer['params']['current_trigger']->id . '] ' . $paramsCustomer['params']['current_trigger']->name : null),
@@ -1391,7 +1391,7 @@ public static function makeRequest($host, $methodSettings, $paramsCustomer)
13911391
'stream_lines' => '',
13921392
'msg_id' => (isset($paramsCustomer['params']['msg']) && is_object($paramsCustomer['params']['msg'])) ? $paramsCustomer['params']['msg']->id : 0,
13931393
'msg_text' => $msg_text,
1394-
], JSON_PRETTY_PRINT | JSON_PARTIAL_OUTPUT_ON_ERROR),
1394+
]), JSON_PRETTY_PRINT | JSON_PARTIAL_OUTPUT_ON_ERROR),
13951395
ezcLog::SUCCESS_AUDIT,
13961396
array(
13971397
'source' => 'Bot',
@@ -1410,7 +1410,7 @@ public static function makeRequest($host, $methodSettings, $paramsCustomer)
14101410
$msgLog->time = time();
14111411
$msgLog->meta_msg = json_encode(['content' => ['html' => [
14121412
'debug' => true,
1413-
'content' => json_encode([
1413+
'content' => json_encode(self::truncateEncodedData([
14141414
'name' => '[' . $paramsCustomer['rest_api']->name . '] ' . (isset($methodSettings['name']) ? $methodSettings['name'] : 'unknown_name'),
14151415
'method_name' => $methodSettings['name'],
14161416
'trigger' => (isset($paramsCustomer['params']['current_trigger']) && is_object($paramsCustomer['params']['current_trigger']) ? 'B['. $paramsCustomer['params']['current_trigger']->bot_id .'] T['.$paramsCustomer['params']['current_trigger']->id . '] ' . $paramsCustomer['params']['current_trigger']->name : null),
@@ -1429,7 +1429,7 @@ public static function makeRequest($host, $methodSettings, $paramsCustomer)
14291429
'msg_id' => (isset($paramsCustomer['params']['msg']) && is_object($paramsCustomer['params']['msg'])) ? $paramsCustomer['params']['msg']->id : 0,
14301430
'msg_text' => $msg_text,
14311431
'line' => __LINE__,
1432-
],JSON_PRETTY_PRINT | JSON_PARTIAL_OUTPUT_ON_ERROR)]]]);
1432+
]),JSON_PRETTY_PRINT | JSON_PARTIAL_OUTPUT_ON_ERROR)]]]);
14331433
$msgLog->msg = '[' . $paramsCustomer['rest_api']->name . '] ' . '[i]'.(isset($methodSettings['name']) ? $methodSettings['name'] : 'unknown_name').'[/i]';
14341434

14351435
$statusWorkflow = erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.log_msg', array(

0 commit comments

Comments
 (0)