GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (917)

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.

src/Locale/Locale.php (3 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 Nip\Locale;
4
5
use Locale as PhpLocale;
6
use Nip_File_System;
7
8
/**
9
 * Class Locale
10
 * @package Nip\Locale
11
 */
12
class Locale
13
{
14
15
    protected $supported;
16
17
    protected $data = [];
18
19
    protected $default = 'en_US';
20
21
    protected $current;
22
23
    public function getSupported()
24
    {
25
        if (!$this->supported) {
26
            $files = Nip_File_System::instance()->scanDirectory($this->getDataFolder());
27
            foreach ($files as $file) {
28
                if (substr($file, 0, 1) != '_') {
29
                    $name = str_replace('.php', '', $file);
30
                    $this->supported[] = $name;
31
                }
32
            }
33
        }
34
        return $this->supported;
35
    }
36
37
    /**
38
     * @return string
39
     */
40
    protected function getDataFolder()
41
    {
42
        return dirname(__FILE__) . '/data/';
43
    }
44
45
    /**
46
     * @param array $path
47
     * @param bool $locale
48
     * @return bool|mixed
49
     */
50
    public function getOption($path = [], $locale = false)
51
    {
52
        $data = $this->getData($locale);
53
        $value = $data;
54
        $pathFlat = '';
55
        foreach ($path as $key) {
56
            $pathFlat .= $key;
57
            if (isset ($value[$key])) {
58
                $value = $value[$key];
59
            } else {
60
                trigger_error("invalid path [{$pathFlat}] for " . __CLASS__ . "->" . __METHOD__, E_USER_WARNING);
61
                return false;
62
            }
63
        }
64
65
        return $value;
66
    }
67
68
    /**
69
     * @param bool $locale
70
     * @return mixed
71
     */
72
    public function getData($locale = false)
73
    {
74
        $locale = $locale ? $locale : $this->getCurrent();
75
        if (!isset($this->data[$locale])) {
76
            $data = $this->getDataFromFile($locale);
77
            $this->data[$locale] = $data;
78
        }
79
80
        return $this->data[$locale];
81
    }
82
83
    public function getCurrent()
84
    {
85
        if (!$this->current) {
86
            $this->initCurrent();
87
        }
88
89
        return $this->current;
90
    }
91
92
    /**
93
     * @param $locale
94
     */
95
    public function setCurrent($locale)
96
    {
97
        if ($this->isSupported($locale)) {
98
            $this->current = $locale;
99
        } else {
100
            $this->current = $this->default;
101
        }
102
    }
103
104
    public function initCurrent()
105
    {
106
        $locale = $this->getFromINI();
107
        if ($this->isSupported($locale)) {
108
            $this->setCurrent($locale);
109
        } else {
110
            $this->setCurrent($this->default);
111
        }
112
    }
113
114
    /**
115
     * @return string
116
     */
117
    public function getFromINI()
118
    {
119
        if (class_exists('Locale', false)) {
120
            return PhpLocale::getDefault();
121
        }
122
123
        return setlocale(LC_TIME, 0);
124
    }
125
126
    /**
127
     * @param $name
128
     * @return bool
129
     */
130
    public function isSupported($name)
131
    {
132
        return $this->hasDataFile($name);
133
    }
134
135
    /**
136
     * @param $name
137
     * @return bool
138
     */
139
    protected function hasDataFile($name)
140
    {
141
        return is_file($this->getDataFile($name));
142
    }
143
144
    /**
145
     * @param $name
146
     * @return string
147
     */
148
    protected function getDataFile($name)
149
    {
150
        return $this->getDataFolder() . $name . '.php';
151
    }
152
153
    /**
154
     * @param $name
155
     * @param array $data
156
     * @return array
157
     */
158
    protected function getDataFromFile($name, $data = [])
159
    {
160
        $file = $this->getDataFile($name);
161
162
        if (is_file($file)) {
163
            include $file;
164
            if (isset ($_import)) {
0 ignored issues
show
The variable $_import seems to never exist, and therefore isset should always return false. Did you maybe rename this variable?

This check looks for calls to isset(...) or empty() on variables that are yet undefined. These calls will always produce the same result and can be removed.

This is most likely caused by the renaming of a variable or the removal of a function/method parameter.

Loading history...
165
                $data = $this->getDataFromFile($_import);
166
            }
167
            if (isset ($_data)) {
0 ignored issues
show
The variable $_data seems to never exist, and therefore isset should always return false. Did you maybe rename this variable?

This check looks for calls to isset(...) or empty() on variables that are yet undefined. These calls will always produce the same result and can be removed.

This is most likely caused by the renaming of a variable or the removal of a function/method parameter.

Loading history...
168
                $data = \Nip\HelperBroker::get('Arrays')->merge_distinct($data, $_data);
0 ignored issues
show
It seems like you code against a specific sub-type and not the parent class Nip\Helpers\AbstractHelper as the method merge_distinct() does only exist in the following sub-classes of Nip\Helpers\AbstractHelper: Nip_Helper_Arrays. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
169
            }
170
        } else {
171
            trigger_error("no locale data file at [{$file}]", E_USER_NOTICE);
172
        }
173
174
        return $data;
175
    }
176
}
177