Issues (10)

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/Mutable.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
namespace Sofa\Eloquence;
4
5
use Sofa\Eloquence\Mutable\Hooks;
6
use Sofa\Eloquence\Mutator\Mutator;
7
use Sofa\Eloquence\Contracts\Mutator as MutatorContract;
8
9
/**
10
 * @property array $setterMutators
11
 * @property array $getterMutators
12
 */
13
trait Mutable
14
{
15
    /**
16
     * Attribute mutator instance.
17
     *
18
     * @var \Sofa\Eloquence\Contracts\Mutator
19
     */
20
    protected static $attributeMutator;
21
22
    /**
23
     * Register hooks for the trait.
24
     *
25
     * @codeCoverageIgnore
26
     *
27
     * @return void
28
     */
29
    public static function bootMutable()
30
    {
31
        if (!isset(static::$attributeMutator)) {
32
            if (function_exists('app') && app()->bound('eloquence.mutator')) {
33
                static::setAttributeMutator(app('eloquence.mutator'));
34
            } else {
35
                static::setAttributeMutator(new Mutator);
36
            }
37
        }
38
        
39
        $hooks = new Hooks;
40
41
        foreach (['setAttribute', 'getAttribute', 'toArray'] as $method) {
42
            static::hook($method, $hooks->{$method}());
43
        }
44
    }
45
46
    /**
47
     * Mutate mutable attributes for array conversion.
48
     *
49
     * @param  array $attributes
50
     * @return array
51
     */
52 View Code Duplication
    protected function mutableAttributesToArray(array $attributes)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
53
    {
54
        foreach ($attributes as $key => $value) {
55
            if ($this->hasGetterMutator($key)) {
56
                $attributes[$key] = $this->mutableMutate($key, $value, 'getter');
57
            }
58
        }
59
60
        return $attributes;
61
    }
62
63
    /**
64
     * Determine whether an attribute has getter mutators defined.
65
     *
66
     * @param  string  $key
67
     * @return boolean
68
     */
69
    public function hasGetterMutator($key)
70
    {
71
        return array_key_exists($key, $this->getMutators('getter'));
72
    }
73
74
    /**
75
     * Determine whether an attribute has setter mutators defined.
76
     *
77
     * @param  string  $key
78
     * @return boolean
79
     */
80
    public function hasSetterMutator($key)
81
    {
82
        return array_key_exists($key, $this->getMutators('setter'));
83
    }
84
85
    /**
86
     * Mutate the attribute.
87
     *
88
     * @param  string $key
89
     * @param  string $value
90
     * @param  string $dir
91
     * @return mixed
92
     */
93
    protected function mutableMutate($key, $value, $dir)
94
    {
95
        $mutators = $this->getMutatorsForAttribute($key, $dir);
96
97
        return static::$attributeMutator->mutate($value, $mutators);
98
    }
99
100
    /**
101
     * Get the mutators for an attribute.
102
     *
103
     * @param  string $key
104
     * @return string
105
     */
106
    protected function getMutatorsForAttribute($key, $dir)
107
    {
108
        return $this->getMutators($dir)[$key];
109
    }
110
111
    /**
112
     * Get the array of attribute mutators.
113
     *
114
     * @param  string $dir
115
     * @return array
116
     */
117
    public function getMutators($dir)
118
    {
119
        $property = ($dir === 'setter') ? 'setterMutators' : 'getterMutators';
120
121
        return (property_exists($this, $property)) ? $this->{$property} : [];
122
    }
123
124
    /**
125
     * Set attribute mutator instance.
126
     *
127
     * @codeCoverageIgnore
128
     *
129
     * @param  \Sofa\Eloquence\Contracts\Mutator $mutator
130
     * @return void
131
     */
132
    public static function setAttributeMutator(MutatorContract $mutator)
133
    {
134
        static::$attributeMutator = $mutator;
135
    }
136
137
    /**
138
     * Get attribute mutator instance.
139
     *
140
     * @codeCoverageIgnore
141
     *
142
     * @return \Sofa\Eloquence\Contracts\Mutator
143
     */
144
    public static function getAttributeMutator()
145
    {
146
        return static::$attributeMutator;
147
    }
148
}
149