I want to allow users to create their own Python scripts that run on the server and give output to the users. Likely I'll be allowing users to use Selenium in their scripts, and to write to files in a specific folder. I'm new to Python however assume there are security risks. How would you suggest I protect the server from malicious user code? Below is the C# code I'm using at present to run Python.
public static string Run()
{
string fileName = @"C:\temp\text.py";
Process p = new Process();
p.StartInfo = new ProcessStartInfo(@"python", fileName)
{
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
};
p.Start();
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
return output;
}