public function assessTarget(TargetInterface $target, array $policies, \DateTime $start = NULL, \DateTime $end = NULL, $remediate = FALSE)
  {
    $start = $start ?: new \DateTime('-1 day');
    $end   = $end ?: new \DateTime();

    $policies = array_filter($policies, function ($policy) {
      return $policy instanceof Policy;
    });

    $log = Container::getLogger();
    $is_progress_bar = $log instanceof ProgressBar;

    foreach ($policies as $policy) {
      if ($is_progress_bar) {
        $log->setTopic($this->uri . '][' . $policy->get('title'));
      }

      $log->info("Assessing policy...");

      // Setup the sandbox to run the assessment.
      $sandbox = new Sandbox($target, $policy, $this);
      $sandbox->setReportingPeriod($start, $end);

      $response = $sandbox->run();

      // Attempt remediation.
      if ($remediate && !$response->isSuccessful()) {
        $log->info("\xE2\x9A\xA0 Remediating " . $policy->get('title'));
        $response = $sandbox->remediate();
      }

      if ($is_progress_bar) {
        $log->advance();
      }
    }

    return $this;
  }
public function assessTarget(TargetInterface $target, array $policies, \DateTime $start = NULL, \DateTime $end = NULL, $remediate = FALSE)
  {
    $start = $start ?: new \DateTime('-1 day');
    $end   = $end ?: new \DateTime();

    $policies = array_filter($policies, function ($policy) {
      return $policy instanceof Policy;
    });

    $log = Container::getLogger();
    $is_progress_bar = $log instanceof ProgressBar;

    foreach ($policies as $policy) {
      if ($is_progress_bar) {
        $log->setTopic($this->uri . '][' . $policy->get('title'));
      }

      $log->info("Assessing policy...");

      // Setup the sandbox to run the assessment.
      $sandbox = new Sandbox($target, $policy, $this);
      $sandbox->setReportingPeriod($start, $end);

      $response = $sandbox->run();

      // Attempt remediation.
      if ($remediate && !$response->isSuccessful()) {
        $log->info("\xE2\x9A\xA0 Remediating " . $policy->get('title'));
        $response = $sandbox->remediate();
      }

      if ($is_progress_bar) {
        $log->advance();
      }
    }

    return $this;
  }
public function assessTarget ( TargetInterface $ target , array $ policies , \ DateTime $ start = NULL , \ DateTime $ end = NULL , $ remediate = FALSE ) { $ start = $ start ? : new \ DateTime ( '-1 day' ) ; $ end = $ end ? : new \ DateTime ( ) ; $ policies = array_filter ( $ policies , function ( $ policy ) { return $ policy instanceof Policy ; } ) ; $ log = Container :: getLogger ( ) ; $ is_progress_bar = $ log instanceof ProgressBar ; foreach ( $ policies as $ policy ) { if ( $ is_progress_bar ) { $ log -> setTopic ( $ this -> uri . '][' . $ policy -> get ( 'title' ) ) ; } $ log -> info ( "Assessing policy..." ) ; // Setup the sandbox to run the assessment. $ sandbox = new Sandbox ( $ target , $ policy , $ this ) ; $ sandbox -> setReportingPeriod ( $ start , $ end ) ; $ response = $ sandbox -> run ( ) ; // Attempt remediation. if ( $ remediate && ! $ response -> isSuccessful ( ) ) { $ log -> info ( "\xE2\x9A\xA0 Remediating " . $ policy -> get ( 'title' ) ) ; $ response = $ sandbox -> remediate ( ) ; } if ( $ is_progress_bar ) { $ log -> advance ( ) ; } } return $ this ; }
Assess a Target.

@param TargetInterface $target
@param array $policies each item should be a Drutiny\Policy object.
@param DateTime $start The start date of the reporting period. Defaults to -1 day.
@param DateTime $end The end date of the reporting period. Defaults to now.
@param bool $remediate If an Drutiny\Audit supports remediation and the policy failes, remediate the policy. Defaults to FALSE.
Assess a Target .