Skip to content

Add ctl:auditengine action support to libmodsecurity #2606

Closed
@alekravch

Description

@alekravch

Hello.
Suggest to make work “ctl:auditengine” option.
Attached patch implements this.
ctl_auditengine2_patch.txt

Feature ctl:auditengine is not yet implemented, but IMHO it’s quite important and useful feature for logging and debugging, mentioned even in ModSecutiry Handbook (Chapter 4. Logging. Selective Audit Logging)

This example from the book will not work.

4 Logging

Selective Audit Logging

SecRule HIGHEST_SEVERITY "@lt 4"
id:9000,phase:5,pass,nolog,setvar:ip.logflag=1,expirevar:ip.logflag=3600
Finally, we add a rule that detects the flag and forces logging for all the requests from the flagged IP address:
SecRule IP:logflag "@gt 0"
id:9001,phase:5,pass,nolog,ctl:auditEngine=On

Implementation Proposal

This feature should operate on a transaction scope, not interfering with the global rule set.
So we store AuditLogStatus in the transaction and then use function AuditLog::getActualStatus to get AuditLogStatus either from the transaction scope (if set), or from the global rule set (unless it’s not set on the transaction scope). This function is used in AuditLog::init and AuditLog::saveIfRelevant.

Aleksey Kravchuk

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.xRelated to ModSecurity version 3.x

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions