Issues (46)

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/PSolr/Request/SolrRequest.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 PSolr\Request;
4
5
use Guzzle\Http\QueryString;
6
use PSolr\Client\SolrClient;
7
8
/**
9
 * Base class for PSolr request objects.
10
 */
11
class SolrRequest extends QueryString
12
{
13
    /**
14
     * @var string|null
15
     */
16
    protected $handlerName = null;
17
18
    /**
19
     * $var string
20
     */
21
    protected $responseClass = '\PSolr\Response\Response';
22
23
    /**
24
     * @param array $params
25
     */
26
    public function __construct(array $params = array())
27
    {
28
        parent::__construct($params);
29
        $this->init();
30
    }
31
32
    /**
33
     * @param array $params
34
     *
35
     * @return \PSolr\Request\SolrRequest
36
     */
37
    static public function factory(array $params = array())
0 ignored issues
show
As per PSR2, the static declaration should come after the visibility declaration.
Loading history...
38
    {
39
        return new static($params);
40
    }
41
42
    /**
43
     * Initialization hook. Useful for setting default params.
44
     */
45
    public function init() {}
46
47
    /**
48
     * {@inheritDoc}
49
     *
50
     * Converts booleans to strings.
51
     */
52
    public function set($key, $value)
53
    {
54
        if (is_bool($value)) {
55
            $value = $value ? 'true' : 'false';
56
        }
57
58
        return parent::set($key, $value);
59
    }
60
61
    /**
62
     * @param string $handlerName
63
     *
64
     * @return \PSolr\Request\SolrRequest
65
     */
66
    public function setHandlerName($handlerName)
67
    {
68
        $this->handlerName = $handlerName;
69
        return $this;
70
    }
71
72
    /**
73
     * @return string
74
     */
75
    public function getHandlerName()
76
    {
77
        return $this->handlerName;
78
    }
79
80
    /**
81
     * Renders the body, most often overridden by request objects that generate
82
     * JSON or XML, e.g. update requests.
83
     *
84
     * @return string|null
85
     */
86
    public function renderBody()
87
    {
88
        return null;
89
    }
90
91
    /**
92
     * Escape a value for use in XML.
93
     *
94
     * @param string $value
95
     *
96
     * @return string
97
     */
98
    public static function escapeXml($value)
99
    {
100
        return htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8');
101
    }
102
103
    /**
104
     * Replace control (non-printable) characters from string that are invalid
105
     * to Solr's XML parser with a space.
106
     *
107
     * @param string $rawXml
108
     *
109
     * @return string
110
     *
111
     * @see http://drupalcode.org/project/apachesolr.git/blob/1dc510227f5077ccbc047be13dcf0de3120b100c:/Apache_Solr_Document.php#l399
112
     */
113
    public static function stripCtrlChars($rawXml)
114
    {
115
        // @see http://w3.org/International/questions/qa-forms-utf-8.html
116
        // Printable utf-8 does not include any of these chars below x7F
117
        return preg_replace('@[\x00-\x08\x0B\x0C\x0E-\x1F]@', ' ', $rawXml);
118
    }
119
120
    /**
121
     * @param \Psolr\Component\ComponentInterface $component
122
     *
123
     * @return \PSolr\Request\SolrRequest
124
     */
125
    public function addComponent(ComponentInterface $component)
126
    {
127
        $component->preMergeParams($this);
128
        return $this->overwriteWith($component->toArray());
129
    }
130
131
    /**
132
     * @param \PSolr\Request\SolrClient $solr
133
     * @param array|null $headers
134
     * @param array $options
135
     *
136
     * @return \PSolr\Response\Response|\SimpleXMLElement
137
     *
138
     * @throws \UnexpectedValueException
139
     */
140
    public function sendRequest(SolrClient $solr, $headers = null, array $options = array())
141
    {
142
        // If we don't have a request handler, then the passed request is only a
143
        // component and we cannot execute the search.
144
        if (null === $this->handlerName) {
145
            throw new \UnexpectedValueException('Unable to send request: handler name missing');
146
        }
147
148
        // @todo Add a method in \PSolr\Response\Response to normalize the XML
149
        // in to an array. Just use JSON and all is right in the world.
150
        $params = $this->toArray();
151
        $data = $solr->sendRequest($this->handlerName, $params, $this->renderBody(), $headers, $options);
152
        return is_array($data) ? new $this->responseClass($data, $params) : $data;
153
    }
154
}
155