Validate scripts before saving
This commit is contained in:
1 parent
b342cfd159
commit
bdcb856655
1 file changed
+13
@@ -41,6 +41,7 @@
|
|||||||
url = require 'url'
|
url = require 'url'
|
||||||
mongodb = require 'mongodb'
|
mongodb = require 'mongodb'
|
||||||
querystring = require 'querystring'
|
querystring = require 'querystring'
|
||||||
|
vm = require 'vm'
|
||||||
|
|
||||||
config = require './config'
|
config = require './config'
|
||||||
common = require './common'
|
common = require './common'
|
||||||
@@ -156,6 +157,12 @@ listener = (request, response) ->
|
|||||||
_id: provisionName
|
_id: provisionName
|
||||||
script: body.toString()
|
script: body.toString()
|
||||||
}
|
}
|
||||||
|
try
|
||||||
|
new vm.Script("\"use strict\";(function(){\n#{object.script}\n})();")
|
||||||
|
catch err
|
||||||
|
response.writeHead(400)
|
||||||
|
response.end("#{err.name}: #{err.message}")
|
||||||
|
return
|
||||||
|
|
||||||
db.provisionsCollection.save(object, (err) ->
|
db.provisionsCollection.save(object, (err) ->
|
||||||
return throwError(err, response) if err
|
return throwError(err, response) if err
|
||||||
@@ -184,6 +191,12 @@ listener = (request, response) ->
|
|||||||
_id: virtualParameterName
|
_id: virtualParameterName
|
||||||
script: body.toString()
|
script: body.toString()
|
||||||
}
|
}
|
||||||
|
try
|
||||||
|
new vm.Script("\"use strict\";(function(){\n#{object.script}\n})();")
|
||||||
|
catch err
|
||||||
|
response.writeHead(400)
|
||||||
|
response.end("#{err.name}: #{err.message}")
|
||||||
|
return
|
||||||
|
|
||||||
db.virtualParametersCollection.save(object, (err) ->
|
db.virtualParametersCollection.save(object, (err) ->
|
||||||
return throwError(err, response) if err
|
return throwError(err, response) if err
|
||||||
|
|||||||
Reference in new issue
Block a user