Issues (7)

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/AbstractMigration.php (4 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 Rey\BitrixMigrations;
4
5
use Doctrine\DBAL\Migrations\AbstractMigration as DoctrineAbstractMigration;
6
use Rey\BitrixMigrations\Exception\UnexpectedTypeException;
7
8
/**
9
 * Абстрактный класс для миграции
10
 * Содержит вспомогательные функции для работы с api Битрикса
11
 */
12
abstract class AbstractMigration extends DoctrineAbstractMigration
13
{
14
    /**
15
     * @var string
16
     */
17
    private $siteId = 's1';
18
19
    /**
20
     * @var string
21
     */
22
    private $siteLanguageId = 'ru';
23
24
    /**
25
     * Получить формат даты и времени
26
     *
27
     * @return string
28
     */
29
    protected function getDateTimeFormat()
30
    {
31
        return 'DD.MM.YYYY HH:MI:SS';
32
    }
33
34
    /**
35
     * Получить путь до корня проекта
36
     *
37
     * @return string
38
     */
39
    protected function getDocumentRoot()
0 ignored issues
show
getDocumentRoot uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
40
    {
41
        return $_SERVER['DOCUMENT_ROOT'];
42
    }
43
44
    /**
45
     * Получить путь к personal root сайта
46
     *
47
     * Переопределить метод получения путей до дириктории PersonalRoot
48
     * в зависимости от Id сайта ($this->getSiteId()) при многосайтовости.
49
     *
50
     * @return null|string
51
     */
52
    protected function getPersonalRoot()
0 ignored issues
show
getPersonalRoot uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
53
    {
54
        return $_SERVER['BX_PERSONAL_ROOT'];
55
    }
56
57
    /**
58
     * Установить Id сайта
59
     *
60
     * @param string $siteId
61
     *
62
     * @throws Rey\BitrixMigrations\Exception\UnexpectedTypeException Если арумент $siteId не строка
63
     */
64
    protected function setSiteId($siteId)
65
    {
66
        if (!is_string($siteId)) {
67
            throw new UnexpectedTypeException($siteId, 'string');
68
        }
69
70
        $this->siteId = $siteId;
71
    }
72
73
    /**
74
     * Получить Id сайта
75
     *
76
     * @return string
77
     */
78
    protected function getSiteId()
79
    {
80
        return $this->siteId;
81
    }
82
83
    /**
84
     * Установить идентификатор языковой версии сайта
85
     *
86
     * @param string $siteLanguageId
87
     *
88
     * @throws Rey\BitrixMigrations\Exception\UnexpectedTypeException Если арумент $siteLanguageId не строка
89
     */
90
    protected function setSiteLanguageId($siteLanguageId)
91
    {
92
        if (!is_string($siteLanguageId)) {
93
            throw new UnexpectedTypeException($siteLanguageId, 'string');
94
        }
95
96
        $this->siteLanguageId = $siteLanguageId;
97
    }
98
99
    /**
100
     * Получить идентификатор языковой версии сайта
101
     *
102
     * @return string
103
     */
104
    protected function getSiteLanguageId()
105
    {
106
        return $this->siteLanguageId;
107
    }
108
109
    /**
110
     * Подключить api Битрикса
111
     */
112
    protected function enableBitrixAPI()
0 ignored issues
show
enableBitrixAPI uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
113
    {
114
        global $DBType, $DBHost, $DBLogin, $DBPassword, $DBName, $DBDebug;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
115
116
        $_SERVER['DOCUMENT_ROOT'] = $this->getDocumentRoot();
117
        $_SERVER['BX_PERSONAL_ROOT'] = $this->getPersonalRoot();
118
        $_SERVER['HTTP_X_REAL_IP'] = '127.0.0.1';
119
120
        $siteId = $this->getSiteId();
121
        $siteLanguageId = $this->getSiteLanguageId();
122
123
        define('FORMAT_DATETIME', $this->getDateTimeFormat());
124
        define('SITE_ID', $siteId);
125
        define('LANG', $siteLanguageId);
126
        define('NO_KEEP_STATISTIC', true);
127
        define('NOT_CHECK_PERMISSIONS', true);
128
        define('BX_CLUSTER_GROUP', -1);
129
130
        $this->disableCacheIBlock();
131
132
        require $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php';
133
134
        //Подключение автозагрузчика Bitrix
135
        if (function_exists('\__autoload')) {
136
            spl_autoload_register('\__autoload');
137
        }
138
    }
139
140
    /**
141
     * Выключает кеширование инфоблоков, типов инфоблоков и свойств
142
     *
143
     * Решает проблему при создание типа инфоблока и добавление новых инфоблоков в одной миграции
144
     */
145
    private function disableCacheIBlock()
146
    {
147
        define('CACHED_b_iblock_type', false);
148
        define('CACHED_b_iblock', false);
149
        define('CACHED_b_iblock_property_enum', false);
150
    }
151
}
152