Add Lua SWIG bindings#91
Draft
Copilot wants to merge 3 commits into
Draft
Conversation
Agent-Logs-Url: https://github.com/corazawaf/libcoraza/sessions/2dc3850e-7ac2-4bf1-93b0-e2472e9a0da0 Co-authored-by: jptosso <1236942+jptosso@users.noreply.github.com>
Agent-Logs-Url: https://github.com/corazawaf/libcoraza/sessions/2dc3850e-7ac2-4bf1-93b0-e2472e9a0da0 Co-authored-by: jptosso <1236942+jptosso@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add swig support for LUA and testable example
Add Lua SWIG bindings
Apr 12, 2026
|
So I'm already using this branch for APISIX, everything works. However there's an issue with callbacks (debug and error) which SIGSEGV (happens frequently when configuring coraza using |
Member
|
There are many improvements from upstream wasm project we should apply here, I will try to bring them |
|
Maybe better in a new pull request after this one is merged (hopefully soon...) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds Lua SWIG bindings for libcoraza, enabling Kong/OpenResty integrators to build a connector, following the same patterns as the Python and Java connectors.
coraza.i%typemap(argout) char **er: Add#elif defined(SWIGLUA)branch — SWIG Lua has noSWIG_Error; uselua_pushstring+SWIG_failinstead.#ifdef SWIGLUAblock:(const unsigned char *data, int length)→ single Lua string vialuaL_checklstring._swig_lua_error_trampoline/_swig_lua_debug_trampolinestore Lua functions in the registry and invoke them synchronously (safe because Go's CGO runtime pins the goroutine to the calling OS thread).%nativewrappers forcoraza_set_error_callbackandcoraza_set_debug_log_callback— note:%ignoremust not precede%nativein SWIG Lua or the function is silently dropped from the module table.examples/lua/Makefile:swig -lua→coraza.so;pkg-configfor Lua headers; Linux/macOS aware.simple_get.lua: 7 test cases — full transaction lifecycle, request body from file, WAF merge, error + debug callbacks, redirect intervention, WAF creation error, invalid input rejection.README.md: Prerequisites, build/run instructions, and a Kong/OpenResty usage snippet:CI
swig-luajob inswig.yml:ubuntu-latest+macos-latest× 2 Go versions; installslua5.4/liblua5.4-dev(Linux) orluavia Homebrew (macOS).