Note that there are some explanatory texts on larger screens.

plurals
  1. POSecure spreadsheet evaluation using JavaScript. Is it possible?
    primarykey
    data
    text
    <p>I was thinking about creating spreadsheets using JSON and JavaScript. This is actually rather a theoretical question about JavaScript.</p> <p>In some cases, it would be a lot more useful, when you could generate a whole column using a single function. Like in this example:</p> <pre><code>{ "type": "jsheet", "version": "1", "author": "John Doe", "title": "Example Spreadsheet", "groups": [ { "name": "Document Information", "columns": [ { "name": "Title", "rows": [ "_.title" ] }, { "name": "Author", "rows": [ "_.author" ] } ] } { "name": "Numbers 1-10", "columns": [ { "name": "Even numbers", "rows": "_.range(1,10).evens()" }, { "name": "Odd numbers", "rows": "_.range(1,10).odds()" } ] } ] } </code></pre> <p>This seems perfectly ok, when you work only with code from trusted source and only on your computer. But think about a cloud service like Google Drive. If users paste insecure code or open insecure spreadsheets, they can run into danger. For example, a script could manipulate the DOM, even could get access to cookies, perform requests and so on. Is there a way to securely prevent this from happening, without implementing a custom JavaScript parser?</p> <p>EDIT on Kenneth's answer: Of course I'm not planning to use <code>eval()</code> to parse the document itself. I'm only thinking about using <code>eval()</code>, or functions defined in the document to evaluate expressions. Think about the possibility of specifying a whole column using this single line of script: <code>_.range(1,10).evens()</code> or <code>_.range(10,200).filter(isprime)</code>. Where <code>_</code> is an object which has methods that return another objects, which have similar methods. Like the chain in jQuery and d3.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload