基于成员的站点在编码器中的安全问题


Member based sites security issue in codeigniter

嗨,朋友们,我只是想知道当用户在我的网站上发布任何使用表单的东西时,我应该记住什么安全。我加密了codeigniter会话,并启用了将会话存储在数据库中的功能,我的示例Model函数如下所示。我启用了表单验证,并启用了xss和csrf全局。

我认为sql注入是由CI的活动记录功能自动处理的。请告诉我,在生产这个网站之前,我还需要检查什么。由于
        function AddSomeMemberPost(){
                $now = date('Y-m-d H:i:s', strtotime('now'));
        $data = array(
            'topic' => $this->input->post('title'),
            'status' => 'draft',
            'content' => $this->input->post('body'),
            'category_id' => $this->input->post('categoryid'),
            'featured' => '0',
            'lang' => $this->input->post('lang'),
                    'pubdate' => $now,
                    'video' => $this->input->post('tube_video'),
                    'user_id' => $this->session->userdata('user_id'),
                    'username' => $this->session->userdata('username')
        );
$this->db->insert('my_table', $data);

验证是这样做的,我需要验证会话数据吗?它正在通过模型。

$this->form_validation->set_rules('topic', 'Topic', 'required|min_length[8]|max_length[90]');
            $this->form_validation->set_rules('content', 'Content', 'required|min_length[8]');
            $this->form_validation->set_rules('tags', 'Tag', 'required|miax_length[50]');
            $this->form_validation->set_rules('video', 'Youtube Video Link', 'min_length[8]');

建议修改PHP错误报告级别,该级别在main/index.php文件中设置。

error_reporting(0)

注意:你可以在钩子中设置它,这样你就可以保持标准CI文件不变。

通常,在将所有数据放入任何SQL(包括会话中使用的数据)之前,即使使用内置的CI DB函数,也应该清理所有数据。例如,在将数字添加到SQL

之前,应该始终对它们进行强制转换。
$val = (int)$val;

(注意:为了提高性能,您可以在尝试运行查询之前检查这些值是否在有效范围内,以避免运行您知道将不返回任何结果的查询。例如,如果您正在搜索一个正整数值,那么您不需要运行查询if $val <= 0)