Issues (789)

Security Analysis    not enabled

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.

app/services/AnnotationService.php (3 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
namespace App\Services;
4
5
use Nette\Utils\ArrayHash;
6
use App\Models\BlockModel;
7
use App\Models\ProgramModel;
8
use Nette\Database\Table\ActiveRow;
9
10
class AnnotationService
11
{
12
13
	/**
14
	 * @var BlockModel
15
	 */
16
	protected $blockModel;
17
18
	/**
19
	 * @var ProgramModel
20
	 */
21
	protected $programModel;
22
23
	/**
24
	 * @param BlockModel $block
25
	 * @param ProgramModel $program
26
	 */
27
	public function __construct(BlockModel $block, ProgramModel $program)
28
	{
29
		$this->setBlockModel($block);
30
		$this->setProgramModel($program);
31
	}
32
33
	/**
34
	 * @param  string $id
0 ignored issues
show
There is no parameter named $id. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
35
	 * @param  string $type
36
	 * @return Row
37
	 */
38
	public function findByType(string $guid, string $type)
39
	{
40
		return $this->getModelByType($type)->findBy('guid', $guid);
41
	}
42
43
	/**
44
	 * @param  ActiveRow $annotation
45
	 * @return ActiveRow
46
	 */
47
	public function findParentProgram(ActiveRow $annotation): ActiveRow
48
	{
49
		if(array_key_exists('block', $annotation->toArray())) {
50
			$parentProgram = $this->getBlockModel()->find($annotation->block);
51
		} else {
52
			$parentProgram = $annotation;
53
		}
54
55
		return $parentProgram;
56
	}
57
58
	/**
59
	 * @param  string    $type
60
	 * @param  ArrayHash $annotation
61
	 * @return Row
62
	 */
63
	public function updateByType(string $type, ArrayHash $annotation)
64
	{
65
		return $this->getModelByType($type)->updateBy('guid', $annotation->guid, (array) $annotation);
66
	}
67
68
	/**
69
	 * @param  string $type
70
	 * @return ProgramModel | BLockModel
71
	 */
72
	protected function getModelByType(string $type)
73
	{
74
		switch ($type) {
75
			case 'block':
76
				$model = $this->getBlockModel();
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->getBlockModel(); of type App\Models\BlockModel adds the type App\Models\BlockModel to the return on line 86 which is incompatible with the return type documented by App\Services\AnnotationService::getModelByType of type App\Models\ProgramModel.
Loading history...
77
				break;
78
			case 'program':
79
				$model = $this->getProgramModel();
80
				break;
81
			default:
82
				throw new Exception('Annotation model not found!');
83
				break;
0 ignored issues
show
break; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
84
		}
85
86
		return $model;
87
	}
88
89
	/**
90
	 * @return ProgramModel
91
	 */
92
	protected function getProgramModel()
93
	{
94
		return $this->programModel;
95
	}
96
97
	/**
98
	 * @param  ProgramModel $model
99
	 * @return self
100
	 */
101
	protected function setProgramModel(ProgramModel $model): self
102
	{
103
		$this->programModel = $model;
104
105
		return $this;
106
	}
107
108
	/**
109
	 * @return BlockModel
110
	 */
111
	protected function getBlockModel(): BlockModel
112
	{
113
		return $this->blockModel;
114
	}
115
116
	/**
117
	 * @param  BlockModel $model
118
	 * @return self
119
	 */
120
	protected function setBlockModel(BlockModel $model): self
121
	{
122
		$this->blockModel = $model;
123
124
		return $this;
125
	}
126
127
}
128