Issues (302)

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.

examples/Metrica/Stat/index.php (1 issue)

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
 * User: Tanya Kalashnik
4
 * Date: 21.07.14 12:47
5
 */
6
7
use Yandex\Metrica\Management\ManagementClient;
8
9
10
$counters = [];
11
$errorMessage = false;
12
13
//Is auth
14
if (isset($_COOKIE['yaAccessToken']) && isset($_COOKIE['yaClientId'])) {
15
    $settings = require_once '../../settings.php';
16
17
18
    try {
19
        $managementClient = new ManagementClient($_COOKIE['yaAccessToken']);
20
21
        $paramsObj = new \Yandex\Metrica\Management\Models\CountersParams();
22
        $paramsObj
23
            /**
24
             * Тип счетчика. Возможные значения:
25
             * simple ― счетчик создан пользователем в Метрике;
26
             * partner ― счетчик импортирован из РСЯ.
27
             */
28
            ->setType(\Yandex\Metrica\Management\AvailableValues::TYPE_SIMPLE)
29
            ->setField('goals,mirrors,grants,filters,operations');
30
31
        /**
32
         * @see http://api.yandex.ru/metrika/doc/beta/management/counters/counters.xml
33
         */
34
        $counters = $managementClient->counters()->getCounters($paramsObj)->getCounters();
35
    } catch (\Yandex\Common\Exception\UnauthorizedException $ex) {
36
        $errorMessage = '<p>Недействительный токен. Вам необходимо '
37
            . '<a href="' . rtrim(str_replace($_SERVER['DOCUMENT_ROOT'], '', __DIR__), "/") . '/../OAuth/' . '">авторизироваться</a> и повторить попытку.</p>';
38
    } catch (\Yandex\Common\Exception\ForbiddenException $ex) {
39
        $errorMessage = '<p>Возможно, у приложения нет прав на доступ к ресурсу. Попробуйте '
40
            . '<a href="' . rtrim(str_replace($_SERVER['DOCUMENT_ROOT'], '', __DIR__), "/") . '/../OAuth/' . '">авторизироваться</a> и повторить.</p>';
41
    } catch (\Exception $ex) {
42
        $errorMessage = $ex->getMessage();
43
    }
44
}
45
?>
46
<!doctype html>
47
<html lang="en-US">
48
<head>
49
    <meta charset="UTF-8">
50
    <title>Yandex.SDK: Metrica Demo</title>
51
52
    <link rel="stylesheet" href="//yandex.st/bootstrap/3.0.3/css/bootstrap.min.css">
53
    <link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
54
    <link rel="stylesheet" href="/examples/Disk/css/style.css">
55
56
</head>
57
<body>
58
59
<div class="container">
60
    <div class="jumbotron">
61
        <h2><a href="/examples/Metrica"><span class="glyphicon glyphicon-tasks"></span></a> Пример работы с Яндекс Метрикой</h2>
62
    </div>
63
    <ol class="breadcrumb">
64
        <li><a href="/examples">Examples</a></li>
65
        <li><a href="/examples/Metrica">Metrica</a></li>
66
        <li class="active">Stat</li>
67
    </ol>
68
    <?php
69
    if (!isset($_COOKIE['yaAccessToken']) || !isset($_COOKIE['yaClientId'])) {
70
        ?>
71
        <div class="alert alert-info">
72
            Для просмотра этой страницы вам необходимо авторизироваться.
73
            <a id="goToAuth" href="/examples/OAuth" class="alert-link">Перейти на страницу авторизации</a>.
74
        </div>
75
    <?php
76
    } else {
77
        if ($errorMessage) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $errorMessage of type false|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== false instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
78
            ?>
79
            <div class="alert alert-danger"><?= $errorMessage ?></div>
80
        <?php
81
        } else {
82
            ?>
83
            <div>
84
                <h3>Счетчики:</h3>
85
                <table id="countersTable" class="table table-striped table-bordered table-hover">
86
                    <thead>
87
                    <tr>
88
                        <td>ID</td>
89
                        <td>Название</td>
90
                    </tr>
91
                    </thead>
92
                    <tbody>
93
                    <?php
94
                    if ($counters instanceof Traversable) {
95
                        foreach ($counters as $counter) {
96
                            ?>
97
                            <tr data-counter-id="<?= $counter->getId() ?>">
98
                                <td><?= $counter->getId() ?></td>
99
                                <td><?= $counter->getName() ?></td>
100
                                <td>
101
                                    <a href="/examples/Metrica/Stat/data.php?counter-id=<?= $counter->getId() ?>"
102
                                       class="btn btn-primary">Отчет «Технологии — Браузеры»</a><br/>
103
                                    <a href="/examples/Metrica/Stat/bytime.php?counter-id=<?= $counter->getId() ?>"
104
                                       class="btn btn-info">Отображение данных по времени</a><br/>
105
                                    <a href="/examples/Metrica/Stat/comparison.php?counter-id=<?= $counter->getId() ?>"
106
                                       class="btn btn-warning">Сравнение сегментов</a><br/>
107
                                </td>
108
                            </tr>
109
110
                        <?php
111
                        }
112
                    }
113
                    ?>
114
                    </tbody>
115
                </table>
116
            </div>
117
        <?php
118
        }
119
    }
120
    ?>
121
</div>
122
123
<!-- Modal -->
124
<div class="modal fade" id="errorModal" tabindex="-1" role="dialog" aria-hidden="true">
125
    <div class="modal-dialog">
126
        <div class="modal-content">
127
            <div class="modal-header">
128
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
129
                <h4 class="modal-title">Ошибка</h4>
130
            </div>
131
            <div class="modal-body">
132
                <div id="errorMessage"></div>
133
            </div>
134
            <div class="modal-footer">
135
                <button type="button" class="btn btn-default" data-dismiss="modal">Закрыть</button>
136
            </div>
137
        </div>
138
    </div>
139
</div>
140
141
<script src="http://yandex.st/jquery/2.0.3/jquery.min.js"></script>
142
<script src="http://yandex.st/bootstrap/3.0.3/js/bootstrap.min.js"></script>
143
144
</body>
145
</html>
146