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/local-search.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  07.02.14 13:57
7
 */
8
9
use Yandex\Common\Exception\YandexException;
10
use Yandex\SafeBrowsing\Adapter\RedisAdapter;
11
use Yandex\SafeBrowsing\SafeBrowsingClient;
12
use Yandex\SafeBrowsing\SafeBrowsingException;
13
14
ini_set('memory_limit', '256M');
15
?>
16
<!doctype html>
17
<html lang="en-US">
18
<head>
19
    <meta charset="UTF-8">
20
    <title>Yandex PHP Library: Safe Browsing Demo</title>
21
    <link rel="stylesheet" href="//yandex.st/bootstrap/3.0.0/css/bootstrap.min.css">
22
    <link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
23
    <link rel="stylesheet" href="/examples/Disk/css/style.css">
24
    <style>
25
        .btn {
26
            padding: 6px 12px;
27
        }
28
    </style>
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">Поиск префикса хеша сайта в локальной БД</li>
37
    </ol>
38
    <h3>Поиск префикса хеша сайта в локальной БД</h3>
39
    <?php
40
    try {
41
42
        $settings = require_once '../settings.php';
43
44
        if (empty($settings['safebrowsing']['key'])) {
45
            throw new SafeBrowsingException('Empty Safe Browsing key');
46
        }
47
        if (empty($settings['safebrowsing']['redis_dsn'])) {
48
            throw new SafeBrowsingException('Empty Safe Browsing Redis DSN');
49
        }
50
51
        if (isset($_GET['url']) && $_GET['url']) {
52
            $url = $_GET['url'];
53
54
            $key = $settings['safebrowsing']['key'];
55
            $redisDsn = $settings['safebrowsing']['redis_dsn'];
56
            $redisOptions = [];
57 View Code Duplication
            if (isset($settings['safebrowsing']['redis_database'])) {
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...
58
                $redisOptions['parameters']['database'] = $settings['safebrowsing']['redis_database'];
59
            }
60 View Code Duplication
            if (isset($settings['safebrowsing']['redis_password'])) {
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...
61
                $redisOptions['parameters']['password'] = $settings['safebrowsing']['redis_password'];
62
            }
63
64
            $safeBrowsing = new SafeBrowsingClient($key);
65
            $redisAdapter = new RedisAdapter($redisDsn, $redisOptions);
66
67
            $hashes = $safeBrowsing->getHashesByUrl($url);
68
69
            if ($shaVars = $redisAdapter->getShaVarsByHashes($hashes)) {
70
                ?>
71
                <div class="alert alert-danger">
72
                    <p>Хеш для "<?= htmlentities($url) ?>" найден в списках:</p>
73
                    <ul>
74
                        <?php foreach ($shaVars as $shaVar) { ?>
75
                            <li><?= $shaVar ?></li>
76
                        <?php } ?>
77
                    </ul>
78
                </div>
79
            <?php
80
            } else {
81
                ?>
82
                <div class="alert alert-success"><?= htmlentities($url) ?> - не найден в списке опасных сайтов</div>
83
            <?php
84
            }
85
        }
86
        ?>
87
88
        <form method="get">
89
            <div class="input-group">
90
                <input name="url" placeholder="URL" type="text" class="form-control"/>
91
                <span class="input-group-btn">
92
                    <input class="btn btn-primary" type="submit" value="Проверить URL"/>
93
                </span>
94
            </div>
95
        </form>
96
        <p>
97
            Пример: http://www.wmconvirus.narod.ru/
98
        </p>
99
        <div>
100
            Также можно посмотреть примеры:
101
            <ul>
102
                <li>
103
                    <a href="index.php">Проверить адреса</a>
104
                </li>
105
                <li>
106
                    <a href="lookup.php">Lookup API и Check Adult API</a>
107
                </li>
108
                <li>
109
                    <a href="save-prefixes-db.php">Сохранение базы префиксов хешей вредоносных сайтов (начнется
110
                        автоматически)</a>
111
                </li>
112
                <li>
113
                    <a href="update-prefixes-db.php">Обновить локальную базу префиксов хешей вредоносных сайтов (начнется
114
                        автоматически)</a>
115
                </li>
116
            </ul>
117
        </div>
118
    <?php
119
    } catch (SafeBrowsingException $e) {
120
        echo "Safe Browsing Exception:<br/>";
121
        echo nl2br($e->getMessage());
122
    } catch (YandexException $e) {
123
        echo "Yandex Library Exception:<br/>";
124
        echo nl2br($e->getMessage());
125
    } catch (\Exception $e) {
126
        echo get_class($e) . "<br/>";
127
        echo nl2br($e->getMessage());
128
    }
129
    ?>
130
</div>
131
132
</body>
133
</html>
134