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/EntityViewMethods.php (4 issues)

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\Common\Log;
13
use Slick\Filter\StaticFilter;
14
use Slick\Mvc\Exception\Service\EntityNotFoundException;
15
use Slick\Orm\EntityInterface;
16
17
/**
18
 * Entity View Methods
19
 * 
20
 * @package Slick\Mvc\Controller
21
 * @author  Filipe Silva <[email protected]>
22
 */
23
trait EntityViewMethods
24
{
25
26
    /**
27
     * Add a warning flash message
28
     *
29
     * @param string $message
30
     * @return self
31
     */
32
    abstract public function addWarningMessage($message);
33
34
    /**
35
     * Get missing entity warning message
36
     * 
37
     * @param mixed $entityId
38
     * 
39
     * @return string
40
     */
41 2
    protected function getMissingEntityMessage($entityId)
42
    {
43 2
        $singleName = $this->getEntityNameSingular();
44 2
        $message = "The {$singleName} with ID %s was not found.";
45 2
        return sprintf($this->translate($message), $entityId);
46
    }
47
48
    /**
49
     * Redirect callback after missing entity detection
50
     * 
51
     * @return $this|\Slick\Mvc\ControllerInterface|static
52
     */
53 2
    protected function redirectFromMissingEntity()
54
    {
55 2
        return $this->redirect($this->getBasePath());
0 ignored issues
show
It seems like getBasePath() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
The method redirect() does not exist on Slick\Mvc\Controller\EntityViewMethods. Did you maybe mean redirectFromMissingEntity()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
56
    }
57
58
    /**
59
     * Handles the request to view an entity
60
     *
61
     * @param int $entityId
62
     * 
63
     * @return null|EntityInterface
64
     */
65 4
    public function show($entityId = 0)
66
    {
67 4
        $entityId = StaticFilter::filter('text', $entityId);
68 4
        $entity = null;
69
        try {
70 4
            $entity = $this->getEntity($entityId);
71 2
            $this->set($this->getEntityNameSingular(), $entity);
0 ignored issues
show
It seems like set() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
72 3
        } catch (EntityNotFoundException $caught) {
73 2
            Log::logger()->addNotice($caught->getMessage());
0 ignored issues
show
The method addNotice() does not exist on Psr\Log\LoggerInterface. Did you maybe mean notice()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
74 2
            $this->addWarningMessage(
75 2
                $this->getMissingEntityMessage($entityId)
76 1
            );
77 2
            $this->redirectFromMissingEntity();
78
        }
79 4
        return $entity;
80
    }
81
82
    /**
83
     * Gets entity with provided primary key
84
     *
85
     * @param mixed $entityId
86
     *
87
     * @return EntityInterface
88
     *
89
     * @throws EntityNotFoundException If no entity was found with
90
     *   provided primary key
91
     */
92
    abstract protected function getEntity($entityId);
93
94
    /**
95
     * Get entity singular name used on controller actions
96
     *
97
     * @return string
98
     */
99
    abstract protected function getEntityNameSingular();
100
101
    /**
102
     * Returns the translation for the provided message
103
     *
104
     * @param string $message
105
     * @param string $domain
106
     * @param string $locale
107
     *
108
     * @return string
109
     */
110
    abstract public function translate(
111
        $message, $domain = null, $locale = null
112
    );
113
}