GithubHelp home page GithubHelp logo

microsoft / waflab Goto Github PK

View Code? Open in Web Editor NEW
27.0 6.0 9.0 1.75 MB

A web-based testing platform for WAF (Web Application Firewall)'s correctness

Home Page: https://waflab.org

License: MIT License

Go 61.29% HTML 0.82% CSS 0.92% JavaScript 36.69% Dockerfile 0.28%
modsecurity modsecurity-core-rule-set core-rule-set waf

waflab's Introduction

WAFLab 🐾

WAFLab is a web-based platform for testing WAFs.

Live Demo

https://waflab.org/

Architecture

WAFLab contains 2 parts:

Name Description Language Source code
Frontend Web frontend UI for WAFLab Javascript + React + Ant Design https://github.com/microsoft/waflab/tree/master/web
Backend RESTful API backend for WAFLab Golang + Beego + MySQL https://github.com/microsoft/waflab

Installation

Prerequisites

Server-side

Get the source code from Github via Git

git clone https://github.com/microsoft/waflab.git

Set up the database

WAFLab use database to store generated testcases and test results.

Prepare a Xorm ORM supported database (MySQL is recommended), replace root:123@tcp(localhost:3306)/ in conf/app.conf with your own connection string. WAFLab will create a database named waflab and necessary tables in it if not exist. All Xorm supported databases are listed here.

Use docker-compose

You can start the application if you have docker-compose installed by

docker-compose up

Then, you can access the frontend UI via localhost:7000. Alternatively, you can also set up the frontend and backend separately using following method.

Setup Go backend

Run Server-backend (at port 7070 by default):

cd waflab
go run main.go

Use your own WAFBench image (optional)

If you want to add some customized behavior to the package sending process. You can use your own WAFBench image. Once your made the change to the WAFBench codebase, you need to build a new Docker image and upload it to DockerHub.

cd WAFBench
docker build . -t org/wafbench
docker login
docker push org/wafbench

Then, change the docker.io/waflab/wafbench within docker/master.go to the image you just build. Ex. docker.io/org/wafbench

Setup frontend web UI

Install the frontend dependencies with NPM (or Yarn if you like):

cd waflab/web
npm install

Run frontend (at port 7000 by default):

npm start

WAFLab web UI is now avaliable at: http://localhost:7000

Build frontend into static files and it will be served by Go server at port 7070 together with backend API:

npm build

License

This project is licensed under the MIT license.

If you have any issues or feature requests, please contact us. PR is welcomed.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

waflab's People

Contributors

gumulaola avatar hsluoyz avatar olament avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

waflab's Issues

Problem starting using compose

Trying to get this working, but fails on docker compose up:

❯ docker compose up
[+] Running 2/0
 ⠿ Container waflab_frontend_1  Created                                                                           0.0s
 ⠿ Container waflab_backend_1   Created                                                                           0.0s
Attaching to backend_1, frontend_1
backend_1   | {"status":"Pulling from waflab/wafbench","id":"latest"}
backend_1   | {"status":"Digest: sha256:1e94302e53cee0e390b2b7a13fb28f971fa39ac99f9a9b0a0d7a9fef7e0520c0"}
backend_1   | {"status":"Status: Image is up to date for waflab/wafbench:latest"}
backend_1   | panic: Error response from daemon: container cannot be disconnected from host network or connected to host network
backend_1   |
backend_1   | goroutine 1 [running]:
backend_1   | github.com/waflab/waflab/docker.MakeMaster(0x5, 0x200000003)
backend_1   | 	/go/src/app/docker/master.go:134 +0x410
backend_1   | github.com/waflab/waflab/object.InitMaster(...)
backend_1   | 	/go/src/app/object/run.go:18
backend_1   | main.main()
backend_1   | 	/go/src/app/main.go:15 +0x34
backend_1 exited with code 2

Is something additionally required?

Command `waflab generate` panics generating tests

Hi Team!

Cannot get waflab generate to work. After building the container, generate panics:

root@docker-desktop:/go/src/app# waflab generate repos/coreruleset/rules/ repos/coreruleset/tests/regression/ -c 1
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0xbbc209]

goroutine 1 [running]:
github.com/waflab/waflab/cmd/command.generateTestfile.func1(0x0, 0x0, 0x0, 0x0, 0xe66c20, 0xc00036d380, 0x2, 0x2)
	/go/src/app/cmd/command/utils.go:21 +0x49
path/filepath.Walk(0x0, 0x0, 0xc00035fc70, 0x32, 0x135e840)
	/usr/local/go/src/path/filepath/path.go:499 +0x7e
github.com/waflab/waflab/cmd/command.generateTestfile(0x0, 0x0, 0x1, 0x3, 0x3, 0x2, 0xc00000f980, 0xc00035fd58)
	/go/src/app/cmd/command/utils.go:20 +0x85
github.com/waflab/waflab/cmd/command.generate(0x1320c60, 0xc0003a0e80, 0x2, 0x4)
	/go/src/app/cmd/command/generate.go:37 +0x9a
github.com/spf13/cobra.(*Command).execute(0x1320c60, 0xc0003a0e40, 0x4, 0x4, 0x1320c60, 0xc0003a0e40)
	/go/pkg/mod/github.com/spf13/[email protected]/command.go:856 +0x2c2
github.com/spf13/cobra.(*Command).ExecuteC(0x1320ee0, 0xc00035ff58, 0x2, 0x2)
	/go/pkg/mod/github.com/spf13/[email protected]/command.go:960 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
	/go/pkg/mod/github.com/spf13/[email protected]/command.go:897
github.com/waflab/waflab/cmd/command.Execute()
	/go/src/app/cmd/command/root.go:35 +0x7d
main.main()
	/go/src/app/cmd/main.go:6 +0x25

Error generating tests for coreruleset v3.4/dev branch

root@docker-desktop:/go/src/app/repos/coreruleset# git checkout v3.4/dev
Switched to branch 'v3.4/dev'
Your branch is up to date with 'origin/v3.4/dev'.
root@docker-desktop:/go/src/app/repos/coreruleset# cd ../..
root@docker-desktop:/go/src/app# waflab generate
repos/coreruleset/rules
2021/12/16 13:41:41 Err while parsing rule string SecRule TX:EXECUTING_PARANOIA_LEVEL "@lt 1" "id:932011,phase:1,pass,nolog,skipAfter:END-REQUEST-932-APPLICATION-ATTACK-RCE"
SecRule TX:EXECUTING_PARANOIA_LEVEL "@lt 1" "id:932012,phase:2,pass,nolog,skipAfter:END-REQUEST-932-APPLICATION-ATTACK-RCE"

Live demo?

Is it me, or the live demo is not live anymore?

How does `logContains` work for you?

Hi! I'm wondering how are you reading logs for testing that the waf is matching.

  • from reading the logContains method in
    func logContains(expression string, logPath string) (bool, error) {
    , the match looks only a regexp match in the file
  • this will not work unless each test fires up one and just one rule per test. That is not the common case.

👉 what ftw and go-ftw have been doing is reading the log backwards until the time of the request. I don't see that here.

Can you please explain what is your use case, and how does it work for you?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.