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 (1881)

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/class-thumbnails.php (8 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
 * FooGallery Thumbnail Resizing class
4
 */
5
6
if ( !class_exists( 'FooGallery_Thumbnails' ) ) {
7
8
	class FooGallery_Thumbnails {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
9
10
		function __construct() {
11
			//generate thumbs using WPThumb
12
			add_filter( 'foogallery_attachment_resize_thumbnail', array( $this, 'resize' ), 10, 3 );
13
14
			add_filter( 'foogallery_test_thumb_url', array( $this, 'find_first_image_in_media_library' ) );
15
16
			add_filter( 'foogallery_thumbnail_resize_args', array( $this, 'check_for_force_original_thumb') );
17
		}
18
19
		function check_for_force_original_thumb( $args ){
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...
20
			global $current_foogallery;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
21
22
			if ( isset( $current_foogallery ) ) {
23
				$args['force_use_original_thumb'] = $current_foogallery->force_use_original_thumbs;
24
			}
25
26
			return $args;
27
		}
28
29
		function resize( $original_image_src, $args, $thumbnail_object ) {
30
			global $current_foogallery;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
31
		    global $foogallery_last_generated_thumb_url;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
32
33
			$arg_defaults = array(
34
				'width'                   => 0,
35
				'height'                  => 0,
36
				'crop'                    => true,
37
				'jpeg_quality'            => foogallery_thumbnail_jpeg_quality(),
38
				'thumb_resize_animations' => foogallery_get_setting( 'thumb_resize_animations' ),
39
				'foogallery_attachment_id'=> $thumbnail_object->ID
40
			);
41
42
			if ( isset( $current_foogallery ) ) {
43
				$arg_defaults['foogallery_id'] = $current_foogallery->ID;
44
			}
45
46
			$args = wp_parse_args( $args, $arg_defaults );
47
48
			//allow for plugins to change the thumbnail creation args
49
			$args = apply_filters( 'foogallery_thumbnail_resize_args', $args, $original_image_src, $thumbnail_object );
50
51
			//check the current arguments passed in by the shortcode
52
			global $current_foogallery_arguments;
53
			if ( isset( $current_foogallery_arguments ) && isset( $current_foogallery_arguments['template'] ) ) {
54
				$thumbnail_args = apply_filters( 'foogallery_calculate_thumbnail_dimensions-' . $current_foogallery_arguments['template'], $args, $current_foogallery_arguments );
55
				$args = wp_parse_args( $thumbnail_args, $args );
56
			}
57
58
			$width  = (int)$args['width'];
59
			$height = (int)$args['height'];
60
			$crop   = (bool)$args['crop'];
61
62
			if ( 0 === $width && 0 === $height ) {
63
				return $original_image_src;
64
			}
65
66
			//we can force the use of the originally uploaded full-size image
67
			$force_use_original_image = isset( $args['force_use_original_image'] ) && true === $args['force_use_original_image'];
68
69
			if ( $force_use_original_image ) {
70
				$fullsize = wp_get_attachment_image_src( $thumbnail_object->ID, 'fullsize' );
71
72
				return $fullsize[0];
73
			}
74
75
			//we can force the use of the original WP icon or WP-generated thumb by passing through args individually
76
			$force_use_original_thumb = isset( $args['force_use_original_thumb'] ) && true === $args['force_use_original_thumb'];
77
78
			if ( $force_use_original_thumb ) {
79
				$thumbnail_icon = wp_get_attachment_image_src( $thumbnail_object->ID, array( $width, $height ) );
80
81
				return $thumbnail_icon[0];
82
			}
83
84
			//we can force the use of original WP thumbs by passing through args individually, or by saved settings
85
			$use_original_thumbs = ( isset( $args['use_original_thumbs'] ) && true === $args['use_original_thumbs'] ) || 'on' === foogallery_get_setting( 'use_original_thumbs' );
86
87
			if ( $use_original_thumbs ) {
88
89
				$option_thumbnail_size_w = get_option( 'thumbnail_size_w' );
90
				$option_thumbnail_size_h = get_option( 'thumbnail_size_h' );
91
				$option_thumbnail_crop = get_option( 'thumbnail_crop' );
92
93
				//check if we are trying to get back the default thumbnail that we already have
94
				if ( $thumbnail_object->ID > 0 && $width == $option_thumbnail_size_w && $height == $option_thumbnail_size_h && $crop == $option_thumbnail_crop ) {
95
					$thumbnail_attributes = wp_get_attachment_image_src( $thumbnail_object->ID );
96
97
					return $thumbnail_attributes[0];
98
				}
99
			}
100
101
			if ( $thumbnail_object->ID > 0 ) {
102
				$crop_from_position = get_post_meta( $thumbnail_object->ID, 'wpthumb_crop_pos', true );
103
104
				if ( !empty( $crop_from_position ) ) {
105
					$args['crop_from_position'] = $crop_from_position;
106
				}
107
			}
108
109
			//remove invalid resize args
110
			if ( array_key_exists( 'height', $args ) && 0 === $args['height'] ) {
111
				unset( $args['height'] );
112
			}
113
114
			//do some checks to see if the image is smaller
115
			if ( $this->should_resize( $thumbnail_object, $args ) ) {
116
				//save the generated thumb url to a global so that we can use it later if needed
117
				$foogallery_last_generated_thumb_url = wpthumb( $original_image_src, $args );
118
			} else {
119
				$foogallery_last_generated_thumb_url = $original_image_src;
120
			}
121
122
            return $foogallery_last_generated_thumb_url;
123
		}
124
125
		function should_resize($thumbnail_object, $args) {
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...
126
			$original_width = $thumbnail_object->width;
127
			$original_height = $thumbnail_object->height;
128
			$new_width = isset( $args['width'] ) ? $args['width'] : 0;
129
			$new_height = isset( $args['height'] ) ? $args['height'] : 0;
130
131
			if ( $new_width > 0 && $new_height > 0 ) {
132
				return $original_width > $new_width || $original_height > $new_height;
133
			} else if ( $new_width > 0 ) {
134
				return $original_width > $new_width;
135
			}
136
			return $original_height > $new_height;
137
		}
138
139
		function run_thumbnail_generation_tests() {
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...
140
            $test_image_url = foogallery_test_thumb_url();
141
142
			//next, generate a thumbnail
143
			$test_args = array(
144
				'width'                   => 20,
145
				'height'                  => 20,
146
				'crop'                    => true,
147
				'jpeg_quality'            => foogallery_thumbnail_jpeg_quality()
148
			);
149
150
            //first, clear any previous cached files
151
            $thumb = new WP_Thumb( $test_image_url, $test_args );
152
            wpthumb_rmdir_recursive( $thumb->getCacheFileDirectory() );
153
154
			$test_thumb = new WP_Thumb( $test_image_url, $test_args );
155
            $generated_thumb = $test_thumb->returnImage();
156
            $success = $test_image_url !== $generated_thumb;
157
			$file_info = wp_check_filetype( $test_image_url );
158
159
			$test_results = array(
160
			    'success' => $success,
161
				'thumb' => $generated_thumb,
162
				'error' => $test_thumb->errored() ? $test_thumb->error : '',
163
				'file_info' => $file_info
164
			);
165
166
            do_action( 'foogallery_thumbnail_generation_test', $test_results );
167
168
            return $test_results;
169
		}
170
171
		function find_first_image_in_media_library( $test_thumb_url ) {
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...
172
			if ( 'on' === foogallery_get_setting( 'override_thumb_test', false ) ) {
173
				return 'https://s3.amazonaws.com/foocdn/test.jpg';
174
			}
175
176
			$args = array(
177
				'post_type' => 'attachment',
178
				'post_mime_type' =>'image',
179
				'post_status' => 'inherit',
180
				'posts_per_page' => 1,
181
				'suppress_filters' => 1
182
			);
183
			$query_images = new WP_Query( $args );
184
			foreach ( $query_images->posts as $image) {
185
				return $image->guid;
186
			}
187
			return $test_thumb_url;
188
		}
189
	}
190
}
191