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/analyzer: add more details for icmp_id - v1 #11924

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AkakiAlice
Copy link
Contributor

@AkakiAlice AkakiAlice commented Oct 10, 2024

Ticket: #6360

Make sure these boxes are checked accordingly before submitting your Pull Request -- thank you.

Contribution style:

Our Contribution agreements:

Changes (if applicable):

Link to ticket: https://redmine.openinfosecfoundation.org/issues/6360

Describe changes:

  • Add more details for the icmp_id keyword

SV_BRANCH=OISF/suricata-verify#2088

@inashivb inashivb added the outreachy Contributions made by Outreachy applicants label Oct 10, 2024
Copy link

codecov bot commented Oct 10, 2024

Codecov Report

Attention: Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.

Project coverage is 79.19%. Comparing base (d5dd549) to head (8016a32).
Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11924      +/-   ##
==========================================
- Coverage   82.70%   79.19%   -3.51%     
==========================================
  Files         912      912              
  Lines      249102   248931     -171     
==========================================
- Hits       206018   197150    -8868     
- Misses      43084    51781    +8697     
Flag Coverage Δ
fuzzcorpus 60.72% <0.00%> (+0.04%) ⬆️
livemode 18.72% <0.00%> (-0.01%) ⬇️
pcap 44.12% <0.00%> (+0.01%) ⬆️
suricata-verify ?
unittests 58.99% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

case DETECT_ICMP_ID: {
const DetectIcmpIdData *cd = (const DetectIcmpIdData *)smd->ctx;
jb_open_object(js, "id");
jb_set_uint(js, "number", cd->id);
Copy link
Member

@inashivb inashivb Oct 11, 2024

Choose a reason for hiding this comment

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

Nice job, Alice! We need this little patch here to get this going w your s-v PR:

diff --git a/src/detect-engine-analyzer.c b/src/detect-engine-analyzer.c
index a5e8e293b..3d4d8991a 100644
--- a/src/detect-engine-analyzer.c
+++ b/src/detect-engine-analyzer.c
@@ -928,7 +928,7 @@ static void DumpMatches(RuleAnalyzer *ctx, JsonBuilder *js, const SigMatchData *
             case DETECT_ICMP_ID: {
                 const DetectIcmpIdData *cd = (const DetectIcmpIdData *)smd->ctx;
                 jb_open_object(js, "id");
-                jb_set_uint(js, "number", cd->id);
+                jb_set_uint(js, "number", SCNtohs(cd->id));
                 jb_close(js);
                 break;
             }

This is because we store ICMP IDs in network byte order. I do not know the protocol well enough to explain why but saw that what we expect in the output is actually host byte order. SCNtohs does that conversion for you. :)

Copy link
Member

@inashivb inashivb left a comment

Choose a reason for hiding this comment

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

One change requested inline. Keep up the good work! :)

@inashivb inashivb added the needs rebase Needs rebase to master label Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs rebase Needs rebase to master outreachy Contributions made by Outreachy applicants
Development

Successfully merging this pull request may close these issues.

3 participants