microsoft / playwright-dotnet

.NET version of the Playwright testing and automation library.
https://playwright.dev/dotnet/
MIT License
2.47k stars 235 forks source link

[Feature] Allow to specify custom drivers path (for security reasons) #2317

Open BeniFreitag opened 2 years ago

BeniFreitag commented 2 years ago

We use playwright to serve PDF files in an ASP.NET Web Application (currently .NET 4.8 with IIS but soon .NET core with IIS).

For security reasons all files of the Web Application are on a separate drive at P:\Projects\ProjectName\Website. On that drive Users have no access, just the App-Pool user can access files of the appropriate Project itself. This way all applications are isolated from each other. There were security bulletins in the last years highly recommending that approach.

In that setup Playwright fails, because node can't open files in P:\Projects\ProjectName\.playwright\, unless the App-Pool user has Read-Permission on both P:\ and P:\Projects. Otherwise it throws PlaywrightException: Process exited (details below). But this breaks the security aspects of isolating each application completely.

It's probably an issue of node which can't handle permissions just granted on a deeper level than on the root of a drive. Probably it's not on the top priorities of node to ever fix that.

Suggestion: It would be valuable if the location of the .playwright directory could be specified in this case. Currently the .playwright directory must always be in the Application's directory. If it could be at a custom location, security can be configured as needed for node.

This is related to #2241 but affects both .NET 4.8 and ASP.NET Core. I could imagine that other projects will also benefit, if that .playwright directory could be in a custom path, for various reasons. #2241 would already solve that need.

Exception details (captured in transport.LogReceived):

node:internal/fs/utils:345 
    throw err; 
    ^ 

Error: EPERM: operation not permitted, lstat 'P:\' 
    at Object.realpathSync (node:fs:2461:5) 
    at toRealPath (node:internal/modules/cjs/loader:394:13) 
    at Function.Module._findPath (node:internal/modules/cjs/loader:550:22) 
    at resolveMainPath (node:internal/modules/run_main:19:25) 
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:71:24) 
    at node:internal/main/run_main_module:17:47 { 
  errno: -4048, 
  syscall: 'lstat', 
  code: 'EPERM', 
  path: 'P:\\' 
}
cmeyer001 commented 2 years ago

I'd like to see a custom driver path option as well. I have several dotnet automation projects that can reside on a PC and the current location requires a .playwright folder to be located under the project folder of each project on a PC. A custom location would allow a .playwright folder to have a central location for multiple apps rather than installing the same folder on the same PC in multiple locations.

pnocera commented 6 months ago

I'm hitting the same issue here. Do you guys have some hints on how to overcome this ? I'd like to still benefit from the lib updates.

bkbartonDesign commented 6 months ago

I'm looking for solutions to the same thing. +1