You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[](https://www.repostatus.org/#wip)
10
-
11
-
12
-
# Coraza Web Application Firewall
8
+
[](https://www.repostatus.org/#active)
13
9
14
-
15
-
Welcome to Coraza Web Application Firewall, this project is a Golang port of ModSecurity with the goal to become the first enterprise-grade Open Source Web Application Firewall, extensible enough to serve as the baseline for many projects.
Welcome to Coraza Web Application Firewall, this project is a Golang port of ModSecurity with the goal to become the first enterprise-grade Open Source Web Application Firewall, flexible and powerful enough to serve as the baseline for many projects.
18
14
19
15
## Prerequisites
20
16
@@ -36,12 +32,13 @@ Note this command will compile and install libinjection to your **LIBRARY_PATH**
36
32
## Running the test suite
37
33
38
34
Run the go tests:
35
+
39
36
```sh
40
37
go test ./...
41
38
go test -race ./...
42
39
```
43
40
44
-
### Run the test suite against OWASP CRS:
41
+
### Run the test suite against OWASP CRS
45
42
46
43
You can run the testsuite using our OWASP CRS test docker image, it will run a Coraza instance using Caddy and [go-ftw](https://github.com/fzipi/go-ftw)
47
44
@@ -52,7 +49,6 @@ docker build . -t crs
52
49
docker run crs -name crs
53
50
```
54
51
55
-
56
52
## Your first Coraza WAF project
57
53
58
54
Make sure ``CGO_ENABLED=1`` env is set before compiling and all dependencies are met.
@@ -61,8 +57,8 @@ Make sure ``CGO_ENABLED=1`` env is set before compiling and all dependencies are
61
57
package main
62
58
import(
63
59
"fmt"
64
-
"github.com/jptosso/coraza-waf/pkg/engine"
65
-
"github.com/jptosso/coraza-waf/pkg/seclang"
60
+
engine"github.com/jptosso/coraza-waf/v1"
61
+
"github.com/jptosso/coraza-waf/v1/seclang"
66
62
)
67
63
68
64
funcmain() {
@@ -93,8 +89,8 @@ Using the standard net/http library:
93
89
```go
94
90
package main
95
91
import(
96
-
"github.com/jptosso/coraza-waf/engine"
97
-
"github.com/jptosso/coraza-waf/seclang"
92
+
engine"github.com/jptosso/coraza-waf/v1"
93
+
"github.com/jptosso/coraza-waf/v1/seclang"
98
94
"net/http"
99
95
)
100
96
@@ -123,38 +119,23 @@ In order to avoid issues while handling long buffers Coraza provides the engine.
123
119
124
120
```go
125
121
funcsomeHandler(waf *engine.Waf) http.Handler {
126
-
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
127
-
tx:= waf.NewTransaction()
128
-
tx.ProcessRequest(r)
129
-
if tx.Interruption != nil {
130
-
SomeErrorPage(w)
131
-
}
132
-
// We will use the Coraza response reader:
133
-
tx.ProcessResponseHeaders()
134
-
tx.ResponseBuffer.Write([]byte("Some of the response body"))
135
-
tx.ProcessResponseBody()
136
-
// We will dump the buffered response into the response writer:
137
-
io.Copy(w, tx.ResponseBuffer)
138
-
})
122
+
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
123
+
tx:= waf.NewTransaction()
124
+
tx.ProcessRequest(r)
125
+
if tx.Interruption != nil {
126
+
SomeErrorPage(w)
127
+
}
128
+
// We will use the Coraza response reader:
129
+
tx.ProcessResponseHeaders()
130
+
tx.ResponseBuffer.Write([]byte("Some of the response body"))
131
+
tx.ProcessResponseBody()
132
+
// We will dump the buffered response into the response writer:
133
+
io.Copy(w, tx.ResponseBuffer)
134
+
})
139
135
}
140
-
```
141
-
142
-
We can create our own implementation of [http.ResponseWriter](https://pkg.go.dev/net/http#ResponseWriter), see [examples/response_writer.go](#).
143
-
144
-
## Using the embedded sandbox
145
136
146
-
Coraza WAF repository contains a Sandbox package that can be used to test rules and the Core Ruleset.
147
-
148
-
You may use the sandbox with the following command:
149
-
150
-
```sh
151
-
CGO_ENABLED=1 go run cmd/sandbox/main.go -port 8000 -crs ../coreruleset/rules
152
137
```
153
138
154
-
It will start the sandobox at [http://127.0.0.1:8000/](http://127.0.0.1:8000/)
155
-
156
-
Please note that Coraza Sandbox is not intended to face the public internet, if you do so you may get hacked. Future versions will contain settings to avoid unsafe operations like remote resources, command execution and lua.
157
-
158
139
## Compatibility status
159
140
160
141
We have currently achieved a 91% compatibility with OWASP CRS, some features are under development, like:
@@ -186,7 +167,7 @@ We have currently achieved a 91% compatibility with OWASP CRS, some features are
186
167
* Open Policy Agent package (OPA)
187
168
* Online sandbox
188
169
* HTTP/2 and HTTP/3 support
189
-
* Enhanced rule profiling
170
+
* Enhanced rule profiling
190
171
* Native antivirus integration (maybe)
191
172
* Automatic coreruleset integration (download and setup) (maybe)
192
173
* Enhanced data masking features
@@ -202,6 +183,11 @@ We have currently achieved a 91% compatibility with OWASP CRS, some features are
202
183
*[Gin Middleware (Web Framework)](#) (soon)
203
184
*[Buffalo Plugin (Web Framework)](#) (soon)
204
185
186
+
## Some useful tools
187
+
188
+
*[Go FTW](#): rule testing engine
189
+
*[Coraza Sandbox](#): rule testing sandbox with web interface
0 commit comments