Issues (1)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/Doctrine2.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
declare(strict_types=1);
3
/**
4
 * Caridea
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
7
 * use this file except in compliance with the License. You may obtain a copy of
8
 * the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
 * License for the specific language governing permissions and limitations under
16
 * the License.
17
 *
18
 * @copyright 2015-2018 LibreWorks contributors
19
 * @license   Apache-2.0
20
 */
21
namespace Caridea\Dao;
22
23
use Doctrine\ORM\EntityManager;
24
25
/**
26
 * An abstract Data Access Object for the Doctrine ORM library.
27
 *
28
 * @copyright 2015-2018 LibreWorks contributors
29
 * @license   Apache-2.0
30
 */
31
abstract class Doctrine2 extends Dao
32
{
33
    /**
34
     * @var \Doctrine\ORM\EntityManager The entity manager
35
     */
36
    protected $manager;
37
    /**
38
     * @var string
39
     */
40
    protected $entityName;
41
    /**
42
     * @var \Doctrine\ORM\EntityRepository The entity repository
43
     */
44
    protected $repository;
45
46
    /**
47
     * Creates a new MongoDB DAO.
48
     *
49
     * @param \Doctrine\ORM\EntityManager $manager The entity manager
50
     * @param string $entityName The entity name
51
     * @param \Psr\Log\LoggerInterface $logger A logger
52
     */
53 4
    public function __construct(EntityManager $manager, string $entityName, \Psr\Log\LoggerInterface $logger = null)
0 ignored issues
show
You have injected the EntityManager via parameter $manager. This is generally not recommended as it might get closed and become unusable. Instead, it is recommended to inject the ManagerRegistry and retrieve the EntityManager via getManager() each time you need it.

The EntityManager might become unusable for example if a transaction is rolled back and it gets closed. Let’s assume that somewhere in your application, or in a third-party library, there is code such as the following:

function someFunction(ManagerRegistry $registry) {
    $em = $registry->getManager();
    $em->getConnection()->beginTransaction();
    try {
        // Do something.
        $em->getConnection()->commit();
    } catch (\Exception $ex) {
        $em->getConnection()->rollback();
        $em->close();

        throw $ex;
    }
}

If that code throws an exception and the EntityManager is closed. Any other code which depends on the same instance of the EntityManager during this request will fail.

On the other hand, if you instead inject the ManagerRegistry, the getManager() method guarantees that you will always get a usable manager instance.

Loading history...
54
    {
55 4
        parent::__construct($logger);
56 4
        $this->manager = $manager;
57 4
        $this->entityName = $entityName;
58 4
        $this->repository = $manager->getRepository($entityName);
59 4
    }
60
61
    /**
62
     * Executes something in the context of the entityManager.
63
     *
64
     * Exceptions are caught and translated.
65
     *
66
     * @param Closure $cb The closure to execute, takes the entityManager
67
     * @return mixed whatever the function returns, this method also returns
68
     * @throws \Caridea\Dao\Exception If a database problem occurs
69
     * @see \Caridea\Dao\Exception\Translator\Doctrine
70
     */
71 2
    protected function doExecute(\Closure $cb)
72
    {
73
        try {
74 2
            return $cb($this->manager);
75 1
        } catch (\Exception $e) {
76 1
            throw Exception\Translator\Doctrine::translate($e);
77
        }
78
    }
79
80
    /**
81
     * Executes something in the context of the entityRepository.
82
     *
83
     * Exceptions are caught and translated.
84
     *
85
     * @param Closure $cb The closure to execute, takes the entityRepository
86
     * @return mixed whatever the function returns, this method also returns
87
     * @throws \Caridea\Dao\Exception If a database problem occurs
88
     * @see \Caridea\Dao\Exception\Translator\Doctrine
89
     */
90 2
    protected function doExecuteInRepository(\Closure $cb)
91
    {
92
        try {
93 2
            return $cb($this->repository);
94 1
        } catch (\Exception $e) {
95 1
            throw Exception\Translator\Doctrine::translate($e);
96
        }
97
    }
98
}
99