0
$\begingroup$

Is there any way to avoid malicious code when opening and executing entire notebooks automatically?

I have written code which opens a large series of notebooks one-by-one, evaluates them in their entirety and saves them as a new notebook. I don't believe the Mathematica code which I use to do this is particularly important here, but the notebooks I open are written by others and have a large amount of code in them, not merely data.

My primary goal is to prevent security issues affecting my system outside of Mathematica (deleting files, connecting to the internet, whatever). I am less concerned with later notebooks being affected by earlier ones via the kernel - for the moment my weak protection for that sort of contamination is to clear global variables before a subsequent notebook is opened.

I'm afraid I don't even know what to try, or I'd post it here, but any help would be greatly appreciated. I'd prefer to do this without Workbench as I've never used it, and I don't know if this would even be possible with Workbench.

$\endgroup$
6
  • 1
    $\begingroup$ You may be interested in list of dangerous functions $\endgroup$
    – Kuba
    Commented Mar 22, 2014 at 20:18
  • $\begingroup$ Thanks, that looks interesting indeed; I'll have a thorough read-through of it. $\endgroup$ Commented Mar 22, 2014 at 20:29
  • $\begingroup$ So your question could be reformulated to: how to prevent evaluationg parts of code containing functions from the list? where list is from linked question. What do you think? $\endgroup$
    – Kuba
    Commented Mar 22, 2014 at 20:32
  • $\begingroup$ Thanks @Kuba that's very useful. The list-of-dangerous-functions approach covers a lot of ground (perhaps it does cover everything?), but I was also hoping for a slightly broader consideration. $\endgroup$ Commented Mar 23, 2014 at 6:15
  • $\begingroup$ Thanks @Kuba - very useful. The list-of-dangerous-functions approach covers a lot of ground (eg. whitelisting), but I was also hoping for a slightly broader consideration. In utopia, there might be a way (a single setting, dreaming...?) to bless one notebook (my executing code) as all-powerful, while limiting code (or just Dynamic Content) from the notebooks being processed. Perhaps using different Contexts or separate Kernels is fruitful? Further out of the box might be forcing the incoming notebooks to be CDF, with which I am not yet familiar. (Question improvements still welcome.) $\endgroup$ Commented Mar 23, 2014 at 6:30

0

Browse other questions tagged or ask your own question.