Issues (3)

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.

Controller/Component/ApiPaginationComponent.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
namespace BryanCrowe\ApiPagination\Controller\Component;
3
4
use Cake\Controller\Component;
5
use Cake\Event\Event;
6
7
/**
8
 * This is a simple component that injects pagination info into responses when
9
 * using CakePHP's PaginatorComponent alongside of CakePHP's JsonView or XmlView
10
 * classes.
11
 */
12
class ApiPaginationComponent extends Component
13
{
14
    /**
15
     * Default config.
16
     *
17
     * @var array
18
     */
19
    protected $_defaultConfig = [
20
        'key' => 'pagination',
21
        'aliases' => [],
22
        'visible' => []
23
    ];
24
25
    /**
26
     * Holds the paging information array from the request.
27
     *
28
     * @var array
29
     */
30
    protected $pagingInfo = [];
31
32
    /**
33
     * Injects the pagination info into the response if the current request is a
34
     * JSON or XML request with pagination.
35
     *
36
     * @param \Cake\Event\Event $event The Controller.beforeRender event.
37
     * @return void
38
     */
39 18
    public function beforeRender(Event $event)
40
    {
41 18
        if (!$this->isPaginatedApiRequest()) {
42 3
            return;
43
        }
44
45 15
        $subject = $event->getSubject();
46 15
        $this->pagingInfo = $this->request->getParam('paging')[$subject->getName()];
0 ignored issues
show
Deprecated Code introduced by
The property Cake\Controller\Component::$request has been deprecated with message: 3.4.0 Storing references to the request is deprecated. Use Component::getController() or callback $event->getSubject() to access the controller & request instead.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
47 15
        $config = $this->getConfig();
48
49 15
        if (!empty($config['aliases'])) {
50 6
            $this->setAliases();
51 6
        }
52
53 15
        if (!empty($config['visible'])) {
54 6
            $this->setVisibility();
55 6
        }
56
57 15
        $subject->set($config['key'], $this->pagingInfo);
58 15
        $subject->viewVars['_serialize'][] = $config['key'];
59 15
    }
60
61
    /**
62
     * Aliases the default pagination keys to the new keys that the user defines
63
     * in the config.
64
     *
65
     * @return void
66
     */
67 6
    protected function setAliases()
68
    {
69 6
        foreach ($this->getConfig('aliases') as $key => $value) {
70 6
            $this->pagingInfo[$value] = $this->pagingInfo[$key];
71 6
            unset($this->pagingInfo[$key]);
72 6
        }
73 6
    }
74
75
    /**
76
     * Removes any pagination keys that haven't been defined as visible in the
77
     * config.
78
     *
79
     * @return void
80
     */
81 6
    protected function setVisibility()
82
    {
83 6
        $visible = $this->getConfig('visible');
84 6
        foreach ($this->pagingInfo as $key => $value) {
85 6
            if (!in_array($key, $visible)) {
86 6
                unset($this->pagingInfo[$key]);
87 6
            }
88 6
        }
89 6
    }
90
91
    /**
92
     * Checks whether the current request is a JSON or XML request with
93
     * pagination.
94
     *
95
     * @return bool True if JSON or XML with paging, otherwise false.
96
     */
97 18
    protected function isPaginatedApiRequest()
98
    {
99 18
        if ($this->request->getParam('paging') &&
0 ignored issues
show
Deprecated Code introduced by
The property Cake\Controller\Component::$request has been deprecated with message: 3.4.0 Storing references to the request is deprecated. Use Component::getController() or callback $event->getSubject() to access the controller & request instead.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
100 15
            $this->request->is(['json', 'xml'])
0 ignored issues
show
Deprecated Code introduced by
The property Cake\Controller\Component::$request has been deprecated with message: 3.4.0 Storing references to the request is deprecated. Use Component::getController() or callback $event->getSubject() to access the controller & request instead.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
101 18
        ) {
102 15
            return true;
103
        }
104
105 3
        return false;
106
    }
107
}
108