Issues (13)

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.

Block/Adminhtml/Catalogue/Edit/Form.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
 * File: Form.php
4
 *
5
 * @author      Maciej SÅ‚awik <[email protected]>
6
 * Github:      https://github.com/maciejslawik
7
 */
8
9
namespace MSlwk\ICatalogue\Block\Adminhtml\Catalogue\Edit;
10
11
use Magento\Backend\Block\Template\Context;
12
use Magento\Backend\Block\Widget\Form\Generic;
13
use Magento\Cms\Model\Wysiwyg\Config;
14
use Magento\Framework\Data\Form as DataForm;
15
use Magento\Framework\Data\FormFactory;
16
use Magento\Framework\Registry;
17
use Magento\Store\Model\System\Store;
18
use MSlwk\ICatalogue\Model\Catalogue;
19
use MSlwk\ICatalogue\Api\CatalogueInterface;
20
21
/**
22
 * Class Form
23
 *
24
 * @package MSlwk\ICatalogue\Block\Adminhtml\Catalogue\Edit
25
 */
26
class Form extends Generic
27
{
28
    /**
29
     * @var Store
30
     */
31
    protected $systemStore;
32
33
    /**
34
     * Form constructor.
35
     *
36
     * @param Store $systemStore
37
     * @param Context $context
38
     * @param Registry $registry
39
     * @param FormFactory $formFactory
40
     * @param array $data
41
     */
42
    public function __construct(
43
        Store $systemStore,
44
        Context $context,
45
        Registry $registry,
46
        FormFactory $formFactory,
47
        array $data = []
48
    ) {
49
        $this->systemStore = $systemStore;
50
        parent::__construct($context, $registry, $formFactory, $data);
51
    }
52
53
    /**
54
     * @inheritdoc
55
     */
56
    protected function _construct()
57
    {
58
        parent::_construct();
59
        $this->setId('mslwk_icatalogue_catalogue_form');
60
        $this->setTitle(__('iCatalogue'));
61
    }
62
63
    /**
64
     * @inheritdoc
65
     */
66
    protected function _prepareForm()
67
    {
68
        /** @var Catalogue $catalogue */
69
        $catalogue = $this->_coreRegistry->registry('mslwk_icatalogue_catalogue');
70
71
        /** @var DataForm $form */
72
        $form = $this->_formFactory->create(
73
            [
74
                'data' => [
75
                    'id' => 'edit_form',
76
                    'action' => $this->getData('action'),
77
                    'method' => 'post',
78
                    'enctype' => 'multipart/form-data'
79
                ]
80
            ]
81
        );
82
83
        $form->setHtmlIdPrefix('catalogue_');
84
85
        /**
86
         * General fieldset
87
         */
88
        $fieldsetGeneral = $form->addFieldset(
89
            'general_fieldset',
90
            [
91
                'legend' => __('General Information'),
92
                'class' => 'fieldset-wide'
93
            ]
94
        );
95
96
        if ($catalogue->getId()) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $catalogue->getId() of type integer|null is loosely compared to true; this is ambiguous if the integer can be zero. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For integer values, zero is a special case, in particular the following results might be unexpected:

0   == false // true
0   == null  // true
123 == false // false
123 == null  // false

// It is often better to use strict comparison
0 === false // false
0 === null  // false
Loading history...
97
            $url = '/icatalogue/catalogue/view/id/' . $catalogue->getId();
98
            $catalogue->setUrl($url);
99
            $fieldsetGeneral->addField(
100
                'url',
101
                'text',
102
                [
103
                    'name' => 'url',
104
                    'readonly' => true,
105
                    'label' => __('URL'),
106
                    'title' => __('URL'),
107
                    'after_element_html' => '<a href=' . $url . '>'. __('View').'</a>'
108
                ]
109
            );
110
        }
111
112
        $fieldsetGeneral->addField(
113
            CatalogueInterface::TITLE,
114
            'text',
115
            [
116
                'name' => CatalogueInterface::TITLE,
117
                'label' => __('Title'),
118
                'title' => __('Title'),
119
                'required' => true
120
            ]
121
        );
122
        $fieldsetGeneral->addField(
123
            'stores',
124
            'multiselect',
125
            [
126
                'name' => 'stores[]',
127
                'label' => __('Store Views'),
128
                'title' => __('Store Views'),
129
                'required' => true,
130
                'values' => $this->systemStore->getStoreValuesForForm(false, true),
131
            ]
132
        );
133
134
        /**
135
         * Images fieldset
136
         */
137
        $fieldsetImages = $form->addFieldset(
138
            'images_fieldset',
139
            [
140
                'legend' => __('Images'),
141
                'class' => 'fieldset-wide'
142
            ]
143
        );
144
        $fieldsetImages->addField(
145
            'images',
146
            'MSlwk\ICatalogue\Form\Element\Gallery',
147
            [
148
                'name' => 'images',
149
                'label' => __('Image'),
150
                'title' => __('Image')
151
            ]
152
        );
153
154
        /** Catalogue ID */
155
        if ($catalogue->getId()) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $catalogue->getId() of type integer|null is loosely compared to true; this is ambiguous if the integer can be zero. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For integer values, zero is a special case, in particular the following results might be unexpected:

0   == false // true
0   == null  // true
123 == false // false
123 == null  // false

// It is often better to use strict comparison
0 === false // false
0 === null  // false
Loading history...
156
            $fieldsetGeneral->addField(
157
                CatalogueInterface::CATALOGUE_ID,
158
                'hidden',
159
                [
160
                    'name' => CatalogueInterface::CATALOGUE_ID
161
                ]
162
            );
163
        }
164
165
        $form->setValues($catalogue->getData());
166
        $form->setUseContainer(true);
167
        $this->setForm($form);
168
169
        return parent::_prepareForm();
170
    }
171
}
172