Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect cleanups/v4 #9974

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/detect-engine-content-inspection.c
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,25 @@ bool DetectEngineContentInspection(DetectEngineCtx *de_ctx, DetectEngineThreadCt
return false;
}

/** \brief wrapper around DetectEngineContentInspectionInternal to return true/false only
*
* \param smd sigmatches to evaluate
*/
bool DetectEngineContentInspectionBuffer(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
const Signature *s, const SigMatchData *smd, Packet *p, Flow *f, const InspectionBuffer *b,
const enum DetectContentInspectionType inspection_mode)
{
Comment on lines +748 to +751
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I understand correctly that the difference between this and DetectEngineContentInspection is that this one uses specific types for buffer and inspection type? If so, I wonder if this difference, or an indication of preference of usage should be added to the function description or commit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've update the commit msg. It's a convenience function that keeps the internals of InspectionBuffer hidden from the callers.

det_ctx->buffer_offset = 0;
det_ctx->inspection_recursion_counter = 0;

int r = DetectEngineContentInspectionInternal(de_ctx, det_ctx, s, smd, p, f, b->inspect,
b->inspect_len, b->inspect_offset, b->flags, inspection_mode);
if (r == 1)
return true;
else
return false;
}

#ifdef UNITTESTS
#include "tests/detect-engine-content-inspection.c"
#endif
5 changes: 5 additions & 0 deletions src/detect-engine-content-inspection.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ bool DetectEngineContentInspection(DetectEngineCtx *de_ctx, DetectEngineThreadCt
const uint32_t buffer_len, const uint32_t stream_start_offset, const uint8_t flags,
const enum DetectContentInspectionType inspection_mode);

/* entry for inspection buffers */
bool DetectEngineContentInspectionBuffer(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
const Signature *s, const SigMatchData *smd, Packet *p, Flow *f, const InspectionBuffer *b,
const enum DetectContentInspectionType inspection_mode);

void DetectEngineContentInspectionRegisterTests(void);

#endif /* __DETECT_ENGINE_CONTENT_INSPECTION_H__ */