]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
uricontent simplified to use the existing content + http_uri infrastructure.
authorAnoop Saldanha <anoopsaldanha@gmail.com>
Sun, 24 Feb 2013 14:53:41 +0000 (20:23 +0530)
committerVictor Julien <victor@inliniac.net>
Wed, 20 Mar 2013 10:49:08 +0000 (11:49 +0100)
src/detect-http-uri.c
src/detect-http-uri.h
src/detect-uricontent.c

index 3390f7317a63f72adb0ab92b60e6c63f973a77c1..29cf73f1128a26601b1259c20c82238255db5f72 100644 (file)
@@ -87,7 +87,7 @@ void DetectHttpUriRegister (void) {
  * \retval -1 On failure
  */
 
-int DetectHttpUriSetup (DetectEngineCtx *de_ctx, Signature *s, char *str)
+int DetectHttpUriSetup(DetectEngineCtx *de_ctx, Signature *s, char *str)
 {
     SigMatch *sm = NULL;
     int ret = -1;
index db7e0b7c1a025142a78944f5f7d6c8e21c4c7e58..cb327804ea0ad0d020d76b5c14c0c4b833dd705e 100644 (file)
@@ -27,6 +27,7 @@
 /* prototypes */
 void DetectHttpUriRegister (void);
 
+int DetectHttpUriSetup(DetectEngineCtx *de_ctx, Signature *s, char *str);
 int DetectHttpUriDoMatch(DetectEngineThreadCtx *det_ctx, Signature *s,
         SigMatch *sm, Flow *f, uint8_t flags, void *state);
 
index 49fb70456694fe7b4e5bdee42f55599237b3af75..e743de22601ac431b7ebc4eacf86122788111106 100644 (file)
@@ -28,6 +28,7 @@
 #include "decode.h"
 #include "detect.h"
 #include "detect-content.h"
+#include "detect-http-uri.h"
 #include "detect-uricontent.h"
 #include "detect-engine-mpm.h"
 #include "detect-parse.h"
@@ -156,7 +157,7 @@ void DetectUricontentPrint(DetectContentData *cd)
  *          the rule set.
  * \param   contentstr  Pointer to the string which has been defined in the rule
  */
-DetectContentData *DoDetectUricontentSetup (char *contentstr)
+DetectContentData *DoDetectUricontentSetup(char *contentstr)
 {
     DetectContentData *cd = NULL;
     char *str = NULL;
@@ -206,45 +207,18 @@ DetectContentData *DoDetectUricontentSetup (char *contentstr)
  *
  * \retval 0 on success, -1 on failure
  */
-int DetectUricontentSetup (DetectEngineCtx *de_ctx, Signature *s, char *contentstr)
+int DetectUricontentSetup(DetectEngineCtx *de_ctx, Signature *s, char *contentstr)
 {
     SCEnter();
 
-    DetectContentData *cd = NULL;
-    SigMatch *sm = NULL;
-
-    if (s->alproto != ALPROTO_UNKNOWN && s->alproto != ALPROTO_HTTP) {
-        SCLogError(SC_ERR_CONFLICTING_RULE_KEYWORDS, "rule contains "
-                   "conflicting keywords.");
-        goto error;
-    }
-
-    cd = DoDetectUricontentSetup(contentstr);
-    if (cd == NULL)
+    if (DetectContentSetup(de_ctx, s, contentstr) < 0)
         goto error;
 
-    sm = SigMatchAlloc();
-    if (sm == NULL)
+    if (DetectHttpUriSetup(de_ctx, s, NULL) < 0)
         goto error;
 
-    sm->type = DETECT_CONTENT;
-    sm->ctx = (void *)cd;
-
-    /* Flagged the signature as to inspect the app layer data */
-    s->flags |= SIG_FLAG_APPLAYER;
-
-    s->alproto = ALPROTO_HTTP;
-
-    cd->id = DetectUricontentGetId(de_ctx->mpm_pattern_id_store, cd);
-    SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_UMATCH);
-
     SCReturnInt(0);
-
 error:
-    if (cd != NULL)
-        SCFree(cd);
-    if (sm != NULL)
-        SCFree(sm);
     SCReturnInt(-1);
 }