]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
added hi event squelch
authorRuss Combs <rucombs@cisco.com>
Thu, 6 Nov 2014 02:37:38 +0000 (21:37 -0500)
committerRuss Combs <rucombs@cisco.com>
Thu, 6 Nov 2014 02:37:38 +0000 (21:37 -0500)
12 files changed:
ChangeLog
src/service_inspectors/http_inspect/CMakeLists.txt
src/service_inspectors/http_inspect/Makefile.am
src/service_inspectors/http_inspect/hi_ad.cc
src/service_inspectors/http_inspect/hi_client.cc
src/service_inspectors/http_inspect/hi_events.cc [new file with mode: 0644]
src/service_inspectors/http_inspect/hi_events.h
src/service_inspectors/http_inspect/hi_norm.cc
src/service_inspectors/http_inspect/hi_paf.cc
src/service_inspectors/http_inspect/hi_server.cc
src/service_inspectors/http_inspect/hi_server_norm.cc
src/service_inspectors/http_inspect/http_inspect.cc

index a3450cae3a57cad25c79f16da2ac97cca9e4418f..3d040d151ae2a2274b5402cccef0113bc569215b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -31,6 +31,7 @@
 -- latest from Josh
 -- initial /* comments */ for text rules (needs to ignore \")
 -- latest from Josh
+-- added hi event squelch
 
 126
 -- pulled latest from tom
index afdf206650496567bbdba88ffdb1ce9b764209d4..fd9027fbf72b728cba1c05b12024d0f050b9bac2 100644 (file)
@@ -20,6 +20,7 @@ set (FILE_LIST
     hi_norm.h
     hi_paf.cc 
     hi_paf.h
+    hi_events.cc
     hi_events.h
     hi_module.cc
     hi_module.h
index c0f9ed2f6f200a2fc37c6dac7c2888bce74637ef..e037f072a12ed580d860896e76774332541df2ed 100644 (file)
@@ -8,7 +8,7 @@ hi_client.cc hi_client.h \
 hi_client_norm.cc hi_client_norm.h \
 hi_client_stateful.h \
 hi_cmd_lookup.cc hi_cmd_lookup.h \
-hi_events.h \
+hi_events.cc hi_events.h \
 hi_include.h \
 hi_mi.cc hi_mi.h \
 hi_module.cc hi_module.h \
index 0acc5916f1f1e059b857ffbfed67443e975d37fd..b87bc333c5768df7440fe979b2998071cbb2cb30 100644 (file)
@@ -79,7 +79,7 @@ int hi_server_anomaly_detection(void *S, const u_char *data, int dsize)
         if(data[0]=='H' && data[1]=='T' && data[2]=='T' && data[3]=='P' &&
            data[4]=='/')
         {
-            SnortEventqAdd(GID_HTTP_SERVER, HI_ANOM_SERVER);
+            hi_set_event(GID_HTTP_SERVER, HI_ANOM_SERVER);
         }
     }
 
index 9cf7b83fb9a1cae897b10607ca68ad1e55b85f09..64c2c21e117e31bd8cef5d88dabb12a402a7cb48 100644 (file)
@@ -193,7 +193,7 @@ int CheckChunkEncoding(HI_SESSION *session, const u_char *start, const u_char *e
                      && (iInspectMode == HI_SI_CLIENT_MODE)
                      && (session->server_conf->chunk_length < iChunkLen) )
                 {
-                    SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_LARGE_CHUNK);
+                    hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_LARGE_CHUNK);
                 }
 
                 if (session->server_conf->small_chunk_length.size != 0)
@@ -227,7 +227,7 @@ int CheckChunkEncoding(HI_SESSION *session, const u_char *start, const u_char *e
                         {
                             if ( !alerted )
                             {
-                                SnortEventqAdd(gid, sid);
+                                hi_set_event(gid, sid);
                                 alerted = true;
                             }
                             *chunk_count = 0;
@@ -302,7 +302,7 @@ int CheckChunkEncoding(HI_SESSION *session, const u_char *start, const u_char *e
                             (*ptr != '\n') && (*ptr != '\r')
                             && ((ptr + 1) < end) && (*(ptr + 1) != '\n') )
                     {
-                        SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_CHUNK_SIZE_MISMATCH);
+                        hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_CHUNK_SIZE_MISMATCH);
                     }
                 }
                 else
@@ -373,7 +373,7 @@ int CheckChunkEncoding(HI_SESSION *session, const u_char *start, const u_char *e
                          && (iInspectMode == HI_SI_CLIENT_MODE)
                          && (session->server_conf->chunk_length < iChunkLen) )
                     {
-                        SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_LARGE_CHUNK);
+                        hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_LARGE_CHUNK);
                     }
 
                     iCheckChunk = 0;
@@ -465,7 +465,7 @@ static inline const u_char *FindPipelineReq(HI_SESSION *session,
             if ( session->server_conf->max_hdr_len &&
                 (p - offset) >= session->server_conf->max_hdr_len )
             {
-                SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_LONG_HDR);
+                hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_LONG_HDR);
             }
 
             p++;
@@ -497,7 +497,7 @@ static inline const u_char *FindPipelineReq(HI_SESSION *session,
     if ( session->server_conf->max_hdr_len &&
         (p - start) >= session->server_conf->max_hdr_len )
     {
-        SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_LONG_HDR);
+        hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_LONG_HDR);
     }
 
     return NULL;
@@ -662,7 +662,7 @@ int NextNonWhiteSpace(HI_SESSION *session, const u_char *start,
         {
             if(ServerConf->apache_whitespace.on)
             {
-                SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_APACHE_WS);
+                hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_APACHE_WS);
             }
             (*ptr)++;
             continue;
@@ -963,7 +963,7 @@ int find_non_rfc_delimiter(
     */
     if(ServerConf->iis_delimiter.on)
     {
-        SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_IIS_DELIMITER);
+        hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_IIS_DELIMITER);
 
         uri_ptr->delimiter = *ptr;
 
@@ -1057,7 +1057,7 @@ static inline int CheckLongDir(HI_SESSION *session, URI_PTR *uri_ptr,
 
         if ( iDirLen > session->server_conf->long_dir )
         {
-            SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_OVERSIZE_DIR);
+            hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_OVERSIZE_DIR);
         }
     }
 
@@ -1801,7 +1801,7 @@ const u_char *extract_http_xff(HI_SESSION *session, const u_char *p, const u_cha
 
     if( (hdrs_args->true_clnt_xff & HDRS_BOTH) == HDRS_BOTH)
     {
-        SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_BOTH_TRUEIP_XFF_HDRS);
+        hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_BOTH_TRUEIP_XFF_HDRS);
     }
 
     SkipBlankSpace(start,end,&p);
@@ -1821,7 +1821,7 @@ const u_char *extract_http_xff(HI_SESSION *session, const u_char *p, const u_cha
         if ( session->server_conf->max_spaces &&
             num_spaces >= session->server_conf->max_spaces )
         {
-            SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_EXCEEDS_SPACES);
+            hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_EXCEEDS_SPACES);
         }
 
         p = p + unfold_size;
@@ -1861,14 +1861,14 @@ const u_char *extract_http_xff(HI_SESSION *session, const u_char *p, const u_cha
                     {
                         if((status != SFIP_ARG_ERR) && (status !=SFIP_ALLOC_ERR))
                         {
-                            SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_INVALID_TRUEIP);
+                            hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_INVALID_TRUEIP);
                             return p;
                         }
                     }
                 }
                 else if((status != SFIP_ARG_ERR) && (status !=SFIP_ALLOC_ERR))
                 {
-                    SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_INVALID_TRUEIP);
+                    hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_INVALID_TRUEIP);
                     free(ipAddr);
                     return p;
                 }
@@ -1880,7 +1880,7 @@ const u_char *extract_http_xff(HI_SESSION *session, const u_char *p, const u_cha
                     sfip_free(*true_ip);
                     *true_ip = tmp;
 
-                    SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_MULTIPLE_TRUEIP_IN_SESSION);
+                    hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_MULTIPLE_TRUEIP_IN_SESSION);
                 }
                 else
                     sfip_free(tmp);
@@ -1930,7 +1930,7 @@ const u_char *extract_http_hostname(HI_SESSION *session, const u_char *p, const
         if ( session->server_conf->max_spaces &&
             num_spaces >= session->server_conf->max_spaces )
         {
-            SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_EXCEEDS_SPACES);
+            hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_EXCEEDS_SPACES);
         }
         p = p + unfold_size;
 
@@ -1943,7 +1943,7 @@ const u_char *extract_http_hostname(HI_SESSION *session, const u_char *p, const
 
         if((end_ptr - start_ptr) >= MAX_HOSTNAME)
         {
-            SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_LONG_HOSTNAME);
+            hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_LONG_HOSTNAME);
         }
 
         iRet = HTTP_CopyExtraDataTosession((uint8_t *)start_ptr, (end_ptr - start_ptr), COPY_HOSTNAME, hsd->log_state);
@@ -1971,7 +1971,7 @@ const u_char *extract_http_content_length(HI_SESSION *session,
     int space_present = 0;
     if (header_ptr->content_len.cont_len_start)
     {
-        SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_MULTIPLE_CONTLEN);
+        hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_MULTIPLE_CONTLEN);
         header_ptr->header.uri_end = p;
         header_ptr->content_len.len = 0;
         return p;
@@ -2017,7 +2017,7 @@ const u_char *extract_http_content_length(HI_SESSION *session,
                                 if ( session->server_conf->max_spaces &&
                                     num_spaces >= session->server_conf->max_spaces )
                                 {
-                                    SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_EXCEEDS_SPACES);
+                                    hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_EXCEEDS_SPACES);
                                 }
                                 if ( isdigit((int)*p))
                                     break;
@@ -2225,7 +2225,7 @@ static inline const u_char *extractHeaderFieldValues(HI_SESSION *session,
             /* Alert when there are multiple host headers in one request */
             if(hdrs_args->hst_name_hdr)
             {
-                SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_MULTIPLE_HOST_HDRS);
+                hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_MULTIPLE_HOST_HDRS);
                 return p;
             }
             else
@@ -2360,7 +2360,7 @@ static inline const u_char *hi_client_extract_header(
                         if ( session->server_conf->max_spaces &&
                             num_spaces >= session->server_conf->max_spaces )
                         {
-                            SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_EXCEEDS_SPACES);
+                            hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_EXCEEDS_SPACES);
                         }
                     }
                     break;
@@ -2383,7 +2383,7 @@ static inline const u_char *hi_client_extract_header(
     }
     else
     {
-        SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_UNESCAPED_SPACE_URI);
+        hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_UNESCAPED_SPACE_URI);
         if(p < end)
         {
             crlf = (u_char *)SnortStrnStr((const char *)p, end - p, "\n");
@@ -2413,13 +2413,13 @@ static inline const u_char *hi_client_extract_header(
             if ( session->server_conf->max_hdr_len &&
                 (p - offset) >= session->server_conf->max_hdr_len )
             {
-                SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_LONG_HDR);
+                hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_LONG_HDR);
             }
 
             if (session->server_conf->max_headers &&
                 (header_count > session->server_conf->max_headers))
             {
-                SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_MAX_HEADERS);
+                hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_MAX_HEADERS);
             }
 
             p++;
@@ -2429,7 +2429,7 @@ static inline const u_char *hi_client_extract_header(
             if ( session->server_conf->max_spaces &&
                 num_spaces >= session->server_conf->max_spaces )
             {
-                SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_EXCEEDS_SPACES);
+                hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_EXCEEDS_SPACES);
             }
 
             offset = (u_char*)p;
@@ -2489,7 +2489,7 @@ static inline const u_char *hi_client_extract_header(
     if ( session->server_conf->max_hdr_len &&
         (p - start) >= session->server_conf->max_hdr_len )
     {
-        SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_LONG_HDR);
+        hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_LONG_HDR);
     }
 
     header_ptr->header.uri_end = p;
@@ -2699,7 +2699,7 @@ int StatelessInspection(Packet *p, HI_SESSION *session, HttpsessionData *hsd, in
 
         if(iRet == -1 || (CmdConf == NULL))
         {
-            SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_UNKNOWN_METHOD);
+            hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_UNKNOWN_METHOD);
             Client->request.method = HI_UNKNOWN_METHOD;
         }
     }
@@ -2711,7 +2711,7 @@ int StatelessInspection(Packet *p, HI_SESSION *session, HttpsessionData *hsd, in
              * so we know we're looking for a method and not guessing that we're in
              * the body or somewhere else because we found a non-ascii character */
             if ( !stream_ins )
-                SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_UNKNOWN_METHOD);
+                hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_UNKNOWN_METHOD);
             Client->request.method = HI_UNKNOWN_METHOD;
         }
     }
@@ -2733,7 +2733,7 @@ int StatelessInspection(Packet *p, HI_SESSION *session, HttpsessionData *hsd, in
     if ( iRet == URI_END && ServerConf->max_hdr_len &&
          ((uri_ptr.uri_end - uri_ptr.uri) >= ServerConf->max_hdr_len) )
     {
-        SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_LONG_HDR);
+        hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_LONG_HDR);
     }
 
     if(iRet == URI_END &&
@@ -2906,7 +2906,7 @@ int StatelessInspection(Packet *p, HI_SESSION *session, HttpsessionData *hsd, in
     if(uri_ptr.proxy && session->global_conf->proxy_alert &&
        (!ServerConf->allow_proxy && !ClientConf->allow_proxy))
     {
-        SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_PROXY_USE);
+        hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_PROXY_USE);
     }
 
     return HI_SUCCESS;
diff --git a/src/service_inspectors/http_inspect/hi_events.cc b/src/service_inspectors/http_inspect/hi_events.cc
new file mode 100644 (file)
index 0000000..625d2a5
--- /dev/null
@@ -0,0 +1,81 @@
+/****************************************************************************
+ *
+ * Copyright (C) 2014 Cisco and/or its affiliates. All rights reserved.
+ * Copyright (C) 2003-2013 Sourcefire, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License Version 2 as
+ * published by the Free Software Foundation.  You may not use, modify or
+ * distribute this program under any other version of the GNU General
+ * Public License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ ****************************************************************************/
+// hi_events.cc author Russ Combs <rucombs@cisco.com>
+
+#include "hi_events.h"
+
+#include <assert.h>
+#include <strings.h>
+
+#include "events/event_queue.h"
+
+static THREAD_LOCAL uint64_t gid_client = 0;
+static THREAD_LOCAL uint64_t gid_server = 0;
+
+static inline void set(uint64_t& mask, unsigned sid)
+{
+    assert(sid && sid < 64);
+    mask |= (1 << (sid-1));
+}
+
+static void queue(unsigned gid, uint64_t mask)
+{
+    int sid;
+
+    while ( (sid = ffs(mask)) )
+    {
+        SnortEventqAdd(gid, sid);
+        mask ^= (1 << (sid-1));
+    }
+}
+
+void hi_set_event(unsigned gid, unsigned sid)
+{
+    switch ( gid )
+    {
+    case GID_HTTP_CLIENT:
+        set(gid_client, sid);
+        break;
+
+    case GID_HTTP_SERVER:
+        set(gid_server, sid);
+        break;
+
+    default:
+        assert(false);
+    }
+}
+
+void hi_clear_events()
+{
+    gid_client = gid_server = 0;
+}
+
+void hi_queue_events()
+{
+    if ( gid_client )
+        queue(GID_HTTP_CLIENT, gid_client);
+
+    if ( gid_server )
+        queue(GID_HTTP_SERVER, gid_server);
+}
+
index f8e05bf61c2653fb895fba2248640a103c255395..b1a81ad7e2297ec090b71f78e550a09661842f67 100644 (file)
@@ -187,5 +187,9 @@ typedef enum _HI_EVENTS
 #define HI_SERVER_MIXED_ENCODINGS_STR                \
     "multiple encodings within javascript obfuscated data"
 
+void hi_set_event(unsigned gid, unsigned sid);
+void hi_clear_events();
+void hi_queue_events();
+
 #endif
 
index 12c56623da9a4fd324338bab89e53a276eeab30c..671552c80e647d13f3adc13729a2c98ae15eafb2 100644 (file)
@@ -229,7 +229,7 @@ static int UDecode(HI_SESSION *session, const u_char *start,
 
             if ( !norm_state->param )
             {
-                SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_IIS_UNICODE);
+                hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_IIS_UNICODE);
             }
             *encodeType |= HTTP_ENCODE_TYPE__IIS_UNICODE;
         }
@@ -246,7 +246,7 @@ static int UDecode(HI_SESSION *session, const u_char *start,
     */
     if( !norm_state->param )
     {
-        SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_U_ENCODE);
+        hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_U_ENCODE);
     }
 
     byte_decoded = true;
@@ -387,7 +387,7 @@ static int PercentDecode(HI_SESSION *session, const u_char *start,
 
     if( !norm_state->param )
     {
-        SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_ASCII);
+        hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_ASCII);
     }
 
     return iNorm;
@@ -456,7 +456,7 @@ static int GetChar(HI_SESSION *session, const u_char *start,
             *encodeType |= HTTP_ENCODE_TYPE__BARE_BYTE;
             if ( !norm_state->param )
             {
-                SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_BARE_BYTE);
+                hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_BARE_BYTE);
             }
 
             /*
@@ -592,7 +592,7 @@ static int UTF8Decode(HI_SESSION *session, const u_char *start,
 
             if ( !norm_state->param )
             {
-                SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_IIS_UNICODE);
+                hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_IIS_UNICODE);
             }
             *encodeType |= HTTP_ENCODE_TYPE__IIS_UNICODE;
 
@@ -611,7 +611,7 @@ static int UTF8Decode(HI_SESSION *session, const u_char *start,
 
     if ( !norm_state->param )
     {
-        SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_UTF_8);
+        hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_UTF_8);
     }
 
     return iNorm;
@@ -795,7 +795,7 @@ static int DoubleDecode(HI_SESSION *session, const u_char *start,
 
     if( !norm_state->param )
     {
-        SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_DOUBLE_DECODE);
+        hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_DOUBLE_DECODE);
     }
     byte_decoded = true;
 
@@ -857,7 +857,7 @@ static int GetDecodedByte(HI_SESSION *session, const u_char *start,
     {
         if ( !norm_state->param )
         {
-            SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_IIS_BACKSLASH);
+            hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_IIS_BACKSLASH);
         }
 
         iChar = 0x2f;
@@ -923,7 +923,7 @@ static int DirTrav(
         */
         if ( !norm_state->param )
         {
-            SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_WEBROOT_DIR);
+            hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_WEBROOT_DIR);
         }
     }
 
@@ -1048,7 +1048,7 @@ static int DirNorm(HI_SESSION *session, const u_char *start, const u_char *end,
                 hi_stats.slashes++;
                 if ( !norm_state->param )
                 {
-                    SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_MULTI_SLASH);
+                    hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_MULTI_SLASH);
                 }
 
                 continue;
@@ -1086,7 +1086,7 @@ static int DirNorm(HI_SESSION *session, const u_char *start, const u_char *end,
                                 */
                                 if ( !norm_state->param )
                                 {
-                                    SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_DIR_TRAV);
+                                    hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_DIR_TRAV);
                                 }
 
                                 *ptr = dir_ptr;
@@ -1107,7 +1107,7 @@ static int DirNorm(HI_SESSION *session, const u_char *start, const u_char *end,
                         */
                         if ( !norm_state->param )
                         {
-                            SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_SELF_DIR_TRAV);
+                            hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_SELF_DIR_TRAV);
                         }
 
                         continue;
@@ -1167,7 +1167,7 @@ static int CheckLongDir(HI_SESSION *session, URI_NORM_STATE *norm_state,
         if(iDirLen > session->server_conf->long_dir &&
            !norm_state->param)
         {
-            SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_OVERSIZE_DIR);
+            hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_OVERSIZE_DIR);
         }
     }
 
@@ -1322,7 +1322,7 @@ static inline int InspectUriChar(HI_SESSION *session, int iChar,
             {
                 if(!norm_state->param)
                 {
-                    SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_NON_RFC_CHAR);
+                    hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_NON_RFC_CHAR);
                 }
             }
 
@@ -1432,7 +1432,7 @@ int hi_norm_uri(HI_SESSION *session, u_char *uribuf, int *uribuf_size,
         {
             if(!norm_state.param)
             {
-                SnortEventqAdd(GID_HTTP_CLIENT, HI_CLIENT_NON_RFC_CHAR);
+                hi_set_event(GID_HTTP_CLIENT, HI_CLIENT_NON_RFC_CHAR);
             }
         }
 
index 30910420cdbf1aad4d2730b92274f9a9bf08d87b..95a90fba3fcbd35fbf8199e16699ac3595ed8e3a 100644 (file)
@@ -607,28 +607,28 @@ static inline int xton (int c)
 
 static inline void hi_paf_event_post ()
 {
-    SnortEventqAdd(
+    hi_set_event(
         GID_HTTP_CLIENT,
         HI_CLIENT_UNBOUNDED_POST);
 }
 
 static inline void hi_paf_event_simple ()
 {
-    SnortEventqAdd(
+    hi_set_event(
         GID_HTTP_CLIENT,
         HI_CLIENT_SIMPLE_REQUEST);
 }
 
 static inline void hi_paf_event_msg_size ()
 {
-    SnortEventqAdd(
+    hi_set_event(
         GID_HTTP_SERVER,
         HI_CLISRV_MSG_SIZE_EXCEPTION);
 }
 
 static inline void hi_paf_event_pipe ()
 {
-    SnortEventqAdd(
+    hi_set_event(
         GID_HTTP_CLIENT,
         HI_CLIENT_PIPELINE_MAX);
 }
index 3b69287e627eae0416e18013298d6a94d1dcef9f..85547068d5d012bc9ed92b1fdc8ebe8625844b71 100644 (file)
@@ -321,7 +321,7 @@ static inline int hi_server_extract_status_code(
         else
         {
 
-            SnortEventqAdd(GID_HTTP_SERVER, HI_SERVER_INVALID_STATCODE);
+            hi_set_event(GID_HTTP_SERVER, HI_SERVER_INVALID_STATCODE);
             ptr++;
         }
     }
@@ -379,7 +379,7 @@ static inline const u_char *extract_http_content_type_charset(
     else if ((cmplen > 0) && (*ptr == '7'))
     {
         set_decode_utf_state_charset(&(hsd->utf_state), CHARSET_UTF7);
-        SnortEventqAdd(GID_HTTP_SERVER, HI_SERVER_UTF7);
+        hi_set_event(GID_HTTP_SERVER, HI_SERVER_UTF7);
     }
     else if (cmplen >= 4)
     {
@@ -790,7 +790,7 @@ static inline int hi_server_extract_body(
                 if(!(sd->resp_state.last_pkt_chunked) && !simple_response)
                 {
                     if ( headers )
-                        SnortEventqAdd(GID_HTTP_SERVER, HI_SERVER_NO_CONTLEN);
+                        hi_set_event(GID_HTTP_SERVER, HI_SERVER_NO_CONTLEN);
                 }
                 else
                     sd->resp_state.last_pkt_chunked = 0;
@@ -1012,7 +1012,7 @@ static inline int hi_server_decompress(HI_SESSION *session, HttpsessionData *sd,
         else
         {
             /* No Content-Length or Transfer-Encoding : chunked */
-            SnortEventqAdd(GID_HTTP_SERVER, HI_SERVER_NO_CONTLEN);
+            hi_set_event(GID_HTTP_SERVER, HI_SERVER_NO_CONTLEN);
 
             zRet = uncompress_gzip(decompression_buffer, decompr_avail, ptr, compr_avail,
                     sd, &total_bytes_read, sd->decomp_state->compress_fmt);
@@ -1062,7 +1062,7 @@ static inline int hi_server_decompress(HI_SESSION *session, HttpsessionData *sd,
     {
         if(sd->decomp_state->decompr_bytes_read)
         {
-            SnortEventqAdd(GID_HTTP_SERVER, HI_SERVER_DECOMPR_FAILED);
+            hi_set_event(GID_HTTP_SERVER, HI_SERVER_DECOMPR_FAILED);
         }
     }
 
index 4714aa4505f9e5b56223fe61f8de31dfd74fd4c4..4ba26daf1779bcac0e2b73d7407a733101744ebe 100644 (file)
@@ -246,7 +246,7 @@ int hi_server_norm(HI_SESSION *session, HttpsessionData *hsd)
 
                     if (result == DECODE_UTF_FAILURE)
                     {
-                        SnortEventqAdd(GID_HTTP_SERVER, HI_SERVER_UTF_NORM_FAIL);
+                        hi_set_event(GID_HTTP_SERVER, HI_SERVER_UTF_NORM_FAIL);
                     }
                     SetHttpDecode((uint16_t)bytes_copied);
                     ServerResp->body = HttpDecodeBuf.data;
@@ -360,15 +360,15 @@ int hi_server_norm(HI_SESSION *session, HttpsessionData *hsd)
             {
                 if(js.alerts & ALERT_LEVELS_EXCEEDED) 
                 {
-                    SnortEventqAdd(GID_HTTP_SERVER, HI_SERVER_JS_OBFUSCATION_EXCD);
+                    hi_set_event(GID_HTTP_SERVER, HI_SERVER_JS_OBFUSCATION_EXCD);
                 }
                 if(js.alerts & ALERT_SPACES_EXCEEDED)
                 {
-                    SnortEventqAdd(GID_HTTP_SERVER, HI_SERVER_JS_EXCESS_WS);
+                    hi_set_event(GID_HTTP_SERVER, HI_SERVER_JS_EXCESS_WS);
                 }
                 if(js.alerts & ALERT_MIXED_ENCODINGS)
                 {
-                    SnortEventqAdd(GID_HTTP_SERVER, HI_SERVER_MIXED_ENCODINGS);
+                    hi_set_event(GID_HTTP_SERVER, HI_SERVER_MIXED_ENCODINGS);
                 }
             }
 
index 72d56498dcab96c8a351b788ac45c855df6af454..c29bab8afbf27d3eab15bcabccc7e7eb66275462 100644 (file)
@@ -337,9 +337,11 @@ void HttpInspect::eval (Packet* p)
     assert(p->is_tcp() && p->dsize && p->data);
 
     MODULE_PROFILE_START(hiPerfStats);
+    hi_clear_events();
 
     HttpInspectMain(config, p);
 
+    hi_queue_events();
     ClearHttpBuffers();
 
     /* XXX: