diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..e1cc194 --- /dev/null +++ b/.editorconfig @@ -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 diff --git a/php/commands/launchcheck.php b/php/commands/launchcheck.php index 9ab8c7f..8fd2422 100644 --- a/php/commands/launchcheck.php +++ b/php/commands/launchcheck.php @@ -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=] - * : 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=] - * : 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=] + * : 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=] + * : 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=] - * : 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=] + * : 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=] - * : 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=] + * : 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=] - * : a regular expression matching directories to skip - * - * [--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=] + * : a regular expression matching directories to skip + * + * [--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=] - * : 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=] + * : 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=] - * : 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=] + * : 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' );