]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
signature: checks protocol for file.name keyword
authorPhilippe Antoine <contact@catenacyber.fr>
Thu, 17 Sep 2020 13:22:49 +0000 (15:22 +0200)
committerJason Ish <jason.ish@oisf.net>
Wed, 7 Oct 2020 15:40:38 +0000 (09:40 -0600)
By setting the flags as for the filename keyword (not sticky version)

src/detect-filename.c
src/detect-parse.c

index 7e6fd36d4d9fe2a20807d8a28b5f94a1ea90acce..d737e5b7279ce47bc3a25e38ee0c0a4c26145c34 100644 (file)
@@ -349,6 +349,7 @@ static int DetectFilenameSetupSticky(DetectEngineCtx *de_ctx, Signature *s, cons
 {
     if (DetectBufferSetActiveList(s, g_file_name_buffer_id) < 0)
         return -1;
+    s->file_flags |= (FILE_SIG_NEED_FILE | FILE_SIG_NEED_FILENAME);
     return 0;
 }
 
@@ -571,4 +572,4 @@ void DetectFilenameRegisterTests(void)
     UtRegisterTest("DetectFilenameTestParse02", DetectFilenameTestParse02);
     UtRegisterTest("DetectFilenameTestParse03", DetectFilenameTestParse03);
 }
-#endif /* UNITTESTS */
\ No newline at end of file
+#endif /* UNITTESTS */
index b14a15b2e5ea38a9592387f2295c1721b59b5222..3f33f360e8418bf398549c81ea8951c65ed860a2 100644 (file)
@@ -1857,6 +1857,11 @@ static int SigValidate(DetectEngineCtx *de_ctx, Signature *s)
                     "support file matching", AppProtoToString(s->alproto));
             SCReturnInt(0);
         }
+        if (s->alproto == ALPROTO_HTTP2 && (s->file_flags & FILE_SIG_NEED_FILENAME)) {
+            SCLogError(SC_ERR_NO_FILES_FOR_PROTOCOL,
+                    "protocol HTTP2 doesn't support file name matching");
+            SCReturnInt(0);
+        }
 
         if (s->alproto == ALPROTO_HTTP) {
             AppLayerHtpNeedFileInspection();