Issues (89)

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/AbstractCurlHttpAdapter.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
/*
4
 * This file is part of the Ivory Http Adapter package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\HttpAdapter;
13
14
use Ivory\HttpAdapter\Message\InternalRequestInterface;
15
16
/**
17
 * @author GeLo <[email protected]>
18
 */
19
abstract class AbstractCurlHttpAdapter extends AbstractHttpAdapter
20
{
21
    /**
22
     * @param ConfigurationInterface|null $configuration
23
     * @param bool                        $checkExtension
24
     *
25
     * @throws HttpAdapterException
26
     */
27 4300
    public function __construct(ConfigurationInterface $configuration = null, $checkExtension = true)
28
    {
29 4300
        if ($checkExtension && !function_exists('curl_init')) {
30 4
            throw HttpAdapterException::extensionIsNotLoaded('curl', $this->getName());
31
        }
32
33 4296
        parent::__construct($configuration);
34 4296
    }
35
36
    /**
37
     * @param InternalRequestInterface $internalRequest
38
     *
39
     * @return int
40
     */
41 1344
    protected function prepareProtocolVersion(InternalRequestInterface $internalRequest)
42
    {
43 1344
        return $internalRequest->getProtocolVersion() === InternalRequestInterface::PROTOCOL_VERSION_1_0
44 1012
            ? CURL_HTTP_VERSION_1_0
45 1344
            : CURL_HTTP_VERSION_1_1;
46
    }
47
48
    /**
49
     * @param InternalRequestInterface $internalRequest
50
     *
51
     * @return array|string
52
     */
53 3152
    protected function prepareContent(InternalRequestInterface $internalRequest)
54
    {
55 3152
        $files = $internalRequest->getFiles();
56
57 3152
        if (empty($files)) {
58 2752
            return $this->prepareBody($internalRequest);
59
        }
60
61 400
        $content = [];
62
63 400
        foreach ($internalRequest->getDatas() as $name => $data) {
64 400
            $content = array_merge($content, $this->prepareRawContent($name, $data));
65 320
        }
66
67 400
        foreach ($files as $name => $file) {
68 400
            $content = array_merge($content, $this->prepareRawContent($name, $file, true));
69 320
        }
70
71 400
        return $content;
72
    }
73
74
    /**
75
     * @param string $file
76
     *
77
     * @return mixed
78
     */
79 240
    protected function createFile($file)
80
    {
81 240
        return $this->isSafeUpload() ? new \CurlFile($file) : '@'.$file;
82
    }
83
84
    /**
85
     * @return bool
86
     */
87 240
    protected function isSafeUpload()
88
    {
89 240
        return defined('CURLOPT_SAFE_UPLOAD');
90
    }
91
92
    /**
93
     * @param string       $name
94
     * @param array|string $data
95
     * @param bool         $isFile
96
     *
97
     * @return array
98
     */
99 400
    private function prepareRawContent($name, $data, $isFile = false)
100
    {
101 400 View Code Duplication
        if (is_array($data)) {
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...
102 400
            $preparedData = [];
103
104 400
            foreach ($data as $subName => $subData) {
105 400
                $preparedData = array_merge(
106 320
                    $preparedData,
107 400
                    $this->prepareRawContent($this->prepareName($name, $subName), $subData, $isFile)
108 320
                );
109 320
            }
110
111 400
            return $preparedData;
112
        }
113
114 400
        return [$name => $isFile ? $this->createFile($data) : $data];
115
    }
116
}
117