我希望在替换有害数据时启用xss_clean()的数据库日志记录。
我想在Security.php中启用Security.php()函数的数据库日志记录,基本上我想要知道的是,我为xss_clean()提供的输入是否已被识别为存在恶意数据,这些数据是否已被过滤掉。
所以基本上:
$str = '<script>alert();</script>';
$str = xss_clean($str);对我来说最理想的情况是:
据我所见,在Security.php-文件中,没有任何东西能为我处理这个问题,也没有什么东西可以通过钩子等方式来处理。当然,我可能弄错了。
由于没有记录Security.php中的替换项--我是否被迫扩展Security.php,复制粘贴原始函数中的当前代码并对其进行修改以支持此功能?或者,对于CodeIgniter的未来更新(尤其是被篡改/扩展的文件),是否有更干净和更安全的解决方案?
发布于 2011-07-06 03:52:11
您需要扩展Security类,但是如果只需要输入/输出的日志,则绝对不需要复制和粘贴任何代码。以下内容将使你能够这样做:
Class My_Security extends CI_Security {
public function xss_clean($str, $is_image = FALSE) {
// Do whatever you need here with the input ... ($str, $is_image)
$str = parent::xss_clean($str, $is_image);
// Do whatever you need here with the output ... ($str)
return $str;
}
}这样,您只需要包装现有的函数并处理输入/输出。如果您关心底层方法的更改,通过使用PHP函数参数透明地传递参数对象,您可以更前向兼容。
https://stackoverflow.com/questions/6589498
复制相似问题