Issues (19)

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

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
 * Konfig.
5
 *
6
 * Yet another simple configuration loader library.
7
 *
8
 * PHP version 5
9
 *
10
 * @category Library
11
 * @package  Konfig
12
 * @author   Xeriab Nabil (aka KodeBurner) <[email protected]>
13
 * @license  https://raw.github.com/xeriab/konfig/master/LICENSE MIT
14
 * @link     https://xeriab.github.io/projects/konfig
15
 */
16
17
namespace Exen\Konfig\FileParser;
18
19
use Exen\Konfig\Exception\ParseException;
20
use Exen\Konfig\Utils;
21
22
/**
23
 * Konfig's JSON parser class.
24
 *
25
 * @category FileParser
26
 * @package  Konfig
27
 * @author   Xeriab Nabil (aka KodeBurner) <[email protected]>
28
 * @license  https://raw.github.com/xeriab/konfig/master/LICENSE MIT
29
 * @link     https://xeriab.github.io/projects/konfig
30
 *
31
 * @implements Exen\Konfig\FileParser\AbstractFileParser
32
 */
33
class Json extends AbstractFileParser
34
{
35
    /**
36
     * Loads a JSON file as an array.
37
     *
38
     * @param string $path File path
39
     *
40
     * @throws ParseException If there is an error parsing JSON file
41
     *
42
     * @return array The parsed data
43
     *
44
     * @since 0.1.0
45
     */
46 6
    public function parse($path)
47
    {
48 6
        $data = $this->loadFile($path);
49
50 6
        if (function_exists('json_last_error_msg')) {
51 6
            $error_message = json_last_error_msg();
52 2
        } else {
53
            $error_message = 'Syntax error';
54
        }
55
56 6
        if (json_last_error() !== JSON_ERROR_NONE) {
57 3
            throw new ParseException(
58
                [
59 3
                'message' => $error_message,
60 3
                'type' => json_last_error(),
61 3
                'file' => $path,
62
                ]
63 1
            );
64
        }
65
66 3
        return $data;
67
    }
68
69
    /**
70
     * {@inheritdoc}
71
     *
72
     * @return array Supported extensions
73
     *
74
     * @since 0.1.0
75
     */
76 3
    public function getSupportedFileExtensions()
77
    {
78 3
        return ['json'];
79
    }
80
81
    /**
82
     * Loads in the given file and parses it.
83
     *
84
     * @param string $file File to load
85
     *
86
     * @return array The parsed file data
87
     *
88
     * @since              0.2.4
89
     * @codeCoverageIgnore
90
     */
91
    protected function loadFile($file = null)
92
    {
93
        $this->file = $file;
94
        $contents = $this->parseVars(Utils::getContent($file));
95
96
        return json_decode($contents, true);
97
    }
98
99
    /**
100
     * Returns the formatted configuration file contents.
101
     *
102
     * @param array $contents configuration array
103
     *
104
     * @return string formatted configuration file contents
105
     *
106
     * @since              0.2.4
107
     * @codeCoverageIgnore
108
     */
109
    protected function exportFormat($contents = null)
110
    {
111
        $this->prepVars($contents);
0 ignored issues
show
It seems like $contents defined by parameter $contents on line 109 can also be of type null; however, Exen\Konfig\FileParser\A...tFileParser::prepVars() does only seem to accept array, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
112
        return json_encode($contents);
113
    }
114
115
    /**
116
     * __toString.
117
     *
118
     * @return             string
119
     * @since              0.1.2
120
     * @codeCoverageIgnore
121
     */
122
    public function __toString()
123
    {
124
        return 'Exen\Konfig\FileParser\Json' . PHP_EOL;
125
    }
126
}
127
128
// END OF ./src/FileParser/Json.php FILE
129