Issues (4)

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/Package/File.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
 * Crowdin API implementation in PHP.
4
 *
5
 * @copyright  Copyright (C) 2016 Nikolai Plath (elkuku)
6
 * @license    WTFPL - See license.txt
7
 */
8
9
namespace ElKuKu\Crowdin\Package;
10
11
use ElKuKu\Crowdin\
12
{
13
	Package, Languagefile
14
};
15
16
use Psr\Http\Message\ResponseInterface;
17
18
/**
19
 * Class File
20
 *
21
 * @since  1.0
22
 */
23
Class File extends Package
24
{
25
	/**
26
	 * Add new file to Crowdin project.
27
	 *
28
	 * @param   Languagefile  $languagefile  The translation file object
29
	 * @param   string        $type          The type.
30
	 * @param   string        $branch        The branch.
31
	 *
32
	 * @see https://crowdin.com/page/api/add-file
33
	 * @since  1.0
34
	 *
35
	 * @return ResponseInterface
36
	 */
37 1
	public function add(Languagefile $languagefile, string $type = '', string $branch = '') : ResponseInterface
38
	{
39 1
		$data = [];
40
41 1
		if ($type)
42
		{
43 1
			$data[] = [
44 1
				'name'     => 'type',
45 1
				'contents' => $type
46
			];
47
		}
48
49 1
		if ($branch)
50
		{
51 1
			$data[] = [
52 1
				'name'     => 'branch',
53 1
				'contents' => $branch
54
			];
55
		}
56
57 1
		$data = $this->processLanguageFile($data, $languagefile);
58
59 1
		return $this->getHttpClient()
60 1
			->post($this->getBasePath('add-file'), ['multipart' => $data]);
61
	}
62
63
	/**
64
	 * Upload latest version of your localization file to Crowdin.
65
	 *
66
	 * @param   Languagefile  $languagefile  The translation file object
67
	 * @param   string        $branch        The branch.
68
	 *
69
	 * @see https://crowdin.com/page/api/update-file
70
	 * @since  1.0
71
	 *
72
	 * @return ResponseInterface
73
	 */
74 1 View Code Duplication
	public function update(Languagefile $languagefile, $branch = '') : ResponseInterface
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...
75
	{
76 1
		$data = [];
77
78 1
		if ($branch)
79
		{
80 1
			$data[] = [
81 1
				'name'     => 'branch',
82 1
				'contents' => $branch
83
			];
84
		}
85
86 1
		$data = $this->processLanguageFile($data, $languagefile);
87
88 1
		return $this->getHttpClient()
89 1
			->post($this->getBasePath('update-file'), ['multipart' => $data]);
90
	}
91
92
	/**
93
	 * Delete file from Crowdin project. All the translations will be lost without ability to restore them.
94
	 *
95
	 * @param   Languagefile  $file  The file to delete.
96
	 *
97
	 * @see https://crowdin.com/page/api/delete-file
98
	 * @since  1.0
99
	 *
100
	 * @return ResponseInterface
101
	 */
102 1
	public function delete(Languagefile $file) : ResponseInterface
103
	{
104 1
		return $this->getHttpClient()
105 1
			->post($this->getBasePath('delete-file'), ['form_params' => ['file' => $file->getCrowdinPath()]]);
106
	}
107
108
	/**
109
	 * This method exports single translated files from Crowdin.
110
	 * Additionally, it can be applied to export XLIFF files for offline localization. (@todo)
111
	 *
112
	 * @param   string  $file      The file name.
113
	 * @param   string  $language  The language tag.
114
	 * @param   string  $toPath    Export to path.
115
	 *
116
	 * @see    https://crowdin.com/page/api/export-file
117
	 * @since  1.0
118
	 *
119
	 * @return ResponseInterface
120
	 */
121 1
	public function export(string $file, string $language, string $toPath) : ResponseInterface
122
	{
123 1
		$path = sprintf(
124 1
			'%s&file=%s&language=%s',
125 1
			$this->getBasePath('export-file'),
126 1
			$file,
127 1
			$language
128
		);
129
130 1
		return $this->getHttpClient()
131 1
			->get($path, ['sink' => $toPath]);
132
	}
133
134
	/**
135
	 * Process a language file.
136
	 *
137
	 * @param   array         $data          Data array.
138
	 * @param   Languagefile  $languagefile  The language file object.
139
	 *
140
	 * @return array
141
	 */
142 1
	private function processLanguageFile(array $data, Languagefile $languagefile) : array
143
	{
144 1
		$data[] = [
145 1
			'name'     => 'files[' . $languagefile->getCrowdinPath() . ']',
146 1
			'contents' => fopen($languagefile->getLocalPath(), 'r')
147
		];
148
149 1
		if ($languagefile->getTitle())
150
		{
151 1
			$data[] = [
152 1
				'name'     => 'titles[' . $languagefile->getCrowdinPath() . ']',
153 1
				'contents' => $languagefile->getTitle()
154
			];
155
		}
156
157 1
		if ($languagefile->getExportPattern())
158
		{
159 1
			$data[] = [
160 1
				'name'     => 'export_patterns[' . $languagefile->getCrowdinPath() . ']',
161 1
				'contents' => $languagefile->getExportPattern()
162
			];
163
		}
164
165 1
		return $data;
166
	}
167
}
168