Issues (4122)

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.

includes/libs/UDPTransport.php (1 issue)

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
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License as published by
5
 * the Free Software Foundation; either version 2 of the License, or
6
 * (at your option) any later version.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
 * GNU General Public License for more details.
12
 *
13
 * You should have received a copy of the GNU General Public License along
14
 * with this program; if not, write to the Free Software Foundation, Inc.,
15
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16
 * http://www.gnu.org/copyleft/gpl.html
17
 *
18
 * @file
19
 */
20
21
/**
22
 * A generic class to send a message over UDP
23
 *
24
 * If a message prefix is provided to the constructor or via
25
 * UDPTransport::newFromString(), the payload of the UDP datagrams emitted
26
 * will be formatted with the prefix and a single space at the start of each
27
 * line. This is the payload format expected by the udp2log service.
28
 *
29
 * @since 1.25
30
 */
31
class UDPTransport {
32
	private $host, $port, $prefix, $domain;
0 ignored issues
show
It is generally advisable to only define one property per statement.

Only declaring a single property per statement allows you to later on add doc comments more easily.

It is also recommended by PSR2, so it is a common style that many people expect.

Loading history...
33
34
	/**
35
	 * @param string $host IP address to send to
36
	 * @param int $port port number
37
	 * @param int $domain AF_INET or AF_INET6 constant
38
	 * @param string|bool $prefix Prefix to use, false for no prefix
39
	 */
40
	public function __construct( $host, $port, $domain, $prefix = false ) {
41
		$this->host = $host;
42
		$this->port = $port;
43
		$this->domain = $domain;
44
		$this->prefix = $prefix;
45
	}
46
47
	/**
48
	 * @param string $info In the format of "udp://host:port/prefix"
49
	 * @return UDPTransport
50
	 * @throws InvalidArgumentException
51
	 */
52
	public static function newFromString( $info ) {
53
		if ( preg_match( '!^udp:(?://)?\[([0-9a-fA-F:]+)\]:(\d+)(?:/(.*))?$!', $info, $m ) ) {
54
			// IPv6 bracketed host
55
			$host = $m[1];
56
			$port = intval( $m[2] );
57
			$prefix = isset( $m[3] ) ? $m[3] : false;
58
			$domain = AF_INET6;
59
		} elseif ( preg_match( '!^udp:(?://)?([a-zA-Z0-9.-]+):(\d+)(?:/(.*))?$!', $info, $m ) ) {
60
			$host = $m[1];
61
			if ( !IP::isIPv4( $host ) ) {
62
				$host = gethostbyname( $host );
63
			}
64
			$port = intval( $m[2] );
65
			$prefix = isset( $m[3] ) ? $m[3] : false;
66
			$domain = AF_INET;
67
		} else {
68
			throw new InvalidArgumentException( __METHOD__ . ': Invalid UDP specification' );
69
		}
70
71
		return new self( $host, $port, $domain, $prefix );
72
	}
73
74
	/**
75
	 * @param string $text
76
	 */
77
	public function emit( $text ) {
78
		// Clean it up for the multiplexer
79
		if ( $this->prefix !== false ) {
80
			$text = preg_replace( '/^/m', $this->prefix . ' ', $text );
81
82
			// Limit to 64KB
83
			if ( strlen( $text ) > 65506 ) {
84
				$text = substr( $text, 0, 65506 );
85
			}
86
87
			if ( substr( $text, -1 ) != "\n" ) {
88
				$text .= "\n";
89
			}
90
		} elseif ( strlen( $text ) > 65507 ) {
91
			$text = substr( $text, 0, 65507 );
92
		}
93
94
		$sock = socket_create( $this->domain, SOCK_DGRAM, SOL_UDP );
95
		if ( !$sock ) { // @todo should this throw an exception?
96
			return;
97
		}
98
99
		socket_sendto( $sock, $text, strlen( $text ), 0, $this->host, $this->port );
100
		socket_close( $sock );
101
	}
102
}
103