Issues (1)

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/StorageConverterTrait.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
namespace Benrowe\Laravel\Config;
4
5
/**
6
 * Facilitates the conversion of hierarchical data into a flat structure
7
 *
8
 * @package Benrowe\Laravel\Config
9
 */
10
trait StorageConverterTrait
11
{
12
    /**
13
     * Converts the flat key/value from the storage engine
14
     * to a heirachy structure based on the key sytax
15
     *
16
     * @param  array $data
17
     * @return array
18
     */
19
    private function dataDecode($data)
20
    {
21
        // preprocess the keys into a unique list where the array values are
22
        // stored against the same key
23
24
        $data = $this->unpackArray($data);
25
26
        $newData = [];
27
        foreach ($data as $key => $value) {
28
            $this->arrHelper->set($newData, $key, $value);
0 ignored issues
show
The property arrHelper does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
29
        }
30
31
        return $newData;
32
    }
33
34
    /**
35
     * unpack the keys that are structured for arrays so that they no
36
     * longer have the [] syntax at the end. Rather they're now a proper
37
     * array.
38
     *
39
     * @param  array $data [description]
40
     * @return array
41
     */
42
    private function unpackArray($data)
43
    {
44
        $arrKeys = array_filter($data, function ($val) {
45
            return preg_match(self::ARRAY_PATTERN, $val);
46
        });
47
        foreach ($arrKeys as $key => $value) {
48
            $newKey = preg_replace(self::ARRAY_PATTERN, '', $key);
49
            if (!isset($data[$newKey])) {
50
                $data[$newKey] = [];
51
            }
52
            $data[$newKey][] = $value;
53
            unset($data[$key]);
54
        }
55
        return $data;
56
    }
57
58
    /**
59
     * Flatten a multi-dimensional array into a linear key/value list
60
     *
61
     * @param  array $data
62
     * @param string|null $prefix
63
     * @return array
64
     */
65
    private function dataEncode($data, $prefix = null)
66
    {
67
        $newData = [];
68
        foreach ($data as $key => $value) {
69
            if (is_array($value)) {
70
                $newData = array_merge(
71
                    $newData,
72
                    $this->encodeArray($key, $value, $prefix)
73
                );
74
                continue;
75
            }
76
            $newData[$prefix.$key] = $value;
77
        }
78
        return $newData;
79
    }
80
81
    /**
82
     * Encode the array of values against the provided key
83
     *
84
     * @param  string $key
85
     * @param  array  $value  either an associative or keyed array
86
     * @param  string|null $prefix
87
     * @return array
88
     */
89
    private function encodeArray($key, array $value, $prefix = null)
90
    {
91
        $data = [];
92
        if (!$this->arrHelper->isAssoc($value)) {
93
            foreach ($value as $index => $val) {
94
                $data[$prefix.$key.'['.$index.']'] = $val;
95
            }
96
            return $data;
97
        }
98
        return $this->dataEncode($value, $prefix.$key.self::KEY_DELIMITER);
99
    }
100
}
101