github.com/crowdsecurity/crowdsec@v1.6.1/pkg/appsec/tx.go (about) 1 package appsec 2 3 import ( 4 "github.com/crowdsecurity/coraza/v3" 5 "github.com/crowdsecurity/coraza/v3/experimental" 6 "github.com/crowdsecurity/coraza/v3/experimental/plugins/plugintypes" 7 "github.com/crowdsecurity/coraza/v3/types" 8 ) 9 10 type ExtendedTransaction struct { 11 Tx experimental.FullTransaction 12 } 13 14 func NewExtendedTransaction(engine coraza.WAF, uuid string) ExtendedTransaction { 15 inBoundTx := engine.NewTransactionWithID(uuid) 16 expTx := inBoundTx.(experimental.FullTransaction) 17 tx := NewTransaction(expTx) 18 return tx 19 } 20 21 func NewTransaction(tx experimental.FullTransaction) ExtendedTransaction { 22 return ExtendedTransaction{Tx: tx} 23 } 24 25 func (t *ExtendedTransaction) RemoveRuleByIDWithError(id int) error { 26 t.Tx.RemoveRuleByID(id) 27 return nil 28 } 29 30 func (t *ExtendedTransaction) RemoveRuleByTagWithError(tag string) error { 31 t.Tx.RemoveRuleByTag(tag) 32 return nil 33 } 34 35 func (t *ExtendedTransaction) IsRuleEngineOff() bool { 36 return t.Tx.IsRuleEngineOff() 37 } 38 39 func (t *ExtendedTransaction) ProcessLogging() { 40 t.Tx.ProcessLogging() 41 } 42 43 func (t *ExtendedTransaction) ProcessConnection(client string, cPort int, server string, sPort int) { 44 t.Tx.ProcessConnection(client, cPort, server, sPort) 45 } 46 47 func (t *ExtendedTransaction) AddGetRequestArgument(name string, value string) { 48 t.Tx.AddGetRequestArgument(name, value) 49 } 50 51 func (t *ExtendedTransaction) ProcessURI(uri string, method string, httpVersion string) { 52 t.Tx.ProcessURI(uri, method, httpVersion) 53 } 54 55 func (t *ExtendedTransaction) AddRequestHeader(name string, value string) { 56 t.Tx.AddRequestHeader(name, value) 57 } 58 59 func (t *ExtendedTransaction) SetServerName(name string) { 60 t.Tx.SetServerName(name) 61 } 62 63 func (t *ExtendedTransaction) ProcessRequestHeaders() *types.Interruption { 64 return t.Tx.ProcessRequestHeaders() 65 } 66 67 func (t *ExtendedTransaction) ProcessRequestBody() (*types.Interruption, error) { 68 return t.Tx.ProcessRequestBody() 69 } 70 71 func (t *ExtendedTransaction) WriteRequestBody(body []byte) (*types.Interruption, int, error) { 72 return t.Tx.WriteRequestBody(body) 73 } 74 75 func (t *ExtendedTransaction) Interruption() *types.Interruption { 76 return t.Tx.Interruption() 77 } 78 79 func (t *ExtendedTransaction) IsInterrupted() bool { 80 return t.Tx.IsInterrupted() 81 } 82 83 func (t *ExtendedTransaction) Variables() plugintypes.TransactionVariables { 84 return t.Tx.Variables() 85 } 86 87 func (t *ExtendedTransaction) MatchedRules() []types.MatchedRule { 88 return t.Tx.MatchedRules() 89 } 90 91 func (t *ExtendedTransaction) ID() string { 92 return t.Tx.ID() 93 }