Issues (26)

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/Api/Translation.php (3 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
2
3
declare(strict_types=1);
4
5
/*
6
 * This software may be modified and distributed under the terms
7
 * of the MIT license.  See the LICENSE file for details.
8
 */
9
10
namespace FAPI\PhraseApp\Api;
11
12
use FAPI\PhraseApp\Exception\DomainException;
13
use FAPI\PhraseApp\Model\Translation\Index;
14
use FAPI\PhraseApp\Model\Translation\TranslationCreated;
15
use FAPI\PhraseApp\Model\Translation\TranslationUpdated;
16
use Psr\Http\Client\ClientExceptionInterface;
17
use Psr\Http\Message\ResponseInterface;
18
19
/**
20
 * @author Sascha-Oliver Prolic <[email protected]>
21
 */
22
class Translation extends HttpApi
23
{
24
    /**
25
     * Index a locale.
26
     *
27
     * @param string $projectKey
28
     * @param string $localeId
29
     * @param array  $params
30
     *
31
     * @throws ClientExceptionInterface
32
     * @throws DomainException
33
     *
34
     * @return Index|ResponseInterface
35
     */
36 View Code Duplication
    public function indexLocale(string $projectKey, string $localeId, array $params = [])
0 ignored issues
show
This method seems to be duplicated in 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...
37
    {
38
        if (isset($params['tags'])) {
39
            $params['q'] = 'tags:'.$params['tags'];
40
            unset($params['tags']);
41
        }
42
43
        $response = $this->httpGet(sprintf('/api/v2/projects/%s/locales/%s/translations', $projectKey, $localeId), $params);
44
45
        if (!$this->hydrator) {
46
            return $response;
47
        }
48
49
        if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 201) {
50
            $this->handleErrors($response);
51
        }
52
53
        return $this->hydrator->hydrate($response, Index::class);
54
    }
55
56
    /**
57
     * Create a translation.
58
     *
59
     * @param string $projectKey
60
     * @param string $localeId
61
     * @param string $keyId
62
     * @param string $content
63
     * @param array  $params
64
     *
65
     * @throws ClientExceptionInterface
66
     * @throws DomainException
67
     *
68
     * @return TranslationCreated|ResponseInterface
69
     */
70
    public function create(string $projectKey, string $localeId, string $keyId, string $content, array $params = [])
71
    {
72
        $params['locale_id'] = $localeId;
73
        $params['key_id'] = $keyId;
74
        $params['content'] = $content;
75
76
        $response = $this->httpPost(sprintf('/api/v2/projects/%s/translations', $projectKey), $params);
77
78
        if (!$this->hydrator) {
79
            return $response;
80
        }
81
82
        if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 201) {
83
            $this->handleErrors($response);
84
        }
85
86
        return $this->hydrator->hydrate($response, TranslationCreated::class);
87
    }
88
89
    /**
90
     * Update a translation.
91
     *
92
     * @param string $projectKey
93
     * @param string $translationId
94
     * @param string $content
95
     * @param array  $params
96
     *
97
     * @throws ClientExceptionInterface
98
     * @throws DomainException
99
     *
100
     * @return TranslationUpdated|ResponseInterface
101
     */
102 View Code Duplication
    public function update(string $projectKey, string $translationId, string $content, array $params = [])
0 ignored issues
show
This method seems to be duplicated in 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...
103
    {
104
        $params['content'] = $content;
105
106
        $response = $this->httpPatch(sprintf('/api/v2/projects/%s/translations/%s', $projectKey, $translationId), $params);
107
108
        if (!$this->hydrator) {
109
            return $response;
110
        }
111
112
        if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 201) {
113
            $this->handleErrors($response);
114
        }
115
116
        return $this->hydrator->hydrate($response, TranslationUpdated::class);
117
    }
118
119
    /**
120
     * List translations for a specific key.
121
     *
122
     * @param string $projectKey
123
     * @param string $keyId
124
     * @param array  $params
125
     *
126
     * @throws ClientExceptionInterface
127
     * @throws DomainException
128
     *
129
     * @return Index|ResponseInterface
130
     */
131 View Code Duplication
    public function indexKey(string $projectKey, string $keyId, array $params = [])
0 ignored issues
show
This method seems to be duplicated in 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...
132
    {
133
        if (isset($params['tags'])) {
134
            $params['q'] = 'tags:'.$params['tags'];
135
            unset($params['tags']);
136
        }
137
138
        $response = $this->httpGet(sprintf('/api/v2/projects/%s/keys/%s/translations', $projectKey, $keyId), $params);
139
140
        if (!$this->hydrator) {
141
            return $response;
142
        }
143
144
        if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 201) {
145
            $this->handleErrors($response);
146
        }
147
148
        return $this->hydrator->hydrate($response, Index::class);
149
    }
150
}
151