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-retina.php (5 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
 * Contains the class for running image retina-izing operations
4
 */
5
6
/**
7
 * Increases image size by a given factor
8
 * Arguments:
9
 * - factor by which to multiply image dimensions
10
 * @property float $factor the factor (ex: 2, 1.5, 1.75) to multiply dimension by
11
 */
12
class TimberImageOperationRetina extends TimberImageOperation {
13
14
    private $factor;
15
16
    /**
17
     * Construct our operation
18
     * @param float   $factor to multiply original dimensions by
19
     */
20
    function __construct($factor) {
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...
21
        $this->factor = $factor;
22
    }
23
24
    /**
25
     * Generates the final filename based on the source's name and extension
26
     *
27
     * @param   string    $src_filename     the basename of the file (ex: my-awesome-pic)
28
     * @param   string    $src_extension    the extension (ex: .jpg)
29
     * @return  string    the final filename to be used (ex: [email protected])
30
     */
31
    function filename($src_filename, $src_extension) {
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...
32
        $newbase = $src_filename . '@' . $this->factor . 'x'; // add @2x, @3x, @1.5x, etc.
33
        $new_name = $newbase . '.' . $src_extension;
34
        return $new_name;
35
    }
36
37
    /**
38
     * Performs the actual image manipulation,
39
     * including saving the target file.
40
     *
41
     * @param  string $load_filename filepath (not URL) to source file
42
     *                               (ex: /src/var/www/wp-content/uploads/my-pic.jpg)
43
     * @param  string $save_filename filepath (not URL) where result file should be saved
44
     *                               (ex: /src/var/www/wp-content/uploads/[email protected])
45
     * @return bool                  true if everything went fine, false otherwise
46
     */
47
    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...
48
        $image = wp_get_image_editor( $load_filename );
49
        if ( !is_wp_error( $image ) ) {
50
            $current_size = $image->get_size();
51
            $src_w = $current_size['width'];
52
            $src_h = $current_size['height'];
53
            // Get ratios
54
            $w = $src_w * $this->factor;
55
            $h = $src_h * $this->factor;
56
            $image->crop( 0, 0, $src_w, $src_h, $w, $h );
57
            $result = $image->save( $save_filename );
58 View Code Duplication
            if ( is_wp_error( $result ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
59
            	// @codeCoverageIgnoreStart
60
				TimberHelper::error_log( 'Error resizing image' );
61
				TimberHelper::error_log( $result );
62
				return false;
63
				// @codeCoverageIgnoreEnd
64
            } else {
65
                return true;
66
            }
67 View Code Duplication
        } else if ( isset( $image->error_data['error_loading_image'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
68
            TimberHelper::error_log( 'Error loading ' . $image->error_data['error_loading_image'] );
69
        } else {
70
            TimberHelper::error_log( $image );
71
        }
72
        return false;
73
    }
74
}
75