Developers' Forum

Print to server stdout/stderr from inside question template

Re: Print to server stdout/stderr from inside question template

by Richard Lobb -
Number of replies: 0

Allowing jobs to output to the Jobe server itself rather goes against the design of Jobe, which is meant to be stateless, apart from the caching of files. If question authors are able to generate such output within the template code, students would also be able to generate it, potentially corrupting or overloading your logs. It would be a bit of a security flaw.

That said, most students aren't actually out to crash your system, especially when they know that all their CodeRunner actions are being logged and any attacks are likely to be sheeted back to them. So some things you could try are:

  1. Set up a special log file, writable by all, within JobeInAbox. Write your output to that instead of stdout. Use a script in the server running JobeInABox to download/sync the contents of that file to the server.
  2. Set up a directory on the server to contain the log file and mount it as a volume within jobeinabox. Then you don't have to do any syncing.
  3. Install a database server like mysql on your Jobe server and open a container port to allow JobeInABox to access it. Have your template add log records to the database. This is somewhat more secure than 1 and 2, because you would need a password to access the database. However, done simplistically, students' code would still be able to read the code that is being run and extract the password from it.
Of course, Apache's access.log file records all the runs, and Jobe has its own log files too. So if all you want to do is gather usage stats, you can get them from those files. But I'm assuming you want to log additional things, like the name of the user or information extracted from their submission?