Skip to content

Commit

Permalink
signature: checks protocol for file.name keyword
Browse files Browse the repository at this point in the history
By setting the flags as for the filename keyword (not sticky version)
  • Loading branch information
catenacyber authored and jasonish committed Oct 7, 2020
1 parent bde0c88 commit 61d0cd1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/detect-filename.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -571,4 +572,4 @@ void DetectFilenameRegisterTests(void)
UtRegisterTest("DetectFilenameTestParse02", DetectFilenameTestParse02);
UtRegisterTest("DetectFilenameTestParse03", DetectFilenameTestParse03);
}
#endif /* UNITTESTS */
#endif /* UNITTESTS */
5 changes: 5 additions & 0 deletions src/detect-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 61d0cd1

Please sign in to comment.