Issues (74)

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.

src/services/GeneratorDefinitionService.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 keeko\tools\services;
3
4
use Propel\Generator\Model\Table;
5
6
class GeneratorDefinitionService extends AbstractService {
7
8
	/**
9
	 * Returns code for hydrating a propel model
10
	 *
11
	 * @param string $modelName
12
	 * @return string
13
	 */
14
	public function getWriteFields($modelName) {
15
		$generatorDefinition = $this->project->getGeneratorDefinition();
16
		$filter = $generatorDefinition->getWriteFilter($modelName);
17
		$model = $this->modelService->getModel($modelName);
18
		$computed = $this->getComputedFields($model);
19
		$filter = array_merge($filter, $computed);
20
21
		$fields = [];
22
		$cols = $model->getColumns();
23
		foreach ($cols as $col) {
24
			$prop = $col->getName();
25
26
			if (!in_array($prop, $filter)) {
27
				$fields[] = $prop;
28
			}
29
		}
30
31
		return $fields;
32
	}
33
34
	/**
35
	 * Returns the fields for a model
36
	 *
37
	 * @param string $modelName
38
	 * @return array
39
	 */
40
	public function getReadFields($modelName) {
41
		$generatorDefinition = $this->project->getGeneratorDefinition();
42
		$model = $this->modelService->getModel($modelName);
43
// 		$computed = $this->getComputedFields($model);
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
44
		$filter = $generatorDefinition->getReadFilter($modelName);
45
// 		$filter = array_merge($filter, $computed);
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
46
47
		$fields = [];
48
		$cols = $model->getColumns();
49
		foreach ($cols as $col) {
50
			$prop = $col->getName();
51
52
			if (!in_array($prop, $filter) && !$col->isForeignKey() && !$col->isPrimaryKey()) {
53
				$fields[] = $prop;
54
			}
55
		}
56
57
		return $fields;
58
	}
59
60
	/**
61
	 * Returns computed model fields
62
	 *
63
	 * @param Table $table
64
	 * @return array<string>
65
	 */
66
	public function getComputedFields(Table $table) {
67
		$fields = [];
68
69
		// iterate over behaviors to get their respective columns
70
		foreach ($table->getBehaviors() as $behavior) {
71
			switch ($behavior->getName()) {
72
				case 'timestampable':
73
					$fields[] = $behavior->getParameter('create_column');
74
					$fields[] = $behavior->getParameter('update_column');
75
					break;
76
77
				case 'aggregate_column':
78
					$fields[] = $behavior->getParameter('name');
79
					break;
80
			}
81
		}
82
83
		return $fields;
84
	}
85
86
	/**
87
	 * Returns all attributes that aren't written onto a model (because manually filter or computed)
88
	 *
89
	 * @param Table $model
90
	 * @return array
91
	 */
92
	public function getWriteFilter(Table $model) {
93
		$modelName = $model->getOriginCommonName();
94
		$generatorDefinition = $this->project->getGeneratorDefinition();
95
		$filter = $generatorDefinition->getWriteFilter($modelName);
96
		$computed = $this->getComputedFields($model);
97
		return array_merge($filter, $computed);
98
	}
99
}