Skip to content

feat: implement registering error callbacks#47

Merged
fzipi merged 2 commits into
corazawaf:masterfrom
wtzhang23:error-callbacks
Dec 23, 2025
Merged

feat: implement registering error callbacks#47
fzipi merged 2 commits into
corazawaf:masterfrom
wtzhang23:error-callbacks

Conversation

@wtzhang23

@wtzhang23 wtzhang23 commented Dec 23, 2025

Copy link
Copy Markdown
Contributor

Depends on #46.

This introduces registering the error callback with the following api:

typedef void (*coraza_error_cb) (void *, coraza_matched_rule_t);

coraza_matched_rule_t will support two accessors, one for severity and one for actually retrieving the error log. TBD: determine other important accessors that should be exposed.

Centralizing the header is needed due to cgo linking errors as log.go gets more complicated; make coraza.go handle most of the exporting symbols instead.

@jcchavezs

Copy link
Copy Markdown
Member

This is getting to a great place. I wonder if in later steps we could include e2e package with a proxy here like apache or nginx. Thoughts @jptosso @fzipi

@fzipi

fzipi commented Dec 23, 2025

Copy link
Copy Markdown
Member

I will take a look at doing e2e with begin when back.

Signed-off-by: William Zhang <wtzhang23@gmail.com>
Comment thread libcoraza/coraza.go Outdated
case types.RuleSeverityDebug:
return C.CORAZA_SEVERITY_DEBUG
}
// Unknown severity, return the highest severity so user can be aware of the issue

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not adding an UNKNOWN or UNDEFINED option to the enum, and return it?

Signed-off-by: William Zhang <wtzhang23@gmail.com>

@fzipi fzipi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@fzipi fzipi merged commit 7d19b8d into corazawaf:master Dec 23, 2025
4 checks passed
@wtzhang23

Copy link
Copy Markdown
Contributor Author

Integrated my hack project with the new changes made the last few days which runs the ftw suite and a simple e2e test (PR with test run).

Thanks for reviewing all the PRs I created. Happy holidays!

@jcchavezs

jcchavezs commented Dec 23, 2025 via email

Copy link
Copy Markdown
Member

@wtzhang23 wtzhang23 deleted the error-callbacks branch December 23, 2025 21:47
@wtzhang23

Copy link
Copy Markdown
Contributor Author

I think I actually use that in my e2e tests

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.

3 participants