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/Console/Command/WarmupCommand.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 Go\Zend\Framework\Console\Command;
4
5
use Go\Core\AspectKernel;
6
use Go\Instrument\ClassLoading\SourceTransformingLoader;
7
use Go\Instrument\FileSystem\Enumerator;
8
use Go\Instrument\Transformer\FilterInjectorTransformer;
9
use Symfony\Component\Console\Command\Command;
10
use Symfony\Component\Console\Input\InputArgument;
11
use Symfony\Component\Console\Input\InputInterface;
12
use Symfony\Component\Console\Output\OutputInterface;
13
14
class WarmupCommand extends Command
15
{
16
    /**
17
     * {@inheritDoc}
18
     */
19
    protected function configure()
20
    {
21
        $this
22
            ->setName('goaop:warmup')
23
            ->addArgument(
24
                'applicationConfig',
25
                InputArgument::REQUIRED,
26
                'Path to application config which includes aspects and goaop module'
27
            )
28
            ->setDescription('Warm up the cache with woven aspects')
29
            ->setHelp(<<<EOT
30
Initializes the kernel and, if successful, warm up the cache for PHP
31
files under the application directory.
32
33
By default, the cache directory is taken from configured AspectKernel class.
34
EOT
35
            );
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    protected function execute(InputInterface $input, OutputInterface $output)
42
    {
43
        $output->writeln('Start up application with supplied config...');
44
        $config = $input->getArgument('applicationConfig');
45
        $path   = stream_resolve_include_path($config);
46
        if (!is_readable($path)) {
47
            throw new \InvalidArgumentException("Invalid loader path: {$config}");
48
        }
49
50
        // Init the application once using given config
51
        // This way the late static binding on the AspectKernel
52
        // will be on the goaop-zf2-module kernel
53
        \Zend\Mvc\Application::init(include $path);
54
55
        if (!class_exists(AspectKernel::class, false)) {
56
            $message = "Kernel was not initialized yet. Maybe missing module Go\ZF2\GoAopModule in config {$path}";
57
            throw new \InvalidArgumentException($message);
58
        }
59
60
        $kernel  = AspectKernel::getInstance();
61
        $options = $kernel->getOptions();
62
63
        if (empty($options['cacheDir'])) {
64
            throw new \InvalidArgumentException('Cache warmer require the `cacheDir` options to be configured');
65
        }
66
67
        $enumerator = new Enumerator($options['appDir'], $options['includePaths'], $options['excludePaths']);
68
        $iterator   = $enumerator->enumerate();
69
70
        $totalFiles = iterator_count($iterator);
71
        $output->writeln("Total <info>{$totalFiles}</info> files to process.");
72
        $iterator->rewind();
73
74
        set_error_handler(function($errno, $errstr, $errfile, $errline) {
75
            throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
76
        });
77
78
        $index  = 0;
79
        $errors = [];
80
        foreach ($iterator as $file) {
81
            if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
82
                $output->writeln("Processing file <info>{$file->getRealPath()}</info>");
83
            }
84
            $isSuccess = null;
0 ignored issues
show
$isSuccess is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
85
            try {
86
                // This will trigger creation of cache
87
                file_get_contents(
88
                    FilterInjectorTransformer::PHP_FILTER_READ .
89
                    SourceTransformingLoader::FILTER_IDENTIFIER .
90
                    '/resource=' . $file->getRealPath()
91
                );
92
                $isSuccess = true;
93
            } catch (\Exception $e) {
94
                $isSuccess = false;
95
                $errors[$file->getRealPath()] = $e;
96
            }
97
            if ($output->getVerbosity() == OutputInterface::VERBOSITY_NORMAL) {
98
                $output->write($isSuccess ? '.' : '<error>E</error>');
99
                if (++$index % 50 == 0) {
100
                    $output->writeln("($index/$totalFiles)");
101
                }
102
            }
103
        }
104
105
        restore_error_handler();
106
107
        if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE) {
108
            foreach ($errors as $file=>$error) {
109
                $message = "File {$file} is not processed correctly due to exception: {$error->getMessage()}";
110
                $output->writeln($message);
111
            }
112
        }
113
114
        $output->writeln('<info>Done</info>');
115
    }
116
117
}
118