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/FormAwareMethods.php (2 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\Form\FormInterface;
13
use Slick\Mvc\Form\EntityForm;
14
use Slick\Mvc\Service\Entity\EntityUpdateService;
15
use Slick\Orm\Entity;
16
17
/**
18
 * Form Aware Methods
19
 * 
20
 * @package Slick\Mvc\Controller
21
 * @author  Filipe Silva <[email protected]>
22
 */
23
trait FormAwareMethods
24
{
25
26
    /**
27
     * @var EntityUpdateService
28
     */
29
    protected $updateService;
30
31
    /**
32
     * @return FormInterface|EntityForm
33
     */
34
    abstract function getForm();
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
35
36
    /**
37
     * Get invalid form data message
38
     *
39
     * @return string
40
     */
41
    protected function getInvalidFormDataMessage()
42
    {
43
        $singleName = $this->getEntityNameSingular();
44
        $message = "The {$singleName} could not be saved. Please check the " .
45
            "errors and try again.";
46
        return $this->translate($message);
47
    }
48
49
    /**
50
     * Get invalid form data message
51
     *
52
     * @param \Exception $caught
53
     *
54
     * @return string
55
     */
56
    protected function getGeneralErrorMessage(\Exception $caught)
57
    {
58
        $singleName = $this->getEntityNameSingular();
59
        $message = "There was an error when saving {$singleName} data: %s";
60
        return sprintf($this->translate($message), $caught->getMessage());
61
    }
62
63
    /**
64
     * Get entity singular name used on controller actions
65
     *
66
     * @return string
67
     */
68
    abstract protected function getEntityNameSingular();
69
70
    /**
71
     * Get update service
72
     *
73
     * @return EntityUpdateService
74
     */
75
    public function getUpdateService()
76
    {
77
        if (null == $this->updateService) {
78
            $this->setUpdateService(
79
                new EntityUpdateService($this->getNewEntity())
80
            );
81
        }
82
        return $this->updateService;
83
    }
84
85
    /**
86
     * Set update service
87
     *
88
     * @param EntityUpdateService $updateService
89
     *
90
     * @return EntityCreateMethods
0 ignored issues
show
Comprehensibility Bug introduced by
The return type EntityCreateMethods 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...
91
     */
92
    public function setUpdateService(EntityUpdateService $updateService)
93
    {
94
        $this->updateService = $updateService;
95
        return $this;
96
    }
97
98
    /**
99
     * Get a new entity
100
     *
101
     * @return Entity
102
     */
103
    protected function getNewEntity()
104
    {
105
        $class = $this->getEntityClassName();
106
        return new $class();
107
    }
108
109
    /**
110
     * Gets the entity FQ class name
111
     *
112
     * @return string
113
     */
114
    abstract public function getEntityClassName();
115
116
    /**
117
     * Returns the translation for the provided message
118
     *
119
     * @param string $message
120
     * @param string $domain
121
     * @param string $locale
122
     *
123
     * @return string
124
     */
125
    abstract public function translate(
126
        $message, $domain = null, $locale = null
127
    );
128
}