WACElib tracks every HTTP transaction through a pair of lifecycle functions.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tilsor/ModSecIntl_wace_lib/llms.txt
Use this file to discover all available pages before exploring further.
InitTransaction allocates the internal synchronisation state and plugin result storage for a given transaction ID. CloseTransaction tears everything down, closing channels and freeing maps so that memory does not leak across requests. Every call to InitTransaction must be paired with exactly one call to CloseTransaction, even if analysis or checking fails.
InitTransaction
Signature
What it does
- Starts a new logging context for
transactionId. - Creates a
transactionSyncvalue with an unbufferedChannelandCounterset to0, and stores it in the package-levelanalysisMap. - Calls
plugins.InitTransaction(transactionId)on thePluginManager, which allocates async.Mapin the results store keyed by the transaction ID.
Parameters
An opaque, caller-supplied identifier that must be unique for the lifetime of
the transaction. UUIDs, hex strings, or any collision-resistant ID are
suitable. The same value must be passed to every subsequent
Analyze,
CheckTransaction, and CloseTransaction call for this request.CloseTransaction
Signature
What it does
- Calls
plugins.CloseTransaction(transactionID)on thePluginManager, which closes all sync model status channels and deletes per-transaction results from the results store. - Loads the
transactionSyncfromanalysisMap, closes itsChannel, drains any remaining messages, and deletes the entry fromanalysisMap.
Parameters
The same transaction identifier passed to
InitTransaction.Paired usage pattern
Always wrapCloseTransaction in a defer so it runs even when errors occur in the analysis path.
InitTransaction and CloseTransaction are not safe to call concurrently
for the same transactionID. Each transaction ID must have its lifecycle
managed by a single goroutine, though different transaction IDs can be managed
in separate goroutines simultaneously.