kartikk221 / live-directory

A Simple-To-Use Dynamic Template Content Manager For Webservers
MIT License
11 stars 5 forks source link

live-driectory issue with symbolic link to folders #12

Open matteo-cristino opened 5 months ago

matteo-cristino commented 5 months ago

When inside the folder for which you are creating a new liveDirectory object is present a symbolic link to a folder, the initialization of the object fails with

node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[Error: EISDIR: illegal operation on a directory, read] {
  errno: -21,
  code: 'EISDIR',
  syscall: 'read'
}

This seems due to the _initialize function https://github.com/kartikk221/live-directory/blob/7dd54e2b27015c2d79438377320bbb0c283c13b0/src/components/LiveDirectory.js#L166-L190 in which it is missing a branching for symlink

if(content.isSymbolicLink()) {
  // manage the symlink
}

and thus if it is not a directory it is solved as file, but trying to read a symlink of a folder will get the error on top of this issue.

kartikk221 commented 5 months ago

Interesting, I would assume the content would provide the file path of the original source which can then be loaded into memory? If you have a potential solution in mind which wouldn't hinder performance too much, feel free to make a PR. I would also assume there should be an option to enable or disable symbolic link resolving for tigther security to prevent the filesystem resolves from escaping the target directoy in any way.

matteo-cristino commented 3 weeks ago

Hi there! Thank you for the the PR merge, I'm glad to be part of this project 🙌

I was wondering (if you are satisfied with the code) can you can create a new release over https://npmjs.com? So I can use symbolic links in my project. Thank you very much