-
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
133 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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,36 @@ | ||
// Copyright 2024 Juan Pablo Tosso and the OWASP Coraza contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package experimental | ||
|
||
import ( | ||
"context" | ||
"strings" | ||
|
||
"github.com/corazawaf/coraza/v3/internal/corazawaf" | ||
"github.com/corazawaf/coraza/v3/types" | ||
) | ||
|
||
type Option func(*corazawaf.Options) | ||
|
||
// WithID sets the transaction ID | ||
func WithID(id string) Option { | ||
return func(o *corazawaf.Options) { | ||
o.ID = strings.TrimSpace(id) | ||
} | ||
} | ||
|
||
// WithContext sets the transaction context, this is useful for passing | ||
// a context into the logger. | ||
// The transaction lifecycle isn't tied to the context lifecycle. | ||
func WithContext(ctx context.Context) Option { | ||
return func(o *corazawaf.Options) { | ||
o.Context = ctx | ||
} | ||
} | ||
|
||
// WAFWithOptions is an interface that allows to create transactions | ||
// with options | ||
type WAFWithOptions interface { | ||
NewTransactionWithOptions(opts ...Option) types.Transaction | ||
} |
This file contains 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 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 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 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 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 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 |
---|---|---|
|
@@ -45,5 +45,6 @@ type MatchedRule interface { | |
Rule() RuleMetadata | ||
|
||
AuditLog() string | ||
|
||
ErrorLog() string | ||
} |
This file contains 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