Issues (100)

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/Entities/PatientCRUD.php (6 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
/**
4
 * PatientCRUD
5
 *
6
 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
7
 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
8
 *
9
 * Permission is hereby granted to use or copy this program
10
 * for any purpose, provided the above notices are retained on all copies.
11
 * Permission to modify the code and to distribute modified code is granted,
12
 * provided the above notices are retained, and a notice that the code was
13
 * modified is included with the above copyright notice.
14
 *
15
 * @category  Wp
16
 * @package   Punction
17
 * @author    Andrzej Marcinkowski <[email protected]>
18
 * @copyright 2014 Wojewódzki Szpital Zespolony, Kalisz
19
 * @license   MIT http://opensource.org/licenses/MIT
20
 * @version   1.0 $Format:%H$
21
 * @link      http://
22
 * @since     File available since Release 1.0.0
23
 * PHP Version 5
24
 */
25
namespace Hospitalplugin\Entities;
26
27
use Hospitalplugin\DB\DoctrineBootstrap;
28
use Hospitalplugin\Entities\Patient;
29
use Hospitalplugin\Entities\PatientDeleted;
30
use Hospitalplugin\Entities\PatientFactory;
31
use Hospitalplugin\utils\Utils;
32
33
class PatientCRUD {
34
	
35
	/**
36
	 * getPatients
37
	 *
38
	 * @param int $day
39
	 *        	dayOfTheMonth
40
	 * @param int $month
41
	 *        	month
42
	 *        	
43
	 * @return Patient array
44
	 */
45
	public static function getPatients($month = null, $day = null, $wardId = 0) {
46
		return PatientCRUD::getPatientsDateRange ( Utils::getStartDate ( $month, $day ), Utils::getEndDate ( $month, $day ), $wardId );
47
	}
48
	
49
	/**
50
	 * getPatientsDateRange
51
	 *
52
	 * TODO(AM) testy na przypadki graniczne - pacjenci z data przed polnoca, po polnocy, godzina przed obecna, po obecnej
53
	 *
54
	 * @param int $day
0 ignored issues
show
There is no parameter named $day. 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...
55
	 *        	dayOfTheMonth
56
	 * @param int $month
0 ignored issues
show
There is no parameter named $month. 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...
57
	 *        	month
58
	 *        	
59
	 * @return Patient array
60
	 */
61
	public static function getPatientsDateRange($date1, $date2, $wardId = 0) {
62
		$entityManager = ( object ) DoctrineBootstrap::getEntityManager ();
63
		$params = array (
64
				'from' => $date1,
65
				'to' => $date2,
66
				'oddzialId' => $wardId 
67
		);
68
		$q = $entityManager->createQuery ( 'select p FROM Hospitalplugin\Entities\Patient p WHERE p.dataKategoryzacji BETWEEN :from AND :to and p.oddzialId = :oddzialId ORDER BY p.name' )->setParameters ( $params )->setFirstResult ( 0 )->setMaxResults ( 1000 );
69
		$patients = $q->getResult ();
70
		return $patients;
71
	}
72
	
73
	/**
74
	 * getPatient
75
	 *
76
	 * @param $id $id
0 ignored issues
show
The doc-type $id could not be parsed: Unknown type name "$id" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
77
	 *        	int
78
	 *        	
79
	 * @return Patient Patient
80
	 */
81
	public static function getPatient($id, $type = '') {
82
		$entityManager = ( object ) DoctrineBootstrap::getEntityManager ();
83
		$type = 'Hospitalplugin\Entities\Patient' . $type;
84
		$patient = $entityManager->getRepository ( $type )->findOneBy ( array (
85
				'id' => $id 
86
		) );
87
		return Utils::cast ( $type, ( object ) $patient, 0 );
88
	}
89
	
90
	/**
91
	 * setPatientCategories
92
	 *
93
	 * @param Patient $obj        	
94
	 *
95
	 * @return Patient
96
	 */
97
	public static function setPatientCategories($obj, $type) {
98
		$entityManager = DoctrineBootstrap::getEntityManager ();
99
		$patient = PatientCRUD::getPatient ( $obj->id, $type );
100
		foreach ( get_object_vars ( $obj ) as $key => $value ) {
101
			call_user_func ( array (
102
					$patient,
103
					'set' . ucwords ( $key ) 
104
			), $value );
105
		}
106
		$entityManager->merge ( $patient );
107
		$entityManager->flush ();
108
		return $patient;
109
	}
110
	
111
	/**
112
	 * setPatientCategories
113
	 *
114
	 * @param Patient $obj        	
0 ignored issues
show
There is no parameter named $obj. 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...
115
	 *
116
	 * @return Patient
117
	 */
118
	public static function createPatient($type, $name, $pesel) {
119
		$entityManager = DoctrineBootstrap::getEntityManager ();
120
		$type = 'Hospitalplugin\Entities\Patient' . $type;
121
		$patient = new $type ();
122
		$patient->setName ( $name );
123
		$patient->setPesel ( $pesel );
124
		$entityManager->persist ( $patient );
125
		$entityManager->flush ();
126
		return $patient;
127
	}
128
	
129
	/**
130
	 * deletePatient
131
	 *
132
	 * @param $id $id
0 ignored issues
show
The doc-type $id could not be parsed: Unknown type name "$id" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
133
	 *        	int
134
	 */
135
	public static function deletePatient($id, $userId = 0) {
136
		$entityManager = ( object ) DoctrineBootstrap::getEntityManager ();
137
		$type = 'Hospitalplugin\Entities\Patient';
138
		$patient = $entityManager->getRepository ( $type )->findOneBy ( array (
139
				'id' => $id 
140
		) );
141
		$entityManager->remove ( $patient );
142
		$log = strval($patient);
143
		$audit = new PatientDeleted();
144
		$audit->deletedAt = new \DateTime ();
145
		$audit->deletedByUserId = $userId;
146
		$audit->log = $log;
147
		$entityManager->persist ( $audit );
148
		$entityManager->flush ();
149
	}
150
}
151
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...