Issues (1)

Security Analysis    not enabled

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/SegmentField.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 SilverStripe\Forms;
4
5
use SilverStripe\View\Requirements;
6
7
class SegmentField extends TextField
8
{
9
    /**
10
     * @var array
11
     */
12
    private static $allowed_actions = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
13
        'suggest',
14
    );
15
16
    /**
17
     * @var string
18
     */
19
    protected $template = __CLASS__;
20
21
    /**
22
     * @var array
23
     */
24
    protected $modifiers = array();
25
26
    /**
27
     * @var string
28
     */
29
    protected $preview = '';
30
31
    /**
32
     * @var string
33
     */
34
    protected $helpText;
35
36
    /**
37
     * @param array $modifiers
38
     *
39
     * @return $this
40
     */
41
    public function setModifiers(array $modifiers)
42
    {
43
        $this->modifiers = $modifiers;
44
45
        return $this;
46
    }
47
48
    /**
49
     * @return array
50
     */
51
    public function getModifiers()
52
    {
53
        return $this->modifiers;
54
    }
55
56
    /**
57
     * @param string $preview
58
     *
59
     * @return $this
60
     */
61
    public function setPreview($preview)
62
    {
63
        $this->preview = $preview;
64
65
        return $this;
66
    }
67
68
    /**
69
     * @return string
70
     */
71
    public function Preview()
72
    {
73
        return $this->preview;
74
    }
75
76
    /**
77
     * @inheritdoc
78
     *
79
     * @param array $properties
80
     *
81
     * @return string
82
     */
83
    public function Field($properties = array())
84
    {
85
        Requirements::javascript('silverstripe/segment-field:client/dist/js/segment-field.js');
86
        Requirements::css('silverstripe/segment-field:client/dist/styles/segment-field.css');
87
88
        return parent::Field($properties);
89
    }
90
91
    public function Type()
92
    {
93
        return 'segment text';
94
    }
95
96
    /**
97
     * @inheritdoc
98
     *
99
     * @param mixed $request
100
     *
101
     * @return string
102
     */
103
    public function suggest($request)
104
    {
105
        $form = $this->getForm();
106
107
        $preview = $suggestion = '';
108
109
        foreach ($this->modifiers as $modifier) {
110
            if ($modifier instanceof SegmentFieldModifier) {
111
                $this->setModifierProperties($modifier, $form, $request);
112
113
                $preview = $modifier->getPreview($preview);
114
                $suggestion = $modifier->getSuggestion($suggestion);
115
            }
116
117
            if (is_array($modifier)) {
118
                $preview .= $modifier[0];
119
                $suggestion .= $modifier[1];
120
            }
121
        }
122
123
        return json_encode(array(
124
            'suggestion' => $suggestion,
125
            'preview' => $preview,
126
        ));
127
    }
128
129
    /**
130
     * @param SegmentFieldModifier $modifier
131
     * @param mixed $form
132
     * @param mixed $request
133
     *
134
     * @return $this
135
     */
136
    protected function setModifierProperties(SegmentFieldModifier $modifier, $form, $request)
137
    {
138
        $modifier->setField($this);
139
140
        if ($request) {
141
            $modifier->setRequest($request);
142
        }
143
144
        if ($form) {
145
            $modifier->setForm($form);
146
        }
147
148
        return $this;
149
    }
150
151
    /**
152
     * @param string $string The secondary text to show
153
     * @return $this
154
     */
155
    public function setHelpText($string)
156
    {
157
        $this->helpText = $string;
158
        return $this;
159
    }
160
161
    /**
162
     * @return string the secondary text to show in the template
163
     */
164
    public function getHelpText()
165
    {
166
        return $this->helpText;
167
    }
168
}
169