Issues (233)

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/Utils/JSON.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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 11 and the first side effect is on line 11.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * JSON.php
4
 *
5
 * @author Tian.
6
 */
7
8
namespace Wechat\Utils;
9
10
// for PHP5.3, prevent PHP Notice msg assumed
11
defined('JSON_UNESCAPED_UNICODE') || define('JSON_UNESCAPED_UNICODE', 256);
12
13
/**
14
 * Unicode2multi characters supported for the wechat server
15
 */
16
class JSON
17
{
18
    /**
19
     * To prevent new operation, under static usage only
20
     */
21
    protected function __construct()
22
    {
23
    }
24
25
    /**
26
     * PHP >= 5.3 JSON_UNESCAPED_UNICODE constant supported
27
     *
28
     * @param mixed $value   The value (except a resource) being encoded.
29
     * @param int   $options Bitmask consisting of blah...
30
     * @param int   $depth   Set the maximum depth. Must be greater than zero.
31
     *
32
     * @see http://php.net/manual/en/function.json-encode.php
33
     *
34
     * @return mixed Returns a string containing the JSON representation of data
35
     */
36
    public static function encode($value, $options = 0, $depth = 512)
37
    {
38
        // multi-characters supported by default
39
        $options |= JSON_UNESCAPED_UNICODE;
40
41
        $data = version_compare(PHP_VERSION, '5.5.0', '>=')
42
            ? json_encode($value, $options, $depth)
43
            : json_encode($value, $options);
44
45
        if (JSON_ERROR_NONE !== json_last_error()) {
46
            return $data;
47
        }
48
49
        return version_compare(PHP_VERSION, '5.4.0', '>=')
50
            ? $data
51
            : preg_replace_callback("/\\\\u([0-9a-f]{2})([0-9a-f]{2})/iu", function ($pipe) {
52
                return iconv(
53
                    strncasecmp(PHP_OS, 'WIN', 3) ? 'UCS-2BE' : 'UCS-2',
54
                    'UTF-8',
55
                    chr(hexdec($pipe[1])) . chr(hexdec($pipe[2]))
56
                );
57
            }, $data);
58
    }
59
60
    /**
61
     * PHP >= 5.3 options supported (TODO)
62
     *
63
     * @param string $json    The json string being decoded.
64
     * @param bool   $assoc   When TRUE, returned objects will be converted into associative arrays.
65
     * @param int    $depth   User specified recursion depth.
66
     * @param int    $options Bitmask of JSON decode options blah...
67
     *
68
     * @see http://php.net/manual/en/function.json-decode.php
69
     *
70
     * @return mixed Returns the value encoded in json in appropriate PHP type.
71
     */
72
    public static function decode($json, $assoc = false, $depth = 512, $options = 0)
73
    {
74
        if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
75
            return json_decode($json, $assoc, $depth, $options);
76
        }
77
78
        return json_decode($json, $assoc, $depth);
79
    }
80
}
81