donglong7338 2015-07-30 13:13
浏览 6
已采纳

Symfony,Doctrine和传递参数:应该注意什么?

I have a Symfony controller like the following:

public function postAction($key, Request $request)
{
    /** @var @todo check that the key is passed and that it exists */

    // Get the entity manager
    $em = $this->getDoctrine()->getManager();

    /**
     * This call uses magic abilities of Doctrine that can find a record using
     * the name of the field in the table on which the search has to be performed.
     *
     * ->findOneBy[FieldName]
     *
     */
    $entity = $em->getRepository('AppBundle:Entity')->findOneByKey($key);

As you can see, I pass the $key directly to Doctrine to get the corresponding row in the database.

Now, as this $key is passed through the query string and as an attacker could pass what he wants, my question is: should have I to implement some checks about the correctness of the $key? Should have I to implement some mechanisms to be sure the $key doesn't contain malicious code preventing, in this way, the possibility of a SQL Injection attack?

  • 写回答

1条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥15 写uniapp时遇到的问题
  • ¥15 matlab有限元法求解梁带有若干弹簧质量系统的固有频率
  • ¥15 找一个网络防御专家,外包的
  • ¥100 能不能让两张不同的图片md5值一样,(有尝)
  • ¥15 informer代码训练自己的数据集,改参数怎么改
  • ¥15 请看一下,学校实验要求,我需要具体代码
  • ¥50 pc微信3.6.0.18不能登陆 有偿解决问题
  • ¥20 MATLAB绘制两隐函数曲面的交线
  • ¥15 求TYPCE母转母转接头24PIN线路板图
  • ¥100 国外网络搭建,有偿交流