Skip to content

Commit

Permalink
Security fix -
Browse files Browse the repository at this point in the history
Restrict access to files on webserver by monitoring the request path content before allowing it to be accessed.
  • Loading branch information
samcrowther committed Apr 10, 2015
1 parent eb70a19 commit 2b441cd
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions lib/webPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,50 @@

};

/**
* This function scans through any webPanel request.
* if the request contains the 'path' query parameter then it will pass it
* through a check that ensures the following:
- it contains logs
- it contains 20xx
- it is accessing a .json file
* if it passess the checks it sends the request to the next webPanel function
* otherwise it returns a json error message
*/

webPanel.use(function(req, res, next){

var path = req.query.path

if(path!=null){

if(path.indexOf("logs")!=-1 && path.indexOf("20")!=-1 && path.indexOf(".json")!=-1) {

next();

} else {

var response = {};
response.error = true;
res.json(response);


}

} else {

next();
}




});


/**
* /api
Expand Down

0 comments on commit 2b441cd

Please sign in to comment.