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/model/Book.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
/**
3
 * Class Book
4
 *
5
 * @author       Denis Shestakov <[email protected]>
6
 * @copyright    Copyright (c) 2017, Lan Publishing
7
 * @license      MIT
8
 */
9
10
namespace Lan\Ebs\Sdk\Model;
11
12
use Exception;
13
use Lan\Ebs\Sdk\Classes\Model;
14
use Lan\Ebs\Sdk\Client;
15
16
/**
17
 * Модель книг
18
 *
19
 * @property mixed name
20
 * @property mixed description
21
 * @property mixed isbn
22
 * @property mixed year
23
 * @property mixed edition
24
 * @property mixed pages
25
 * @property mixed specialMarks
26
 * @property mixed classification
27
 * @property mixed authors
28
 * @property mixed authorAdditions
29
 * @property mixed bibliographicRecord
30
 * @property mixed contentQuality
31
 * @property mixed publisher
32
 * @property mixed url
33
 * @property mixed thumb
34
 *
35
 * @package      Lan\Ebs
36
 * @subpackage   Sdk
37
 * @category     Model
38
 */
39
class Book extends Model
40
{
41
    /**
42
     * Наименование книги
43
     */
44
    const FIELD_NAME = 'name';
45
46
    /**
47
     * Описание книги
48
     */
49
    const FIELD_DESCRIPTION = 'description';
50
51
    /**
52
     * ISBN книги
53
     */
54
    const FIELD_ISBN = 'isbn';
55
56
    /**
57
     * Год издания книги
58
     */
59
    const FIELD_YEAR = 'year';
60
61
    /**
62
     * Издание
63
     */
64
    const FIELD_EDITION = 'edition';
65
66
    /**
67
     * Объем книги
68
     */
69
    const FIELD_PAGES = 'pages';
70
71
    /**
72
     * Специальные отметки
73
     */
74
    const FIELD_SPECIAL_MARKS = 'specialMarks';
75
76
    /**
77
     * Гриф
78
     */
79
    const FIELD_CLASSIFICATION = 'classification';
80
81
    /**
82
     * Авторы
83
     */
84
    const FIELD_AUTHORS = 'authors';
85
86
    /**
87
     * Дополнительные авторы
88
     */
89
    const FIELD_AUTHOR_ADDITIONS = 'authorAdditions';
90
91
    /**
92
     * Библиографическая запись
93
     */
94
    const FIELD_BIBLIOGRAPHIC_RECORD = 'bibliographicRecord';
95
96
    /**
97
     * Качество текста книг (процент)
98
     */
99
    const FIELD_CONTENT_QUALITY = 'contentQuality';
100
101
    /**
102
     * Издательство
103
     */
104
    const FIELD_PUBLISHER = 'publisher';
105
106
    /**
107
     * Языл
108
     */
109
    const FIELD_LANG = 'lang';
110
111
    /**
112
     * Ссылка на карточку книги
113
     */
114
    const FIELD_URL = 'url';
115
116
    /**
117
     * Ссылка на обложку книги
118
     */
119
    const FIELD_THUMB = 'thumb';
120
121
    /**
122
     * Конструктор модели пользователя
123
     *
124
     * @param Client $client Инстанс клиента
125
     * @param array $fields Поля для выборки
126
     *
127
     * @throws Exception
128
     */
129 1
    public function __construct(Client $client, array $fields = array())
130
    {
131 1
        parent::__construct($client, $fields);
132 1
    }
133
134
    /**
135
     * Получение текстов книги
136
     *
137
     * @param int $id Идентификатор модели
138
     *
139
     * @return array
140
     *
141
     * @throws Exception
142
     */
143 View Code Duplication
    public function text($id = null)
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...
144
    {
145
        if ($id) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $id 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...
146
            $this->setId($id);
147
        } else {
148
            $id = $this->getId();
149
        }
150
151
        if (empty($id)) {
152
            throw new Exception(Model::MESSAGE_ID_REQUIRED);
153
        }
154
155
        return $this->getClient()->getResponse($this->getUrl(__FUNCTION__, array($id)))['data'];
156
    }
157
158
    /**
159
     * Получение данных для запроса через API
160
     *
161
     * @param string $method Http-метод запроса
162
     * @param array $params Параметры для формирования урла
163
     *
164
     * ```php
165
     *
166
     *  $url = $this->getUrl('get');
167
     * ```
168
     *
169
     * @return array
170
     *
171
     * @throws Exception
172
     */
173 View Code Duplication
    public function getUrl($method, array $params = array())
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...
174
    {
175
        switch ($method) {
176
            case 'get':
177
                return array(
178
                    'url' => vsprintf('/1.0/resource/book/get/%d', $params),
179
                    'method' => 'GET',
180
                    'code' => 200
181
                );
182
            case 'text':
183
                return array(
184
                    'url' => vsprintf('/1.0/resource/book/text/%d', $params),
185
                    'method' => 'GET',
186
                    'code' => 200
187
                );
188
            default:
189
                throw new Exception('Route for ' . $method . ' not found');
190
        }
191
    }
192
}