function security_review_store_results in Security Review 6
Same name and namespace in other branches
- 7 security_review.module \security_review_store_results()
Store checklist results.
3 calls to security_review_store_results()
- security_review_drush in ./
security_review.drush.inc - Run checklist and display results command.
- security_review_run_store in ./
security_review.module - Run the security review checklist and store the results.
- _security_review_batch_finished in ./
security_review.module - Finished callback for Batch processing the checklist.
File
- ./
security_review.module, line 321 - Site security review and reporting Drupal module.
Code
function security_review_store_results($results) {
$log = variable_get('security_review_log', TRUE);
// Store all results in the table.
$saved = $to_save = 0;
foreach ($results as $module => $checks) {
foreach ($checks as $check_name => $check) {
// Clear previous entry.
db_query("DELETE FROM {security_review} WHERE namespace = '%s' AND reviewcheck = '%s'", $module, $check_name);
if (db_affected_rows() && is_null($check['result']) && $log) {
// Last check was deleted and current check returns null so check is
// now no longer applicable.
$message = '!name no longer applicable for checking';
_security_review_log($module, $check_name, $message, array(
'!name' => $check['title'],
), WATCHDOG_INFO);
}
elseif (!is_null($check['result'])) {
$to_save++;
$record = array(
'namespace' => $module,
'reviewcheck' => $check_name,
'result' => $check['result'],
'lastrun' => $check['lastrun'] ? $check['lastrun'] : time(),
);
if (drupal_write_record('security_review', $record) == SAVED_NEW) {
$saved++;
}
elseif ($log) {
_security_review_log($module, $check_name, 'Unable to store check !reviewcheck for !namespace', array(
'!reviewcheck' => $check_name,
'!namespace' => $module,
), WATCHDOG_ERROR);
}
}
}
}
return $to_save == $saved ? TRUE : FALSE;
}