Issues (45)

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/Native/NativeStream.php (2 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
 * Copyright (c) 2014 Robin Appelman <[email protected]>
4
 * This file is licensed under the Licensed under the MIT license:
5
 * http://opensource.org/licenses/MIT
6
 */
7
8
namespace Icewind\SMB\Native;
9
10
use Icewind\SMB\Exception\Exception;
11
use Icewind\SMB\Exception\InvalidRequestException;
12
use Icewind\Streams\File;
13
use InvalidArgumentException;
14
15
abstract class NativeStream implements File {
16
	/**
17
	 * @var resource
18
	 * @psalm-suppress PropertyNotSetInConstructor
19
	 */
20
	public $context;
21
22
	/**
23
	 * @var NativeState
24
	 * @psalm-suppress PropertyNotSetInConstructor
25
	 */
26
	protected $state;
27
28
	/**
29
	 * @var resource
30
	 * @psalm-suppress PropertyNotSetInConstructor
31
	 */
32
	protected $handle;
33
34
	/**
35
	 * @var bool
36
	 */
37
	protected $eof = false;
38
39
	/**
40
	 * @var string
41
	 */
42
	protected $url = '';
43
44
	/**
45
	 * Wrap a stream from libsmbclient-php into a regular php stream
46
	 *
47
	 * @param NativeState $state
48
	 * @param resource $smbStream
49
	 * @param string $mode
50
	 * @param string $url
51
	 * @param class-string<NativeStream> $class
0 ignored issues
show
The doc-type class-string<NativeStream> could not be parsed: Unknown type name "class-string" 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...
52
	 * @return resource
53
	 */
54
	protected static function wrapClass(NativeState $state, $smbStream, string $mode, string $url, string $class) {
55
		if (stream_wrapper_register('nativesmb', $class) === false) {
56
			throw new Exception("Failed to register stream wrapper");
57
		}
58
		$context = stream_context_create([
59
			'nativesmb' => [
60
				'state'  => $state,
61
				'handle' => $smbStream,
62
				'url'    => $url
63 78
			]
64
		]);
65 78
		$fh = fopen('nativesmb://', $mode, false, $context);
66
		if (stream_wrapper_unregister('nativesmb') === false) {
67
			throw new Exception("Failed to unregister stream wrapper");
68
		}
69
		return $fh;
70
	}
71 38
72 38
	public function stream_close() {
73
		try {
74
			return $this->state->close($this->handle, $this->url);
75 38
		} catch (\Exception $e) {
76 38
			return false;
77
		}
78
	}
79 78
80 78
	public function stream_eof() {
81 78
		return $this->eof;
82 78
	}
83 78
84 78
	public function stream_flush() {
85
		return false;
86
	}
87 38
88 38
89 38
	public function stream_open($path, $mode, $options, &$opened_path) {
90 38
		$context = stream_context_get_options($this->context);
91
		if (!isset($context['nativesmb']) || !is_array($context['nativesmb'])) {
92 38
			throw new InvalidArgumentException("context not set");
93
		}
94
		$state = $context['nativesmb']['state'];
95 4
		if (!$state instanceof NativeState) {
96 4
			throw new InvalidArgumentException("invalid context set");
97
		}
98 4
		$this->state = $state;
99
		$handle = $context['nativesmb']['handle'];
100
		if (!is_resource($handle)) {
101
			throw new InvalidArgumentException("invalid context set");
102
		}
103
		$this->handle = $handle;
104 36
		$url = $context['nativesmb']['url'];
105
		if (!is_string($url)) {
106 36
			throw new InvalidArgumentException("invalid context set");
107
		}
108
		$this->url = $url;
109
		return true;
110
	}
111
112 4
	public function stream_read($count) {
113 4
		$result = $this->state->read($this->handle, $count, $this->url);
114
		if (strlen($result) < $count) {
115
			$this->eof = true;
116
		}
117
		return $result;
118
	}
119
120 2
	public function stream_seek($offset, $whence = SEEK_SET) {
121 2
		$this->eof = false;
122
		try {
123
			return $this->state->lseek($this->handle, $offset, $whence, $this->url) !== false;
124 2
		} catch (InvalidRequestException $e) {
125 2
			return false;
126
		}
127
	}
128 2
129 2
	/**
130
	 * @return array{"mtime": int, "size": int, "mode": int}|false
0 ignored issues
show
The doc-type array{"mtime": could not be parsed: Unknown type name "array{"mtime":" 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...
131
	 */
132
	public function stream_stat() {
133
		try {
134
			return $this->state->stat($this->url);
135
		} catch (Exception $e) {
136
			return false;
137
		}
138
	}
139
140
	public function stream_tell() {
141
		return $this->state->lseek($this->handle, 0, SEEK_CUR, $this->url);
142
	}
143
144
	public function stream_write($data) {
145
		return $this->state->write($this->handle, $data, $this->url);
146
	}
147
148
	public function stream_truncate($size) {
149
		return $this->state->ftruncate($this->handle, $size, $this->url);
150
	}
151
152
	public function stream_set_option($option, $arg1, $arg2) {
153
		return false;
154
	}
155
156
	public function stream_lock($operation) {
157
		return false;
158
	}
159
}
160