Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/253.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Symfony,教义和通过的参数:我应该注意什么?_Php_Security_Symfony_Doctrine Orm_Sql Injection - Fatal编程技术网

Php Symfony,教义和通过的参数:我应该注意什么?

Php Symfony,教义和通过的参数:我应该注意什么?,php,security,symfony,doctrine-orm,sql-injection,Php,Security,Symfony,Doctrine Orm,Sql Injection,我有一个Symfony控制器,如下所示: 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 ca

我有一个Symfony控制器,如下所示:

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);
如您所见,我将
$key
直接传递给Doctrine,以获取数据库中相应的行


现在,由于此$key通过查询字符串传递,并且攻击者可以传递他想要的内容,我的问题是:我是否应该对
$key
的正确性进行一些检查?我是否应该实施一些机制来确保
$key
不包含恶意代码,以这种方式防止SQL注入攻击的可能性?

不,您不必担心,条令会帮您做到这一点


请参阅以了解更多信息,并且

原则使用预先准备好的语句,您不必担心sql注入。