Issues (64)

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/cli.php (1 issue)

Labels
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
 * WP_CLI Commands
4
 * @package WordPress_GitHub_Sync
5
 */
6
7
/**
8
 * Class WordPress_GitHub_Sync_CLI
9
 */
10
class WordPress_GitHub_Sync_CLI extends WP_CLI_Command {
11
12
	/**
13
	 * Application container.
14
	 *
15
	 * @var WordPress_GitHub_Sync
16
	 */
17
	protected $app;
18
19
	/**
20
	 * Grab the Application container on instantiation.
21
	 */
22
	public function __construct() {
23
		$this->app = WordPress_GitHub_Sync::$instance;
24
	}
25
26
	/**
27
	 * Exports an individual post
28
	 * all your posts to GitHub
29
	 *
30
	 * ## OPTIONS
31
	 *
32
	 * <post_id|all>
33
	 * : The post ID to export or 'all' for full site
34
	 *
35
	 * <user_id>
36
	 * : The user ID you'd like to save the commit as
37
	 *
38
	 * ## EXAMPLES
39
	 *
40
	 *     wp wpghs export all 1
41
	 *     wp wpghs export 1 1
42
	 *
43
	 * @synopsis <post_id|all> <user_id>
44
	 *
45
	 * @param array $args Command arguments.
46
	 */
47
	public function export( $args ) {
48
		list( $post_id, $user_id ) = $args;
49
50
		if ( ! is_numeric( $user_id ) ) {
51
			WP_CLI::error( __( 'Invalid user ID', 'wp-github-sync' ) );
52
		}
53
54
		$this->app->export()->set_user( $user_id );
55
56
		if ( 'all' === $post_id ) {
57
			WP_CLI::line( __( 'Starting full export to GitHub.', 'wp-github-sync' ) );
58
			$this->app->controller()->export_all();
59
		} elseif ( is_numeric( $post_id ) ) {
60
			WP_CLI::line(
61
				sprintf(
62
					__( 'Exporting post ID to GitHub: %d', 'wp-github-sync' ),
63
					$post_id
64
				)
65
			);
66
			$this->app->controller()->export_post( (int) $post_id );
67
		} else {
68
			WP_CLI::error( __( 'Invalid post ID', 'wp-github-sync' ) );
69
		}
70
	}
71
72
	/**
73
	 * Imports the post in your GitHub repo
74
	 * into your WordPress blog
75
	 *
76
	 * ## OPTIONS
77
	 *
78
	 * <user_id>
79
	 * : The user ID you'd like to save the commit as
80
	 *
81
	 * ## EXAMPLES
82
	 *
83
	 *     wp wpghs import 1
84
	 *
85
	 * @synopsis <user_id>
86
	 *
87
	 * @param array $args Command arguments.
88
	 */
89
	public function import( $args ) {
90
		list( $user_id ) = $args;
91
92
		if ( ! is_numeric( $user_id ) ) {
93
			WP_CLI::error( __( 'Invalid user ID', 'wp-github-sync' ) );
94
		}
95
96
		update_option( '_wpghs_export_user_id', (int) $user_id );
97
98
		WP_CLI::line( __( 'Starting import from GitHub.', 'wp-github-sync' ) );
99
100
		$this->app->controller()->import_master();
101
	}
102
103
	/**
104
	 * Fetches the provided sha or the repository's
105
	 * master branch and caches it.
106
	 *
107
	 * ## OPTIONS
108
	 *
109
	 * <user_id>
110
	 * : The user ID you'd like to save the commit as
111
	 *
112
	 * ## EXAMPLES
113
	 *
114
	 *     wp wpghs prime --branch=master
115
	 *     wp wpghs prime --sha=<commit_sha>
116
	 *
117
	 * @synopsis [--sha=<commit_sha>] [--branch]
118
	 *
119
	 * @param array $args Command arguments.
120
	 * @param array $assoc_args Command associated arguments.
121
	 */
122
	public function prime( $args, $assoc_args ) {
123
		if ( isset( $assoc_args['branch'] ) ) {
124
			WP_CLI::line( __( 'Starting branch import.', 'wp-github-sync' ) );
125
126
			$commit = $this->app->api()->fetch()->master();
127
128
			if ( is_wp_error( $commit ) ) {
129
				WP_CLI::error(
130
					sprintf(
131
						__( 'Failed to import and cache branch with error: %s', 'wp-github-sync' ),
132
						$commit->get_error_message()
133
					)
134
				);
135
			} else {
136
				WP_CLI::success(
137
					sprintf(
138
						__( 'Successfully imported and cached commit %s from branch.', 'wp-github-sync' ),
139
						$commit->sha()
0 ignored issues
show
The method sha does only exist in WordPress_GitHub_Sync_Co...dPress_GitHub_Sync_Tree, but not in stdClass.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
140
					)
141
				);
142
			}
143
		} else if ( isset( $assoc_args['sha'] ) ) {
144
			WP_CLI::line( 'Starting sha import.' );
145
146
			$commit = $this->app->api()->fetch()->commit( $assoc_args['sha'] );
147
148
			WP_CLI::success(
149
				sprintf(
150
					__( 'Successfully imported and cached commit %s.', 'wp-github-sync' ),
151
					$commit->sha()
152
				)
153
			);
154
		} else {
155
			WP_CLI::error( 'Invalid fetch.' );
156
		}
157
	}
158
}
159