summaryrefslogtreecommitdiff
path: root/include/asterisk/stasis.h
diff options
context:
space:
mode:
authorKinsey Moore <kmoore@digium.com>2013-11-22 20:10:46 +0000
committerKinsey Moore <kmoore@digium.com>2013-11-22 20:10:46 +0000
commitd9015a5356dfff70ce15ed2ea5726325de71d9e3 (patch)
treeb4b253dcc96a4cbc27f54ee294dae45264e12dbb /include/asterisk/stasis.h
parent1c45a32ee861fa427e0243abe03c729966fa4436 (diff)
ARI: Don't leak implementation details
This change prevents channels used as implementation details from leaking out to ARI. It does this by preventing creation of JSON blobs of channel snapshots created from those channels and sanitizing JSON blobs of bridge snapshots as they are created. This introduces a framework for excluding information from output targeted at Stasis applications on a consumer-by-consumer basis using channel sanitization callbacks which could be extended to bridges or endpoints if necessary. This prevents unhelpful error messages from being generated by ast_json_pack. This also corrects a bug where BridgeCreated events would not be created. (closes issue ASTERISK-22744) Review: https://reviewboard.asterisk.org/r/2987/ Reported by: David M. Lee ........ Merged revisions 403069 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403070 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk/stasis.h')
-rw-r--r--include/asterisk/stasis.h40
1 files changed, 37 insertions, 3 deletions
diff --git a/include/asterisk/stasis.h b/include/asterisk/stasis.h
index 955bdc3fc..6bc5171e0 100644
--- a/include/asterisk/stasis.h
+++ b/include/asterisk/stasis.h
@@ -187,6 +187,36 @@ struct stasis_message_type;
struct stasis_message;
/*!
+ * \brief Structure containing callbacks for Stasis message sanitization
+ *
+ * \note If either callback is implemented, both should be implemented since
+ * not all callers may have access to the full snapshot.
+ */
+struct stasis_message_sanitizer {
+ /*!
+ * \brief Callback which determines whether a channel should be sanitized from
+ * a message based on the channel's unique ID
+ *
+ * \param channel_id The unique ID of the channel
+ *
+ * \retval non-zero if the channel should be left out of the message
+ * \retval zero if the channel should remain in the message
+ */
+ int (*channel_id)(const char *channel_id);
+
+ /*!
+ * \brief Callback which determines whether a channel should be sanitized from
+ * a message based on the channel's snapshot
+ *
+ * \param snapshot A snapshot generated from the channel
+ *
+ * \retval non-zero if the channel should be left out of the message
+ * \retval zero if the channel should remain in the message
+ */
+ int (*channel_snapshot)(const struct ast_channel_snapshot *snapshot);
+};
+
+/*!
* \brief Virtual table providing methods for messages.
* \since 12
*/
@@ -198,17 +228,19 @@ struct stasis_message_vtable {
* The returned object should be ast_json_unref()'ed.
*
* \param message Message to convert to JSON string.
+ * \param sanitize Snapshot sanitization callback.
+ *
* \return Newly allocated JSON message.
* \return \c NULL on error.
* \return \c NULL if JSON format is not supported.
*/
- struct ast_json *(*to_json)(struct stasis_message *message);
+ struct ast_json *(*to_json)(struct stasis_message *message, const struct stasis_message_sanitizer *sanitize);
/*!
* \brief Build the AMI representation of the message.
*
* May be \c NULL, or may return \c NULL, to indicate no representation.
- * The returned object should be ao2_cleankup()'ed.
+ * The returned object should be ao2_cleanup()'ed.
*
* \param message Message to convert to AMI string.
* \return Newly allocated \ref ast_manager_event_blob.
@@ -292,11 +324,13 @@ const struct timeval *stasis_message_timestamp(const struct stasis_message *msg)
* be ast_json_unref()'ed.
*
* \param message Message to convert to JSON string.
+ * \param sanitize Snapshot sanitization callback.
+ *
* \return Newly allocated string with JSON message.
* \return \c NULL on error.
* \return \c NULL if JSON format is not supported.
*/
-struct ast_json *stasis_message_to_json(struct stasis_message *message);
+struct ast_json *stasis_message_to_json(struct stasis_message *message, struct stasis_message_sanitizer *sanitize);
/*!
* \brief Build the AMI representation of the message.