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/TextOutput/Departures.php (10 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: 11:00
6
 */
7
8
namespace Mvg\TextOutput;
9
10
/**
11
 * Class Departures
12
 * @package Mvg
13
 */
14
class Departures {
15
16
	/**
17
	 * @var \Mvg\Factories\Departures
18
	 */
19
	protected $departuresFactory = null;
20
21
	/**
22
	 * @var mixed
23
	 */
24
	protected $filter = null;
25
26
	/**
27
	 * @param \Mvg\Factories\Departures $departuresFactory
28
	 * @param mixed $filter
29
	 */
30
	public function __construct($departuresFactory, $filter = null) {
31
		$this->setDeparturesFactory($departuresFactory);
32
		$this->setFilter($filter);
33
	}
34
35
	/**
36
	 * @return mixed
37
	 */
38
	protected function getFilter() {
39
		return $this->filter;
40
	}
41
42
	/**
43
	 * @param mixed $filter
44
	 */
45
	protected function setFilter($filter) {
46
		$this->filter = $filter;
47
	}
48
49
50
	/**
51
	 * @return \Mvg\Factories\Departures
52
	 */
53
	protected function getDeparturesFactory() {
54
		return $this->departuresFactory;
55
	}
56
57
58
	/**
59
	 * @param \Mvg\Factories\Departures $departuresFactory
60
	 */
61
	protected function setDeparturesFactory($departuresFactory) {
62
		$this->departuresFactory = $departuresFactory;
63
	}
64
65
	/**
66
	 * found here http://stackoverflow.com/a/11871948
67
	 * @param $input
68
	 * @param $pad_length
69
	 * @param string $pad_string
70
	 * @param int $pad_type
71
	 * @return string
72
	 */
73
	public static function mb_str_pad($input, $pad_length, $pad_string = ' ', $pad_type = STR_PAD_RIGHT) {
0 ignored issues
show
function mb_str_pad() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
$pad_length does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
Coding Style Naming introduced by
The parameter $pad_length is not named in camelCase.

This check marks parameter names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
Coding Style Naming introduced by
The parameter $pad_string is not named in camelCase.

This check marks parameter names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
Coding Style Naming introduced by
The parameter $pad_type is not named in camelCase.

This check marks parameter names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
This method is not in camel caps format.

This check looks for method names that are not written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection seeker becomes databaseConnectionSeeker.

Loading history...
74
		mb_internal_encoding('utf-8'); // @important
75
		$diff = strlen($input) - mb_strlen($input);
76
		return str_pad($input, $pad_length + $diff, $pad_string, $pad_type);
0 ignored issues
show
$pad_length does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
77
	}
78
79
	public function getOutput() {
80
		$maxLenLineNumber = 0;
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 2 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...
81
		$maxLenDestination = 0;
82
		$maxLenTime = 0;
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 8 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...
83
		$departuresItems = $this->getDeparturesFactory()->getItems($this->getFilter());
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 3 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...
84
		foreach ($departuresItems as $departureObject) {
85
86
			if (mb_strlen($departureObject->lineNumber) > $maxLenLineNumber) {
87
				$maxLenLineNumber = mb_strlen($departureObject->lineNumber);
88
			}
89
90
			if (mb_strlen($departureObject->destination) > $maxLenDestination) {
91
				$maxLenDestination = mb_strlen($departureObject->destination);
92
			}
93
			if (mb_strlen($departureObject->time) > $maxLenTime) {
94
				$maxLenTime = mb_strlen($departureObject->time);
95
			}
96
		}
97
		$str = sprintf('Abfahrtzeiten %s %s',
98
			$this->getDeparturesFactory()->getStation()
99
			, $this->getDeparturesFactory()->getCurrentTime()
100
		);
101
102
		$str .= "\n";
103
104
		foreach ($departuresItems as $departureObject) {
105
			$str .= self::mb_str_pad($departureObject->lineNumber, $maxLenLineNumber + 3, ' ', STR_PAD_RIGHT);
106
			$str .= self::mb_str_pad($departureObject->destination, $maxLenDestination + 3, ' ', STR_PAD_RIGHT);
107
			$str .= self::mb_str_pad($departureObject->time, $maxLenTime + 3, ' ', STR_PAD_RIGHT);
108
			$str .= "\n";
109
		}
110
		return $str;
111
	}
112
113
114
}