How to validate a Unix path?

shoemoney

New Member
I'm trying to write a simple C# function to validate a full Unix path to a shell script entered by a user to avoid a couple of things:
  • The path is in correct format, no invalid symbols, like spaces or semi-colons
  • There are no suspicious commands, e.g. \[code\]rm -rf /\[/code\]
  • The path represents a full path, no relatives
  • It does not matter if the script actually exists
The function would take a form like,\[code\]public bool IsUnixPathValid(string path){ return ???; // Do actual validation}\[/code\]Question: Is there an existing library that would perform something like this? And if not, what would be the best approach and what little details should I look out for (think secure).
 
Back
Top