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/Cache/Manager.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
namespace Nip\Cache;
4
5
use Nip\Filesystem\Exception\IOException;
6
use Nip_File_System as FileSystem;
7
8
/**
9
 * Class Manager
10
 * @package Nip\Cache
11
 */
12
class Manager
13
{
14
    protected $active = false;
15
16
    protected $ttl = 180;
17
18
    protected $data;
19
20
    /**
21
     * @param $cacheId
22
     * @return mixed
23
     */
24
    public function get($cacheId)
25
    {
26
        if (!$this->valid($cacheId)) {
27
            return null;
28
        }
29
30
        return $this->getData($cacheId);
31
    }
32
33
    /**
34
     * @param $cacheId
35
     * @return bool
36
     */
37
    public function valid($cacheId)
38
    {
39
        if ($this->isActive() && $this->exists($cacheId)) {
40
            $fmtime = filemtime($this->filePath($cacheId));
41
            if (($fmtime + $this->ttl) > time()) {
42
                return true;
43
            }
44
        }
45
46
        return false;
47
    }
48
49
    /**
50
     * @return bool
51
     */
52
    public function isActive()
53
    {
54
        return $this->active;
55
    }
56
57
    /**
58
     * @param $active
59
     * @return $this
60
     */
61
    public function setActive($active)
62
    {
63
        $this->active = $active;
64
65
        return $this;
66
    }
67
68
    /**
69
     * @param $cacheId
70
     * @return bool
71
     */
72
    public function exists($cacheId)
73
    {
74
        return file_exists($this->filePath($cacheId));
75
    }
76
77
    /**
78
     * @param $cacheId
79
     * @return string
80
     */
81
    public function filePath($cacheId)
82
    {
83
        return $this->cachePath() . $cacheId . '.php';
84
    }
85
86
    /**
87
     * @return string
88
     */
89
    public function cachePath()
90
    {
91
        return app('path.storage') . DIRECTORY_SEPARATOR . 'cache';
92
    }
93
94
    /**
95
     * @param $cacheId
96
     * @return mixed
97
     */
98
    public function getData($cacheId)
99
    {
100
        if (!isset($this->data[$cacheId])) {
101
            $this->data[$cacheId] = $this->loadData($cacheId);
102
        }
103
104
        return $this->data[$cacheId];
105
    }
106
107
    /**
108
     * @param $cacheId
109
     * @param bool $retry
110
     * @return bool|mixed
111
     */
112
    public function loadData($cacheId, $retry = true)
113
    {
114
        $file = $this->filePath($cacheId);
115
        $content = file_get_contents($file);
116
        $data = unserialize($content);
117
118
        if (!$data) {
119
            if ($retry === false) {
120
                return false;
121
            }
122
            $this->reload($cacheId);
123
124
            return $this->loadData($cacheId, false);
125
        }
126
127
        return $data;
128
    }
129
130
    /**
131
     * @param $cacheId
132
     */
133
    public function reload($cacheId)
134
    {
135
    }
136
137
    /**
138
     * @param $cacheId
139
     * @param $data
140
     * @return $this
141
     */
142
    public function set($cacheId, $data)
143
    {
144
        $this->data[$cacheId] = $data;
145
146
        return $this;
147
    }
148
149
    /**
150
     * @param $cacheId
151
     * @param $data
152
     * @return bool
153
     */
154
    public function saveData($cacheId, $data)
155
    {
156
        $file = $this->filePath($cacheId);
157
        $content = serialize($data);
158
159
        return $this->save($file, $content);
160
    }
161
162
    /**
163
     * @param $file
164
     * @param $content
165
     * @return bool
166
     */
167
    public function save($file, $content)
168
    {
169
        $dir = dirname($file);
170
        $filesystem = FileSystem::instance();
171
172
        if (!is_dir($dir)) {
173
            $filesystem->createDirectory($dir, 0777);
174
        }
175
176
        if (file_put_contents($file, $content)) {
177
            try {
178
                $filesystem->chmod($file, 0777);
179
            } catch (IOException $e) {
180
                // discard chmod failure (some filesystem may not support it)
181
            }
182
183
            return true;
184
        } else {
185
            $message = "Cannot open cache file for writing: ";
186
//			if (!Nip_Staging::instance()->isPublic()) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
52% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
187
//				$message .= " [ ".$this->cache_file." ] ";
188
//			}
189
            die($message);
0 ignored issues
show
Coding Style Compatibility introduced by
The method save() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
190
        }
191
    }
192
193
    /**
194
     * @param $cacheId
195
     */
196
    public function delete($cacheId)
197
    {
198
        $file = $this->filePath($cacheId);
199
        if (is_file($file)) {
200
            unlink($file);
201
        }
202
    }
203
}
204