Issues (14)

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/Setting/Form/SettingFormFields.php (4 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 namespace Anomaly\SettingsModule\Setting\Form;
2
3
use Anomaly\SettingsModule\Setting\Contract\SettingRepositoryInterface;
4
use Illuminate\Config\Repository;
5
6
/**
7
 * Class SettingFormFields
8
 *
9
 * @link          http://pyrocms.com/
10
 * @author        PyroCMS, Inc. <[email protected]>
11
 * @author        Ryan Thompson <[email protected]>
12
 */
13
class SettingFormFields
14
{
15
16
    /**
17
     * The config repository.
18
     *
19
     * @var Repository
20
     */
21
    protected $config;
22
23
    /**
24
     * Create a new SettingFormFields instance.
25
     *
26
     * @param Repository $config
27
     */
28
    public function __construct(Repository $config)
29
    {
30
        $this->config = $config;
31
    }
32
33
    /**
34
     * Return the form fields.
35
     *
36
     * @param SettingFormBuilder $builder
37
     */
38
    public function handle(SettingFormBuilder $builder, SettingRepositoryInterface $settings)
39
    {
40
        $namespace = $builder->getFormEntry() . '::';
41
42
        /*
43
         * Get the fields from the config system. Sections are
44
         * optionally defined the same way.
45
         */
46
        if (!$fields = $this->config->get($namespace . 'settings/settings')) {
47
            $fields = $fields = $this->config->get($namespace . 'settings', []);
48
        }
49
50
        if ($sections = $this->config->get($namespace . 'settings/sections')) {
51
            $builder->setSections($sections);
52
        }
53
54
        /*
55
         * Finish each field.
56
         */
57
        foreach ($fields as $slug => &$field) {
58
59
            /*
60
             * Force an array. This is done later
61
             * too in normalization but we need it now
62
             * because we are normalizing / guessing our
63
             * own parameters somewhat.
64
             */
65
            if (is_string($field)) {
66
                $field = [
67
                    'type' => $field,
68
                ];
69
            }
70
71
            // Make sure we have a config property.
72
            $field['config'] = array_get($field, 'config', []);
73
74 View Code Duplication
            if (trans()->has(
0 ignored issues
show
This code seems to be duplicated across 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...
75
                $label = array_get(
76
                    $field,
77
                    'label',
78
                    $namespace . 'setting.' . $slug . '.label'
79
                )
80
            )
81
            ) {
82
                $field['label'] = $label;
83
            }
84
85
            // Default the label.
86
            $field['label'] = array_get(
87
                $field,
88
                'label',
89
                $namespace . 'setting.' . $slug . '.name'
90
            );
91
92
            // Default the warning.
93 View Code Duplication
            if (trans()->has(
0 ignored issues
show
This code seems to be duplicated across 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...
94
                $warning = array_get(
95
                    $field,
96
                    'warning',
97
                    $namespace . 'setting.' . $slug . '.warning'
98
                )
99
            )
100
            ) {
101
                $field['warning'] = $warning;
102
            }
103
104
            // Default the placeholder.
105 View Code Duplication
            if (trans()->has(
0 ignored issues
show
This code seems to be duplicated across 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...
106
                $placeholder = array_get(
107
                    $field,
108
                    'placeholder',
109
                    $namespace . 'setting.' . $slug . '.placeholder'
110
                )
111
            )
112
            ) {
113
                $field['placeholder'] = $placeholder;
114
            }
115
116
            // Default the instructions.
117 View Code Duplication
            if (trans()->has(
0 ignored issues
show
This code seems to be duplicated across 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...
118
                $instructions = array_get(
119
                    $field,
120
                    'instructions',
121
                    $namespace . 'setting.' . $slug . '.instructions'
122
                )
123
            )
124
            ) {
125
                $field['instructions'] = $instructions;
126
            }
127
128
            // Get the value defaulting to the default value.
129
            if (!isset($field['value'])) {
130
                $field['value'] = $settings->value($namespace . $slug, array_get($field['config'], 'default_value'));
131
            }
132
133
            /*
134
             * Disable the field if it
135
             * has a set env value.
136
             */
137
            if (isset($field['env']) && isset($field['bind']) && env($field['env']) !== null) {
138
                $field['disabled'] = true;
139
                $field['warning']  = 'module::message.env_locked';
140
                $field['value']    = $this->config->get($field['bind']);
141
            }
142
        }
143
144
        $builder->setFields($fields);
145
    }
146
}
147