Issues (24)

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/Traits/WooCommerceTrait.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 Codexshaper\WooCommerce\Traits;
4
5
trait WooCommerceTrait
6
{
7
    /**
8
     * GET method.
9
     * Retrieve data.
10
     *
11
     * @param string $endpoint API endpoint.
12
     * @param array  $options
13
     *
14
     * @return array
15
     */
16 View Code Duplication
    public function all($endpoint = '', $options = [])
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...
17
    {
18
        try {
19
            self::__construct();
20
21
            return $this->client->get($endpoint, $options);
0 ignored issues
show
The property client does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
22
        } catch (\Exception $e) {
23
            throw new \Exception($e->getMessage(), 1);
24
        }
25
    }
26
27
    /**
28
     * GET method.
29
     * Retrieve Single data.
30
     *
31
     * @param string $endpoint API endpoint.
32
     * @param array  $options
33
     *
34
     * @return array
35
     */
36 View Code Duplication
    public function find($endpoint = '', $options = [])
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...
37
    {
38
        try {
39
            self::__construct();
40
41
            return $this->client->get($endpoint, $options);
42
        } catch (\Exception $e) {
43
            throw new \Exception($e->getMessage(), 1);
44
        }
45
    }
46
47
    /**
48
     * POST method.
49
     * Insert data.
50
     *
51
     * @param string $endpoint API endpoint.
52
     * @param array  $data
53
     *
54
     * @return array
55
     */
56 View Code Duplication
    public function create($endpoint, $data)
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...
57
    {
58
        try {
59
            self::__construct();
60
61
            return $this->client->post($endpoint, $data);
62
        } catch (\Exception $e) {
63
            throw new \Exception($e->getMessage(), 1);
64
        }
65
    }
66
67
    /**
68
     * PUT method.
69
     * Update data.
70
     *
71
     * @param string $endpoint API endpoint.
72
     * @param array  $data
73
     *
74
     * @return array
75
     */
76 View Code Duplication
    public function update($endpoint, $data)
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...
77
    {
78
        try {
79
            self::__construct();
80
81
            return $this->client->put($endpoint, $data);
82
        } catch (\Exception $e) {
83
            throw new \Exception($e->getMessage(), 1);
84
        }
85
    }
86
87
    /**
88
     * DELETE method.
89
     * Remove data.
90
     *
91
     * @param string $endpoint API endpoint.
92
     * @param array  $options
93
     *
94
     * @return array
95
     */
96 View Code Duplication
    public function delete($endpoint, $options = [])
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...
97
    {
98
        try {
99
            self::__construct();
100
101
            return $this->client->delete($endpoint, $options);
102
        } catch (\Exception $e) {
103
            throw new \Exception($e->getMessage(), 1);
104
        }
105
    }
106
107
    /**
108
     * Return the last request header.
109
     *
110
     * @return \Automattic\WooCommerce\HttpClient\Request
111
     */
112
    public function getRequest()
113
    {
114
        try {
115
            return $this->client->http->getRequest();
116
        } catch (\Exception $e) {
117
            throw new \Exception($e->getMessage(), 1);
118
        }
119
    }
120
121
    /**
122
     * Return the http response headers from last request.
123
     *
124
     * @return \Automattic\WooCommerce\HttpClient\Response
125
     */
126
    public function getResponse()
127
    {
128
        try {
129
            return $this->client->http->getResponse();
130
        } catch (\Exception $e) {
131
            throw new \Exception($e->getMessage(), 1);
132
        }
133
    }
134
135
    /**
136
     * Count the total results and return it.
137
     *
138
     * @return int
139
     */
140
    public function countResults()
141
    {
142
        return (int) $this->getResponse()->getHeaders()[$this->headers['header_total']];
0 ignored issues
show
The property headers does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
143
    }
144
145
    /**
146
     * Count the total pages and return.
147
     *
148
     * @return mixed
149
     */
150
    public function countPages()
151
    {
152
        return (int) $this->getResponse()->getHeaders()[$this->headers['header_total_pages']];
153
    }
154
155
    /**
156
     * Return the current page number.
157
     *
158
     * @return int
159
     */
160
    public function current()
161
    {
162
        return !empty($this->getRequest()->getParameters()['page']) ? $this->getRequest()->getParameters()['page'] : 1;
163
    }
164
165
    /**
166
     * Return the previous page number.
167
     *
168
     * @return int|null
169
     */
170
    public function previous()
171
    {
172
        $currentPage = $this->current();
173
174
        return ($currentPage-- > 1) ? $currentPage : null;
175
    }
176
177
    /**
178
     * Return the next page number.
179
     *
180
     * @return int|null
181
     */
182
    public function next()
183
    {
184
        $currentPage = $this->current();
185
186
        return ($currentPage++ < $this->countPages()) ? $currentPage : null;
187
    }
188
}
189