Issues (5)

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/FieldMigration.php (3 issues)

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 StoutLogic\ACF\Migrations;
4
5
class FieldMigration
6
{
7
    /**
8
     * @var Field
9
     */
10
    private $field;
11
12
    /**
13
     * @var Transform[]
14
     */
15
    private $transforms = [];
16
17
    /**
18
     * Include the option and options pages by default, this is what
19
     * ACF/ACF PRO will name an unnamed options page.
20
     * @var array
21
     */
22
    private $optionPages = ['option', 'options'];
23
24
    /**
25
     * MigrateField constructor.
26
     * @param string $fieldKey ACF Field key of field to be migrated
27
     */
28
    public function __construct($fieldKey)
29
    {
30
        $this->field = new Field($fieldKey);
31
    }
32
33
34
    /**
35
     * @param Transform $transform
36
     * @return $this
37
     */
38
    public function addTransform(Transform $transform)
39
    {
40
        $this->transforms[] = $transform;
41
42
        return $this;
43
    }
44
45
    /**
46
     * @return array
47
     */
48
    public function getTransforms()
49
    {
50
        return $this->transforms;
51
    }
52
53
    /**
54
     * Change the field name.
55
     * @param stirng $newName
56
     * @return $this
57
     */
58
    public function changeName($newName)
59
    {
60
        $this->transforms[] = new ChangeNameTransform($newName);
61
62
        return $this;
63
    }
64
65
    /**
66
     * Change the field key.
67
     * @param stirng $newKey
68
     * @return $this
69
     */
70
    public function changeKey($newKey)
71
    {
72
        $this->transforms[] = new ChangeKeyTransform($newKey);
73
74
        return $this;
75
    }
76
77
    /**
78
     * Pefrom the migration.
79
     */
80
    public function migrate()
81
    {
82
        array_map([$this, 'applyTransform'], $this->transforms);
83
    }
84
85
86
    /**
87
     * @return Field
88
     */
89
    public function getField()
90
    {
91
        return $this->field;
92
    }
93
94
95
    public function includeOptionPage($optionPage)
96
    {
97
        $this->optionPages[] = $optionPage;
98
99
        return $this;
100
    }
101
102
    public function excludeOptionPage($optionPage)
103
    {
104
        $this->optionPages = array_merge(array_filter($this->optionPages, function ($o) use ($optionPage) {
105
            return $o !== $optionPage;
106
        }));
107
108
        return $this;
109
    }
110
111
    public function getSubjects()
112
    {
113
        return array_merge(
114
            $this->getPosts(),
115
            $this->getTerms(),
116
            $this->getUsers(),
117
            $this->getComments(),
118
            $this->getOptions()
119
        );
120
    }
121
122
    private function applyTransform($transform)
123
    {
124
        $transform->setField($this->getField());
125
126
        foreach ($this->getSubjects() as $subject) {
127
            $transform->transformSubject($subject);
128
        }
129
130
        $transform->transformField();
131
    }
132
133
    /**
134
     * @return array
135
     */
136
    protected function getPosts()
137
    {
138
        return array_map(
139
            function ($id) {
140
                return new Post($id);
141
            },
142
            get_posts([
143
                'fields' => 'ids',
144
                'meta_value' => $this->getField()->getKey(),
145
            ])
146
        );
147
    }
148
149
    /**
150
     * @return array
151
     */
152 View Code Duplication
    protected function getTerms()
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...
153
    {
154
        return array_map(
155
            function ($id) {
156
                return new Term($id);
157
            },
158
            get_terms([
159
                'fields' => 'ids',
160
                'hide_empty' => false,
161
                'meta_value' => $this->getField()->getKey()
162
            ])
163
        );
164
    }
165
166
    /**
167
     * @return array
168
     */
169 View Code Duplication
    protected function getUsers()
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...
170
    {
171
        return array_map(
172
            function ($id) {
173
                return new User($id);
174
            },
175
            get_users([
176
                'fields' => 'ids',
177
                'hide_empty' => false,
178
                'meta_value' => $this->getField()->getKey()
179
            ])
180
        );
181
    }
182
183
    /**
184
     * @return array
185
     */
186 View Code Duplication
    protected function getComments()
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...
187
    {
188
        return array_map(
189
            function ($id) {
190
                return new Comment($id);
191
            },
192
            get_comments([
193
                'fields' => 'ids',
194
                'hide_empty' => false,
195
                'meta_value' => $this->getField()->getKey()
196
            ])
197
        );
198
    }
199
    /**
200
     * @return array
201
     */
202
    protected function getOptions()
203
    {
204
        return array_filter(
205
            array_map(function ($id) {
206
                return new OptionPage($id);
207
            }, $this->optionPages),
208
            function (OptionPage $optionPage) {
209
                return $optionPage->hasMetaValue($this->getField()->getKey());
210
            }
211
        );
212
    }
213
214
    /**
215
     * @return array
216
     */
217
    public
218
    function getOptionPages()
219
    {
220
        return $this->optionPages;
221
    }
222
}
223