Issues (15)

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/Admin/presenters/ServersPresenter.php (3 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 the Deploy module for webcms2.
5
 * Copyright (c) @see LICENSE
6
 */
7
8
namespace AdminModule\DeployModule;
9
10
/**
11
 * Servers presenter takes care of managing production servers.
12
 *
13
 * @author Tomas Voslar <[email protected]>
14
 */
15
class ServersPresenter extends BasePresenter
16
{
17
    /**
18
     * Server instance holder.
19
     * 
20
     * @var \WebCMS\DeployModule\Entity\Server
21
     */
22
    private $server;
23
24
    /**
25
     * Server entity repository.
26
     * 
27
     * @var Doctrine\ORM\EntityRepository
28
     */
29
    private $repository;
30
31
    /**
32
     * {@inheritdoc}
33
     */
34 6
    protected function startup()
35
    {
36 6
	   parent::startup();
37
38 6
       $this->repository = $this->em->getRepository('\WebCMS\DeployModule\Entity\Server');
39 6
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44 3
    protected function beforeRender()
45
    {
46 3
	   parent::beforeRender();
47 3
    }
48
49
    /**
50
     * Renders default template with datagrid.
51
     * 
52
     * @param  int    $idPage Id of the page.
53
     * 
54
     * @return void
55
     */
56 1
    public function renderDefault($idPage)
57
    {
58 1
    	$this->reloadContent();
59 1
    	$this->template->idPage = $idPage;
0 ignored issues
show
The property $template is declared private in Nette\Application\UI\Control. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
60 1
    }
61
    
62
    /**
63
     * Creates datagrid with servers.
64
     * 
65
     * @param  string $name                   Name of the datagrid.
66
     * 
67
     * @return \Grido\Grid   Datagrid object.
68
     */
69 1
    protected function createComponentServersGrid($name)
70
    {
71 1
        $grid = $this->createGrid($this, $name, '\WebCMS\DeployModule\Entity\Server');
72
        
73 1
        $grid->addColumnText('name', 'Name')->setSortable()->setFilterText();
74 1
        $grid->addColumnText('path', 'Path')->setSortable()->setFilterText();
75 1
        $grid->addColumnText('ip', 'Ip address')->setSortable()->setFilterText();
76
        
77 1
        $grid->addActionHref("addServer", 'Edit', 'addServer', array('idPage' => $this->actualPage->getId()))->getElementPrototype()->addAttributes(array('class' => 'btn btn-primary ajax'));
78 1
        $grid->addActionHref("deleteServer", 'Delete', 'deleteServer', array('idPage' => $this->actualPage->getId()))->getElementPrototype()->addAttributes(array('class' => 'btn btn-primary btn-danger'));
79
        
80 1
        return $grid;
81
    }
82
83
    /**
84
     * Display server form action. 
85
     *
86
     * @param  int  $id      Application's id.
87
     * @param  int  $idPage  Id of the page.
88
     * 
89
     * @return void
90
     */
91 4
    public function actionAddServer($id, $idPage)
0 ignored issues
show
The parameter $idPage is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
92
    {
93 4
        if (is_numeric($id)) {
94 2
            $this->server = $this->repository->find($id);    
95 2
        } else {
96 2
            $this->server = new \WebCMS\DeployModule\Entity\Server;
97
        }
98 4
    }
99
100
    /**
101
     * Render method for server form.
102
     * 
103
     * @param  int $idPage 
104
     * 
105
     * @return void
106
     */
107 2
    public function renderAddServer($idPage)
108
    {
109 2
        $this->reloadContent();
110 2
        $this->template->idPage = $idPage;
0 ignored issues
show
The property $template is declared private in Nette\Application\UI\Control. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
111 2
    }
112
113
    /**
114
     * Creates server form component.
115
     * 
116
     * @return  \Nette\Application\UI\Form
117
     */
118 4
    public function createComponentServerForm()
119
    {
120 4
        $form = $this->createForm();
121
122 4
        $form->addText('name', 'Name')->setRequired()->setAttribute('class', array('form-control'));
123 4
        $form->addText('path', 'Path')->setRequired()->setAttribute('class', array('form-control'));
124 4
        $form->addText('ip', 'Ip address')->setRequired()->setAttribute('class', array('form-control'));
125
126 4
        $form->addSubmit('send', 'Save')->setAttribute('class', array('btn btn-success'));
127 4
        $form->onSuccess[] = callback($this, 'serverFormSubmitted');
128
129 4
        $form->setDefaults($this->server->toArray());
130
131 4
        return $form;
132
    }
133
134
    /**
135
     * Saves form data into database.
136
     * 
137
     * @param  Nette\Forms\Form $form Server form.
138
     * 
139
     * @return void
140
     */
141 2
    public function serverFormSubmitted($form)
142
    {
143 2
        $values = $form->getValues();
144
145 2
        $this->server->setName($values->name);
146 2
        $this->server->setPath($values->path);
147 2
        $this->server->setIp($values->ip);
148
149 2
        $this->em->persist($this->server);
150 2
        $this->em->flush();
151
152 2
        $this->flashMessage('Server has been added.', 'success');
153 2
        $this->forward('default', array(
154 2
                'idPage' => $this->actualPage->getId()
155 2
            ));
156
    }
157
158
    /**
159
     * Deletes server.
160
     * 
161
     * @param  int $id Server's id to remove.
162
     * 
163
     * @return void
164
     */
165 1 View Code Duplication
    public function actionDeleteServer($id)
166
    {
167 1
        $this->server = $this->repository->find($id);
168
169 1
        $this->em->remove($this->server);
170 1
        $this->em->flush();
171
172 1
        $this->flashMessage('Server has been removed.', 'success');
173 1
        $this->forward('default', array(
174 1
                'idPage' => $this->actualPage->getId()
175 1
            ));
176
    }
177
}
178