Issues (45)

Security Analysis    not enabled

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/Controller/EntityBasedMethods.php (1 issue)

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
3
/**
4
 * This file is part of slick/mvc package
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Slick\Mvc\Controller;
11
12
use Slick\Mvc\Exception\Service\EntityNotFoundException;
13
use Slick\Orm\EntityInterface;
14
use Slick\Orm\Orm;
15
use Slick\Orm\Repository\EntityRepository;
16
use Slick\Orm\RepositoryInterface;
17
18
/**
19
 * Class EntityBasedMethods
20
 * 
21
 * @package Slick\Mvc\Controller
22
 * @author  Filipe Silva <[email protected]>
23
 */
24
trait EntityBasedMethods
25
{
26
27
    /**
28
     * For basic entity metadata
29
     */
30
    use CrudCommonMethods;
31
32
    /**
33
     * @var RepositoryInterface
34
     */
35
    protected $repository;
36
37
    /**
38
     * Gets entity with provided primary key
39
     * 
40
     * @param mixed $entityId
41
     * 
42
     * @return EntityInterface
43
     * 
44
     * @throws EntityNotFoundException If no entity was found with
45
     *   provided primary key
46
     */
47 4
    protected function getEntity($entityId)
48
    {
49 4
        $entity = $this->getRepository()->get($entityId);
50 4
        if (!$entity instanceof EntityInterface) {
51 2
            throw new EntityNotFoundException(
52 1
                "There are no entities with provided entity ID."
53 1
            );
54
        }
55 2
        return $entity;
56
    }
57
58
    /**
59
     * Get entity repository
60
     * 
61
     * @return RepositoryInterface|EntityRepository
62
     */
63 8
    public function getRepository()
64
    {
65 8
        if (null == $this->repository) {
66 4
            $this->setRepository(
67 4
                Orm::getRepository($this->getEntityClassName())
68 2
            );
69 2
        }
70 8
        return $this->repository;
71
    }
72
73
    /**
74
     * Set entity repository
75
     * 
76
     * @param RepositoryInterface $repository
77
     * 
78
     * @return self|$this|EntityBasedMethods
0 ignored issues
show
Comprehensibility Bug introduced by
The return type EntityBasedMethods is a trait, and thus cannot be used for type-hinting in PHP. Maybe consider adding an interface and use that for type-hinting?

In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.

If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.

Loading history...
79
     */
80 4
    public function setRepository(RepositoryInterface $repository)
81
    {
82 4
        $this->repository = $repository;
83 4
        return $this;
84
    }
85
86
    /**
87
     * Get the current entity descriptor
88
     *
89
     * @return \Slick\Orm\Descriptor\EntityDescriptorInterface
90
     */
91 2
    protected function getEntityDescriptor()
92
    {
93 2
        return $this->getRepository()
94 2
            ->getEntityDescriptor();
95
    }
96
97
    /**
98
     * Gets the URL base path form this controller
99
     * 
100
     * @return string
101
     */
102
    abstract protected function getBasePath();
103
}