Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions lib/providers/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ var multiStat = function(paths) {
});
};

var symlinkPath = function(requestedpath, fullpath) {
var dirs = requestedpath.split('/');
if( dirs.length < 2) return false;
var basepath = fullpath.replace(new RegExp(requestedpath+"$"),"");
var testpath = basepath;
for( var i = 1; i < dirs.length-1; i++ ){
testpath = pathjoin(testpath, dirs[i]);
var stat = fs.lstatSync(testpath);
if( stat.isSymbolicLink() ){
return true;
}
}
};

module.exports = function(options) {
var etagCache = {};
var cwd = options.cwd || process.cwd();
Expand Down Expand Up @@ -85,9 +99,13 @@ module.exports = function(options) {
result.modified = stat.mtime.getTime();

if (!symlink) {
// Symlinks removed by default
if(stat.isSymb) {
return RSVP.reject({code: 'EINVAL'});
// Symlinks removed by default
if(stat.isSymb) {
return RSVP.reject({code: 'EINVAL'});
}
// If file is not symlink verify its not accessed by symlinked directory
if(symlinkPath(pathname, stat.path)) {
return RSVP.reject({code: 'EINVAL'});
}

}
Expand Down