]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
refactor file_decomp
authorRuss Combs <rucombs@cisco.com>
Sat, 21 Feb 2015 18:53:58 +0000 (13:53 -0500)
committerRuss Combs <rucombs@cisco.com>
Sat, 21 Feb 2015 18:53:58 +0000 (13:53 -0500)
17 files changed:
configure.ac
doc/config_changes.txt
src/CMakeLists.txt
src/Makefile.am
src/decompress/CMakeLists.txt [new file with mode: 0644]
src/decompress/Makefile.am [new file with mode: 0644]
src/decompress/file_decomp.cc [moved from src/service_inspectors/http_inspect/hi_file_decomp.cc with 99% similarity]
src/decompress/file_decomp.h [moved from src/service_inspectors/http_inspect/hi_file_decomp.h with 95% similarity]
src/decompress/file_decomp_pdf.cc [moved from src/service_inspectors/http_inspect/hi_file_decomp_pdf.cc with 98% similarity]
src/decompress/file_decomp_pdf.h [moved from src/service_inspectors/http_inspect/hi_file_decomp_pdf.h with 97% similarity]
src/decompress/file_decomp_swf.cc [moved from src/service_inspectors/http_inspect/hi_file_decomp_swf.cc with 93% similarity]
src/decompress/file_decomp_swf.h [moved from src/service_inspectors/http_inspect/hi_file_decomp_swf.h with 97% similarity]
src/service_inspectors/http_inspect/CMakeLists.txt
src/service_inspectors/http_inspect/Makefile.am
src/service_inspectors/http_inspect/hi_server.cc
src/service_inspectors/http_inspect/hi_ui_config.h
src/service_inspectors/http_inspect/http_inspect.cc

index f3a2c7bcc180c617620b8b71cd2e9aa3531a6305..1905ce351e5744a6dab155f57d40d5de52194be0 100644 (file)
@@ -137,7 +137,6 @@ else
     AC_MSG_RESULT(no)
 fi
 
-
 #--------------------------------------------------------------------------
 # visibility foo
 #--------------------------------------------------------------------------
@@ -859,6 +858,7 @@ src/codecs/link/Makefile \
 src/codecs/ip/Makefile \
 src/codecs/misc/Makefile \
 src/control/Makefile \
+src/decompress/Makefile \
 src/detection/Makefile \
 src/events/Makefile \
 src/file_api/Makefile \
index 728517c7362b099ede14fb111f47b689fa2af064..53c307109d520d429c7c5335236cd06bdf13c047 100644 (file)
@@ -22,7 +22,6 @@ change -> config 'max_attribute_hosts'  ==> 'attribute_table.max_hosts'
 change -> config 'max_attribute_services_per_host'  ==> 'attribute_table.max_services_per_host'
 change -> config 'nopcre'  ==> 'detection.pcre_enable'
 change -> config 'pkt_count'  ==> 'packets.limit'
-change -> config 'policy_mode'  ==> 'ips.mode'
 change -> config 'rate_filter'  ==> 'alerts.rate_filter_memcap'
 change -> config 'react'  ==> 'react.page'
 change -> config 'threshold'  ==> 'alerts.event_filter_memcap'
@@ -133,16 +132,6 @@ change -> http_inspect_server: 'whitespace_chars' ==> 'profile.whitespace_chars'
 change -> mpls_payload_type: 'config mpls_payload_type: ethernet' ==> 'mpls_payload_type = eth'
 change -> mpls_payload_type: 'config mpls_payload_type: ipv4' ==> 'mpls_payload_type = ip4'
 change -> mpls_payload_type: 'config mpls_payload_type: ipv6' ==> 'mpls_payload_type = ip6'
-change -> normalizers: 'block' ==> 'base'
-change -> normalizers: 'pad' ==> 'base'
-change -> normalizers: 'req_pay' ==> 'base'
-change -> normalizers: 'req_urg' ==> 'base'
-change -> normalizers: 'req_urp' ==> 'base'
-change -> normalizers: 'rsv' ==> 'base'
-change -> normalizers: 'trim_mss' ==> 'trim'
-change -> normalizers: 'trim_rst' ==> 'trim'
-change -> normalizers: 'trim_syn' ==> 'trim'
-change -> normalizers: 'trim_win' ==> 'trim'
 change -> paf_max: 'paf_max [0:63780]' ==> 'max_pdu [1460:63780]'
 change -> perfmonitor: 'accumulate' ==> 'reset = false'
 change -> perfmonitor: 'flow-file' ==> 'flow_file = true'
@@ -153,6 +142,7 @@ change -> perfmonitor: 'flow-ports' ==> 'flow_ports'
 change -> perfmonitor: 'pktcnt' ==> 'packets'
 change -> perfmonitor: 'snortfile' ==> 'file = true'
 change -> perfmonitor: 'time' ==> 'seconds'
+change -> policy_mode: 'inline_test' ==> 'inline-test'
 change -> ppm: 'debug-pkts' ==> 'debug_pkts'
 change -> ppm: 'fastpath-expensive-packets' ==> 'fastpath_expensive_packets'
 change -> ppm: 'max-pkt-time' ==> 'max_pkt_time'
index 2a9621631eebc36f032227351cd903b258c02f8e..f912765a45bc92786e5e0081befc52752e15cf4e 100644 (file)
@@ -111,6 +111,7 @@ target_link_libraries( snort
     network_inspectors
     search_engines
     helpers
+    decompress
     ips_options
     loggers
     service_inspectors
@@ -151,6 +152,7 @@ add_subdirectory(target_based)
 add_subdirectory(time)
 add_subdirectory(utils)
 add_subdirectory(helpers)
+add_subdirectory(decompress)
 add_subdirectory(ips_options)
 add_subdirectory(loggers)
 add_subdirectory(network_inspectors)
index e37c42792e288bebfe2392c140d0785d47edd2b0..8f910ab59c8a932ebb8393e9c325caa6364fdebd 100644 (file)
@@ -67,6 +67,7 @@ hash/libhash.a \
 log/liblog.a \
 packet_io/libpacket_io.a \
 helpers/libhelpers.a \
+decompress/libdecompress.a \
 sfip/libsfip.a \
 sfrt/libsfrt.a \
 protocols/libprotocols.a \
@@ -76,6 +77,7 @@ SUBDIRS = \
 actions \
 codecs \
 control \
+decompress \
 detection \
 events \
 file_api \
diff --git a/src/decompress/CMakeLists.txt b/src/decompress/CMakeLists.txt
new file mode 100644 (file)
index 0000000..7ab7f52
--- /dev/null
@@ -0,0 +1,15 @@
+
+add_library (decompress STATIC
+    file_decomp.cc
+    file_decomp.h
+    file_decomp_pdf.cc
+    file_decomp_pdf.h
+    file_decomp_swf.cc
+    file_decomp_swf.h
+)
+
+
+target_link_libraries(decompress
+    log
+    utils
+)
diff --git a/src/decompress/Makefile.am b/src/decompress/Makefile.am
new file mode 100644 (file)
index 0000000..b5162d9
--- /dev/null
@@ -0,0 +1,13 @@
+AUTOMAKE_OPTIONS=foreign no-dependencies
+
+noinst_LIBRARIES = libdecompress.a
+
+libdecompress_a_SOURCES = \
+file_decomp.cc \
+file_decomp.h \
+file_decomp_pdf.cc \
+file_decomp_pdf.h \
+file_decomp_swf.cc \
+file_decomp_swf.h
+
+AM_CXXFLAGS = @AM_CXXFLAGS@
similarity index 99%
rename from src/service_inspectors/http_inspect/hi_file_decomp.cc
rename to src/decompress/file_decomp.cc
index b6a9eda83f007367767faa6781dd5266170b735c..790007fa791688156b6b5cf48ff0c1947ad21991 100644 (file)
 #include "config.h"
 #endif
 
-#include "util.h"
-#include "hi_file_decomp.h"
+#include "utils/util.h"
+#include "file_decomp.h"
 #include "snort_types.h"
 #include "detection_util.h"
-#include "hi_file_decomp_pdf.h"
-#include "hi_file_decomp_swf.h"
+#include "file_decomp_pdf.h"
+#include "file_decomp_swf.h"
 
 static const char PDF_Sig[5] = { '%', 'P', 'D', 'F', '-' };
 static const char SWF_ZLIB_Sig[3] = { 'C', 'W', 'S' };
@@ -415,3 +415,4 @@ void File_Decomp_Alert( fd_session_p_t SessionPtr, int Event )
     if( (SessionPtr != NULL) && (SessionPtr->Alert_Callback != NULL) && (SessionPtr->Alert_Context) )
         (SessionPtr->Alert_Callback)(SessionPtr->Alert_Context, Event);
 }
+
similarity index 95%
rename from src/service_inspectors/http_inspect/hi_file_decomp.h
rename to src/decompress/file_decomp.h
index ea35dc40389a969505ec087cb055291a09c039a2..b4d12bcb17c7213c757b19ced57400b42e1bf7f0 100644 (file)
 // 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //--------------------------------------------------------------------------
 
-#ifndef HI_FILE_DECOMP_H
-#define HI_FILE_DECOMP_H
-
-// FIXIT-H temporary for development convenience
-//#define LZMA 1
+#ifndef FILE_DECOMP_H
+#define FILE_DECOMP_H
 
 #include <stdint.h>
 #include <string.h>
@@ -50,8 +47,8 @@ typedef enum file_compression_type
 
 typedef struct fd_session_s *fd_session_p_t, fd_session_t;
 
-#include "hi_file_decomp_pdf.h"
-#include "hi_file_decomp_swf.h"
+#include "file_decomp_pdf.h"
+#include "file_decomp_swf.h"
 #include <zlib.h>
 
 #ifdef LZMA
@@ -68,6 +65,16 @@ typedef struct fd_session_s *fd_session_p_t, fd_session_t;
 #define FILE_PDF_ANY         (FILE_PDF_DEFL_BIT)
 #define FILE_SWF_ANY         (FILE_SWF_LZMA_BIT | FILE_SWF_ZLIB_BIT)
 
+enum FileDecompError
+{
+    FILE_DECOMP_ERR_SWF_ZLIB_FAILURE,
+    FILE_DECOMP_ERR_SWF_LZMA_FAILURE,
+    FILE_DECOMP_ERR_PDF_DEFL_FAILURE,
+    FILE_DECOMP_ERR_PDF_UNSUP_COMP_TYPE,
+    FILE_DECOMP_ERR_PDF_CASC_COMP,
+    FILE_DECOMP_ERR_PDF_PARSE_FAILURE
+};
+
 /* Private Types */
 typedef enum file_type
 {
similarity index 98%
rename from src/service_inspectors/http_inspect/hi_file_decomp_pdf.cc
rename to src/decompress/file_decomp_pdf.cc
index f80cebdf2ed07dbdd9cf6d352884cccced9b771c..5d10c66ccd328b19aef7dd84dd31e50c92ef35f7 100644 (file)
 #include <string.h>
 #include <stdlib.h>
 
-#include "hi_file_decomp.h"
-#include "hi_file_decomp_pdf.h"
-#include "hi_events.h"
+#include "file_decomp.h"
+#include "file_decomp_pdf.h"
 #include "mstring.h"
+#include "service_inspectors/http_inspect/hi_events.h"
 
 /* Define characters and tokens in PDF grammar */
 #define TOK_STRM_OPEN      "stream"
@@ -158,7 +158,7 @@ static inline void Process_One_Filter( fd_session_p_t SessionPtr, uint8_t *Token
         /* Check if we've found one already.  Indicate cascading if we did. */
         if( SessionPtr->Decomp_Type != FILE_COMPRESSION_TYPE_NONE )
         {
-            File_Decomp_Alert( SessionPtr, HI_SERVER_PDF_CASC_COMP );
+            File_Decomp_Alert( SessionPtr, FILE_DECOMP_ERR_PDF_CASC_COMP );
             SessionPtr->Decomp_Type = FILE_COMPRESSION_TYPE_NONE;
         }
         else
@@ -170,7 +170,7 @@ static inline void Process_One_Filter( fd_session_p_t SessionPtr, uint8_t *Token
     }
     else
     {
-        File_Decomp_Alert( SessionPtr, HI_SERVER_PDF_UNSUP_COMP_TYPE );
+        File_Decomp_Alert( SessionPtr, FILE_DECOMP_ERR_PDF_UNSUP_COMP_TYPE );
         SessionPtr->Decomp_Type = FILE_COMPRESSION_TYPE_NONE;
     }
 }
@@ -923,7 +923,7 @@ static fd_status_t Init_Stream( fd_session_p_t SessionPtr )
 
             if( z_ret != Z_OK )
             {
-                File_Decomp_Alert( SessionPtr, HI_SERVER_PDF_DEFL_FAILURE );
+                File_Decomp_Alert( SessionPtr, FILE_DECOMP_ERR_PDF_DEFL_FAILURE );
                 return( File_Decomp_Error );
             }
 
@@ -968,7 +968,7 @@ static fd_status_t Decomp_Stream( fd_session_p_t SessionPtr )
             if( z_ret != Z_OK )
             {
                 DEBUG_WRAP(DebugMessage(DEBUG_HTTPINSPECT, "Decompression Error: objnum: %u\n", StPtr->Parse.Obj_Number););
-                File_Decomp_Alert( SessionPtr, HI_SERVER_PDF_DEFL_FAILURE );
+                File_Decomp_Alert( SessionPtr, FILE_DECOMP_ERR_PDF_DEFL_FAILURE );
                 return( File_Decomp_Error );
             }
 
@@ -1019,7 +1019,7 @@ fd_status_t File_Decomp_End_PDF( fd_session_p_t SessionPtr )
 
             if( z_ret != Z_OK )
             {
-                File_Decomp_Alert( SessionPtr, HI_SERVER_PDF_DEFL_FAILURE );
+                File_Decomp_Alert( SessionPtr, FILE_DECOMP_ERR_PDF_DEFL_FAILURE );
                 return( File_Decomp_Error );
             }
 
@@ -1104,7 +1104,7 @@ fd_status_t File_Decomp_PDF( fd_session_p_t SessionPtr )
                     Ret_Code = File_Decomp_End_PDF( SessionPtr );
                     if( Close_Stream( SessionPtr ) != File_Decomp_OK )
                         return( File_Decomp_Error );
-                    File_Decomp_Alert( SessionPtr, HI_SERVER_PDF_DEFL_FAILURE );
+                    File_Decomp_Alert( SessionPtr, FILE_DECOMP_ERR_PDF_DEFL_FAILURE );
                     break;
                 }
 
@@ -1121,7 +1121,7 @@ fd_status_t File_Decomp_PDF( fd_session_p_t SessionPtr )
                     Ret_Code = File_Decomp_End_PDF( SessionPtr );
                     if( Close_Stream( SessionPtr ) != File_Decomp_OK )
                         return( File_Decomp_Error );
-                    File_Decomp_Alert( SessionPtr, HI_SERVER_PDF_DEFL_FAILURE );
+                    File_Decomp_Alert( SessionPtr, FILE_DECOMP_ERR_PDF_DEFL_FAILURE );
                     break;
                 }
                 /* OK -> circle back for more input */
similarity index 97%
rename from src/service_inspectors/http_inspect/hi_file_decomp_pdf.h
rename to src/decompress/file_decomp_pdf.h
index 8d715692def2c33903289408c95369e2c87bbb98..a2ee9f28967a8e10e0ef58159770cf06632dc606 100644 (file)
@@ -17,8 +17,8 @@
 // 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //--------------------------------------------------------------------------
 
-#ifndef HI_FILE_DECOMP_PDF_H
-#define HI_FILE_DECOMP_PDF_H
+#ifndef FILE_DECOMP_PDF_H
+#define FILE_DECOMP_PDF_H
 
 #include <zlib.h>
 
similarity index 93%
rename from src/service_inspectors/http_inspect/hi_file_decomp_swf.cc
rename to src/decompress/file_decomp_swf.cc
index 43d8ddf5503ed1c24b10a4b6f414e1a74eeea80d..c2cf5d3d5061b3b89c2a774ebdaf7c7d80683e66 100644 (file)
@@ -27,9 +27,9 @@
 #include <lzma.h>
 #endif
 
-#include "hi_file_decomp.h"
-#include "hi_file_decomp_swf.h"
-#include "hi_events.h"
+#include "file_decomp.h"
+#include "file_decomp_swf.h"
+//#include "service_inspectors/http_inspect/hi_events.h"
 
 #ifdef LZMA
 #define LZMA_HEADER_LEN  (13)
@@ -58,7 +58,7 @@ static fd_status_t File_Decomp_Process_LZMA_Header( fd_session_p_t SessionPtr )
 
     if( SWF_Uncomp_Len < SWF_HDR_LEN )
     {
-        SessionPtr->Error_Event = HI_SERVER_SWF_LZMA_FAILURE;
+        SessionPtr->Error_Event = FILE_DECOMP_ERR_SWF_LZMA_FAILURE;
         return( File_Decomp_DecompError );
     }
     
@@ -90,7 +90,7 @@ static fd_status_t File_Decomp_Process_LZMA_Header( fd_session_p_t SessionPtr )
 
     if( l_ret != LZMA_OK )
     {
-        SessionPtr->Error_Event = HI_SERVER_SWF_LZMA_FAILURE;
+        SessionPtr->Error_Event = FILE_DECOMP_ERR_SWF_LZMA_FAILURE;
         return( File_Decomp_DecompError );
     }
 
@@ -120,7 +120,7 @@ static fd_status_t Decomp( fd_session_p_t SessionPtr )
 
             if( z_ret != Z_OK )
             {
-                SessionPtr->Error_Event = HI_SERVER_SWF_ZLIB_FAILURE;
+                SessionPtr->Error_Event = FILE_DECOMP_ERR_SWF_ZLIB_FAILURE;
                 return( File_Decomp_DecompError );
             }
 
@@ -146,7 +146,7 @@ static fd_status_t Decomp( fd_session_p_t SessionPtr )
 
             if( l_ret != LZMA_OK )
             {
-                SessionPtr->Error_Event = HI_SERVER_SWF_LZMA_FAILURE;
+                SessionPtr->Error_Event = FILE_DECOMP_ERR_SWF_LZMA_FAILURE;
                 return( File_Decomp_DecompError );
             }
 
@@ -176,7 +176,7 @@ fd_status_t File_Decomp_End_SWF( fd_session_p_t SessionPtr )
 
             if( z_ret != Z_OK )
             {
-                SessionPtr->Error_Event = HI_SERVER_SWF_ZLIB_FAILURE;
+                SessionPtr->Error_Event = FILE_DECOMP_ERR_SWF_ZLIB_FAILURE;
                 return( File_Decomp_DecompError );
             }
 
@@ -232,7 +232,7 @@ fd_status_t File_Decomp_Init_SWF( fd_session_p_t SessionPtr )
 
             if( z_ret != Z_OK )
             {
-                SessionPtr->Error_Event = HI_SERVER_SWF_ZLIB_FAILURE;
+                SessionPtr->Error_Event = FILE_DECOMP_ERR_SWF_ZLIB_FAILURE;
                 return( File_Decomp_DecompError );
             }
 
@@ -257,7 +257,7 @@ fd_status_t File_Decomp_Init_SWF( fd_session_p_t SessionPtr )
 
             if( l_ret != LZMA_OK )
             {
-                SessionPtr->Error_Event = HI_SERVER_SWF_LZMA_FAILURE;
+                SessionPtr->Error_Event = FILE_DECOMP_ERR_SWF_LZMA_FAILURE;
                 return( File_Decomp_DecompError );
             }
 
similarity index 97%
rename from src/service_inspectors/http_inspect/hi_file_decomp_swf.h
rename to src/decompress/file_decomp_swf.h
index 46c243350c1caddece121b33d0e330b3cde69a85..567a2828a0e657ae3b1229ebb9ba8b1f119bd498 100644 (file)
@@ -17,8 +17,8 @@
 // 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //--------------------------------------------------------------------------
 
-#ifndef HI_FILE_DECOMP_SWF_H
-#define HI_FILE_DECOMP_SWF_H
+#ifndef FILE_DECOMP_SWF_H
+#define FILE_DECOMP_SWF_H
 
 #include <zlib.h>
 #ifdef LZMA
index f643fd2b1f3332fb1c488b92cc5172aa610007fe..f9570f18271718839eb8f301aa2a7f39e347ffa5 100644 (file)
@@ -11,12 +11,6 @@ set (FILE_LIST
     hi_client_norm.h
     hi_cmd_lookup.cc 
     hi_cmd_lookup.h
-    hi_file_decomp.cc
-    hi_file_decomp.h
-    hi_file_decomp_pdf.cc
-    hi_file_decomp_pdf.h
-    hi_file_decomp_swf.cc
-    hi_file_decomp_swf.h
     hi_include.h
     hi_mi.cc 
     hi_mi.h
index 135ed08c46254045814bf48ce13c95a5131fc7ef..de3d23e77a37d0606b89580666535825adeee77c 100644 (file)
@@ -8,9 +8,6 @@ hi_client.cc hi_client.h \
 hi_client_norm.cc hi_client_norm.h \
 hi_cmd_lookup.cc hi_cmd_lookup.h \
 hi_events.cc hi_events.h \
-hi_file_decomp.cc hi_file_decomp.h \
-hi_file_decomp_pdf.cc hi_file_decomp_pdf.h \
-hi_file_decomp_swf.cc hi_file_decomp_swf.h \
 hi_include.h \
 hi_mi.cc hi_mi.h \
 hi_module.cc hi_module.h \
index 50be3091f23b0d0f7dbe9d86c544aed46ff6f288..2cac8b62deb443db33fc24345430dfcb64a13880 100644 (file)
@@ -819,8 +819,27 @@ static inline int hi_server_extract_body(
 
 static void LogFileDecomp(void*, int event)
 {
-    // FIXIT-H first argument is supposed to be pointer to session which may be needed to
-    // generate the event correctly.
+    switch ( event )
+    {
+    case FILE_DECOMP_ERR_SWF_ZLIB_FAILURE:
+        event = HI_SERVER_SWF_ZLIB_FAILURE;
+        break;
+    case FILE_DECOMP_ERR_SWF_LZMA_FAILURE:
+        event = HI_SERVER_SWF_LZMA_FAILURE;
+        break;
+    case FILE_DECOMP_ERR_PDF_DEFL_FAILURE:
+        event = HI_SERVER_PDF_DEFL_FAILURE;
+        break;
+    case FILE_DECOMP_ERR_PDF_UNSUP_COMP_TYPE:
+        event = HI_SERVER_PDF_UNSUP_COMP_TYPE;
+        break;
+    case FILE_DECOMP_ERR_PDF_CASC_COMP:
+        event = HI_SERVER_PDF_CASC_COMP;
+        break;
+    case FILE_DECOMP_ERR_PDF_PARSE_FAILURE:
+        event = HI_SERVER_PDF_PARSE_FAILURE;
+        break;
+    }
     hi_set_event(GID_HTTP_SERVER, event);
 }
 
index 99d8da715e70dc66265f698d1f00973f07b44cda..b1a2c1683f71da263ad1bee6d878be0a345ea4bb 100644 (file)
@@ -39,7 +39,7 @@
 #include "sf_ip.h"
 #include "hi_util_kmap.h"
 #include "file_api/file_api.h"
-#include "hi_file_decomp.h"
+#include "decompress/file_decomp.h"
 #include "framework/bits.h"
 
 /*
index 30fec34506f9fc99c2bb519a6a173405b819e09d..5437ad2c0fcfe650e4028c718069741407b2c27b 100644 (file)
@@ -47,7 +47,7 @@
 #include "snort_debug.h"
 #include "util.h"
 #include "parser.h"
-#include "hi_file_decomp.h"
+#include "decompress/file_decomp.h"
 
 #include "hi_client.h"
 #include "hi_ui_config.h"