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

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/libs/twitter.php (4 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
// Exit if accessed directly
4
if ( !defined( 'ABSPATH' ) ) {
5
	exit;
6
}
7
8
/**
9
 * Twitter Class
10
 *
11
 * Handles all twitter functions
12
 *
13
 */
14
if( !class_exists( 'PPP_Twitter' ) ) {
15
16
	class PPP_Twitter {
17
18
		var $twitter;
19
20
		public function __construct( $_user_id = 0 ) {
21
			ppp_maybe_start_session();
22
23
			$this->user_id = $_user_id;
0 ignored issues
show
The property user_id 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...
24
		}
25
26
		/**
27
		 * Include Twitter Class
28
		 *
29
		 * Handles to load twitter class
30
		 */
31
		public function ppp_load_twitter() {
32
				if( !class_exists( 'TwitterOAuth' ) ) {
33
					require_once ( PPP_PATH . '/includes/libs/twitter/twitteroauth.php' );
34
				}
35
36
				ppp_set_social_tokens();
37
38
				if ( ! defined( 'PPP_TW_CONSUMER_KEY' ) || ! defined( 'PPP_TW_CONSUMER_SECRET' ) ) {
39
					return false;
40
				}
41
42
				$this->twitter = new TwitterOAuth( PPP_TW_CONSUMER_KEY, PPP_TW_CONSUMER_SECRET );
43
44
				return true;
45
		}
46
47
		public function revoke_access() {
48
			global $ppp_social_settings;
49
50
			unset( $ppp_social_settings['twitter'] );
51
52
			update_option( 'ppp_social_settings', $ppp_social_settings );
53
		}
54
55
		/**
56
		 * Initializes Twitter API
57
		 *
58
		 */
59
		public function ppp_initialize_twitter() {
60
61
			//when user is going to logged in in twitter and verified successfully session will create
62
			if ( ! empty( $_REQUEST['oauth_verifier'] ) ) {
63
				$ppp_social_settings = get_option( 'ppp_social_settings' );
64
65
				//load twitter class
66
				$twitter = $this->ppp_load_twitter();
67
68
				//check twitter class is loaded or not
69
				if( ! $twitter ) {
70
					return false;
71
				}
72
73
				$this->twitter = new TwitterOAuth( PPP_TW_CONSUMER_KEY, PPP_TW_CONSUMER_SECRET, $_SESSION['ppp_twt_oauth_token'], $_SESSION['ppp_twt_oauth_token_secret'] );
74
75
				// Request access tokens from twitter
76
				$ppp_tw_access_token = $this->twitter->getAccessToken( $_REQUEST['oauth_verifier'] );
77
78
				//session for verifier
79
				$verifier['oauth_verifier'] = $_REQUEST['oauth_verifier'];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$verifier was never initialized. Although not strictly required by PHP, it is generally a good practice to add $verifier = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
80
81
				$_SESSION[ 'ppp_twt_user_cache' ] = $verifier;
82
83
				//getting user data from twitter
84
				$response = $this->twitter->get('account/verify_credentials');
85
86
				//if user data get successfully
87
				if ( $response->id_str ) {
88
89
					$data['user'] = $response;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$data was never initialized. Although not strictly required by PHP, it is generally a good practice to add $data = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
90
					$data['user']->accessToken = $ppp_tw_access_token;
91
92
					$ppp_social_settings['twitter'] = $data;
93
					update_option( 'ppp_social_settings', $ppp_social_settings );
94
95
				}
96
			}
97
		}
98
99
		public function ppp_verify_twitter_credentials() {
100
			$this->ppp_load_twitter();
101
102
			global $ppp_social_settings;
103
			if ( isset( $ppp_social_settings['twitter'] ) ) {
104
105
				$this->twitter = new TwitterOAuth(
106
					PPP_TW_CONSUMER_KEY,
107
					PPP_TW_CONSUMER_SECRET,
108
					$ppp_social_settings['twitter']['user']->accessToken['oauth_token'],
109
					$ppp_social_settings['twitter']['user']->accessToken['oauth_token_secret']
110
				);
111
112
				$response = $this->twitter->get('account/verify_credentials');
113
				if ( is_object( $response ) && property_exists( $response, 'errors' ) && count( $response->errors ) > 0 ) {
114
					foreach ( $response->errors as $error ) {
115
						if ( $error->code == 89 ) { // Expired or revoked tokens
116
							unset( $ppp_social_settings['twitter'] );
117
							update_option( 'ppp_social_settings', $ppp_social_settings );
118
119
							return array( 'error' => __( 'Post Promoter Pro has been removed from your Twitter account. Please reauthorize to continue promoting your content.', 'ppp-txt' ) );
120
						}
121
					}
122
				}
123
			}
124
125
			return true;
126
		}
127
128
		/**
129
		 * Get auth url for twitter
130
		 *
131
		 */
132
		public function ppp_get_twitter_auth_url ( $return_url = '' ) {
133
134
			if ( empty( $return_url ) ) {
135
				$return_url = admin_url( 'admin.php?page=ppp-social-settings' );
0 ignored issues
show
$return_url is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
136
			}
137
			//load twitter class
138
			$twitter = $this->ppp_load_twitter();
139
140
			//check twitter class is loaded or not
141
			if( !$twitter ) {
142
				return false;
143
			}
144
145
			$request_token = $this->twitter->getRequestToken( 'oob' );
146
147
			// If last connection failed don't display authorization link.
148
			switch( $this->twitter->http_code ) {
149
150
			case 200:
151
				$_SESSION['ppp_twt_oauth_token']        = $request_token['oauth_token'];
152
				$_SESSION['ppp_twt_oauth_token_secret'] = $request_token['oauth_token_secret'];
153
154
				$token = $request_token['oauth_token'];
155
				$url = $this->twitter->getAuthorizeURL( $token, NULL );
156
				break;
157
			default:
158
				$url = '';
159
				break;
160
			}
161
			return $url;
162
		}
163
164
		public function ppp_tweet( $message = '', $media = null ) {
165
			if ( empty( $message ) ) {
166
				return false;
167
			}
168
169
			$verify = $this->ppp_verify_twitter_credentials();
170
			if ( $verify === true ) {
171
				$args = array();
172
				if ( ! empty( $media ) ) {
173
					$endpoint = 'statuses/update_with_media';
174
					$args['media[]'] = wp_remote_retrieve_body( wp_remote_get( $media ) );
175
				} else {
176
					$endpoint = 'statuses/update';
177
				}
178
				$args['status'] = $message;
179
180
				return $this->twitter->post( $endpoint, $args, true );
181
			} else {
182
				return false;
183
			}
184
		}
185
186
	}
187
188
}
189