Issues (21)

Security Analysis    no request data  

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.

lib/Base/AdminBaseDto.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 Ridibooks\Platform\Common\Base;
4
5
use ReflectionClass;
6
use ReflectionProperty;
7
use Symfony\Component\HttpFoundation\Request;
8
9
/**
10
 * 이 클래스는 "상속받은 클래스가 DTO" 임을 의미하고, 이와 관련된 최소한의 정보만 다룬다.
11
 */
12
class AdminBaseDto
13
{
14
	/**
15
	 * @var
16
	 * @depecated Request에 종속적인 정보
17
	 */
18
	public $command; //명령어 (insert / update / ...)
19
	/**
20
	 * @var
21
	 * @depecated DB에 종속적인 정보, id는 모델에서 저장하도록
22
	 */
23
	public $id; //공통으로 쓰이는 id
24
	/**
25
	 * @var
26
	 * @depecated Request에 종속적인 정보
27
	 */
28
	public $page; //paging에서 공통으로 쓰이는 page
29
	/**
30
	 * @var
31
	 * @depecated Request에 종속적인 정보
32
	 */
33
	public $search_text; //공통으로 쓰이는 검색어
34
35
	/**
36
	 * AdminBaseDto constructor.
37
	 * @param null $param
38
	 * @deprecated 암시적으로 생성자 사용하지 않고, 명시적으로 import, export 호출
39
	 */
40
	public function __construct($param = null)
41
	{
42
		if ($param instanceof Request) {
0 ignored issues
show
The class Symfony\Component\HttpFoundation\Request does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
43
			$this->importFromRequest($param);
44
		} elseif ($param instanceof \stdClass) {
45
			$this->importFromStdClass($param);
46
		} elseif (is_array($param)) {
47
			$this->importFromArray($param);
48
		}
49
	}
50
51
	/**
52
	 * Request class를 이용하여 클래스를 초기화한다.
53
	 * @param Request $request
54
	 * @internal public 이 아닌 protected 로 변경필요
55
	 */
56
	public function importFromRequest($request)
57
	{
58
		$reflect = new ReflectionClass(get_called_class());
59
		$properties = $reflect->getProperties(ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_PROTECTED);
60
		foreach ($properties as $property) {
61
			$property->setValue($this, $request->get($property->getName()));
62
		}
63
	}
64
65
	/**stdClass 일 경우 클래스 초기화
66
	 * @param \stdClass $stdClass
67
	 * @internal public 이 아닌 protected 로 변경필요
68
	 */
69 View Code Duplication
	public function importFromStdClass($stdClass)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
70
	{
71
		$reflect = new ReflectionClass(get_called_class());
72
		$properties = $reflect->getDefaultProperties();
73
		foreach ($properties as $key => $value) {
74
			$this->{$key} = $stdClass->{$key};
75
		}
76
	}
77
78
	/**interface의 function을 가져와 클래스를 초기화 한다.
79
	 * @param $reader
80
	 * @deprecated UniversalBookReader 를 상속받아 구현할것
81
	 */
82 View Code Duplication
	public function importFromInterface($reader)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
83
	{
84
		$reflect = new ReflectionClass(get_called_class());
85
		$default_properties = $reflect->getDefaultProperties();
86
		foreach ($default_properties as $key => $value) {
87
			if (method_exists($reader, $key)) {
88
				$this->{$key} = $reader->$key();
89
			}
90
		}
91
	}
92
93
	/**
94
	 * 배열을 이용하여 클래스를 초기화한다
95
	 * @param array $array
96
	 * @throws \Exception
97
	 * @internal public 이 아닌 protected 로 변경필요
98
	 */
99
	public function importFromArray($array)
100
	{
101
		if (!is_array($array)) {
102
			throw new \Exception('invalid array');
103
		}
104
		$reflect = new ReflectionClass(get_called_class());
105
		$properties = $reflect->getDefaultProperties();
106
		foreach ($properties as $key => $value) {
107
			if (array_key_exists($key, $array)) {
108
				$this->{$key} = $array[$key];
109
			}
110
		}
111
	}
112
113
	/**
114
	 * 함수를 호출한 클래스의 기본 멤버변수만을(동적, 부모 멤버변수 제외) 리턴한다.
115
	 * @return array
116
	 * @internal public 이 아닌 protected 로 변경필요
117
	 */
118
	public function exportAsArray()
119
	{
120
		$reflect = new ReflectionClass(get_called_class());
121
		$reflect_parent = $reflect->getParentClass();
122
		$default_properties = $reflect->getDefaultProperties();
123
124
		$columns = [];
125
		foreach ($default_properties as $key => $value) {
126
			if ($reflect_parent->hasProperty($key)) {
127
				// 부모 클래스의 properties는 무시한다.
128
				continue;
129
			}
130
			$columns = array_merge($columns, [$key => $this->{$key}]);
131
		}
132
133
		return $columns;
134
	}
135
136
	/**
137
	 * 함수를 호출한 클래스의 기본 멤버변수만큼(동적, 부모 멤버변수 제외) 리턴한다.
138
	 * 단, Null값을 가진 column은 제외한다.
139
	 * @return array
140
	 * @internal public 이 아닌 protected 로 변경필요
141
	 * @deprecated use exportAsArray
142
	 */
143
	public function exportAsArrayExceptNull()
144
	{
145
		$columns = $this->exportAsArray();
146
147
		foreach ($columns as $key => $value) {
148
			if ($value === null) {
149
				unset($columns[$key]);
150
			}
151
		}
152
153
		return $columns;
154
	}
155
}
156