Skip to content

feat: added Lua5.5 support#3525

Merged
airween merged 3 commits intoowasp-modsecurity:v3/masterfrom
airween:v3/lua55
Mar 28, 2026
Merged

feat: added Lua5.5 support#3525
airween merged 3 commits intoowasp-modsecurity:v3/masterfrom
airween:v3/lua55

Conversation

@airween
Copy link
Copy Markdown
Member

@airween airween commented Mar 28, 2026

what

This PR adds Lua5.5 support.

Steps of implementation:

  • I added Lua5.5 as possible version in build/lua.m4
  • in lua.cc I had to add this version as an exception
    • note, that probably we should change this build logic in the future, eg. if a new Lua version will be released or Lua 5.1 will be unsupported
  • I had to align the test/test-cases/data/match-getvars.lua which is used in one of the regression test with operator @inspectFile. Lua5.5 does not allow to change the iterator variable's value, so we need to create a local variable.

why

Lua5.5 was released and added to macOS, where we also run regression tests. Tests were failed there because Lua5.5 wasn't supported in libmodsecurity3.

references

Closes #3523

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds build/runtime accommodations for Lua 5.5 so libmodsecurity3 can compile and pass regression tests on platforms that ship Lua 5.5 (e.g., macOS).

Changes:

  • Extend build/lua.m4 to detect/link Lua 5.5 and define WITH_LUA_5_5.
  • Update Lua engine error-handling to avoid referencing LUA_ERRGCMM when building against Lua 5.5.
  • Adjust a Lua regression-test helper script to avoid mutating generic-for iterator variables (Lua 5.5 behavior).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
build/lua.m4 Adds Lua 5.5 library candidates + version detection/defines.
src/engine/lua.cc Excludes LUA_ERRGCMM switch case when compiling with Lua 5.5.
test/test-cases/data/match-getvars.lua Updates table-dump helper to avoid mutating loop iterator variables.
Comments suppressed due to low confidence (1)

build/lua.m4:47

  • The Lua version compile tests have a logic bug for Lua 5.5: _msc_lua_ver is set to 505 by the 5.5 check, but the subsequent 5.4 AC_COMPILE_IFELSE runs unconditionally and will fail on 5.5, resetting _msc_lua_ver to empty and preventing detection. Gate the 5.4 (and subsequent) checks behind if test -z "$_msc_lua_ver"; then ... fi or rewrite these as an if/elif chain so a successful match isn’t overwritten.
        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <lua.h> ]],
            [[ #if (LUA_VERSION_NUM == 504)
               return 0;
               #else
               #error not 5.4

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@sonarqubecloud
Copy link
Copy Markdown

@airween airween merged commit ad8b8a8 into owasp-modsecurity:v3/master Mar 28, 2026
125 of 126 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build failure with Lua 5.5.0: LUA_ERRGCMM undeclared

3 participants