-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
analysis: report rule state altered by other rule - v2 #12311
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1047,6 +1047,16 @@ void EngineAnalysisRules2(const DetectEngineCtx *de_ctx, const Signature *s) | |
break; | ||
} | ||
|
||
if (s->init_data->is_rule_state_dependant) { | ||
jb_open_object(ctx.js, "rule_state_dependant"); | ||
jb_set_uint(ctx.js, "rule_depends_on_sid", s->init_data->rule_state_dependant_id); | ||
jb_set_string(ctx.js, "rule_depends_on_flowbit", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can this just be Also, as Shivani is asking: this is 1-N essentially, can we list them all? I'm changing my mind a bit on this. I think being complete is probably best. So "rule_state_dependant": {
"sids": [ 1901, 124, 666 ],
"flowbits": [ "fb2", "abc" ],
}, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought only one rule could There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
From what I got from Victor's comment, I think your approach is what we want so you can skip that :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you were actually right, thanks for the explanations and feedback :) |
||
VarNameStoreSetupLookup(s->init_data->rule_state_variable_idx, VAR_TYPE_FLOW_BIT)); | ||
jb_close(ctx.js); | ||
} else { | ||
jb_set_bool(ctx.js, "rule_state_dependant", s->init_data->is_rule_state_dependant); | ||
} | ||
|
||
jb_open_array(ctx.js, "flags"); | ||
if (s->flags & SIG_FLAG_SRC_ANY) { | ||
jb_append_string(ctx.js, "src_any"); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -597,6 +597,11 @@ typedef struct SignatureInitData_ { | |
|
||
/* highest list/buffer id which holds a DETECT_CONTENT */ | ||
uint32_t max_content_list_id; | ||
|
||
/* inter-signature state dependency */ | ||
bool is_rule_state_dependant; | ||
uint32_t rule_state_dependant_id; | ||
uint32_t rule_state_variable_idx; | ||
Comment on lines
+600
to
+604
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we get this info to analyzer w/o inflating this struct so much? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is fine. This is an init-time only helper struct |
||
} SignatureInitData; | ||
|
||
/** \brief Signature container */ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if there are multiple dependencies?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought of that at first, but from what I understood, only one rule can
set
a flowbits variable, isn't that so?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a rule is only "dependent" on a certain rule or flowbit when you're checking whether a flowbit was set so essentially the
isset
command.set
does not mean the rule is dependent.isset
that can show you multiple dependencies are as follows. Assumefb1
was set bysid: 1
andfb2
was set bysid: 2
and
support:flowbits: isset, fb1; flowbits: isset, fb2;
-> dependent onsid:1
andsid: 2
.or
support:flowbits: isset, fb1|fb2;
-> also dependent onsid:1
andsid: 2
.