Issues (10)

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/tags/AbstractVarTypeTag.php (1 issue)

Labels
Severity

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 declare(strict_types=1);
2
/*
3
 * This file is part of the Docblock package.
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 *
7
 * @license MIT License
8
 */
9
10
namespace gossi\docblock\tags;
11
12
use phootwork\lang\Text;
13
14
/**
15
 * Represents tags which are in the format
16
 *
17
 *   @tag [Type] [Variable] [Description]
18
 */
19
abstract class AbstractVarTypeTag extends AbstractTypeTag {
20
	protected string $variable = '';
0 ignored issues
show
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
21
	protected bool $isVariadic = false;
22
23
	/**
24
	 * @see https://github.com/phpDocumentor/ReflectionDocBlock/blob/master/src/phpDocumentor/Reflection/DocBlock/Tag/ParamTag.php Original Method: setContent()
25
	 * @see \gossi\docblock\tags\AbstractTypeTag::parse()
26
	 *
27
	 * @param string $content
28
	 */
29 15
	protected function parse(string $content): void {
30 15
		$parts = preg_split('/(\s+)/Su', $content, 3, PREG_SPLIT_DELIM_CAPTURE);
31
32 15
		$this->parseType($parts);
33 15
		$this->parseVariable($parts);
34 15
		$this->setDescription(implode('', $parts));
35 15
	}
36
37
	/**
38
	 * Parses the type from the extracted parts
39
	 * 
40
	 * @param string[] $parts
41
	 */
42 15
	private function parseType(array &$parts): void {
43
		// if the first item that is encountered is not a variable; it is a type
44 15
		if (isset($parts[0])
45 15
				&& (strlen($parts[0]) > 0)
46 15
				&& !str_starts_with($parts[0], '$')
47 15
				&& !str_starts_with($parts[0], '...$')) {
48 8
			$this->type = array_shift($parts);
49 8
			array_shift($parts);
50
		}
51 15
	}
52
53
	/**
54
	 * Parses the variable from the extracted parts
55
	 *
56
	 * @param string[] $parts
57
	 */
58 15
	private function parseVariable(array &$parts): void {
59
		// if the next item starts with a $ or ...$ it must be the variable name
60 15
		if (isset($parts[0])
61 15
				&& (strlen($parts[0]) > 0)
62 15
				&& (str_starts_with($parts[0], '$') || str_starts_with($parts[0], '...$'))) {
63 7
			$this->variable = array_shift($parts);
64 7
			array_shift($parts);
65
66 7
			if (str_starts_with($this->variable, '...')) {
67 3
				$this->isVariadic = true;
68 3
				$this->variable = substr($this->variable, 3);
69
			}
70
		}
71 15
	}
72
73 8
	public function toString(): string {
74 8
		$type = $this->type === '' ? '' : $this->type . ' ';
75 8
		$var = $this->variable !== ''
76 8
			? ($this->isVariadic ? '...' : '') . $this->variable . ' ' : '';
77
78 8
		return trim(sprintf('@%s %s%s%s', $this->tagName, $type, $var, $this->description));
79
	}
80
81
	/**
82
	 * Returns the variable name, starting with `$`
83
	 * 
84
	 * @return string the variable name
85
	 */
86 2
	public function getExpression(): string {
87 2
		return $this->variable;
88
	}
89
90
	/**
91
	 * Sets the variable name
92
	 *
93
	 * @param string $variable the new variable name
94
	 *
95
	 * @return $this        	
96
	 */
97 3
	public function setVariable(string $variable): self {
98 3
		if (str_starts_with($variable, '...')) {
99 1
			$this->setVariadic(true);
100 1
			$variable = substr($variable, 3);
101
		}
102
103 3
		$this->variable = str_starts_with($variable, '$') ? $variable : "\$$variable";
104
105 3
		return $this;
106
	}
107
108
	/**
109
	 * Returns the variable name
110
	 *
111
	 * @return string the variable name
112
	 */
113 2
	public function getVariable(): string {
114 2
		$variable = new Text($this->variable);
115
116 2
		return $variable->isEmpty() ? '' : $variable->slice(1)->toString();
117
	}
118
119
	/**
120
	 * Returns if the variable is variadic
121
	 * 
122
	 * @return bool if the variable is variadic
123
	 */
124 3
	public function isVariadic(): bool {
125 3
		return $this->isVariadic;
126
	}
127
128
	/**
129
	 * Sets whether the variable should be variadic
130
	 * 
131
	 * @param bool $variadic
132
	 *
133
	 * @return $this        	
134
	 */
135 2
	public function setVariadic(bool $variadic): self {
136 2
		$this->isVariadic = $variadic;
137
138 2
		return $this;
139
	}
140
}
141