Issues (8)

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/Analyser.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
namespace phphound;
3
4
use phphound\output\AbstractOutput;
5
use phphound\output\filter\OutputFilterInterface;
6
use phphound\output\TriggerableInterface;
7
8
/**
9
 * Run all script analysers and outputs their result.
10
 */
11
class Analyser
12
{
13
    const EVENT_STARTING_ANALYSIS = 0;
14
    const EVENT_STARTING_TOOL = 1;
15
    const EVENT_FINISHED_TOOL = 2;
16
    const EVENT_FINISHED_ANALYSIS = 3;
17
18
    const VERSION = '0.7.1';
19
20
    /**
21
     * Composer binaries path.
22
     * @var string directory path.
23
     */
24
    protected $binariesPath;
25
26
    /**
27
     * Analysis target.
28
     * @var string[] file or directory path.
29
     */
30
    protected $analysedPaths;
31
32
    /**
33
     * Ignored paths.
34
     * @var string[] comma separated list of directories to ignore.
35
     */
36
    protected $ignoredPaths;
37
38
    /**
39
     * Output service.
40
     * @var AbstractOutput output instance.
41
     */
42
    protected $output;
43
44
    /**
45
     * Analysis result filter.
46
     * @var OutputFilterInterface filter instance.
47
     */
48
    protected $resultsFilter;
49
50
    /**
51
     * Set dependencies and initialize CLI.
52
     * @param AbstractOutput $output Output target.
53
     * @param string $binariesPath Composer binaries path.
54
     * @param string[] $analysedPaths target file or directory path.
55
     * @param string[] $ignoredPaths comma separated list of ignored directories.
56
     */
57
    public function __construct(AbstractOutput $output, $binariesPath, $analysedPaths, $ignoredPaths)
58
    {
59
        $this->output = $output;
60
        $this->binariesPath = $binariesPath;
61
        $this->analysedPaths = $analysedPaths;
62
        $this->ignoredPaths = $ignoredPaths;
63
    }
64
65
    /**
66
     * Run each configured PHP analysis tool.
67
     * @return boolean true if it didn't find code issues.
68
     */
69
    public function run()
70
    {
71
        $result = $this->createResult();
72
        $this->trigger(
73
            self::EVENT_STARTING_ANALYSIS,
74
            ['ignoredPaths' => $this->ignoredPaths]
0 ignored issues
show
array('ignoredPaths' => $this->ignoredPaths) is of type array<string,array<integ...rray<integer,string>"}>, but the function expects a string|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
75
        );
76
77
        foreach ($this->getAnalysisTools() as $tool) {
78
            $message = ['description' => $tool->getDescription()];
79
            $this->trigger(self::EVENT_STARTING_TOOL, $message);
0 ignored issues
show
$message is of type array<string,?,{"description":"?"}>, but the function expects a string|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
80
            $tool->run($this->getAnalysedPaths());
81
            $result->mergeWith($tool->getAnalysisResult());
82
            $this->trigger(self::EVENT_FINISHED_TOOL);
83
        }
84
85
        if ($this->resultsFilter) {
86
            $result->setResultsFilter($this->resultsFilter);
87
        }
88
89
        $this->output->result($result);
90
        $this->trigger(self::EVENT_FINISHED_ANALYSIS);
91
92
        return !$result->hasIssues();
93
    }
94
95
    /**
96
     * Call an output trigger if supported.
97
     * @param int $event occurred event.
98
     * @param string|null $message optional message.
99
     * @return void
100
     */
101
    protected function trigger($event, $message = null)
102
    {
103
        if ($this->output instanceof TriggerableInterface) {
104
            $this->output->trigger($event, $message);
105
        }
106
    }
107
108
    /**
109
     * Get a list of paths to be ignored by the analysis.
110
     * @return string[] a list of file and/or directory paths.
111
     */
112
    public function getIgnoredPaths()
113
    {
114
        return $this->ignoredPaths;
115
    }
116
117
    /**
118
     * Analysis target path.
119
     * @return string[] target path.
120
     */
121
    public function getAnalysedPaths()
122
    {
123
        return $this->analysedPaths;
124
    }
125
126
    /**
127
     * Add an output filter to delegate to the analysis result object.
128
     * @param OutputFilterInterface $filter filter instance.
129
     */
130
    public function setResultsFilter(OutputFilterInterface $filter)
131
    {
132
        $this->resultsFilter = $filter;
133
    }
134
135
    /**
136
     * Set target files and/or directories to be analysed.
137
     * @param string[] $paths target paths.
138
     * @return void
139
     */
140
    public function setAnalysedPaths(array $paths)
141
    {
142
        $this->analysedPaths = $paths;
143
    }
144
145
    /**
146
     * List of PHP analys integration classes.
147
     * @return string[] array of class names.
148
     */
149
    protected function getAnalysisToolsClasses()
150
    {
151
        return [
152
            'phphound\integration\PHPCodeSniffer',
153
            'phphound\integration\PHPCopyPasteDetector',
154
            'phphound\integration\PHPMessDetector',
155
        ];
156
    }
157
158
    /**
159
     * Set of PHP analys integration objects.
160
     * @return phphound\integration\AbstractIntegration[] set of objects.
161
     */
162
    protected function getAnalysisTools()
163
    {
164
        $objects = [];
165
166
        foreach ($this->getAnalysisToolsClasses() as $className) {
167
            $tool = new $className($this->binariesPath, sys_get_temp_dir());
168
            $tool->setIgnoredPaths($this->getIgnoredPaths());
169
            $objects[] = $tool;
170
        }
171
172
        return $objects;
173
    }
174
175
    /**
176
     * Create an empty analysis result.
177
     * @return AnalysisResult instance.
178
     */
179
    protected function createResult()
180
    {
181
        return new AnalysisResult;
182
    }
183
}
184