-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
16 changed files
with
731 additions
and
549 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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const express = require('express'); | ||
const easyWaf = require('easy-waf'); | ||
const app = express(); | ||
|
||
app.use(easyWaf({ | ||
preBlockHook: (req, moduleInfo, ip) => { // Executed before a request is blocked. If false is returned, the request will not be blocked. | ||
if (moduleInfo.name === 'xss' | ||
&& ['::1', '127.0.0.1', '::ffff:127.0.0.1'].includes(ip) | ||
&& req.url.match('^[^?]*')[0] === '/test') { // Do not block xss from localhost at path /test | ||
return false; | ||
} | ||
}, | ||
postBlockHook: (req, moduleInfo, ip) => { // Executed after a request is blocked. See send-notification.js for an example. | ||
// ... | ||
} | ||
})); | ||
|
||
app.get('/get', function(req, res){ | ||
res.status(200).send(); | ||
}); | ||
|
||
app.listen(3000); |
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,29 @@ | ||
const express = require('express'); | ||
const easyWaf = require('easy-waf'); | ||
const nodemailer = require('nodemailer'); | ||
const app = express(); | ||
|
||
var mailTransporter = nodemailer.createTransport({ | ||
host: 'mail.example.com', | ||
port: 587, secure: false, | ||
auth: { user: 'user@example.com', pass: 'pass' } | ||
}); | ||
|
||
app.use(easyWaf({ | ||
postBlockHook: (req, moduleInfo, ip) => { // Executed after a request is blocked. | ||
mailTransporter.sendMail({ | ||
from: 'from@example.com', | ||
to: 'to@example.com', | ||
subject: `EasyWAF Blocked Request from ${ip}`, | ||
html: `Module: ${moduleInfo.name}<br>Url: ${req.url}<br>...` | ||
}).catch(function (e) { | ||
console.log('Error on sendMail: ' + e.message); | ||
}); | ||
} | ||
})); | ||
|
||
app.get('/get', function (req, res) { | ||
res.status(200).send(); | ||
}); | ||
|
||
app.listen(3000); |
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
Oops, something went wrong.