Skip to content

Commit

Permalink
Use tabs, not spaces, for indentation in the launch check command
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbachhuber committed Nov 17, 2015
1 parent 47a13da commit 647273c
Show file tree
Hide file tree
Showing 2 changed files with 196 additions and 175 deletions.
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

# WordPress Coding Standards
# https://make.wordpress.org/core/handbook/coding-standards/

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab

[{.jshintrc,*.json,*.yml}]
indent_style = space
indent_size = 2

[{*.txt,wp-config-sample.php}]
end_of_line = crlf
350 changes: 175 additions & 175 deletions php/commands/launchcheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,192 +4,192 @@
* @version 0.1.4
*/
class LaunchCheck extends WP_CLI_Command {
public $fs;
public $skipfiles = array();
public $output = array();
public $fs;
public $skipfiles = array();
public $output = array();

/**
* run all checks
*
* ## OPTIONS
*
*/
public function all($args, $assoc_args) {
$searcher = new \Pantheon\Filesearcher(getcwd().'/wp-content');
$searcher->register( new \Pantheon\Checks\Sessions() );
$searcher->register( new \Pantheon\Checks\Insecure() );
$searcher->register( new \Pantheon\Checks\Exploited() );
$searcher->execute();
$checker = new \Pantheon\Checker();
$checker->register( new \Pantheon\Checks\Plugins(isset($assoc_args['all'])) );
$checker->register( new \Pantheon\Checks\Cron() );
$checker->register( new \Pantheon\Checks\Objectcache() );
$checker->register( new \Pantheon\Checks\Database() );
$checker->execute();
$format = isset($assoc_args['format']) ? $assoc_args['format'] : 'raw';
\Pantheon\Messenger::emit($format);
}
/**
* run all checks
*
* ## OPTIONS
*
*/
public function all($args, $assoc_args) {
$searcher = new \Pantheon\Filesearcher(getcwd().'/wp-content');
$searcher->register( new \Pantheon\Checks\Sessions() );
$searcher->register( new \Pantheon\Checks\Insecure() );
$searcher->register( new \Pantheon\Checks\Exploited() );
$searcher->execute();
$checker = new \Pantheon\Checker();
$checker->register( new \Pantheon\Checks\Plugins(isset($assoc_args['all'])) );
$checker->register( new \Pantheon\Checks\Cron() );
$checker->register( new \Pantheon\Checks\Objectcache() );
$checker->register( new \Pantheon\Checks\Database() );
$checker->execute();
$format = isset($assoc_args['format']) ? $assoc_args['format'] : 'raw';
\Pantheon\Messenger::emit($format);
}

/**
* Checks the cron
*
* ## OPTIONS
*
* [--format=<json>]
* : use to output json
*
*/
function cron($args, $assoc_args) {
$checker = new \Pantheon\Checker();
$checker->register( new \Pantheon\Checks\Cron() );
$checker->execute();
$format = isset($assoc_args['format']) ? $assoc_args['format'] : 'raw';
\Pantheon\Messenger::emit($format);
}
/**
* Check database for potential issues
*
* ## OPTIONS
*
* [--format=<json>]
* : use to output json
*
*/
function database($args, $assoc_args) {
$checker = new \Pantheon\Checker();
$checker->register( new \Pantheon\Checks\Database() );
$checker->execute();
$format = isset($assoc_args['format']) ? $assoc_args['format'] : 'raw';
\Pantheon\Messenger::emit($format);
}
/**
* Checks the cron
*
* ## OPTIONS
*
* [--format=<json>]
* : use to output json
*
*/
function cron($args, $assoc_args) {
$checker = new \Pantheon\Checker();
$checker->register( new \Pantheon\Checks\Cron() );
$checker->execute();
$format = isset($assoc_args['format']) ? $assoc_args['format'] : 'raw';
\Pantheon\Messenger::emit($format);
}
/**
* Check database for potential issues
*
* ## OPTIONS
*
* [--format=<json>]
* : use to output json
*
*/
function database($args, $assoc_args) {
$checker = new \Pantheon\Checker();
$checker->register( new \Pantheon\Checks\Database() );
$checker->execute();
$format = isset($assoc_args['format']) ? $assoc_args['format'] : 'raw';
\Pantheon\Messenger::emit($format);
}

/**
* Checks for best practice
*
* ## OPTIONS
*
* [--format=<json>]
* : use to output json
*
*/
function general($args, $assoc_args) {
$checker = new \Pantheon\Checker();
$checker->register( new \Pantheon\Checks\General() );
$checker->execute();
$format = isset($assoc_args['format']) ? $assoc_args['format'] : 'raw';
\Pantheon\Messenger::emit($format);
}
/**
* Checks for best practice
*
* ## OPTIONS
*
* [--format=<json>]
* : use to output json
*
*/
function general($args, $assoc_args) {
$checker = new \Pantheon\Checker();
$checker->register( new \Pantheon\Checks\General() );
$checker->execute();
$format = isset($assoc_args['format']) ? $assoc_args['format'] : 'raw';
\Pantheon\Messenger::emit($format);
}

/**
* checks for object caching
*
* ## OPTIONS
*
* [--format=<format>]
* : output as json
*
* ## EXAMPLES
*
* wp launchcheck object-cache
*
* @alias object-cache
*/
public function object_cache($args, $assoc_args) {
$checker = new \Pantheon\Checker();
$checker->register( new \Pantheon\Checks\Objectcache() );
$format = isset($assoc_args['format']) ? $assoc_args['format'] : 'raw';
$checker->execute();
$format = isset($assoc_args['format']) ? $assoc_args['format'] : 'raw';
\Pantheon\Messenger::emit($format);
}
/**
* checks for object caching
*
* ## OPTIONS
*
* [--format=<format>]
* : output as json
*
* ## EXAMPLES
*
* wp launchcheck object-cache
*
* @alias object-cache
*/
public function object_cache($args, $assoc_args) {
$checker = new \Pantheon\Checker();
$checker->register( new \Pantheon\Checks\Objectcache() );
$format = isset($assoc_args['format']) ? $assoc_args['format'] : 'raw';
$checker->execute();
$format = isset($assoc_args['format']) ? $assoc_args['format'] : 'raw';
\Pantheon\Messenger::emit($format);
}

/**
* checks files for insecure code and checks the wpvulndb.com/api for known vulnerabilities
*
* ## OPTIONS
*
* [--skip=<regex>]
* : a regular expression matching directories to skip
*
* [--format=<format>]
* : output as json
*
* ## EXAMPLES
*
* wp secure --skip=wp-content/themes
*
*/
public function secure($args, $assoc_args) {
$searcher = new \Pantheon\Filesearcher(getcwd().'/wp-content');
$searcher->register( new \Pantheon\Checks\Insecure() );
$searcher->register( new \Pantheon\Checks\Exploited() );
$format = isset($assoc_args['format']) ? $assoc_args['format'] : 'raw';
$searcher->execute();
$format = isset($assoc_args['format']) ? $assoc_args['format'] : 'raw';
\Pantheon\Messenger::emit($format);
}
/**
* checks files for insecure code and checks the wpvulndb.com/api for known vulnerabilities
*
* ## OPTIONS
*
* [--skip=<regex>]
* : a regular expression matching directories to skip
*
* [--format=<format>]
* : output as json
*
* ## EXAMPLES
*
* wp secure --skip=wp-content/themes
*
*/
public function secure($args, $assoc_args) {
$searcher = new \Pantheon\Filesearcher(getcwd().'/wp-content');
$searcher->register( new \Pantheon\Checks\Insecure() );
$searcher->register( new \Pantheon\Checks\Exploited() );
$format = isset($assoc_args['format']) ? $assoc_args['format'] : 'raw';
$searcher->execute();
$format = isset($assoc_args['format']) ? $assoc_args['format'] : 'raw';
\Pantheon\Messenger::emit($format);
}

/**
* checks plugins for vulnerbities using the wpscan vulnerability DB
* - https://wpvulndb.com/api
*
* ## OPTIONS
*
* [--all]
* : check both active and inactive plugins ( default is active only )
*
* [--format=<format>]
* : output as json
*
* ## EXAMPLES
*
* wp launchcheck plugins --all
*
*/
public function plugins($args, $assoc_args) {
$checker = new \Pantheon\Checker();
$checker->register( new \Pantheon\Checks\Plugins( isset($assoc_args['all'])) );
$format = isset($assoc_args['format']) ? $assoc_args['format'] : 'raw';
$checker->execute();
$format = isset($assoc_args['format']) ? $assoc_args['format'] : 'raw';
\Pantheon\Messenger::emit($format);
}
/**
* checks plugins for vulnerbities using the wpscan vulnerability DB
* - https://wpvulndb.com/api
*
* ## OPTIONS
*
* [--all]
* : check both active and inactive plugins ( default is active only )
*
* [--format=<format>]
* : output as json
*
* ## EXAMPLES
*
* wp launchcheck plugins --all
*
*/
public function plugins($args, $assoc_args) {
$checker = new \Pantheon\Checker();
$checker->register( new \Pantheon\Checks\Plugins( isset($assoc_args['all'])) );
$format = isset($assoc_args['format']) ? $assoc_args['format'] : 'raw';
$checker->execute();
$format = isset($assoc_args['format']) ? $assoc_args['format'] : 'raw';
\Pantheon\Messenger::emit($format);
}

/**
* checks the files for session_start()
*
* ## OPTIONS
*
* [--format=<format>]
* : output as json
*
* ## EXAMPLES
*
* wp launchcheck sessions
*
*/
public function sessions( $args, $assoc_args ) {
$searcher = new \Pantheon\Filesearcher(getcwd().'/wp-content');
$searcher->register( new \Pantheon\Checks\Sessions() );
$format = isset($assoc_args['format']) ? $assoc_args['format'] : 'raw';
$searcher->execute();
$format = isset($assoc_args['format']) ? $assoc_args['format'] : 'raw';
\Pantheon\Messenger::emit($format);
}
/**
* checks the files for session_start()
*
* ## OPTIONS
*
* [--format=<format>]
* : output as json
*
* ## EXAMPLES
*
* wp launchcheck sessions
*
*/
public function sessions( $args, $assoc_args ) {
$searcher = new \Pantheon\Filesearcher(getcwd().'/wp-content');
$searcher->register( new \Pantheon\Checks\Sessions() );
$format = isset($assoc_args['format']) ? $assoc_args['format'] : 'raw';
$searcher->execute();
$format = isset($assoc_args['format']) ? $assoc_args['format'] : 'raw';
\Pantheon\Messenger::emit($format);
}
}

// register our autoloader
spl_autoload_register(function($class) {
if (class_exists($class)) return $class;
$class = strtolower($class);
if (strstr($class,"pantheon")) {
$class = str_replace('\\','/',$class);
$path = dirname( dirname( __FILE__ ) ) ."/".$class.'.php';
if (file_exists($path)) {
require_once($path);
}
}
if (class_exists($class)) return $class;
$class = strtolower($class);
if (strstr($class,"pantheon")) {
$class = str_replace('\\','/',$class);
$path = dirname( dirname( __FILE__ ) ) ."/".$class.'.php';
if (file_exists($path)) {
require_once($path);
}
}
});

WP_CLI::add_command( 'launchcheck', 'LaunchCheck' );

0 comments on commit 647273c

Please sign in to comment.