Issues (11)

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/Command/ConvertCommand.php (2 issues)

Labels
Severity

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 PHP Translation package.
5
 *
6
 * (c) PHP Translation team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Translation\Converter\Command;
13
14
use Symfony\Component\Console\Command\Command;
15
use Symfony\Component\Console\Input\InputArgument;
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Input\InputOption;
18
use Symfony\Component\Console\Output\OutputInterface;
19
use Symfony\Component\Translation\Loader;
20
use Translation\Converter\Reader\JmsReader;
21
use Translation\Converter\Service\Converter;
22
23
/**
24
 * @author Tobias Nyholm <[email protected]>
25
 */
26
class ConvertCommand extends Command
27
{
28
    const SUPPORTED_FORMATS = ['jms', 'csv', 'ini', 'json', 'mo', 'php', 'yml', 'xlf'];
29
30
    protected function configure()
31
    {
32
        $this
33
            ->setName('translation:convert')
34
            ->setDescription('Convert your existing translation files to Xliff')
35
            ->addArgument('input_dir', InputArgument::REQUIRED, 'Where are your existing translations?')
36
            ->addArgument('output_dir', InputArgument::REQUIRED, 'Where should we put the new translations?')
37
            ->addOption('format', null, InputOption::VALUE_REQUIRED, 'The format to convert from. Supported formats are: '.implode(', ', self::SUPPORTED_FORMATS))
38
        ;
39
    }
40
41
    protected function execute(InputInterface $input, OutputInterface $output)
42
    {
43
        $files = scandir($input->getArgument('input_dir'));
44
45
        $formats = [];
46
        $locales = [];
47
        foreach ($files as $file) {
48
            if (preg_match('|.+\.(.+)\.(.+)|', $file, $matches)) {
49
                $locales[] = $matches[1];
50
                $formats[] = $matches[2];
51
            }
52
        }
53
54
        if (null === $format = $input->getOption('format')) {
55
            $formats = array_unique($formats);
56
            if (1 !== count($formats)) {
57
                throw new \InvalidArgumentException('More than one format found. Please specify a format with --format=xxx');
58
            }
59
            $format = reset($formats);
60
        }
61
62
        $reader = $this->getReader($format);
63
        $converter = new Converter($reader, 'jms' === $format ? ['xlf', 'xliff'] : $format);
64
        $converter->convert($input->getArgument('input_dir'), $input->getArgument('output_dir'), array_unique($locales));
0 ignored issues
show
It seems like $input->getArgument('input_dir') targeting Symfony\Component\Consol...nterface::getArgument() can also be of type array<integer,string> or null; however, Translation\Converter\Service\Converter::convert() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
It seems like $input->getArgument('output_dir') targeting Symfony\Component\Consol...nterface::getArgument() can also be of type array<integer,string> or null; however, Translation\Converter\Service\Converter::convert() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
65
    }
66
67
    /**
68
     * @param string $format
69
     *
70
     * @return Loader\LoaderInterface
71
     */
72
    private function getReader($format)
73
    {
74
        switch ($format) {
75
            case 'jms':
76
                return new JmsReader();
77
            case 'csv':
78
                return new Loader\CsvFileLoader();
79
            case 'ini':
80
                return new Loader\IniFileLoader();
81
            case 'json':
82
                return new Loader\JsonFileLoader();
83
            case 'mo':
84
                return new Loader\MoFileLoader();
85
            case 'php':
86
                return new Loader\PhpFileLoader();
87
            case 'yml':
88
            case 'yaml':
89
                return new Loader\YamlFileLoader();
90
            case 'xlf':
91
            case 'xliff':
92
                return new Loader\XliffFileLoader();
93
            default:
94
                throw new \InvalidArgumentException(sprintf('Format "%s" is not a valid format', $format));
95
        }
96
    }
97
}
98