Issues (36)

Security Analysis    no request data  

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

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
 *
4
 * This file is part of the Apix Project.
5
 *
6
 * (c) Franck Cassedanne <franck at ouarz.net>
7
 *
8
 * @license     http://opensource.org/licenses/BSD-3-Clause  New BSD License
9
 *
10
 */
11
12
namespace Apix\Cache;
13
14
use Apix\Cache;
15
16
/**
17
 * Apix Cache Factory class provides a PSR-Cache wrapper.
18
 *
19
 * @author Franck Cassedanne <franck at ouarz.net>
20
 */
21
class Factory
22
{
23
24
    const ERROR = '%s requires either a supported client object e.g. "\Redis", "\MongoClient", ...; or an object that implements Apix\Cache\Adapter; or an adapter name (string) e.g. "APC", "array"; or even an a plain array().';
25
26
    /**
27
     * Holds an array of supported cache clients.
28
     * @var array
29
     */
30
    public static $clients = array(
31
        'Runtime', 'Array', 'ArrayObject', 'Apc',
32
        'Redis', 'MongoClient', 'Memcached', 'PDO',
33
        'Files', 'Directory'
34
    );
35
36
    /**
37
     * Holds an associative array of cache adapters.
38
     * @var array
39
     */
40
    public static $adapters = array(
41
        'MongoClient'   => 'Mongo',
42
        'PDO'           => 'Pdo',
43
        'ArrayObject'   => 'Runtime'
44
    );
45
46
    /**
47
     * Factory pattern.
48
     *
49
     * @param  mixed                                   $mix      Either a supported client object e.g. '\Redis';
50
     *                                                           or one that implements \Apix\Cache\Adapter;
51
     *                                                           or an adapter name (string) e.g. "APC", "Runtime";
52
     *                                                           or even a plain array() or \ArrayObject.
53
     * @param  array                                   $options  An array of options
54
     * @param  boolean                                 $taggable Wether to return a taggable pool.
55
     * @return PsrCache\Pool|PsrCache\TaggablePool
56
     * @throws PsrCache\InvalidArgumentException
57
     * @throws Apix\Cache\Exception
58
     */
59 289
    public static function getPool($mix, array $options=array(), $taggable=false)
60
    {
61 289
        switch (true) {
62
63 289
            case is_a($mix, 'Apix\Cache\Adapter'):
64 34
                $class = $mix;
65 34
                $mix = null;
66 34
            break;
67
68 255
            case is_object($mix)
0 ignored issues
show
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
69 255
                 && in_array($name = get_class($mix), self::$clients):
70
71 34
                if ($name == 'PDO') {
72 17
                    $name = 'Pdo\\' . AbstractPdo::getDriverName($mix);
73 17
                } else {
74 17
                    $name = isset(self::$adapters[$name])
75 17
                            ? self::$adapters[$name]
76 17
                            : $name;
77
                }
78 34
            break;
79
80 221
            case is_string($mix)
81 221
                 && in_array(
82 136
                        $name = strtolower($mix),
83 136
                        $clients = array_map('strtolower', self::$clients)
84 221
                    ):
85 119
                $key = array_search($name, $clients);
86 119
                $name = self::$clients[$key];
87 119
                $name = $name == 'Array' || $name == 'ArrayObject' ? 'Runtime' : $name;
88 119
                $mix = null;
89 119
            break;
90
91 102
            case is_array($mix):
92 68
                $name = 'Runtime';
93 68
            break;
94
95 34
            default:
96 34
                throw new PsrCache\InvalidArgumentException(
97 34
                    sprintf(self::ERROR, __CLASS__)
98 34
                );
99 34
        }
100
101 255
        if (!isset($class)) {
102 221
            $class = '\Apix\Cache\\' . $name;
103 221
        }
104
105 255
        $cache = null === $mix
106 255
                 ? new $class($options)
107 255
                 : new $class($mix, $options);
108
109
        return $taggable
110 255
                ? new PsrCache\TaggablePool($cache)
111 255
                : new PsrCache\Pool($cache);
112
    }
113
114
    /**
115
     * @see self::getPool
116
     * @return PsrCache\TaggablePool
117
     */
118 17
    public static function getTaggablePool($mix, array $options=array())
119
    {
120 17
        return self::getPool($mix, $options, true);
121
    }
122
123
}
124