Issues (3887)

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.

TranslationBundle/Provider/AbstractAPIAdapter.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 Oro\Bundle\TranslationBundle\Provider;
4
5
use Psr\Log\LoggerAwareTrait;
6
use Psr\Log\NullLogger;
7
8
use Guzzle\Http\Exception\BadResponseException;
9
use Guzzle\Http\Client;
10
use Guzzle\Http\Message\Request;
11
12
abstract class AbstractAPIAdapter implements APIAdapterInterface
13
{
14
    use LoggerAwareTrait;
15
16
    /** @var string */
17
    protected $apiKey;
18
19
    /** @var string */
20
    protected $projectId;
21
22
    /** @var Client */
23
    protected $client;
24
25
    public function __construct(Client $client)
26
    {
27
        $this->client = $client;
28
        $this->setLogger(new NullLogger());
29
    }
30
31
    /**
32
     * @param string $apiKey
33
     */
34
    public function setApiKey($apiKey)
35
    {
36
        $this->apiKey = $apiKey;
37
    }
38
39
    /**
40
     * @return string
41
     */
42
    public function getApiKey()
43
    {
44
        return $this->apiKey;
45
    }
46
47
    /**
48
     * @param string $projectId
49
     */
50
    public function setProjectId($projectId)
51
    {
52
        $this->projectId = $projectId;
53
    }
54
55
    /**
56
     * Upload source files to translation service
57
     *
58
     * @param string $files file list with translations
59
     * @param string $mode 'update' or 'add'
60
     *
61
     * @return mixed
62
     */
63
    abstract public function upload($files, $mode = 'add');
64
65
    /**
66
     * Allow adapter to modify request before sending,
67
     * adding API key by default
68
     *
69
     * @param Request $request
70
     */
71
    protected function preprocessRequest(Request $request)
72
    {
73
        $request->getQuery()->add('key', $this->getApiKey());
74
    }
75
76
    /**
77
     * {@inheritdoc}
78
     */
79
    public function request($uri, $data = [], $method = 'GET', $options = [], $headers = [])
80
    {
81
        $request = $this->client->createRequest(
82
            $method,
83
            $uri,
84
            $headers,
85
            $data,
86
            $options
87
        );
88
89
        if (!in_array($method, ['POST', 'PUT'], true)) {
90
            $request->getQuery()->merge($data);
91
        }
92
93
        $this->preprocessRequest($request);
0 ignored issues
show
$request of type object<Guzzle\Http\Message\RequestInterface> is not a sub-type of object<Guzzle\Http\Message\Request>. It seems like you assume a concrete implementation of the interface Guzzle\Http\Message\RequestInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
94
        try {
95
            $response = $request->send();
96
        } catch (BadResponseException $e) {
97
            $response = $e->getResponse();
98
        }
99
100
        return $response;
101
    }
102
103
    /**
104
     * Extract list of folders recursively from file paths
105
     *
106
     * @param array $files
107
     *
108
     * @return array
109
     */
110
    protected function getFileFolders(array $files)
111
    {
112
        $dirs = [];
113
114
        foreach ($files as $remotePath) {
115
            $subFolders = explode(DIRECTORY_SEPARATOR, dirname($remotePath));
116
117
            $currentDir = [];
118
            foreach ($subFolders as $folderName) {
119
                $currentDir[] = $folderName;
120
121
                // crowdin understand only "/" as directory separator
122
                $path         = implode('/', $currentDir);
123
                $dirs[]  = $path;
124
            }
125
        }
126
127
        return $dirs;
128
    }
129
}
130