eval

Evaluate function within package environment without attaching package

﹥>﹥吖頭↗ 提交于 2019-12-24 02:56:15
问题 Background I would like to evaluate a set of R function with a package environment without attaching this package I would like to avoid using package:: Example Data Given sample dummy data set: # Data -------------------------------------------------------------------- tmpCSV <- tempfile(fileext = ".CSV", pattern = "mtcars_data_") write.csv(x = mtcars[, 1:5], file = tmpCSV, row.names = FALSE) # Confirm # readLines(con = tmpCSV)[1] Reading library I could read it with use of read_csv function

Is the a ScriptEngine or eval()-like function in Swift?

余生颓废 提交于 2019-12-24 02:25:37
问题 In Java, we can build up expressions to be called using ScriptEngine . This is nice for building up frameworks based on a common naming convention. In JavaScript, there is of course eval() . Does Swift have some sort of mechanism for evaluating a string which contains a swift expression? I'm aware that this could be potentially abused; however, it would simplify my present development. 回答1: No. Swift is a compiled language, and the runtime doesn't include the compiler. The iOS SDK doesn't

String containing code to executable function

╄→尐↘猪︶ㄣ 提交于 2019-12-24 02:06:41
问题 I basically want to convert a string containing code like this - var code = "function Solve(args) { // do stuff and return value};"; into an executable function which you can pass arguments. When I use it with eval(code + "Solve(args);"); It gives me no errors but the results are not as expected. I also tried: var fu = eval(code); var result = fu(args); fu stays undefined. Am I doing something wrong or is there a better way to do this. 回答1: Using eval is normally a very bad way of doing

Python之eval函数实例解释

我与影子孤独终老i 提交于 2019-12-24 01:19:42
源码 def set_value(self, key, value): logger.debug('DataBus: Storing key: [%s] value: [%s]', key, value) a = "[random.randint(0,1) for b in range(0,128)]" b = "[0 for b in range(0,32)]" c = "1 + 2" set_value(key, eval(value)) 结果 [1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0,

php 安全基础 附录B. 函数

蹲街弑〆低调 提交于 2019-12-24 00:52:00
附录B. 函数 在我写作本书的时候,http://php.net/quickref.php列出了共3917个函数,其中包括一些类似函数的语法结构,在此我不准备把它们从函数中区分开来,而是把它作为函数看待。 由于函数数量很大,一一说明它们的正确及安全用法是不太可能的。在此我选出了我认为最需要注意的函数。选择的标准包括使用的频繁度、使用时的危险(安全)度及我本人的经验。 对于每一个列出的函数,我都会提供推荐的使用方法。在提出这些方法时,我会把安全作为重点考虑。请在实际使用时根据你的需求进行相应调整。 当一个函数与另一个有相同的风险时,我会给出参见另一个函数的信息,而不是多余地再次描述一遍。 B.1. eval( ) eval( )函数用于对一个字符串以PHP语句方式解析运行。如: <?php $name = 'Chris'; $string = 'echo "Hello, $name";'; eval($string); ?> 上例中会把$string作为PHP语句来运行,因此等价于: <?php $name = 'Chris'; echo "Hello, $name"; ?> 虽然eval( )非常有用,但是当使用了被污染数据时会非常危险。例如,在下例中,如果$name是被污染的,攻击者可以任意运行PHP代码: <?php $name = $_GET['name']; eval(

PHP漏洞全解(二)-命令注入攻击

孤人 提交于 2019-12-24 00:50:41
本文主要介绍针对PHP网站常见的攻击方式中的命令攻击。Command Injection,即命令注入攻击,是指这样一种攻击手段,黑客通过把HTML代码输入一个输入机制(例如缺乏有效验证限制的表格域)来改变网页的动态 生成的内容。使用系统命令是一项危险的操作,尤其在你试图使用远程数据来构造要执行的命令时更是如此。如果使用了被污染数据,命令注入漏洞就产生了。 命令注入攻击 PHP中可以使用下列5个函数来执行外部的应用程序或函数 system、exec、passthru、shell_exec、“(与shell_exec功能相同) 函数原型 string system(string command, int &return_var) command 要执行的命令 return_var 存放执行命令的执行后的状态值 string exec (string command, array &output, int &return_var) command 要执行的命令 output 获得执行命令输出的每一行字符串 return_var 存放执行命令后的状态值 void passthru (string command, int &return_var) command 要执行的命令 return_var 存放执行命令后的状态值 string shell_exec (string command)

Can't eval break statement

删除回忆录丶 提交于 2019-12-24 00:25:46
问题 Why is this piece of code : var myBreak = 'break;'; for(var i=0; i < 5; i++) { console.log('i is : ' + i); eval(myBreak); } console.log('done !'); triggering the : unlabelled break must be inside loop or switch error message in Firebug in place of returning done ! in the console ? Is it not possible to eval() break statements ? Thank you in advance ! EDIT : I'm getting confused now. ^^ Why does it fail ? Is Jack Wanders right then with eval having it's own 'execution context' ? If yes, why

Call to eval() blocked by CSP with Selenium IDE

倖福魔咒の 提交于 2019-12-24 00:02:52
问题 I have a selenium test developed in Selenium IDE . I have a step in this suite that should type a value in a text field. It fails at that step giving the following error: 18. click on id=firstName Failed:11:12:59 call to eval() blocked by CSP 回答1: CSP Content Security Policy (CSP) acts as a added layer of security that helps to detect and mitigate attacks including Cross Site Scripting (XSS) and data injection attacks. These attacks are primarily used for data theft and distribution of

Why does SBCL eval function lose the macrolet it's running in?

纵然是瞬间 提交于 2019-12-23 17:58:21
问题 (print x) prints exactly what I want to eval, but (eval x) fails, but if I run x it works! What am I missing? Please tell me why this doesn't work, or if I'm doing something stupid. I'm trying to print a table of dynamic size and setting lambda variables to eventually evaluate an expression for each cell in the table. BTW I figured out why eval fails. (eval x) is losing the macrolet, but WHY?! This works: (defvar varlist '(a b c d)) (defvar vvars '(c d)) (defvar hvars '(a b)) (macrolet (

How do I eval a simple math formula inside a MySQL stored _function_?

試著忘記壹切 提交于 2019-12-23 17:43:52
问题 Inside my stored function I have : formula := "(10+10 * 1000)/12"; (a simple math formula, with numbers only, dynamically created as a string) How do I eval this, and return the result ? I can't use EXECUTE (not possible inside a stored function) and if I make it a stored procedure and call it from a stored function, I get "Dynamic SQL is not allowed in stored function or trigger" -as if I would have the eval directly inside the function. I need a stored function, and not a procedure, because