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

lua: expose hash function to lua scripts - v1 #12437

Closed
wants to merge 3 commits into from

Conversation

jasonish
Copy link
Member

@jasonish jasonish commented Jan 20, 2025

Expose md5, sha1, and sha256 to Lua scripts with
require("suricata.hashing").

Draft as a few things are missing:

  • Documentation
  • Hex variations

But does the API look OK? I put them all into the "suricata.hashing" namespace.
But we could also do something like require("suricata.hashing.md5") to be
more fine grained.

Ticket: https://redmine.openinfosecfoundation.org/issues/7073

SV_BRANCH=OISF/suricata-verify#2247

Copy link

codecov bot commented Jan 20, 2025

Codecov Report

Attention: Patch coverage is 92.51101% with 17 lines in your changes missing coverage. Please review.

Project coverage is 80.67%. Comparing base (95e8427) to head (a8b9e2d).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12437      +/-   ##
==========================================
+ Coverage   80.63%   80.67%   +0.04%     
==========================================
  Files         920      921       +1     
  Lines      258704   258919     +215     
==========================================
+ Hits       208595   208893     +298     
+ Misses      50109    50026      -83     
Flag Coverage Δ
fuzzcorpus 56.77% <0.96%> (-0.05%) ⬇️
livemode 19.37% <0.00%> (-0.03%) ⬇️
pcap 44.29% <0.96%> (-0.05%) ⬇️
suricata-verify 63.34% <91.78%> (+0.07%) ⬆️
unittests 58.47% <13.21%> (-0.05%) ⬇️

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

@suricata-qa
Copy link

Information: QA ran without warnings.

Pipeline 24283

@victorjulien
Copy link
Member

I think it looks good.

@victorjulien
Copy link
Member

I suppose one thing that will come up quickly, is how to keep state between invocations? Not something this PR should fix, but something to think about?

Make all the hasher's have the same variants:
- add hex digest for sha256
- add finalize to hex for sha1
- add hex digest for sha1
Expose md5, sha1, and sha256 to Lua scripts with
`require("suricata.hashing")`.

Ticket: 7073
@suricata-qa
Copy link

Information: QA ran without warnings.

Pipeline 24316

@jasonish
Copy link
Member Author

Updated here and ready for final review: #12449

@jasonish jasonish closed this Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants