Issues (7)

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/Exception/WosServerException.php (6 issues)

Labels
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
3
/**
4
 * PHP Client for DDN Web Object Scalar (WOS) API
5
 *
6
 * @package Wosclient
7
 * @author  Casey McLaughlin <[email protected]>
8
 * @license http://opensource.org/licenses/MIT MIT
9
 * @link    https://github.com/caseyamcl/wosclient
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 *
14
 * ------------------------------------------------------------------
15
 */
16
17
namespace WosClient\Exception;
18
19
/**
20
 * WOS Exceptions are thrown when the WOS returns error codes
21
 *
22
 * Specifically, non-0 x-ddn-status HTTP headers are translated to this
23
 *
24
 * @author Casey McLaughlin <[email protected]>
25
 */
26
class WosServerException extends WosException
27
{
28
    const UNKNOWN_NAME    = 'UNKNOWN';
29
    const UNKNOWN_MEANING = 'Unknown or undocumented WOS error code returned';
30
31
    /**
32
     * Code Names Map
33
     *
34
     * @var array|string[]
35
     */
36
    private static $codeNames  = [
37
        200 => 'NoNodeForPolicy',
38
        201 => 'NoNodeForObject',
39
        202 => 'UnknownPolicyName',
40
        203 => 'InternalError',
41
        205 => 'InvalidObjId',
42
        206 => 'NoSpace',
43
        207 => 'ObjNotFound',
44
        208 => 'ObjCorrupted',
45
        209 => 'FsCorrupted',
46
        210 => 'PolicyNotSupported',
47
        211 => 'IOErr',
48
        212 => 'InvalidObjectSize',
49
        214 => 'TemporarilyNotSupported',
50
        216 => 'ReservationNotFound',
51
        217 => 'EmptyObject',
52
        218 => 'InvalidMetadataKey',
53
        219 => 'UnusedReservation',
54
        220 => 'WireCorruption',
55
        221 => 'CommandTimeout',
56
        222 => 'InvalidGetSpan'
57
    ];
58
59
    /**
60
     * Code Meanings Map
61
     *
62
     * @var array|string[]
63
     */
64
    private static $codeMeanings = [
65
        200 => 'No nodes will accept Put or Reserve operations for this policy',
66
        201 => 'No nodes have a copy of the requested object',
67
        202 => 'Policy name or id is not currently supported by the cluster',
68
        203 => 'Unknown internal Error',
69
        205 => 'An invalid OID was specified',
70
        206 => 'The cluster is full',
71
        207 => 'Object cannot be located',
72
        208 => 'Object does not match its checksum',
73
        209 => 'Filesystem internal structures are corrupted',
74
        210 => 'Insufficient cluster resources to service Put or Reserve request for this policy',
75
        211 => 'Unrecoverable drive error',
76
        212 => '> 5 TB',
77
        214 => 'Operation should be retried momentarily',
78
        216 => 'Reservation not found for specified OID',
79
        217 => 'Attempt to store a zero-length object',
80
        218 => 'Invalid metadata key specified',
81
        219 => 'Attempted Get of an unused reservation',
82
        220 => 'Uncorrectable network corruption of the object',
83
        221 => 'Command did not complete in a timely manner',
84
        222 => 'Illegal combination of buffered=true, integity=false'
85
    ];
86
87
    // ---------------------------------------------------------------
88
89
    /**
90
     * WosServerException constructor.
91
     *
92
     * @param string     $code
93
     * @param string     $message
94
     * @param \Exception $previous
95
     */
96
    public function __construct($code, $message = '', \Exception $previous = null)
97
    {
98
        // If we get a '0' from the server, and we throw this exception, then
99
        // something is wrong in this codebase.
100
        if ($code == 0) {
101
            throw new \LogicException('0 DDN code is not an error code (it is the success code)');
102
        }
103
104
        // Automatically set message if not specified
105
        if (! $message) {
106
            $message = array_key_exists($code, static::$codeMeanings)
0 ignored issues
show
Since $codeMeanings is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $codeMeanings to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
107
                ? static::$codeMeanings[$code]
0 ignored issues
show
Since $codeMeanings is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $codeMeanings to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
108
                : static::UNKNOWN_MEANING;
109
        }
110
111
        parent::__construct($message, $code, $previous);
112
    }
113
114
    /**
115
     * Get DDN error name
116
     *
117
     * @return string
118
     */
119
    public function getErrorName()
120
    {
121
        return array_key_exists($this->getCode(), static::$codeNames)
0 ignored issues
show
Since $codeNames is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $codeNames to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
122
            ? static::$codeNames[$this->getCode()]
0 ignored issues
show
Since $codeNames is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $codeNames to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
123
            : static::UNKNOWN_NAME;
124
    }
125
126
    /**
127
     * Get the DDN error meaning
128
     *
129
     * @return string
130
     */
131
    public function getErrorMeaning()
132
    {
133
        return array_key_exists($this->getCode(), static::$codeMeanings)
0 ignored issues
show
Since $codeMeanings is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $codeMeanings to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
134
            ? static::$codeMeanings[$this->getCode()]
0 ignored issues
show
Since $codeMeanings is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $codeMeanings to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
135
            : static::UNKNOWN_MEANING;
136
    }
137
138
    /**
139
     * @return string
140
     */
141
    public function __toString()
142
    {
143
        return sprintf('%s %s: %s', $this->getCode(), $this->getErrorName(), $this->getErrorMeaning());
144
    }
145
}
146