Issues (70)

Security Analysis    no vulnerabilities found

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/Mvg/RequestHandler/Html/HttpGetDepartures.php (4 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
 * User: ms
4
 * Date: 29.08.15
5
 * Time: 09:35
6
 */
7
namespace Mvg\RequestHandler\Html;
8
9
use Zend\Http\Client;
10
11
/**
12
 * Class Http
13
 * @package Mvg
14
 */
15
class HttpGetDepartures {
16
	/**
17
	 * @var string
18
	 */
19
	protected $schema;
20
	/**
21
	 * @var string
22
	 */
23
	protected $host;
24
	/**
25
	 * @var string
26
	 */
27
	protected $path;
28
	/**
29
	 * @var array
30
	 */
31
	protected $parameter;
32
33
	/**
34
	 * @param $schema
35
	 * @param $host
36
	 * @param $path
37
	 */
38
	public function __construct($schema, $host, $path) {
39
		$this->setHost($host);
40
		$this->setSchema($schema);
41
		$this->setPath($path);
42
43
		$this->setParameter(
44
			[
45
				'ubahn' => 'checked'
46
				, 'bus' => 'checked'
47
				, 'tram' => 'checked'
48
				, 'sbahn' => 'checked'
49
			]
50
		);
51
52
	}
53
54
	/**
55
	 * @return string
56
	 * @throws \Exception
57
	 */
58
	protected function doGetRequest() {
59
60
		$url = sprintf('%s://%s/%s?%s'
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
61
			, $this->getSchema()
62
			, $this->getHost()
63
			, $this->getPath()
64
			, http_build_query($this->getParameter(), PHP_QUERY_RFC3986)
65
		);
66
		$client = new Client();
67
		$client->setUri($url)
68
			->setMethod(\Zend\Http\Request::METHOD_GET);
69
		$response = $client->send();
70
		if ($response->getStatusCode() !== 200) {
71
			throw new \Exception(sprintf('Request Response: Status Code %d', $response->getStatusCode()));
72
		}
73
		return utf8_encode($response->getBody());
74
	}
75
76
	/**
77
	 * @return string
0 ignored issues
show
Should the return type not be string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
78
	 */
79
	public function getStations() {
80
		//@todo implement me
0 ignored issues
show
Coding Style Best Practice introduced by
Comments for TODO tasks are often forgotten in the code; it might be better to use a dedicated issue tracker.
Loading history...
81
	}
82
83
	/**
84
	 * @param $station
85
	 * @return string
86
	 */
87
	public function getDeparturesForStation($station) {
88
		$this->addParameter('haltestelle', $station);
89
		$htmlResponse = $this->doGetRequest();
90
		return $htmlResponse;
91
	}
92
93
	public function getNewsTicker() {
94
95
	}
96
97
	/**
98
	 * @return string
99
	 */
100
	protected function getSchema() {
101
		return $this->schema;
102
	}
103
104
	/**
105
	 * @param string $schema
106
	 */
107
	protected function setSchema($schema) {
108
		$this->schema = $schema;
109
	}
110
111
	/**
112
	 * @return string
113
	 */
114
	protected function getHost() {
115
		return $this->host;
116
	}
117
118
	/**
119
	 * @param string $host
120
	 */
121
	protected function setHost($host) {
122
		$this->host = $host;
123
	}
124
125
	/**
126
	 * @return string
127
	 */
128
	protected function getPath() {
129
		return $this->path;
130
	}
131
132
	/**
133
	 * @param string $path
134
	 */
135
	protected function setPath($path) {
136
		$this->path = $path;
137
	}
138
139
	/**
140
	 * @return string
0 ignored issues
show
Should the return type not be array? Also, consider making the array more specific, something like array<String>, or String[].

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

If the return type contains the type array, this check recommends the use of a more specific type like String[] or array<String>.

Loading history...
141
	 */
142
	public function getParameter() {
143
		return $this->parameter;
144
	}
145
146
	/**
147
	 * @param string $key
148
	 * @param string $value
149
	 */
150
	protected function addParameter($key, $value) {
151
		$this->parameter[$key] = utf8_decode($value);
152
	}
153
154
	/**
155
	 * @param array $parameter
156
	 */
157
	protected function setParameter($parameter) {
158
		$this->parameter = $parameter;
159
	}
160
161
162
}