Issues (311)

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.

lib/image/timber-image-operation-tojpg.php (4 issues)

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
2
3
/**
4
 * Implements converting a PNG file to JPG.
5
 * Argument:
6
 * - color to fill transparent zones
7
 */
8
class TimberImageOperationToJpg extends TimberImageOperation {
9
10
	private $color;
11
12
	/**
13
	 * @param string $color hex string of color to use for transparent zones
14
	 */
15
	function __construct($color) {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
16
		$this->color = $color;
17
	}
18
19
	/**
20
	 * @param   string    $src_filename     the basename of the file (ex: my-awesome-pic)
21
	 * @param   string    $src_extension    ignored
22
	 * @return  string    the final filename to be used (ex: my-awesome-pic.jpg)
23
	 */
24
	function filename($src_filename, $src_extension = 'jpg') {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
25
		$new_name = $src_filename . '.jpg';
26
		return $new_name;
27
	}
28
29
	/**
30
	 * Performs the actual image manipulation,
31
	 * including saving the target file.
32
	 *
33
	 * @param  string $load_filename filepath (not URL) to source file (ex: /src/var/www/wp-content/uploads/my-pic.jpg)
34
	 * @param  string $save_filename filepath (not URL) where result file should be saved
35
	 *                               (ex: /src/var/www/wp-content/uploads/my-pic.png)
36
	 * @return bool                  true if everything went fine, false otherwise
37
	 */
38
	function run($load_filename, $save_filename) {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
39
		$input = self::image_create( $load_filename );
40
		list( $width, $height ) = getimagesize( $load_filename );
41
		$output = imagecreatetruecolor( $width, $height );
42
		$c = self::hexrgb( $this->color );
43
		$color = imagecolorallocate( $output, $c['red'], $c['green'], $c['blue'] );
44
		imagefilledrectangle( $output, 0, 0, $width, $height, $color );
45
		imagecopy( $output, $input, 0, 0, 0, 0, $width, $height );
46
		imagejpeg( $output, $save_filename );
47
		return true;
48
	}
49
50
	/**
51
	 * @param string $filename
52
	 * @return resource an image identifier representing the image obtained from the given filename
53
	 *                  will return the same data type regardless of whether the source is gif or png
54
	 */
55
	function image_create( $filename, $ext = 'auto' ) {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
56
		if ( $ext == 'auto' ) {
57
			$ext = wp_check_filetype($filename);
58
			if (isset($ext['ext'])) {
59
				$ext = $ext['ext'];
60
			}
61
		}
62
		$ext = strtolower($ext);
63
		if ( $ext == 'gif' ) {
64
			return imagecreatefromgif($filename);
65
		}
66
		if ( $ext == 'png' ) {
67
			return imagecreatefrompng($filename);
68
		}
69
		if ( $ext == 'jpg' || $ext == 'jpeg' ) {
70
			return imagecreatefromjpeg($filename);
71
		}
72
		throw new InvalidArgumentException( 'image_create only accepts PNG, GIF and JPGs. File extension was: '.$ext );
73
	}
74
}
75