-
Notifications
You must be signed in to change notification settings - Fork 8
feat: full coraza-nginx rework — config inheritance, dlopen wrapper, bug fixes #5
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
Merged
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
6e0af0a
chore: update libcoraza api
fzipi 9458cd2
Initial plan
Copilot 917b0cd
Fix review comments: return types, debug messages, null checks, and d…
Copilot 7455be0
Improve typedef comment for coraza_waf_config_t
Copilot 04c389b
Improve comment about config ownership model
Copilot b82f036
Final update: all review comments addressed
Copilot e855f86
Merge pull request #4 from corazawaf/copilot/sub-pr-3
fzipi 4fd9b30
fix: tests
fzipi 093eec4
fix: ngx_str_to_char pass pointer by reference
ppomes 2f53dc4
fix: Dockerfile prove runs only coraza tests
ppomes b77a9da
fix: Dockerfile test runner
ppomes 8ae8f72
fix: intervention memory leaks
ppomes fcc5551
feat: transaction ID tracking and access denied logging
ppomes e38a4a7
fix: set intervention_triggered flag consistently
ppomes 95479e4
fix: check body limit intervention before processing rules
ppomes 0c4806c
fix: config inheritance for locations without rules
ppomes d24a47c
fix: adapt tests for Coraza compatibility
ppomes 83384d8
test: mark unsupported libcoraza features as TODO
ppomes 86063cc
fix: use ppomes/libcoraza fork with working rules_merge
ppomes 774b496
Merge pull request #1 from ppomes/chore/update-latest-libcoraza
ppomes a609d97
fix: enable passing tests and fix audit log assertions
ppomes 95b9c5b
fix: delay response headers until phase 4 body inspection completes
ppomes 6f60f15
Merge pull request #2 from ppomes/chore/update-latest-libcoraza
ppomes e3cd8c6
fix: dlopen libcoraza after fork to avoid Go runtime deadlock
ppomes eec1d9c
fix: address review feedback
ppomes 6079ccf
Add cross-platform dynlib abstraction for dlopen/LoadLibrary
ppomes 425a3fd
Apply review feedback: CORAZA_DYNLIB_BASENAME, Win64 guard
ppomes ad91bdb
Use official upstream libcoraza
ppomes 08711d1
Pin libcoraza to release v1.0.0
ppomes 65945f3
Fix CI: use libcoraza release tag instead of branch
ppomes da3d368
Fix CI: only run coraza tests, not all nginx tests
ppomes 3bec425
Fix CI: remove unnecessary dynamic modules and deps
ppomes 89f9c94
Fix CI: ldconfig after libcoraza install, suppress unused-function wa…
ppomes 2b09f72
Fix double-free in exit_process WAF cleanup, add ldconfig and -Wno-un…
ppomes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| . |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| /* | ||
| * Cross-platform dynamic library loading abstraction. | ||
| * | ||
| * Wraps dlopen/dlsym/dlclose/dlerror (Unix) and | ||
| * LoadLibrary/GetProcAddress/FreeLibrary/FormatMessage (Windows) | ||
| * behind a common API. | ||
| * | ||
| * Shared between coraza-apache and coraza-nginx. | ||
| */ | ||
|
|
||
| #ifndef DYNLIB_H | ||
| #define DYNLIB_H | ||
|
|
||
| #if defined(_WIN32) || defined(_WIN64) | ||
|
|
||
| #include <windows.h> | ||
|
|
||
| typedef HMODULE dynlib_t; | ||
|
|
||
| /* Windows typically doesn't use "lib" prefix */ | ||
| #define CORAZA_DYNLIB_BASENAME "coraza" | ||
| /* Library file extension per platform */ | ||
ppomes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #define DYNLIB_EXT ".dll" | ||
|
|
||
| static inline dynlib_t dynlib_open(const char *path) | ||
| { | ||
| return LoadLibraryA(path); | ||
| } | ||
|
|
||
| static inline void *dynlib_sym(dynlib_t lib, const char *name) | ||
| { | ||
| return (void *)GetProcAddress(lib, name); | ||
| } | ||
|
|
||
| static inline int dynlib_close(dynlib_t lib) | ||
| { | ||
| return FreeLibrary(lib) ? 0 : -1; | ||
| } | ||
|
|
||
| static inline const char *dynlib_error(void) | ||
| { | ||
| static __declspec(thread) char buf[256]; | ||
| FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), | ||
| 0, buf, sizeof(buf), NULL); | ||
| return buf; | ||
| } | ||
|
|
||
| #else /* Unix (Linux, macOS, FreeBSD, ...) */ | ||
|
|
||
| #include <dlfcn.h> | ||
|
|
||
| typedef void *dynlib_t; | ||
|
|
||
ppomes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #define CORAZA_DYNLIB_BASENAME "libcoraza" | ||
|
|
||
| #ifdef __APPLE__ | ||
| #define DYNLIB_EXT ".dylib" | ||
| #else | ||
| #define DYNLIB_EXT ".so" | ||
| #endif | ||
|
|
||
| static inline dynlib_t dynlib_open(const char *path) | ||
| { | ||
| return dlopen(path, RTLD_NOW | RTLD_LOCAL); | ||
| } | ||
|
|
||
| static inline void *dynlib_sym(dynlib_t lib, const char *name) | ||
| { | ||
| return dlsym(lib, name); | ||
| } | ||
|
|
||
| static inline int dynlib_close(dynlib_t lib) | ||
| { | ||
| return dlclose(lib); | ||
| } | ||
|
|
||
| static inline const char *dynlib_error(void) | ||
| { | ||
| return dlerror(); | ||
| } | ||
|
|
||
| #endif /* _WIN32 || _WIN64 */ | ||
|
|
||
| #endif /* DYNLIB_H */ | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.