GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (217)

Security Analysis    no vulnerabilities found

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.

classes/backup/class-backup-engine.php (7 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 HM\BackUpWordPress;
4
5
/**
6
 * The base Backup Engine
7
 *
8
 * Base Backup Engine types should extend this class and call parent::__construct in
9
 * there constructor.
10
 *
11
 * Defines base functionality shared across all types of backups
12
 */
13
abstract class Backup_Engine {
14
15
	/**
16
	 * An array of backup errors.
17
	 *
18
	 * @var array
19
	 */
20
	private $errors = array();
21
22
	/**
23
	 * An array of backup warnings.
24
	 *
25
	 * @var array
26
	 */
27
	private $warnings = array();
28
29
	public function __construct() {
30
31
		/**
32
		 * Raise the `memory_limit` and `max_execution time`
33
		 *
34
		 * Respects the WP_MAX_MEMORY_LIMIT Constant and the `admin_memory_limit`
35
		 * filter.
36
		 */
37
		@ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) );
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
38
		@set_time_limit( 0 );
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
39
40
		// Set a custom error handler so we can track errors
41
		set_error_handler( array( $this, 'error_handler' ) );
42
43
	}
44
45
	/**
46
	 * Backup Engine Types should always implement the `verify_backup` method.
47
	 *
48
	 * @return bool Whether the backup completed successfully or not.
49
	 */
50
	abstract public function verify_backup();
51
52
	/**
53
	 * Get the full filepath to the backup file.
54
	 *
55
	 * @return string The backup filepath.
56
	 */
57
	public function get_backup_filepath() {
58
		return trailingslashit( Path::get_path() ) . $this->get_backup_filename();
59
	}
60
61
	/**
62
	 * Get the filename of the backup.
63
	 *
64
	 * @return string The backup filename.
65
	 */
66
	public function get_backup_filename() {
67
		return $this->backup_filename;
0 ignored issues
show
The property backup_filename does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
68
	}
69
70
	/**
71
	 * Set the filename of the backup.
72
	 *
73
	 * @param string $filename The backup filename.
74
	 */
75
	public function set_backup_filename( $filename ) {
76
		$this->backup_filename = strtolower( sanitize_file_name( remove_accents( $filename ) ) );
77
	}
78
79
	/**
80
	 * Get the array of errors encountered during the backup process.
81
	 *
82
	 * @param  string $context The context for the error, usually the Backup
0 ignored issues
show
Should the type for parameter $context not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
83
	 *                         Engine that encountered the error.
84
	 *
85
	 * @return array           The array of errors.
86
	 */
87 View Code Duplication
	public function get_errors( $context = null ) {
88
89
		// Only return a specific contexts errors.
90
		if ( ! empty( $context ) ) {
91
			return isset( $this->errors[ $context ] ) ? $this->errors[ $context ] : array();
92
		}
93
94
		return $this->errors;
95
96
	}
97
98
	/**
99
	 * Add an error to the errors array.
100
	 *
101
	 * An error is always treat as fatal and should only be used for unrecoverable
102
	 * issues with the backup process.
103
	 *
104
	 * @param  string $context The context for the error.
105
	 * @param  string $error   The error that was encountered.
106
	 */
107 View Code Duplication
	public function error( $context, $error ) {
108
109
		if ( empty( $context ) || empty( $error ) ) {
110
			return;
111
		}
112
113
		// Ensure we don't store duplicate errors by md5'ing the error as the key
114
		$this->errors[ $context ][ md5( implode( ':', (array) $error ) ) ] = $error;
115
116
	}
117
118
	/**
119
	 * Get the array of warnings encountered during the backup process.
120
	 *
121
	 * @param  string $context The context for the warning, usually the Backup
0 ignored issues
show
Should the type for parameter $context not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
122
	 *                         Engine that encountered the warning.
123
	 *
124
	 * @return array           The array of warnings.
125
	 */
126 View Code Duplication
	public function get_warnings( $context = null ) {
127
128
		// Only return a specific contexts errors.
129
		if ( ! empty( $context ) ) {
130
			return isset( $this->warnings[ $context ] ) ? $this->warnings[ $context ] : array();
131
		}
132
133
		return $this->warnings;
134
135
	}
136
137
	/**
138
	 * Add an warning to the errors warnings.
139
	 *
140
	 * A warning is always treat as non-fatal and should only be used for recoverable
141
	 * issues with the backup process.
142
	 *
143
	 * @param  string $context The context for the warning.
144
	 * @param  string $error   The warning that was encountered.
0 ignored issues
show
There is no parameter named $error. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
145
	 */
146 View Code Duplication
	public function warning( $context, $warning ) {
147
148
		if ( empty( $context ) || empty( $warning ) ) {
149
			return;
150
		}
151
152
		// Ensure we don't store duplicate warnings by md5'ing the error as the key
153
		$this->warnings[ $context ][ md5( implode( ':', (array) $warning ) ) ] = $warning;
154
155
	}
156
157
	/**
158
	 * Hooked into `set_error_handler` to catch any PHP errors that happen during
159
	 * the backup process.
160
	 *
161
	 * PHP errors are always treat as warnings rather than errors.
162
	 *
163
	 * @param  int $type   The level of error raised
164
	 *
165
	 * @return false       Return false to pass the error back to PHP so it can
0 ignored issues
show
Should the return type not be boolean?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
166
	 *                     be handled natively.
167
	 */
168
	public function error_handler( $type ) {
169
170
		// Skip strict & deprecated warnings
171
		if ( ( defined( 'E_DEPRECATED' ) && E_DEPRECATED === $type ) || ( defined( 'E_STRICT' ) && E_STRICT === $type ) || 0 === error_reporting() ) {
172
			return false;
173
		}
174
175
		/**
176
		 * Get the details of the error.
177
		 *
178
		 * These are:
179
		 *
180
		 * @param int    $errorno   The error level expressed as an integer/
181
		 * @param string $errstr    The error message.
182
		 * @param string $errfile   The file that the error raised in.
183
		 * @param string $errorline The line number the error was raised on.
184
		 */
185
		$args = func_get_args();
186
187
		// Strip the error level
188
		array_shift( $args );
189
190
		// Fire a warning for the PHP error passing the message, file and line number.
191
		$this->warning( 'php', implode( ', ', array_splice( $args, 0, 3 ) ) );
192
193
		return false;
194
195
	}
196
}
197