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/SafeBrowsing/lookup.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
 * Example of usage Yandex\SafeBrowsing package
4
 *
5
 * @author   Alexander Khaylo <[email protected]>
6
 * @created  10.02.14 18:06
7
 */
8
9
use Yandex\SafeBrowsing\SafeBrowsingClient;
10
use Yandex\SafeBrowsing\SafeBrowsingException;
11
use Yandex\Common\Exception\YandexException;
12
13
?>
14
<!doctype html>
15
<html lang="en-US">
16
<head>
17
    <meta charset="UTF-8">
18
    <title>Yandex PHP Library: Safe Browsing Demo</title>
19
20
    <link rel="stylesheet" href="//yandex.st/bootstrap/3.0.0/css/bootstrap.min.css">
21
    <link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
22
    <link rel="stylesheet" href="/examples/Disk/css/style.css">
23
    <style>
24
        .btn {
25
            padding: 6px 12px;
26
        }
27
    </style>
28
29
</head>
30
<body>
31
32
<div class="container">
33
    <ol class="breadcrumb">
34
        <li><a href="/examples">Examples</a></li>
35
        <li><a href="/examples/SafeBrowsing">SafeBrowsing</a></li>
36
        <li class="active">Lookup API и Check Adult API</li>
37
    </ol>
38
    <h3>Lookup API и Check Adult API</h3>
39
    <?php
40
    try {
41
42
        $settings = require_once '../settings.php';
43
44 View Code Duplication
        if (!isset($settings["safebrowsing"]["key"]) || !$settings["safebrowsing"]["key"]) {
0 ignored issues
show
This code seems to be duplicated across 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...
45
            throw new SafeBrowsingException('Empty Safe Browsing key');
46
        }
47
48
        if (isset($_GET['url']) && $_GET['url']) {
49
            $url = $_GET['url'];
50
51
            $key = $settings["safebrowsing"]["key"];
52
53
            $safeBrowsing = new SafeBrowsingClient($key);
54
55
            /**
56
             * Using "lookup" request
57
             */
58
            $result = $safeBrowsing->lookup($url);
59
60
            if ($result) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $result 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...
61
                ?>
62
                <div class="alert alert-danger">Небезопасный адресс. Lookup ответ: "<?= $result ?>"</div>
63
            <?php
64
            } else {
65
                ?>
66
                <div class="alert alert-success"><?= htmlentities($url) ?> - не найден в списке опасных сайтов</div>
67
            <?php
68
            }
69
            /**
70
             * Using "cp" request
71
             */
72
            if ($safeBrowsing->checkAdult($url)) {
73
                ?>
74
                <div class="alert alert-danger">Сайт для взрослых</div>
75
            <?php
76
            } else {
77
                ?>
78
                <div class="alert alert-success">Сайт для всех</div>
79
            <?php
80
            }
81
        }
82
        ?>
83
84
        <form method="get">
85
            <div class="input-group">
86
                <input name="url" placeholder="URL" type="text" class="form-control"/>
87
                <span class="input-group-btn">
88
                    <input class="btn btn-primary" type="submit" value="Проверить URL"/>
89
                </span>
90
            </div>
91
        </form>
92
        <p>
93
            Пример: http://www.wmconvirus.narod.ru/
94
        </p>
95
        <div>
96
            Также можно посмотреть примеры:
97
            <ul>
98
                <li>
99
                    <a href="index.php">Проверить адреса</a>
100
                </li>
101
                <li>
102
                    <a href="local-search.php">Поиск префикса хеша сайта в локальной БД</a>
103
                </li>
104
                <li>
105
                    <a href="save-prefixes-db.php">Сохранение базы префиксов хешей вредоносных сайтов (начнется
106
                        автоматически)</a>
107
                </li>
108
                <li>
109
                    <a href="update-prefixes-db.php">Обновить локальную базу префиксов хешей вредоносных сайтов (начнется
110
                        автоматически)</a>
111
                </li>
112
            </ul>
113
        </div>
114
    <?php
115
    } catch (SafeBrowsingException $e) {
116
        echo "Safe Browsing Exception:<br/>";
117
        echo nl2br($e->getMessage());
118
    } catch (YandexException $e) {
119
        echo "Yandex Library Exception:<br/>";
120
        echo nl2br($e->getMessage());
121
    } catch (\Exception $e) {
122
        echo get_class($e) . "<br/>";
123
        echo nl2br($e->getMessage());
124
    }
125
    ?>
126
</div>
127
</body>
128
</html>
129