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/Analytics/by-country.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: tanchik
4
 * Date: 28.07.14 13:32
5
 */
6
7
use Yandex\Metrica\Analytics\AnalyticsClient;
8
9
$data = array();
10
$errorMessage = false;
11
12
//Is auth
13
if (isset($_COOKIE['yaAccessToken']) && isset($_COOKIE['yaClientId'])) {
14
    $settings = require_once '../../settings.php';
15
16
    try {
17
        $analyticsClient = new AnalyticsClient($_COOKIE['yaClientId']);
18
19
        if (isset($_GET['counter-id']) && $_GET['counter-id']) {
20
            $counterId = $_GET['counter-id'];
21
22
            $paramsObj = new \Yandex\Metrica\Analytics\Models\Params();
23
            $paramsObj
24
                /**
25
                 * Метрики позволяют получать данные о статистике посещаемости и активности пользователей сайта.
26
                 * Если в запросе вы не укажете ни одной группировки,
27
                 * то API вернет общее значение метрики для выбранного временного интервала
28
                 * без разделения его на какие-либо группы
29
                 */
30
                ->setMetrics(\Yandex\Metrica\Analytics\MetricConst::GA_PAGE_VIEWS)
31
32
                /**
33
                 * Дата начала отчетного периода
34
                 */
35
                ->setStartDate('6daysAgo')
36
37
                /**
38
                 * Дата окончания отчетного периода
39
                 */
40
                ->setEndDate('today')
41
42
                /**
43
                 * Номер счетчика, данные которого необходимо получить
44
                 */
45
                ->setIds('ga:' . $_GET['counter-id'])
46
47
                /**
48
                 * Измерения группируют данные по критериям
49
                 */
50
                ->setDimensions(\Yandex\Metrica\Analytics\DimensionsConst::GA_COUNTRY);
51
52
            $analyticsClient = new AnalyticsClient($_COOKIE['yaAccessToken']);
53
54
            /**
55
             * @see http://api.yandex.ru/metrika/doc/beta/ga/queries/requestjson.xml
56
             */
57
            $data = $analyticsClient->ga()->getGaData($paramsObj);
58
        }
59
    } catch (\Exception $ex) {
60
        $errorMessage = $ex->getMessage();
61
        if ($errorMessage === 'PlatformNotAllowed') {
62
            $errorMessage .= '<p>Возможно, у приложения нет прав на доступ к ресурсу. Попробуйте '
63
                . '<a href="' . rtrim(str_replace($_SERVER['DOCUMENT_ROOT'], '', __DIR__), "/") . '/../OAuth/' . '">авторизироваться</a> и повторить.</p>';
64
        }
65
    }
66
}
67
?>
68
<!doctype html>
69
<html lang="en-US">
70
<head>
71
    <meta charset="UTF-8">
72
    <title>Yandex.SDK: Metrica Demo</title>
73
74
    <link rel="stylesheet" href="//yandex.st/bootstrap/3.0.3/css/bootstrap.min.css">
75
    <link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
76
    <link rel="stylesheet" href="/examples/Disk/css/style.css">
77
78
</head>
79
<body>
80
81
<div class="container">
82
    <div class="jumbotron">
83
        <h2><a href="/examples/Metrica"><span class="glyphicon glyphicon-tasks"></span></a> Пример работы с Яндекс Метрикой</h2>
84
    </div>
85
    <ol class="breadcrumb">
86
        <li><a href="/examples">Examples</a></li>
87
        <li><a href="/examples/Metrica">Metrica</a></li>
88
        <li><a href="/examples/Metrica/Analytics">Analytics</a></li>
89
        <li class="active">Просмотры по странам</li>
90
    </ol>
91
    <?php
92
    if (!isset($_COOKIE['yaAccessToken']) || !isset($_COOKIE['yaClientId'])) {
93
        ?>
94
        <div class="alert alert-info">
95
            Для просмотра этой страницы вам необходимо авторизироваться.
96
            <a id="goToAuth" href="/examples/OAuth" class="alert-link">Перейти на страницу авторизации</a>.
97
        </div>
98
    <?php
99
    } else {
100
        if ($errorMessage) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $errorMessage of type string|false 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...
101
            ?>
102
            <div class="alert alert-danger"><?= $errorMessage ?></div>
103
        <?php
104
        } else {
105
            ?>
106
            <div>
107
                <?php
108
                if ($data) {
109
                    ?>
110
                    <h3>Сравнение визитов с мобильных и не мобильных устройств:</h3>
111
                    <table id="accountTable" class="table table-striped table-bordered table-hover">
112
                        <thead>
113
                        <tr>
114
                            <td>Страна</td>
115
                            <td>Количество просмотров</td>
116
                        </tr>
117
                        </thead>
118
                        <tbody>
119
                        <?php
120
                        foreach ($data->getRows() as $row) { ?>
121
                            <tr>
122
                                <td><?= current($row) ?></td>
123
                                <td><?= end($row) ?></td>
124
                            </tr>
125
                        <?php
126
                        } ?>
127
                        </tbody>
128
                    </table>
129
                <?php
130
                }
131
                ?>
132
            </div>
133
        <?php
134
        }
135
    }
136
    ?>
137
</div>
138
139
<script src="http://yandex.st/jquery/2.0.3/jquery.min.js"></script>
140
<script src="http://yandex.st/bootstrap/3.0.3/js/bootstrap.min.js"></script>
141
142
</body>
143
</html>