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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Jun 7 10:50:55 CDT 2009


Author: russell
Date: Sun Jun  7 10:50:52 2009
New Revision: 199513

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=199513
Log:
Add support and test code for successful auth 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=199513&r1=199512&r2=199513
==============================================================================
--- team/group/security_events/include/asterisk/security_events_defs.h (original)
+++ team/group/security_events/include/asterisk/security_events_defs.h Sun Jun  7 10:50:52 2009
@@ -95,6 +95,10 @@
 	 * \brief Request received with bad formatting
 	 */
 	AST_SECURITY_EVENT_REQ_BAD_FORMAT,
+	/*!
+	 * \brief FYI FWIW, Successful authentication has occurred
+	 */
+	AST_SECURITY_EVENT_SUCCESSFUL_AUTH,
 	/* \brief This _must_ stay at the end. */
 	AST_SECURITY_EVENT_NUM_TYPES
 };
@@ -575,6 +579,49 @@
 	const char *request_params;
 };
 
+/*!
+ * \brief Successful authentication
+ */
+struct ast_security_event_successful_auth {
+	/*!
+	 * \brief Event descriptor version
+	 * \note This _must_ be changed if this event descriptor is changed.
+	 */
+	#define AST_SECURITY_EVENT_SUCCESSFUL_AUTH_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 required
+	 */
+	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;
+};
+
 #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=199513&r1=199512&r2=199513
==============================================================================
--- team/group/security_events/main/security_events.c (original)
+++ team/group/security_events/main/security_events.c Sun Jun  7 10:50:52 2009
@@ -252,6 +252,28 @@
 	},
 },
 
+[AST_SECURITY_EVENT_SUCCESSFUL_AUTH] = {
+	.name     = "SuccessfulAuth",
+	.version  = AST_SECURITY_EVENT_SUCCESSFUL_AUTH_VERSION,
+	.severity = AST_SECURITY_EVENT_SEVERITY_INFO,
+	.required_ies = {
+		{ AST_EVENT_IE_EVENT_TV, 0 },
+		{ AST_EVENT_IE_SEVERITY, 0 },
+		{ AST_EVENT_IE_SERVICE, SEC_EVT_FIELD(common, service) },
+		{ AST_EVENT_IE_EVENT_VERSION, SEC_EVT_FIELD(common, version) },
+		{ AST_EVENT_IE_ACCOUNT_ID, SEC_EVT_FIELD(inval_acct_id, account_id) },
+		{ AST_EVENT_IE_SESSION_ID, SEC_EVT_FIELD(inval_acct_id, session_id) },
+		{ AST_EVENT_IE_LOCAL_ADDR, SEC_EVT_FIELD(inval_acct_id, local_addr) },
+		{ AST_EVENT_IE_REMOTE_ADDR, SEC_EVT_FIELD(inval_acct_id, remote_addr) },
+		{ AST_EVENT_IE_END, 0 }
+	},
+	.optional_ies = {
+		{ AST_EVENT_IE_MODULE, SEC_EVT_FIELD(inval_acct_id, module) },
+		{ AST_EVENT_IE_SESSION_TV, SEC_EVT_FIELD(inval_acct_id, session_tv) },
+		{ AST_EVENT_IE_END, 0 }
+	},
+},
+
 #undef SEC_EVT_FIELD
 
 };

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=199513&r1=199512&r2=199513
==============================================================================
--- team/group/security_events/security_events.txt (original)
+++ team/group/security_events/security_events.txt Sun Jun  7 10:50:52 2009
@@ -134,7 +134,7 @@
 Successful Auth
   -> informational event
   -> everything from inval account ID
-  DevNotes:
+  DevNotes: defined, has test code
 
 Invalid formatting of Request
   -> everything from inval account ID

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=199513&r1=199512&r2=199513
==============================================================================
--- team/group/security_events/tests/test_security_events.c (original)
+++ team/group/security_events/tests/test_security_events.c Sun Jun  7 10:50:52 2009
@@ -45,6 +45,7 @@
 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);
+static void evt_gen_successful_auth(void);
 
 typedef void (*evt_generator)(void);
 static const evt_generator evt_generators[AST_SECURITY_EVENT_NUM_TYPES] = {
@@ -57,6 +58,7 @@
 	[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,
+	[AST_SECURITY_EVENT_SUCCESSFUL_AUTH]         = evt_gen_successful_auth,
 };
 
 static void evt_gen_failed_acl(void)
@@ -398,6 +400,43 @@
 	sin_remote.sin_port = htons(2121);
 
 	ast_security_event_report(AST_SEC_EVT(&req_bad_format));
+}
+
+static void evt_gen_successful_auth(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_successful_auth successful_auth = {
+		.common.event_type = AST_SECURITY_EVENT_SUCCESSFUL_AUTH,
+		.common.version    = AST_SECURITY_EVENT_SUCCESSFUL_AUTH_VERSION,
+		.common.service    = "TEST",
+
+		.module     = AST_MODULE,
+		.account_id = "ValidUser",
+		.session_id = "Session456",
+		.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,
+		},
+	};
+
+	inet_aton("10.1.2.3", &sin_local.sin_addr);
+	sin_local.sin_port = htons(4321);
+
+	inet_aton("10.1.2.4", &sin_remote.sin_addr);
+	sin_remote.sin_port = htons(1234);
+
+	ast_security_event_report(AST_SEC_EVT(&successful_auth));
 }
 
 static void gen_events(struct ast_cli_args *a)




More information about the asterisk-commits mailing list