Issues (5)

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/PhpunitController.php (2 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
 * HiDev plugin for PHPUnit
4
 *
5
 * @link      https://github.com/hiqdev/hidev-phpunit
6
 * @package   hidev-phpunit
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2018, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hidev\phpunit\console;
12
13
use hidev\handlers\BaseHandler;
14
use Yii;
15
16
/**
17
 * PHPunit.
18
 */
19
class PhpunitController extends \hidev\base\Controller
20
{
21
    protected $_before = ['phpunit.xml.dist'];
22
23
    public $force;
24
25
    public function getComponent()
26
    {
27
        return $this->take('phpunit');
28
    }
29
30
    /**
31
     * Generates `tests/_bootstrap.php` and runs tests.
32
     */
33
    public function actionIndex()
34
    {
35
        $this->getComponent()->touchBootstrap();
36
37
        return $this->doRun();
38
    }
39
40
    protected function doRun()
41
    {
42
        $args = $this->getComponent()->prepareArgs();
43
44
        return $this->passthru('phpunit', $args);
45
    }
46
47
    /**
48
     * Generates skeleton class for fake.
49
     */
50 View Code Duplication
    public function actionGenfake($file)
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...
51
    {
52
        $path = $this->buildFakePath($file);
53
        if (!$this->force && file_exists($path)) {
54
            Yii::warning("already exists: $path");
55
56
            return 1;
57
        }
58
59
        return $this->genFake($file, $path);
60
    }
61
62
    protected function genFake($file, $path)
63
    {
64
        $text = $this->getView()->render('phpunit/fake.twig', [
65
            'class'         => $this->buildClass($file),
66
            'namespace'     => $this->buildTestNamespace(),
67
            'name'          => $file,
68
        ]);
69
        BaseHandler::write($path, $text);
70
    }
71
72
    /**
73
     * Generates skeleton class for test.
74
     */
75 View Code Duplication
    public function actionGentest($file)
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...
76
    {
77
        $path = $this->buildTestPath($file);
78
        if (!$this->force && file_exists($path)) {
79
            Yii::warning("already exists: $path");
80
81
            return 1;
82
        }
83
84
        return $this->genSkel($file);
85
    }
86
87
    protected static function prepareFile($file)
88
    {
89
        return substr($file, -4) === '.php' ? substr($file, 0, -4) : $file;
90
    }
91
92
    protected function genSkel($file)
93
    {
94
        $destPath = $this->buildTestPath($file);
95
        $dir = dirname($destPath);
96
        if (!file_exists($dir)) {
97
            mkdir($dir, 0777, true);
98
        }
99
100
        return $this->passthru('phpunit-skelgen', [
101
            'generate-test', '--bootstrap', 'tests/_bootstrap.php', '--',
102
            $this->buildClass($file), $this->buildPath($file), $this->buildTestClass($file), $destPath,
103
        ]);
104
    }
105
106
    protected function buildNamespace($dir = '')
107
    {
108
        return $this->take('package')->namespace . ($dir ? '\\' . strtr($dir, '/', '\\') : '');
109
    }
110
111
    protected function buildTestNamespace($dir = 'tests\\unit')
112
    {
113
        return $this->buildNamespace($dir);
114
    }
115
116
    protected function buildClass($file, $dir = '', $postfix = '')
117
    {
118
        return $this->buildNamespace($dir) . '\\' . strtr(static::prepareFile($file), '/', '\\') . $postfix;
119
    }
120
121
    protected function buildTestClass($file, $dir = 'tests\\unit', $postfix = 'Test')
122
    {
123
        return $this->buildClass($file, $dir, $postfix);
124
    }
125
126
    protected function buildPath($file, $dir = 'src', $prefix = '', $postfix = '')
127
    {
128
        return $dir . DIRECTORY_SEPARATOR . $prefix . static::prepareFile($file) . $postfix . '.php';
129
130
        //## XXX getting absolute path, think if needed
131
        //return strncmp($path, '/', 1) === 0 ? $path : Yii::getAlias("@root/$path");
132
    }
133
134
    protected function buildTestPath($file, $dir = 'tests/unit', $prefix = '', $postfix = 'Test')
135
    {
136
        return $this->buildPath($file, $dir, $prefix, $postfix);
137
    }
138
139
    protected function buildFakePath($file, $dir = 'tests/unit', $prefix = 'Fake', $postfix = '')
140
    {
141
        return $this->buildPath($file, $dir, $prefix, $postfix);
142
    }
143
}
144