Skip to content

Commit 1e797df

Browse files
authored
New v1 release candidate (#60)
* first mayor update, release v1
1 parent 144ee69 commit 1e797df

156 files changed

Lines changed: 421 additions & 1128 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/regression.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Download vendored dependencies
3333
run: go mod vendor
3434
- name: Tests and coverage
35-
run: CGO_ENABLED=1 go test -v -coverpkg=./... -coverprofile=docs/coverage-waf.out ./...
35+
run: CGO_ENABLED=1 go test -v -coverpkg=./... -coverprofile=coverage-waf.out ./...
3636
- name: SonarCloud Scan
3737
uses: sonarsource/sonarcloud-github-action@master
3838
env:

.vscode/launch.json

Lines changed: 0 additions & 53 deletions
This file was deleted.

readme.md renamed to README.md

Lines changed: 39 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
<img src="https://github.com/jptosso/coraza-waf/raw/master/docs/logo.png" width="50%">
1+
# Coraza Web Application Firewall
22

33
![Build Status](https://github.com/jptosso/coraza-waf/actions/workflows/regression.yml/badge.svg)
44
![CodeQL](https://github.com/jptosso/coraza-waf/workflows/CodeQL/badge.svg)
5-
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=jptosso_coraza-waf&metric=bugs)](https://sonarcloud.io/dashboard?id=jptosso_coraza-waf)
65
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=jptosso_coraza-waf&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=jptosso_coraza-waf)
76
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=jptosso_coraza-waf&metric=coverage)](https://sonarcloud.io/dashboard?id=jptosso_coraza-waf)
87
[![GoDoc](https://godoc.org/github.com/jptosso/coraza-waf?status.svg)](https://godoc.org/github.com/jptosso/coraza-waf)
9-
[![Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip)
10-
11-
12-
# Coraza Web Application Firewall
8+
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
139

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.
16-
17-
Please note Coraza is still a WIP.
10+
<div align="center">
11+
<img src="https://jptosso.github.io/coraza-waf/images/company_logo.png" width="50%">
12+
</div>
13+
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.
1814

1915
## Prerequisites
2016

@@ -36,12 +32,13 @@ Note this command will compile and install libinjection to your **LIBRARY_PATH**
3632
## Running the test suite
3733

3834
Run the go tests:
35+
3936
```sh
4037
go test ./...
4138
go test -race ./...
4239
```
4340

44-
### Run the test suite against OWASP CRS:
41+
### Run the test suite against OWASP CRS
4542

4643
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)
4744

@@ -52,7 +49,6 @@ docker build . -t crs
5249
docker run crs -name crs
5350
```
5451

55-
5652
## Your first Coraza WAF project
5753

5854
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
6157
package main
6258
import(
6359
"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"
6662
)
6763

6864
func main() {
@@ -93,8 +89,8 @@ Using the standard net/http library:
9389
```go
9490
package main
9591
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"
9894
"net/http"
9995
)
10096

@@ -123,38 +119,23 @@ In order to avoid issues while handling long buffers Coraza provides the engine.
123119

124120
```go
125121
func someHandler(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+
})
139135
}
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
145136

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
152137
```
153138

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-
158139
## Compatibility status
159140

160141
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
186167
* Open Policy Agent package (OPA)
187168
* Online sandbox
188169
* HTTP/2 and HTTP/3 support
189-
* Enhanced rule profiling
170+
* Enhanced rule profiling
190171
* Native antivirus integration (maybe)
191172
* Automatic coreruleset integration (download and setup) (maybe)
192173
* Enhanced data masking features
@@ -202,6 +183,11 @@ We have currently achieved a 91% compatibility with OWASP CRS, some features are
202183
* [Gin Middleware (Web Framework)](#) (soon)
203184
* [Buffalo Plugin (Web Framework)](#) (soon)
204185

186+
## Some useful tools
187+
188+
* [Go FTW](#): rule testing engine
189+
* [Coraza Sandbox](#): rule testing sandbox with web interface
190+
205191
## Troubleshooting
206192

207193
## How to contribute
@@ -215,7 +201,13 @@ egrep -Rin "TODO|FIXME" -R --exclude-dir=vendor *
215201

216202
## Useful links
217203

218-
## Special thanks
204+
## Special thanks
219205

220206
* Modsecurity team for creating SecLang
221-
* OWASP Coreruleset team for the CRS and their feedback
207+
* OWASP Coreruleset team for the CRS and their feedback
208+
209+
## About
210+
211+
The name **Coraza** is trademarked, **Coraza** is a registered trademark of Juan Pablo Tosso.
212+
213+
* Author on Twitter [@jptosso](https://twitter.com/jptosso)

SECURITY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ Versions currently being supported with security updates.
66

77
| Version | Supported |
88
| ------- | ------------------ |
9-
| 0.1.x | :white_check_mark: |
9+
| v1.x | :white_check_mark: |
1010

1111
## Reporting a Vulnerability
1212

13-
Please send any vulnerability to [email protected] before making them public, as Coraza is a WIP, we will just provide a thank you note on the PR.
13+
Please send any vulnerability to [email protected] before making them public, as Coraza is a WIP, we will just provide a thank you note on the PR.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
package actions
1616

1717
import (
18-
"github.com/jptosso/coraza-waf/pkg/engine"
18+
engine "github.com/jptosso/coraza-waf/v1"
1919
)
2020

2121
func ActionsMap() map[string]engine.Action {
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@
1515
package actions
1616

1717
import (
18-
"github.com/jptosso/coraza-waf/pkg/engine"
18+
"fmt"
19+
20+
engine "github.com/jptosso/coraza-waf/v1"
1921
)
2022

2123
//0 nothing, 1 phase, 2 request
2224
type Allow struct {
2325
allow int
2426
}
2527

26-
func (a *Allow) Init(r *engine.Rule, b1 string) string {
28+
func (a *Allow) Init(r *engine.Rule, b1 string) error {
2729
// Does not require
2830
if b1 == "phase" {
2931
a.allow = 1
@@ -32,9 +34,9 @@ func (a *Allow) Init(r *engine.Rule, b1 string) string {
3234
} else if b1 == "" {
3335
a.allow = 0
3436
} else {
35-
return "Invalid value for action allow"
37+
fmt.Errorf("Invalid value for action allow")
3638
}
37-
return ""
39+
return nil
3840
}
3941

4042
func (a *Allow) Evaluate(r *engine.Rule, tx *engine.Transaction) {
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,15 @@
1414

1515
package actions
1616

17-
import (
18-
"github.com/jptosso/coraza-waf/pkg/engine"
19-
)
17+
import engine "github.com/jptosso/coraza-waf/v1"
2018

2119
type Append struct {
2220
Data string
2321
}
2422

25-
func (a *Append) Init(r *engine.Rule, data string) string {
23+
func (a *Append) Init(r *engine.Rule, data string) error {
2624
a.Data = data
27-
return ""
25+
return nil
2826
}
2927

3028
func (a *Append) Evaluate(r *engine.Rule, tx *engine.Transaction) {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
package actions
1616

1717
import (
18-
"github.com/jptosso/coraza-waf/pkg/engine"
18+
engine "github.com/jptosso/coraza-waf/v1"
1919
)
2020

2121
type Block struct{}
2222

23-
func (a *Block) Init(r *engine.Rule, b1 string) string {
23+
func (a *Block) Init(r *engine.Rule, b1 string) error {
2424
r.DisruptiveAction = engine.ACTION_DISRUPTIVE_BLOCK
25-
return ""
25+
return nil
2626
}
2727

2828
func (a *Block) Evaluate(r *engine.Rule, tx *engine.Transaction) {
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@
1414

1515
package actions
1616

17-
import (
18-
"github.com/jptosso/coraza-waf/pkg/engine"
19-
)
17+
import engine "github.com/jptosso/coraza-waf/v1"
2018

2119
type Capture struct{}
2220

23-
func (a *Capture) Init(r *engine.Rule, b1 string) string {
21+
func (a *Capture) Init(r *engine.Rule, b1 string) error {
2422
//r.Capture = true
25-
return ""
23+
return nil
2624
}
2725

2826
func (a *Capture) Evaluate(r *engine.Rule, tx *engine.Transaction) {
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@
1414

1515
package actions
1616

17-
import (
18-
"github.com/jptosso/coraza-waf/pkg/engine"
19-
)
17+
import engine "github.com/jptosso/coraza-waf/v1"
2018

2119
type Chain struct{}
2220

23-
func (a *Chain) Init(r *engine.Rule, b1 string) string {
21+
func (a *Chain) Init(r *engine.Rule, b1 string) error {
2422
r.HasChain = true
25-
return ""
23+
return nil
2624
}
2725

2826
func (a *Chain) Evaluate(r *engine.Rule, tx *engine.Transaction) {

0 commit comments

Comments
 (0)