Issues (6)

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/Api/Validation.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
namespace ComicVine\Api;
4
5
use ComicVine\Api\Filters\FilterCheck;
6
use ComicVine\Api\Filters\FilterValidation;
7
8
/**
9
 * Check validation of inputs for ControllerQuery.
10
 *
11
 * Class Validation
12
 *
13
 * @package grzgajda/comicvine-api
14
 * @author  Grzegorz Gajda <[email protected]>
15
 */
16
class Validation
17
{
18
    use FilterCheck;
19
    use FilterValidation;
20
21
    /**
22
     * Mock for enabled filters.
23
     *
24
     * @var array
25
     */
26
    protected $enabledFilters = [];
27
28
    /**
29
     * Validation constructor.
30
     *
31
     * @param array $filters
32
     */
33
    public function __construct($filters = [])
34
    {
35
        if ($filters !== []) {
36
            $this->enabledFilters = $filters;
37
        }
38
    }
39
40
    /**
41
     * Check validation for $input
42
     *
43
     * @param string       $type
44
     * @param string|array $input
45
     *
46
     * @return boolean|null
47
     */
48
    public function validation($type = "", $input)
49
    {
50
        switch ($type) {
51
            case 'field_list':
52
                return $this->validFieldList($input);
53
            case 'limit':
54
                return $this->validNumber('limit', $input, 0, 100);
55
            case 'offset':
56
                return $this->validNumber('offset', $input, 0);
57
            case 'filter':
58
                return $this->validFilter($input);
59
            case 'sort':
60
                return $this->validSort($input);
61
            default:
62
                return false;
63
        }
64
    }
65
66
    /**
67
     * Validation for FIELD_LIST parameter.
68
     *
69
     * @param string|array $input
70
     *
71
     * @return bool
72
     */
73
    protected function validFieldList($input)
74
    {
75
        if (is_array($input) === false) {
76
            return false;
77
        }
78
79
        foreach ($input as $key => $value) {
80
            if ($this->isKeyAndValueAre($key, 'int', $value, 'string') === false) {
81
                return false;
82
            }
83
        }
84
85
        return true;
86
    }
87
88
    /**
89
     * Check if offset or limit is valid.
90
     *
91
     * @param string       $type  Type of valid (offset or limit)
92
     * @param string|array $input Value
93
     * @param integer      $min   Min range what value can be
94
     * @param integer      $max   Max range what value can be
95
     *
96
     * @return $this|bool
97
     */
98
    protected function validNumber($type, $input, $min, $max = "")
99
    {
100
        if ($this->isIntAndBetween($input, $min, $max) === false) {
101
            return false;
102
        }
103
104
        return $this->isEnabledFilter($type, $this->enabledFilters);
105
    }
106
107
    /**
108
     * Validation for FILTER parameter.
109
     *
110
     * @param string|array $input
111
     *
112
     * @return boolean|null
113
     */
114 View Code Duplication
    protected function validFilter($input)
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...
115
    {
116
        if (is_array($input) === false) {
117
            return false;
118
        }
119
120
        foreach ($input as $key => $value) {
121
            if ($this->isKeyAndValueAre($key, 'string', $value, ['string', 'int', 'float']) === false) {
122
                return false;
123
            }
124
        }
125
126
        return $this->isEnabledFilter('filter', $this->enabledFilters);
127
    }
128
129
    /**
130
     * Validation for SORT parameter.
131
     *
132
     * @param string|array $input
133
     *
134
     * @return boolean|null
135
     */
136 View Code Duplication
    protected function validSort($input)
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...
137
    {
138
        if (is_array($input) === false) {
139
            return false;
140
        }
141
142
        foreach ($input as $key => $value) {
143
            if ($this->isParamAValue($key, 'string', $value, ['asc', 'desc']) === false) {
144
                return false;
145
            }
146
        }
147
148
        return $this->isEnabledFilter('sort', $this->enabledFilters);
149
    }
150
}