Issues (34)

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/Comments/CommController.php (7 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
namespace Anax\Comments;
4
5
use \Anax\Configure\ConfigureInterface;
6
use \Anax\Configure\ConfigureTrait;
7
use \Anax\DI\InjectionAwareInterface;
8
use \Anax\DI\InjectionAwareTrait;
9
use \Anax\Comments\HTMLForm\CreateCommForm;
10
use \Anax\Comments\HTMLForm\UpdateCommForm;
11
use \Anax\Comments\HTMLForm\DeleteCommForm;
12
use \Anax\Comments\HTMLForm\AdminDeleteCommForm;
13
use \Anax\Comments\ShowOneService;
14
use \Anax\Comments\ShowAllService;
15
16
/**
17
 * A controller class.
18
 */
19
class CommController implements
20
    ConfigureInterface,
21
    InjectionAwareInterface
22
{
23
    use ConfigureTrait,
24
        InjectionAwareTrait;
25
26
27
    /**
28
     * Sends data to view
29
     *
30
     * @param string $title
31
     * @param string $crud, path to view
0 ignored issues
show
There is no parameter named $crud,. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
32
     * @param array $data, htmlcontent to view
0 ignored issues
show
There is no parameter named $data,. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
33
     */
34
    public function toRender($title, $crud, $data)
35
    {
36
        $view       = $this->di->get("view");
37
        $pageRender = $this->di->get("pageRender");
38
        $view->add($crud, $data);
39
        $tempfix = "";
40
        $pageRender->renderPage($tempfix, ["title" => $title]);
41
    }
42
43
44
    /**
45
     * Show all items.
46
     *
47
     * @return void
48
     */
49 View Code Duplication
    public function getIndex()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
50
    {
51
        $title      = "Inlägg";
52
53
        $text = new ShowAllService($this->di);
54
55
        $data = [
56
            "items" => $text->getHTML(),
57
        ];
58
59
        $crud = "comm/crud/front";
60
        $this->toRender($title, $crud, $data);
61
    }
62
63
64
65
    /**
66
     * Handler with form to create a new item.
67
     *
68
     * @return void
69
     */
70
    public function getPostCreateItem($id = null)
71
    {
72
        $title      = "Skriv ett inlägg";
73
74
        $session = $this->di->get("session");
75
        $sess = $session->get("user");
76
77
        if ($sess) {
78
            $form       = new CreateCommForm($this->di, $sess['id'], $id);
79
            $form->check();
80
81
            $data = [
82
                "form" => $form->getHTML(),
83
            ];
84
        } else {
85
            $data = [
86
                "form" => "Enbart för inloggade. Sorry!",
87
            ];
88
        }
89
90
        $crud = "comm/crud/create";
91
        $this->toRender($title, $crud, $data);
92
    }
93
94
95
    /**
96
    *
97
    * @return sessionobject
98
    */
99
    public function getSess()
100
    {
101
        $session = $this->di->get("session");
102
        $sess = $session->get("user");
103
        return $sess;
104
    }
105
106
107
    /**
108
     * Handler with form to delete an item.
109
     *
110
     * @return void
111
     */
112 View Code Duplication
    public function getPostDeleteItem($id)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
113
    {
114
        $title      = "Ta bort ett inlägg";
115
        $sess = $this->getSess();
116
117
        if ($sess) {
118
            $form       = new DeleteCommForm($this->di, $id);
119
            $form->check();
120
121
            $data = [
122
                "form" => $form->getHTML(),
123
            ];
124
        } else {
125
            $data = [
126
                "form" => "Enbart för inloggade. Sorry!",
127
            ];
128
        }
129
130
        $crud = "comm/crud/delete";
131
        $this->toRender($title, $crud, $data);
132
    }
133
134
135
136
    /**
137
     * Handler with form to update an item.
138
     *
139
     * @return void
140
     */
141 View Code Duplication
    public function getPostAdminDeleteItem()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
142
    {
143
        $title      = "Ta bort text";
144
        $form       = new AdminDeleteCommForm($this->di);
145
146
        $form->check();
147
148
        $data = [
149
            "form" => $form->getHTML(),
150
        ];
151
152
        $crud = "comm/crud/admindelete";
153
        $this->toRender($title, $crud, $data);
154
    }
155
156
157
158
    /**
159
     * Handler with form to update an item.
160
     *
161
     * @return void
162
     */
163 View Code Duplication
    public function getPostUpdateItem($id)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
164
    {
165
        $title      = "Uppdatera ditt inlägg";
166
167
        $sess = $this->getSess();
168
169
        if ($sess) {
170
            $form       = new UpdateCommForm($this->di, $id, $sess['id']);
171
            $form->check();
172
173
            $data = [
174
                "form" => $form->getHTML(),
175
            ];
176
        } else {
177
            $data = [
178
                "form" => "Enbart för inloggade. Sorry!",
179
            ];
180
        }
181
182
        $crud = "comm/crud/update";
183
        $this->toRender($title, $crud, $data);
184
    }
185
186
187
    /**
188
     * Handler with form to just show an item.
189
     *
190
     * @return void
191
     */
192 View Code Duplication
    public function getPostShow($id)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
193
    {
194
        $title      = "Inlägg";
195
        $text       = new ShowOneService($this->di, $id);
196
197
        $data = [
198
            "items" => $text->getHTML(),
199
        ];
200
201
        $crud = "comm/crud/view-one";
202
        $this->toRender($title, $crud, $data);
203
    }
204
}
205