Exemple #1
0
 public function message(Messenger $messenger)
 {
     if (!empty($this->alerts)) {
         $details = sprintf("Found %s files that reference risky function. \n\t-> %s", count($this->alerts), View::make('table', array('headers' => array('File', 'Line', 'Match'), 'rows' => $this->alerts)));
         $this->score = 1;
         $this->result .= $details;
         $this->action = "You do not need to deactivate these files, but please scrutinize them in the event of a security issue.";
     }
     $messenger->addMessage(get_object_vars($this));
     return $this;
 }
Exemple #2
0
 public function message(Messenger $messenger)
 {
     if (!empty($this->alerts)) {
         $details = sprintf("Found %s files that contain likely exploits \n\t-> %s", count($this->alerts), View::make('table', array('headers' => array('File', 'Line', 'Match'), 'rows' => $this->alerts)));
         $this->score = 2;
         $this->result .= $details;
         $this->action = "You should deactivate this plugin unless you can verify this is the intended use.";
     } else {
         $this->result .= "No exploits found.";
     }
     $messenger->addMessage(get_object_vars($this));
 }
 public function message(Messenger $messenger)
 {
     if (!empty($this->alerts)) {
         $checks = array(array('message' => sprintf("Found %s files that reference sessions. %s ", count($this->alerts), $this->action), 'class' => 'fail'));
         $this->result .= View::make('checklist', array('rows' => $checks));
         $this->result .= View::make('table', array('headers' => array('File', 'Line', 'Match'), 'rows' => $this->alerts));
         $this->score = 2;
     } else {
         if ($this->has_plugin) {
             $this->result .= 'You are running wp-native-php-sessions plugin.';
         } else {
             $this->result .= 'No files referencing sessions found.';
         }
     }
     $messenger->addMessage(get_object_vars($this));
 }
Exemple #4
0
 public function message(Messenger $messenger)
 {
     if (!empty($this->alerts)) {
         $total = 0;
         $rows = array();
         foreach ($this->alerts as $alert) {
             $total += $alert['code'];
             $label = 'info';
             if (1 === $alert['code']) {
                 $label = 'warning';
             } elseif (2 >= $alert['code']) {
                 $label = 'error';
             }
             $rows[] = array('message' => $alert['message'], 'class' => $label);
         }
         $avg = $total / count($this->alerts);
         $this->result = sprintf("%s\n%s", $this->description, View::make('checklist', array('rows' => $rows)));
         // format the cron table
         $rows = array();
         if ($this->cron_rows) {
             $headers = array('jobname' => 'Job', 'schedule' => 'Frequency', 'next' => 'Next Run');
             $this->result .= sprintf("<hr/>%s", View::make('table', array('rows' => $this->cron_rows, 'headers' => $headers)));
             $this->score = $avg;
         }
     }
     $messenger->addMessage(get_object_vars($this));
 }
 public function execute()
 {
     foreach ($this->callbacks as $class => $object) {
         $object->init();
     }
     foreach ($this->callbacks as $class => $object) {
         $object->run($file);
     }
     foreach ($this->callbacks as $class => $object) {
         $object->message(Messenger::instance());
     }
 }
 public function message(Messenger $messenger)
 {
     if (!empty($this->alerts)) {
         $total = 0;
         $rows = array();
         foreach ($this->alerts as $alert) {
             $total += $alert['code'];
             $label = 'info';
             if (1 === $alert['code']) {
                 $label = 'warning';
             } elseif (2 >= $alert['code']) {
                 $label = 'error';
             }
             $rows[] = array('message' => $alert['message'], 'class' => $label);
         }
         $avg = $total / count($this->alerts);
         $this->result = sprintf("%s\n%s", $this->description, View::make('checklist', array('rows' => $rows)));
         // format the cron table
         $rows = array();
         $headers = array('jobname' => 'Job', 'schedule' => 'Frequency', 'next' => 'Next Run');
         // @TODO move this logic to the run() function or checkCron() function
         if ($this->cron) {
             foreach ($this->cron as $timestamp => $crons) {
                 foreach ($crons as $job => $data) {
                     $class = 'ok';
                     $data = array_shift($data);
                     if ($timestamp < time()) {
                         $class = "error";
                         $this->action = "<div class='warning'>Some cronjobs are outdated.</div>";
                     }
                     $rows[] = array('class' => $class, 'data' => array('jobname' => $job, 'schedule' => $data['schedule'], 'next' => date('M j,Y @ H:i:s', $timestamp)));
                 }
             }
         }
         $this->result .= sprintf("<hr/>%s", View::make('table', array('rows' => $rows, 'headers' => $headers)));
         $this->score = $avg;
     }
     $messenger->addMessage(get_object_vars($this));
 }
 function testFileSearch()
 {
     // replace this with some actual testing code
     $searcher = new Filesearcher(dirname(__FILE__) . "/data");
     $searcher->register(new \Pantheon\Checks\Exploited());
     $searcher->register(new \Pantheon\Checks\Insecure());
     $searcher->register(new \Pantheon\Checks\Sessions());
     $searcher->execute();
     foreach ($searcher->callbacks() as $check) {
         $this->assertNotEquals(0, $check->score);
     }
     Messenger::emit();
 }
 public function message(Messenger $messenger)
 {
     if (!empty($this->alerts)) {
         $total = 0;
         $rows = array();
         // this is dumb and left over from the previous iterationg. @TODO move scoring to run() method
         foreach ($this->alerts as $alert) {
             $total += $alert['code'];
             $alert['class'] = 'ok';
             if (-1 === $alert['code']) {
                 $alert['class'] = 'fail';
             } elseif (2 > $alert['code']) {
                 $alert['class'] = 'warning';
             }
             $rows[] = $alert;
         }
         $avg = $total / count($this->alerts);
         $this->result = View::make('checklist', array('rows' => $rows));
         $this->score = $avg;
         $this->action = "You should use object caching";
     }
     $messenger->addMessage(get_object_vars($this));
 }
 public function execute()
 {
     foreach ($this->callbacks() as $class => $object) {
         $object->init();
     }
     $files = $this->finder->files()->in($this->dir)->name("*.php");
     foreach ($files as $file) {
         if (\WP_CLI::get_config('debug')) {
             \WP_CLI::line(sprintf("-> %s", $file->getRelativePathname()));
         }
         foreach ($this->callbacks() as $class => $object) {
             $object->run($file);
         }
     }
     foreach ($this->callbacks() as $class => $object) {
         $object->message(Messenger::instance());
     }
 }
Exemple #10
0
 public function message(Messenger $messenger)
 {
     if (!empty($this->alerts)) {
         $headers = array('slug' => "Plugin", 'installed' => "Current", 'available' => "Available", 'needs_update' => "Needs Update", 'vulnerable' => "Vulnerabilities");
         $rows = array();
         $count_update = 0;
         $count_vuln = 0;
         foreach ($this->alerts as $alert) {
             $class = 'ok';
             if ($alert['needs_update']) {
                 $class = 'warning';
                 $count_update++;
             }
             if ('None' != $alert['vulnerable']) {
                 $class = 'error';
                 $count_vuln++;
             }
             $rows[] = array('class' => $class, 'data' => $alert);
         }
         $rendered = PHP_EOL;
         $rendered .= sprintf("Found %d plugins needing updates and %d known vulnerabilities ... \n" . PHP_EOL, $count_update, $count_vuln);
         $rendered .= View::make('table', array('headers' => $headers, 'rows' => $rows));
         $this->result .= $rendered;
         if ($count_update > 0) {
             $this->score = 1;
             $this->action = "You should update all out-of-date plugins";
         }
         if ($count_vuln > 0) {
             $this->score = 2;
             $this->action = "Update plugins to fix vulnerabilities";
         }
     } else {
         $this->result .= "No plugins found.";
     }
     $messenger->addMessage(get_object_vars($this));
 }
Exemple #11
0
 public function message(Messenger $messenger)
 {
     if (!empty($this->alerts)) {
         $total = 0;
         $rows = array();
         // this is dumb and left over from the previous iterationg. @TODO move scoring to run() method
         foreach ($this->alerts as $alert) {
             $total += $alert['code'];
             $rows[] = $alert;
         }
         $avg = $total / count($this->alerts);
         $this->result = View::make('checklist', array('rows' => $rows));
         $this->score = round($avg);
     }
     $messenger->addMessage(get_object_vars($this));
 }
 /**
  * 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);
 }