[asterisk-commits] russell: branch group/security_events r199366 - in /team/group/security_event...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Jun 6 12:16:46 CDT 2009


Author: russell
Date: Sat Jun  6 12:16:40 2009
New Revision: 199366

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=199366
Log:
Add support and test code for "request bad format" security event

Modified:
    team/group/security_events/include/asterisk/security_events_defs.h
    team/group/security_events/main/security_events.c
    team/group/security_events/security_events.txt
    team/group/security_events/tests/test_security_events.c

Modified: team/group/security_events/include/asterisk/security_events_defs.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/security_events/include/asterisk/security_events_defs.h?view=diff&rev=199366&r1=199365&r2=199366
==============================================================================
--- team/group/security_events/include/asterisk/security_events_defs.h (original)
+++ team/group/security_events/include/asterisk/security_events_defs.h Sat Jun  6 12:16:40 2009
@@ -91,6 +91,10 @@
 	 * \brief The attempted authentication method is not allowed
 	 */
 	AST_SECURITY_EVENT_AUTH_METHOD_NOT_ALLOWED,
+	/*!
+	 * \brief Request received with bad formatting
+	 */
+	AST_SECURITY_EVENT_REQ_BAD_FORMAT,
 	/* \brief This _must_ stay at the end. */
 	AST_SECURITY_EVENT_NUM_TYPES
 };
@@ -503,6 +507,59 @@
 	const char *auth_method;
 };
 
+/*!
+ * \brief Invalid formatting of request
+ */
+struct ast_security_event_req_bad_format {
+	/*!
+	 * \brief Event descriptor version
+	 * \note This _must_ be changed if this event descriptor is changed.
+	 */
+	#define AST_SECURITY_EVENT_REQ_BAD_FORMAT_VERSION 1
+	/*! \brief Common security event descriptor elements */
+	struct ast_security_event_common common;
+	/*!
+	 * \brief Module, Normally the AST_MODULE define
+	 * \note optional
+	 */
+	const char *module;
+	/*!
+	 * \brief Account ID, specific to the service type
+	 * \note optional
+	 */
+	const char *account_id;
+	/*!
+	 * \brief Session ID, specific to the service type
+	 * \note required
+	 */
+	const char *session_id;
+	/*!
+	 * \brief Session timeval, when the session started
+	 * \note optional
+	 */
+	const struct timeval *session_tv;
+	/*!
+	 * \brief Local address the request came in on
+	 * \note required
+	 */
+	struct ast_security_event_ipv4_addr local_addr;
+	/*!
+	 * \brief Remote address the request came from
+	 * \note required
+	 */
+	struct ast_security_event_ipv4_addr remote_addr;
+	/*!
+	 * \brief Request type that was made
+	 * \note required
+	 */
+	const char *request_type;
+	/*!
+	 * \brief Request type that was made
+	 * \note optional
+	 */
+	const char *request_params;
+};
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif

Modified: team/group/security_events/main/security_events.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/security_events/main/security_events.c?view=diff&rev=199366&r1=199365&r2=199366
==============================================================================
--- team/group/security_events/main/security_events.c (original)
+++ team/group/security_events/main/security_events.c Sat Jun  6 12:16:40 2009
@@ -207,6 +207,28 @@
 	.optional_ies = {
 		{ AST_EVENT_IE_MODULE, SEC_EVT_FIELD(auth_method_not_allowed, module) },
 		{ AST_EVENT_IE_SESSION_TV, SEC_EVT_FIELD(auth_method_not_allowed, session_tv) },
+		{ AST_EVENT_IE_END, 0 }
+	},
+},
+
+[AST_SECURITY_EVENT_REQ_BAD_FORMAT] = {
+	.name    = "RequestBadFormat",
+	.version = AST_SECURITY_EVENT_REQ_BAD_FORMAT_VERSION,
+	.required_ies = {
+		{ AST_EVENT_IE_EVENT_TV, 0 },
+		{ AST_EVENT_IE_SERVICE, SEC_EVT_FIELD(common, service) },
+		{ AST_EVENT_IE_EVENT_VERSION, SEC_EVT_FIELD(common, version) },
+		{ AST_EVENT_IE_SESSION_ID, SEC_EVT_FIELD(req_bad_format, session_id) },
+		{ AST_EVENT_IE_LOCAL_ADDR, SEC_EVT_FIELD(req_bad_format, local_addr) },
+		{ AST_EVENT_IE_REMOTE_ADDR, SEC_EVT_FIELD(req_bad_format, remote_addr) },
+		{ AST_EVENT_IE_REQUEST_TYPE, SEC_EVT_FIELD(req_bad_format, request_type) },
+		{ AST_EVENT_IE_END, 0 }
+	},
+	.optional_ies = {
+		{ AST_EVENT_IE_MODULE, SEC_EVT_FIELD(req_bad_format, module) },
+		{ AST_EVENT_IE_SESSION_TV, SEC_EVT_FIELD(req_bad_format, session_tv) },
+		{ AST_EVENT_IE_ACCOUNT_ID, SEC_EVT_FIELD(req_bad_format, account_id) },
+		{ AST_EVENT_IE_REQUEST_PARAMS, SEC_EVT_FIELD(req_bad_format, request_params) },
 		{ AST_EVENT_IE_END, 0 }
 	},
 },

Modified: team/group/security_events/security_events.txt
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/security_events/security_events.txt?view=diff&rev=199366&r1=199365&r2=199366
==============================================================================
--- team/group/security_events/security_events.txt (original)
+++ team/group/security_events/security_events.txt Sat Jun  6 12:16:40 2009
@@ -139,7 +139,8 @@
 Invalid formatting of Request
  -> everything from inval account ID
  -> account ID optional
- (+) reason (free form text for why it failed) (defined list of reasons?)
+ (-) Request Type
+ (+) Request parameters
  DevNotes:
 
 Call Limit Reached
@@ -206,7 +207,8 @@
 IE: SecurityEvent
 Content: This is the security event sub-type.
 Values: FailedACL, InvalidAccountID, CallLimit, MemoryLimit, LoadAverageLimit,
-        RequestNotSupported, RequestNotAllowed, AuthMethodNotAllowed
+        RequestNotSupported, RequestNotAllowed, AuthMethodNotAllowed,
+        ReqBadFormat
 
 IE: EventVersion
 Content: This is a numeric value that indicates when updates are made to the

Modified: team/group/security_events/tests/test_security_events.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/security_events/tests/test_security_events.c?view=diff&rev=199366&r1=199365&r2=199366
==============================================================================
--- team/group/security_events/tests/test_security_events.c (original)
+++ team/group/security_events/tests/test_security_events.c Sat Jun  6 12:16:40 2009
@@ -44,9 +44,10 @@
 static void evt_gen_req_no_support(void);
 static void evt_gen_req_not_allowed(void);
 static void evt_gen_auth_method_not_allowed(void);
+static void evt_gen_req_bad_format(void);
 
 typedef void (*evt_generator)(void);
-evt_generator evt_generators[AST_SECURITY_EVENT_NUM_TYPES] = {
+static const evt_generator evt_generators[AST_SECURITY_EVENT_NUM_TYPES] = {
 	[AST_SECURITY_EVENT_FAILED_ACL]              = evt_gen_failed_acl,
 	[AST_SECURITY_EVENT_INVAL_ACCT_ID]           = evt_gen_inval_acct_id,
 	[AST_SECURITY_EVENT_CALL_LIMIT]              = evt_gen_call_limit,
@@ -55,6 +56,7 @@
 	[AST_SECURITY_EVENT_REQ_NO_SUPPORT]          = evt_gen_req_no_support,
 	[AST_SECURITY_EVENT_REQ_NOT_ALLOWED]         = evt_gen_req_not_allowed,
 	[AST_SECURITY_EVENT_AUTH_METHOD_NOT_ALLOWED] = evt_gen_auth_method_not_allowed,
+	[AST_SECURITY_EVENT_REQ_BAD_FORMAT]          = evt_gen_req_bad_format,
 };
 
 static void evt_gen_failed_acl(void)
@@ -357,6 +359,45 @@
 	sin_remote.sin_port = htons(8745);
 
 	ast_security_event_report(AST_SEC_EVT(&auth_method_not_allowed));
+}
+
+static void evt_gen_req_bad_format(void)
+{
+	struct sockaddr_in sin_local = {
+		.sin_family = AF_INET
+	};
+	struct sockaddr_in sin_remote = {
+		.sin_family = AF_INET
+	};
+	struct timeval session_tv = ast_tvnow();
+	struct ast_security_event_req_bad_format req_bad_format = {
+		.common.event_type = AST_SECURITY_EVENT_REQ_BAD_FORMAT,
+		.common.version    = AST_SECURITY_EVENT_REQ_BAD_FORMAT_VERSION,
+		.common.service    = "TEST",
+
+		.module     = AST_MODULE,
+		.account_id = "Larry",
+		.session_id = "838383fhfhf83hf8h3f8h",
+		.session_tv = &session_tv,
+		.local_addr = {
+			.sin  = &sin_local,
+			.transport  = AST_SECURITY_EVENT_TRANSPORT_TCP,
+		},
+		.remote_addr = {
+			.sin = &sin_remote,
+			.transport  = AST_SECURITY_EVENT_TRANSPORT_TCP,
+		},
+		.request_type = "CheeseBurger",
+		.request_params = "Onions,Swiss,MotorOil",
+	};
+
+	inet_aton("10.110.220.230", &sin_local.sin_addr);
+	sin_local.sin_port = htons(1212);
+
+	inet_aton("10.120.210.200", &sin_remote.sin_addr);
+	sin_remote.sin_port = htons(2121);
+
+	ast_security_event_report(AST_SEC_EVT(&req_bad_format));
 }
 
 static void gen_events(struct ast_cli_args *a)




More information about the asterisk-commits mailing list