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: provide base64 lib to lua - v3 #12513

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jasonish
Copy link
Member

@jasonish jasonish commented Jan 30, 2025

Previous PR: #12498

Add a "base64" library to lua.

Add a base64 nopad encoded and decoder, as well as a padding optional decoder.

Changes from last PR:

  • Fix up greedy search and replace
  • Use malloc for buffers
  • Don't re-order enum
  • Expose RFC* decoders

SV_BRANCH=OISF/suricata-verify#2260

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

@jasonish
Copy link
Member Author

Missed some search and replace in fuzz targets.

A no padding option is provided as a mode, as its a variant suitable
for encoding and decoding.

A padding optional function is added that is indifferent to padding
when decoding. This can be useful when you're not sure if padding
exists, and don't really care.
Export our base64 decoding and encoding functions to Lua.

Ticket: OISF#7074
Copy link

codecov bot commented Jan 30, 2025

Codecov Report

Attention: Patch coverage is 89.47368% with 12 lines in your changes missing coverage. Please review.

Project coverage is 80.69%. Comparing base (cfbf8fd) to head (ed375f2).
Report is 9 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12513      +/-   ##
==========================================
+ Coverage   80.56%   80.69%   +0.12%     
==========================================
  Files         925      926       +1     
  Lines      259292   258983     -309     
==========================================
+ Hits       208906   208992      +86     
+ Misses      50386    49991     -395     
Flag Coverage Δ
fuzzcorpus 56.78% <11.76%> (+0.63%) ⬆️
livemode 19.39% <0.00%> (-0.01%) ⬇️
pcap 44.20% <0.00%> (+<0.01%) ⬆️
suricata-verify 63.41% <88.23%> (+0.01%) ⬆️
unittests 58.36% <21.05%> (-0.09%) ⬇️

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 24454

Copy link
Contributor

@jufajardini jufajardini left a comment

Choose a reason for hiding this comment

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

just minor stuff in the docs 🙇🏽

doc/userguide/lua/libs/base64.rst Outdated Show resolved Hide resolved
doc/userguide/lua/libs/base64.rst Outdated Show resolved Hide resolved
Comment on lines +15 to +21
Encode a buffer with standard base64 encoding. This standard encoding
includes padding.

``decode(string)``
^^^^^^^^^^^^^^^^^^

Decode a base64 string that contains padding.
Copy link
Contributor

Choose a reason for hiding this comment

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

are the terms string and buffer considered interchangeable in this Base64 section?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, and I somewhat did that purposefully. In Lua the datatype is string, whether or not that data is a string of characters like a char *, or a binary blob of data uint8_t *.

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 guess one difference is that encode usually takes what you might call a buffer. And decode always takes a string.

@suricata-qa
Copy link

WARNING:

field baseline test %
SURI_TLPR1_stats_chk
.uptime 623 649 104.17%

Pipeline 24464

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