Skip to content

Commit

Permalink
updating documentation - adding more usage example. Changing version …
Browse files Browse the repository at this point in the history
…for npm package push with new documentation and changes...
  • Loading branch information
undertuga committed Nov 6, 2019
1 parent 78889e1 commit 59c7f42
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ In order to install ***WAF-JS*** package, simply run: <br>
---

#### Available Methods
- ***isBotCheck(req.headers['user-agent'])***
- ***isBotCheck({'user-agent'})***
Based on pre-defined rules / signatures (with the possibility of extending them), and taking the ``user-agent`` field from the request headers, it tries to check of the request is from a known bot / crawler / spider, etc.. Receives the ***user-agent*** as argument and returns a boolean value (if bot: ***true*** | not bot: ***false***)

- ***extendBotSigs({signatures})***
Expand All @@ -35,11 +35,11 @@ Allows the extensions of pre-defined bot / crawlers, spiders, etc... signatures.
- ***removeBotSig({signature})***
Removes a signature from the list.

- ***reqCheck(req.method, req.headers['content-type'])***
- ***reqCheck({request method}, {content-type})***
Checks the request, analysing the HTTP request method and content type, and matching it with the given config (allowed methods & content types).
Receives the request method and request headers ***content-type*** property and returns a boolean value (valid / allowed request: ***true*** | invalid / forbidden request: ***false***)

- ***wafChecks(req.headers['user-agent'], req.method, req.headers['content-type'])***
- ***wafChecks({user-agent}, {request method}, {content-type})***
Performs both checks (bot and requests) returning a boolean value as response, according with the validity of the request components.
Receives the request headers ***user-agent*** property, the request method and the request headers ***content-type*** property as parameters.
Returns a boolean (not a bot AND valid request: ***true*** | is bot OR invalid request: ***false***)
Expand Down Expand Up @@ -74,6 +74,27 @@ if(_wafjs.isBotCheck(req.headers['user-agent'])){
res.end()
}


// usage example | extend bot signatures
_wafjs.extendBotSigs(['newSig#1', 'newSig#2'])


// usage example | remove signature
_wafjs.removeBotSig('newSig#1')


// usage example | request check
if(_wafjs.reqCheck(req.method, req.headers['content-type'])){
res.statusCode = 403
res.end()
}


// usage example | waf checks
if(_wafjs.wafChecks(req.headers['user-agent'], req.method, req.headers['content-type'])){
res.statusCode = 403
res.end()
}
````

---
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wafjs",
"version": "1.0.0",
"version": "1.0.1",
"description": "Simple WAF to integrate with Node.js web systems",
"main": "lib/waf.js",
"scripts": {
Expand Down

0 comments on commit 59c7f42

Please sign in to comment.