From cbaa27142c41a57e9f17b0b47fbe42cd345b4304 Mon Sep 17 00:00:00 2001 From: Matthew Jordan Date: Thu, 6 Feb 2014 21:24:32 +0000 Subject: security_events: Add AMI documentation; output optional fields This patch adds documentation for the Security Events that are emited over AMI. It also notes these events in the UPGRADE/CHANGES file. ........ Merged revisions 407589 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407602 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/security_events.c | 348 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 346 insertions(+), 2 deletions(-) (limited to 'main/security_events.c') diff --git a/main/security_events.c b/main/security_events.c index a82c7c3bd..54cca2d5e 100644 --- a/main/security_events.c +++ b/main/security_events.c @@ -28,6 +28,338 @@ core ***/ +/*** DOCUMENTATION + + + Raised when a request violates an ACL check. + + + The time the event was detected. + + + A relative severity of the security event. + + + + + + + The Asterisk service that raised the security event. + + + The version of this event. + + + The Service account associated with the security event + notification. + + + A unique identifier for the session in the service + that raised the event. + + + The address of the Asterisk service that raised the + security event. + + + The remote address of the entity that caused the + security event to be raised. + + + If available, the name of the module that raised the event. + + + If available, the name of the ACL that failed. + + + The timestamp reported by the session. + + + + + + + Raised when a request fails an authentication check due to an invalid account ID. + + + + + + + + + + + + + + + + + Raised when a request fails due to exceeding the number of allowed concurrent sessions for that service. + + + + + + + + + + + + + + + + + Raised when a request fails due to an internal memory allocation failure. + + + + + + + + + + + + + + + + + Raised when a request fails because a configured load average limit has been reached. + + + + + + + + + + + + + + + + + Raised when a request fails due to some aspect of the requested item not being supported by the service. + + + + + + + + + + + The type of request attempted. + + + + + + + + + Raised when a request is not allowed by the service. + + + + + + + + + + + + + + Parameters provided to the rejected request. + + + + + + + Raised when a request used an authentication method not allowed by the service. + + + + + + + + + + + The authentication method attempted. + + + + + + + + + Raised when a request is received with bad formatting. + + + + + + + + + + + + + + The account ID associated with the rejected request. + + + + + + + + Raised when a request successfully authenticates with a service. + + + + + + + + + + + Whether or not the authentication attempt included a password. + + + + + + + + + Raised when a request has a different source address then what is expected for a session already in progress with a service. + + + + + + + + + + + The address that the request was expected to use. + + + + + + + + + Raised when a request's attempt to authenticate has been challenged, and the request failed the authentication challenge. + + + + + + + + + + + The challenge that was sent. + + + The response that was received. + + + The expected response to the challenge. + + + + + + + + + Raised when a request provides an invalid password during an authentication attempt. + + + + + + + + + + + + + The challenge that was sent. + + + The challenge that was received. + + + The hash that was received. + + + + + + + Raised when an Asterisk service sends an authentication challenge to a request. + + + + + + + + + + + + + + + + + + Raised when a request attempts to use a transport not allowed by the Asterisk service. + + + + + + + + + + + The transport type that the request attempted to use. + + + + + + + ***/ + #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision$") @@ -61,7 +393,7 @@ static int append_event_str_single(struct ast_str **str, struct ast_json *json, ast_assert(json_string != NULL); - if (ast_str_append(str, 0, "%s: %s\r\n", ie_type_key, ast_json_string_get(json_string)) == -1) { + if (ast_str_append(str, 0, "%s: %s\r\n", ie_type_key, S_OR(ast_json_string_get(json_string), "")) == -1) { return -1; } @@ -73,6 +405,10 @@ static int append_event_str_from_json(struct ast_str **str, struct ast_json *jso { unsigned int i; + if (!ies) { + return 0; + } + for (i = 0; ies[i].ie_type != AST_EVENT_IE_END; i++) { if (append_event_str_single(str, json, ies[i].ie_type)) { return -1; @@ -99,7 +435,15 @@ static struct ast_manager_event_blob *security_event_to_ami_blob(struct ast_json if (append_event_str_from_json(&str, json, ast_security_event_get_required_ies(event_type))) { - ast_log(LOG_ERROR, "Failed to issue a security event to AMI.\n"); + ast_log(AST_LOG_ERROR, "Failed to issue a security event to AMI: " + "error occurred when adding required event fields.\n"); + return NULL; + } + + if (append_event_str_from_json(&str, json, + ast_security_event_get_optional_ies(event_type))) { + ast_log(AST_LOG_ERROR, "Failed to issue a security event to AMI: " + "error occurred when adding optional event fields.\n"); return NULL; } -- cgit v1.2.3