Issues (2)

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.

Model/ListingPageProcessor.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
declare(strict_types=1);
4
5
/**
6
 * File: ListingPageProcessor.php
7
 *
8
 * @author Bartosz Kubicki [email protected]>
9
 * @copyright Copyright (C) 2018 Lizard Media (http://lizardmedia.pl)
10
 */
11
12
namespace LizardMedia\AllProductsListing\Model;
13
14
use LizardMedia\AllProductsListing\Api\ListingPageProcessorInterface;
15
use Magento\Catalog\Api\Data\CategoryInterface;
16
use Magento\Catalog\Model\Category;
17
use Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator;
18
use Magento\Catalog\Model\Design;
19
use Magento\Framework\DataObject;
20
use Magento\Framework\View\Page\Config as PageConfig;
21
use Magento\Framework\View\Result\Page;
22
23
/**
24
 * Class ListingPageProcessor
25
 * @package LizardMedia\AllProductsListing\Model
26
 */
27
class ListingPageProcessor implements ListingPageProcessorInterface
28
{
29
    /**
30
     * @var Design
31
     */
32
    private $catalogDesign;
33
34
    /**
35
     * @var CategoryUrlPathGenerator
36
     */
37
    private $categoryUrlPathGenerator;
38
39
    /**
40
     * @var PageConfig
41
     */
42
    private $pageConfig;
43
44
    /**
45
     * ListingPageProcessor constructor.
46
     * @param Design $design
47
     * @param CategoryUrlPathGenerator $categoryUrlPathGenerator
48
     */
49
    public function __construct(Design $design, CategoryUrlPathGenerator $categoryUrlPathGenerator)
50
    {
51
        $this->catalogDesign = $design;
52
        $this->categoryUrlPathGenerator = $categoryUrlPathGenerator;
53
    }
54
55
    /**
56
     * @param CategoryInterface | Category $category
57
     * @param Page $page
58
     * @return void
59
     */
60
    public function process(CategoryInterface $category, Page $page): void
61
    {
62
        $settings = $this->catalogDesign->getDesignSettings($category);
63
        $this->pageConfig = $page->getConfig();
64
        $this->applyCustomDesign($settings);
65
66
        $this->applyCustomPageLayout($page, $settings);
67
        $type = $this->getCategoryType($category);
68
        $this->addPageLayoutHandles($category, $page, $type);
69
        $this->applyLayoutUpdates($page, $settings);
70
        $this->configurePage($page, $category);
71
    }
72
73
    /**
74
     * @param DataObject $settings
75
     * @return void
76
     */
77
    private function applyCustomDesign(DataObject $settings) : void
78
    {
79
        $customDesign = $settings->getCustomDesign();
80
        if ($customDesign) {
81
            $this->catalogDesign->applyCustomDesign($customDesign);
82
        }
83
    }
84
85
    /**
86
     * @param Page $page
87
     * @param DataObject $settings
88
     */
89
    private function applyCustomPageLayout(Page $page, DataObject $settings) : void
0 ignored issues
show
The parameter $page 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...
90
    {
91
        $pageLayout = $settings->getPageLayout();
92
        if ($pageLayout) {
93
            $this->pageConfig->setPageLayout($pageLayout);
94
        }
95
    }
96
97
    /**
98
     * @param CategoryInterface | Category $category
99
     * @return string
100
     */
101
    private function getCategoryType(CategoryInterface $category) : string
102
    {
103
        if ($category->getData('is_anchor')) {
104
            $type = $category->hasChildren() ? 'layered' : 'layered_without_children';
105
        } else {
106
            $type = $category->hasChildren() ? 'default' : 'default_without_children';
107
        }
108
109
        return $type;
110
    }
111
112
    /**
113
     * @param CategoryInterface | Category  $category
114
     * @param Page $page
115
     * @param string $type
116
     * @return void
117
     */
118
    private function addPageLayoutHandles(CategoryInterface $category, Page $page, string $type) : void
119
    {
120
        if (!$category->hasChildren()) {
121
            $parentType = strtok($type, '_');
122
            $page->addPageLayoutHandles(['type' => $parentType]);
123
        }
124
125
        $page->addPageLayoutHandles(['type' => $type, 'id' => $category->getId()]);
126
    }
127
128
    /**
129
     * @param Page $page
130
     * @param DataObject $settings
131
     * @return void
132
     */
133
    private function applyLayoutUpdates(Page $page, DataObject $settings) : void
134
    {
135
        $layoutUpdates = $settings->getLayoutUpdates();
136
        if ($layoutUpdates && is_array($layoutUpdates)) {
137
            foreach ($layoutUpdates as $layoutUpdate) {
138
                $page->addUpdate($layoutUpdate);
139
            }
140
        }
141
    }
142
143
    /**
144
     * @param Page $page
145
     * @param CategoryInterface $category
146
     * @return void
147
     */
148
    private function configurePage(Page $page, CategoryInterface $category) : void
0 ignored issues
show
The parameter $page 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...
149
    {
150
        $this->pageConfig->addBodyClass('page-products')
151
            ->addBodyClass(sprintf('categorypath-%s', $this->categoryUrlPathGenerator->getUrlPath($category)))
152
            ->addBodyClass(sprintf('category-%s', $category->getUrlKey()));
153
        $this->pageConfig->getTitle()->set(__('All products'));
154
    }
155
}
156