Issues (325)

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.

Command/GenerateModelCommand.php (16 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
namespace Yoghi\Bundle\MaddaBundle\Command;
4
5
use League\Flysystem\Adapter\Local;
6
use League\Flysystem\Filesystem;
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Input\ArrayInput;
9
use Symfony\Component\Console\Input\InputArgument;
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Input\InputOption;
12
use Symfony\Component\Console\Output\BufferedOutput;
13
use Symfony\Component\Console\Output\OutputInterface;
14
use Symfony\Component\Console\Style\SymfonyStyle;
15
use Yoghi\Bundle\MaddaBundle\Finder\Finder;
16
use Yoghi\Bundle\MaddaBundle\Generator\DDDGenerator;
17
use Yoghi\Bundle\MaddaBundle\Model\Reader;
18
19
class GenerateModelCommand extends Command
20
{
21
    private $logger;
22
    private $errors;
23
24
    protected function configure()
25
    {
26
        $this
27
            ->setName('generate:model')
28
            ->setDescription('Genera tutto il modello a partire da un file yml')
29
            ->addArgument('directory', InputArgument::REQUIRED, 'Directory sorgente')
30
            ->addArgument('outputdirectory', InputArgument::REQUIRED, 'Directory output delle classi generate')
31
            ->addOption('clean', null, InputOption::VALUE_OPTIONAL, 'Option clean output directory')
32
            // ->addArgument('argument', InputArgument::OPTIONAL, 'Argument description')
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
33
            // ->addOption('option', null, InputOption::VALUE_NONE, 'Option description')
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
34
        ;
35
    }
36
37
    // protected function generateClasses(Local $fullPathFile, Local $directoryOutput, $io)
0 ignored issues
show
Unused Code Comprehensibility introduced by
48% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
38
    // {
39
        // $adapter = new Local($directoryOutput);
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
40
        // $filesystem = new Filesystem($adapter);
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
41
        // $io->section('Analisi di '.$baseDirectory.'/'.$fileName);
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
42
//
43
        // $rym = new Reader();
0 ignored issues
show
Unused Code Comprehensibility introduced by
46% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
44
        // $rym->readYaml($baseDirectory, $fileName);
0 ignored issues
show
Unused Code Comprehensibility introduced by
73% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
45
        // $specList = $rym->getProperties();
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
46
    // }
47
48
    protected function execute(InputInterface $input, OutputInterface $output)
49
    {
50
        // throw new \Exception('boo');
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
51
52
        $directory = realpath($input->getArgument('directory'));
53
        $directoryOutput = $input->getArgument('outputdirectory');
54
55
        /* @var $logger Psr\Log\LoggerInterface */
56
        $this->logger = $this->getContainer()->get('logger');
0 ignored issues
show
The method getContainer() does not seem to exist on object<Yoghi\Bundle\Madd...d\GenerateModelCommand>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
57
58
        $io = new SymfonyStyle($input, $output);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $io. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
59
        $io->title('DDD Model Generation');
60
61
        $clean = $input->hasOption('clean');
62
        if ($clean) {
63
            $io->section('Clean output directoty');
64
            $fs = new \Symfony\Component\Filesystem\Filesystem();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $fs. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
65
            try {
66
                $fs->remove($directoryOutput);
67
            } catch (IOExceptionInterface $e) {
0 ignored issues
show
The class Yoghi\Bundle\MaddaBundle...nd\IOExceptionInterface does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
68
                $io->error($e->getMessage());
69
            }
70
            $io->text('clean of '.$directoryOutput.' completed');
71
        }
72
73
        if (is_dir($directory)) {
74
            $finder = new Finder();
75
            $finder->search($directory);
0 ignored issues
show
The call to search() misses a required argument $extension.

This check looks for function calls that miss required arguments.

Loading history...
76
            foreach ($finder->getFindedFiles() as $file) {
77
                if (pathinfo($file, PATHINFO_FILENAME) == 'model.yml') {
78
                    $io->text('Analizzo model.yml in '.pathinfo($file, PATHINFO_DIRNAME));
79
                    $dddGenerator = new DDDGenerator();
80
                    $dddGenerator->setLogger($this->logger);
81
                    $dddGenerator->analyze($file);
82
                    $dddGenerator->generate($directoryOutput);
83
                }
84
            }
85
86
            $io->section('Php-Cs-Fixer on generated files');
87
88
            $fixer = new \Symfony\CS\Console\Command\FixCommand();
89
90
            $input = new ArrayInput([
91
                'path' => $directoryOutput,
92
                '--level' => 'psr2',
93
                '--fixers' => 'eof_ending,strict_param,short_array_syntax,trailing_spaces,indentation,line_after_namespace,php_closing_tag',
94
            ]);
95
96
            $output = new BufferedOutput();
97
            $fixer->run($input, $output);
98
            $content = $output->fetch();
99
100
            $io->text($content);
101
102
            if (count($this->errors) == 0) {
103
                $io->success('Completed generation');
104
            } else {
105
                $io->error($this->errors);
106
            }
107
        } else {
108
            $io->caution('Directory '.$directory.' not valid');
109
        }
110
111
        // PER I WARNING RECUPERABILI
112
        //$io->note('Generate Class');
0 ignored issues
show
Unused Code Comprehensibility introduced by
86% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
113
    }
114
}
115