Issues (29)

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.

src/Zamm.php (4 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
 * This software package is licensed under `AGPL, Commercial` license[s].
5
 *
6
 * @package maslosoft/zamm
7
 * @license AGPL, Commercial
8
 *
9
 * @copyright Copyright (c) Peter Maselkowski <[email protected]>
10
 * @link https://maslosoft.com/zamm/
11
 */
12
13
namespace Maslosoft\Zamm;
14
15
use Maslosoft\EmbeDi\EmbeDi;
16
use Maslosoft\Zamm\Interfaces\ConverterInterface;
17
use Maslosoft\Zamm\Converters\PhpConverter;
18
use Maslosoft\Zamm\Decorators\StarRemover;
19
use Maslosoft\Zamm\Extractors\AddendumExtractor;
20
use Maslosoft\Zamm\Interfaces\Extractors\ExtractorInterface;
21
use Maslosoft\Zamm\Extractors\NullExtractor;
22
use Maslosoft\Zamm\Interfaces\FileDecoratorInterface;
23
use Maslosoft\Zamm\FileDecorators\IgnoreFileDecorator;
24
use Maslosoft\Zamm\FileDecorators\MadeByFileDecorator;
25
use Maslosoft\Zamm\Interfaces\SourceAccessorInterface;
26
use Maslosoft\Zamm\Outputs\FileOutput;
27
use Maslosoft\Zamm\Interfaces\OutputInterface;
28
use Maslosoft\Zamm\Renderers\ClassRenderer;
29
use Maslosoft\Zamm\Interfaces\Renderers\ClassRendererInterface;
30
use Maslosoft\Zamm\Interfaces\Renderers\MethodRendererInterface;
31
use Maslosoft\Zamm\Interfaces\Renderers\PropertyRendererInterface;
32
use Maslosoft\Zamm\Interfaces\Renderers\RendererInterface;
33
use Maslosoft\Zamm\Renderers\MethodRenderer;
34
use Maslosoft\Zamm\Renderers\PropertyRenderer;
35
36
/**
37
 * Zamm: PHP Doc extractor for code fragments
38
 * This class allows extracting code fragments into documentation.
39
 * It is designed to be IDE friendly. It should autocomplete and automatically reflect code refactors if properly used.
40
 * This documentation is also processed with Zamm.
41
 *
42
 * @author Piotr Maselkowski <pmaselkowski at gmail.com>
43
 */
44
class Zamm implements SourceAccessorInterface
45
{
46
47
	use Traits\SourceMagic;
48
49
	/**
50
	 * @deprecated
51
	 * TODO See if it's used somewhere
52
	 */ 
53
	const Version = '1.0.0';
0 ignored issues
show
Constant Version should be defined in uppercase
Loading history...
54
	const MadeBy = 'Generated by Maslosoft Zamm';
0 ignored issues
show
Constant MadeBy should be defined in uppercase
Loading history...
55
	const DefaultInstanceId = 'zamm';
0 ignored issues
show
Constant DefaultInstanceId should be defined in uppercase
Loading history...
56
57
	/**
58
	 * Input for documentation
59
	 * Array of folders and files to process.
60
	 * @var string[]
61
	 */
62
	public $input = [
63
		'docs'
64
	];
65
66
	public $output = [
67
68
	];
69
70
	/**
71
	 * Configuration of decorators.
72
	 * This should be array with keys of renderer interface names and values of decorator classes.
73
	 * @var string[][]
74
	 */
75
	public $decorators = [
76
		// All around decorators
77
		RendererInterface::class => [
78
			StarRemover::class
79
		],
80
		// Class decorators
81
		ClassRendererInterface::class => [
82
		],
83
		// Property decorators
84
		PropertyRendererInterface::class => [
85
		],
86
		// Method decorators
87
		MethodRendererInterface::class => [
88
		],
89
	];
90
91
	/**
92
	 * Configuration of file decorators.
93
	 * This should be array with keys of converter names and values of file decorator classes.
94
	 * @var string[][]
95
	 */
96
	public $fileDecorators = [
97
		// All file decorators
98
		FileDecoratorInterface::class => [
99
			MadeByFileDecorator::class
100
		],
101
		// PHP converter decorators
102
		PhpConverter::class => [
103
			IgnoreFileDecorator::class
104
		]
105
	];
106
107
	/**
108
	 * Converters
109
	 * Array of class names of converters. These will be applied in order specified here, to all files.
110
	 * All converters should implement `IConverter` interface.
111
	 * @see ConverterInterface
112
	 * @var string[]
113
	 */
114
	public $converters = [
115
		PhpConverter::class
116
	];
117
118
	/**
119
	 * Outputs classes
120
	 * Array of class names of outputs. These will be applied in order specified here, to all files.
121
	 * All outputs should implement `IOutput` interface.
122
	 * @see OutputInterface
123
	 * @var string[]
124
	 */
125
	public $outputs = [
126
		FileOutput::class
127
	];
128
129
	/**
130
	 * Extractor class name.
131
	 * This class will be used to extract source fragments. Defaults to `AddendumExtractor`.
132
	 * It implements `IExtractor` interface.
133
	 * @see AddendumExtractor
134
	 * @see ExtractorInterface
135
	 * @var string
136
	 */
137
	public $extractor = AddendumExtractor::class;
138
139
	/**
140
	 * Extractor instance
141
	 * @var ExtractorInterface
142
	 */
143
	private $_extractor = null;
144
145
	/**
146
	 * Working class name
147
	 * @var string|null
148
	 */
149
	private $_className = '';
150
151
	/**
152
	 * EmbeDi instance
153
	 * @var EmbeDi
154
	 */
155
	private $_di = null;
156
157
	public function __construct($className = null)
158
	{
159
		$this->_className = $className;
160
		$this->_di = new EmbeDi(self::DefaultInstanceId);
161
		$this->_di->configure($this);
162
	}
163
164
	public function init()
165
	{
166
		$this->_di->store($this);
167
	}
168
169
	public function methods()
170
	{
171
		/**
172
		 * TODO Return all method names
173
		 */
174
	}
175
176
	public function properties()
177
	{
178
		/**
179
		 * TODO Return all property names
180
		 */
181
	}
182
183
	public function method($name)
184
	{
185
		return new MethodRenderer($this->getExtractor(), $name);
186
	}
187
188
	public function property($name)
189
	{
190
		return new PropertyRenderer($this->getExtractor(), $name);
191
	}
192
193
	public function setExtractor(ExtractorInterface $extractor)
194
	{
195
		$this->_extractor = $extractor;
196
	}
197
198
	public function getExtractor()
199
	{
200
		if (null === $this->_extractor)
201
		{
202
203
			if (!$this->_className)
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->_className of type string|null is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
204
			{
205
				$extractorClass = NullExtractor::class;
206
			}
207
			else
208
			{
209
				$extractorClass = $this->extractor;
210
			}
211
			$extractor = new $extractorClass();
212
			$extractor->setClassName($this->_className);
213
			$this->_extractor = $extractor;
214
		}
215
		return $this->_extractor;
216
	}
217
218
	public static function __callStatic($name, $arguments)
219
	{
220
		$className = get_called_class();
221
		return new MethodRenderer((new Zamm($className))->getExtractor(), $name);
222
	}
223
224
	/**
225
	 *
226
	 * @return ClassRenderer
227
	 */
228
	public function __toString()
229
	{
230
		return (string) new ClassRenderer($this->getExtractor());
231
	}
232
233
}
234