Issues (183)

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.php (1 issue)

Severity

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
namespace FMUP;
3
4
use FMUP\Cache\Factory;
5
6
/**
7
 * Get the Cache instance
8
 * @package FMUP
9
 * @example
10
 */
11
class Cache
12
{
13
    /**
14
     * Cache instance
15
     * @var Cache
16
     */
17
    private static $instance = array();
18
19
    private $driver = Factory::DRIVER_RAM;
20
    private $cacheInstance = null;
21
    private $params = array();
22
    private $factory;
23
24
    /**
25
     * Multiton - private construct
26
     */
27 3
    private function __construct()
28
    {
29 3
    }
30
31
    /**
32
     * @param string $instanceKey
33
     * @return $this
34
     */
35 3
    final public static function getInstance($instanceKey)
36
    {
37 3
        if (!isset(self::$instance[$instanceKey])) {
38 3
            $class = get_called_class();
39
            /* @var $instance $this */
0 ignored issues
show
The doc-type $instance could not be parsed: Unknown type name "$instance" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
40 3
            $instance = new $class;
41 3
            self::$instance[$instanceKey] = $instance->setDriver($instanceKey);
42
        }
43 3
        return self::$instance[$instanceKey];
44
    }
45
46
    /**
47
     * @return Cache\CacheInterface
48
     * @throws Cache\Exception
49
     */
50 6
    final public function getCacheInstance()
51
    {
52 6
        if (!is_null($this->cacheInstance)) {
53 4
            return $this->cacheInstance;
54
        }
55
56 2
        $this->cacheInstance = $this->getFactory()->create($this->driver, $this->params);
57
58 1
        return $this->cacheInstance;
59
    }
60
61
    /**
62
     * Define a factory
63
     * @param Factory $factory
64
     * @return $this
65
     */
66 1
    public function setFactory(Factory $factory)
67
    {
68 1
        $this->factory = $factory;
69 1
        return $this;
70
    }
71
72
    /**
73
     * Get factory instance
74
     * @return Factory
75
     */
76 3
    public function getFactory()
77
    {
78 3
        if (!$this->factory) {
79 2
            $this->factory = Factory::getInstance();
80
        }
81 3
        return $this->factory;
82
    }
83
84
    /**
85
     * set cacheInstance
86
     * @param \FMUP\Cache\CacheInterface $instance
87
     * @return \FMUP\Cache
88
     */
89 2
    public function setCacheInstance(Cache\CacheInterface $instance)
90
    {
91 2
        $this->cacheInstance = $instance;
92 2
        return $this;
93
    }
94
95
    /**
96
     * set driver
97
     * @param string $driver
98
     * @return \FMUP\Cache
99
     */
100 4
    public function setDriver($driver)
101
    {
102 4
        $this->driver = $driver;
103 4
        return $this;
104
    }
105
106
    /**
107
     * Get defined driver
108
     * @return string
109
     */
110 2
    public function getDriver()
111
    {
112 2
        return $this->driver;
113
    }
114
115
    /**
116
     * set params for construct \FMUP\Cache\CacheInterface
117
     * @param array $params
118
     * @return $this
119
     */
120 1
    public function setParams(array $params)
121
    {
122 1
        $this->params = (array)$params;
123 1
        return $this;
124
    }
125
126
    /**
127
     * Driver settings
128
     * @return array
129
     */
130 2
    public function getParams()
131
    {
132 2
        return $this->params;
133
    }
134
135
    /**
136
     * set a param in cache
137
     * @param string $key
138
     * @param mixed $value
139
     * @return $this
140
     */
141 1
    public function set($key, $value)
142
    {
143 1
        $this->getCacheInstance()->set((string)$key, $value);
144 1
        return $this;
145
    }
146
147
    /**
148
     * return value of a param
149
     * @param string $key
150
     * @return mixed|null
151
     */
152 1
    public function get($key)
153
    {
154 1
        return $this->getCacheInstance()->get((string)$key);
155
    }
156
157
    /**
158
     * check param is set
159
     * @param string $key
160
     * @return bool
161
     */
162 2
    public function has($key)
163
    {
164 2
        return $this->getCacheInstance()->has((string)$key);
165
    }
166
167
    /**
168
     * remove param
169
     * @param string $key
170
     * @return $this
171
     */
172 1
    public function remove($key)
173
    {
174 1
        $this->getCacheInstance()->remove((string)$key);
175 1
        return $this;
176
    }
177
}
178