Révision bb746689
Ajouté par Assos Assos il y a plus de 9 ans
drupal7/sites/all/modules/security_review/security_review.drush.inc | ||
---|---|---|
6 | 6 |
*/ |
7 | 7 |
|
8 | 8 |
// Include security_review.inc file for when invoked from outside the site. |
9 |
require_once __DIR__ . '/security_review.inc';
|
|
9 |
include_once dirname(__FILE__) . '/security_review.inc';
|
|
10 | 10 |
|
11 | 11 |
/** |
12 | 12 |
* Implementation of hook_drush_command(). |
... | ... | |
23 | 23 |
'log' => 'Log results of each check to watchdog, defaults to off', |
24 | 24 |
'lastrun' => 'Do not run the checklist, just print last results', |
25 | 25 |
'check' => 'Comma-separated list of specified checks to run. See README.txt for list of options', |
26 |
'skip' => 'Invert behavior of --check. Run all checks except specified checks', |
|
26 | 27 |
'short' => "Short result messages instead of full description (e.g. 'Text formats').", |
27 | 28 |
'results' => 'Show the incorrect settings for failed checks.', |
28 | 29 |
), |
... | ... | |
57 | 58 |
* Run checklist and display results command. |
58 | 59 |
*/ |
59 | 60 |
function security_review_drush() { |
61 |
if (!function_exists('security_review_get_checklist')) { |
|
62 |
return drush_set_error('REQUIREMENTS_ERROR', 'File security_review.inc is required to run the checklist.'); |
|
63 |
} |
|
60 | 64 |
// Retrieve the checklist. |
61 | 65 |
$checklist = security_review_get_checklist(); |
62 | 66 |
|
... | ... | |
69 | 73 |
$store = $log = $lastrun = FALSE; |
70 | 74 |
} |
71 | 75 |
$specific_checks = drush_get_option_list('check'); |
76 |
$skip = drush_get_option('skip'); |
|
72 | 77 |
$short_titles = drush_get_option('short'); |
73 | 78 |
if (!empty($short_titles)) { |
74 | 79 |
$short_titles = TRUE; |
... | ... | |
87 | 92 |
|
88 | 93 |
if (!$lastrun) { |
89 | 94 |
if (!empty($specific_checks)) { |
90 |
// Run specified checks only.
|
|
91 |
$new_checklist = array();
|
|
95 |
// Get specified checks.
|
|
96 |
$specific_checklist = array();
|
|
92 | 97 |
foreach ($specific_checks as $check_name) { |
93 | 98 |
if (empty($check_name)) { |
94 | 99 |
continue; // Can happen if user puts space after comma. |
... | ... | |
100 | 105 |
$module = 'security_review'; |
101 | 106 |
} |
102 | 107 |
if (isset($checklist[$module][$check_name])) { |
103 |
$new_checklist[$module][$check_name] = $checklist[$module][$check_name]; |
|
108 |
$specific_checklist[$module][$check_name] = $checklist[$module][$check_name]; |
|
109 |
} |
|
110 |
} |
|
111 |
if ($skip) { |
|
112 |
// Run all checks except specified checks. |
|
113 |
foreach ($specific_checklist as $module => $checks) { |
|
114 |
foreach (array_keys($checks) as $check_name) { |
|
115 |
unset($checklist[$module][$check_name]); |
|
116 |
} |
|
104 | 117 |
} |
105 | 118 |
} |
106 |
$checklist = $new_checklist; |
|
119 |
else { |
|
120 |
// Run only specified checks. |
|
121 |
$checklist = $specific_checklist; |
|
122 |
} |
|
107 | 123 |
} |
108 | 124 |
else { |
109 | 125 |
// Unset file_perms of security_review because drush is running as a |
... | ... | |
141 | 157 |
} |
142 | 158 |
elseif ($lastrun) { |
143 | 159 |
// Retrieve results from last run of the checklist. |
144 |
$results = db_query("SELECT namespace, reviewcheck, result, lastrun, skip, skiptime, skipuid FROM {security_review}"); |
|
145 |
while($record = $results->fetchAssoc()) { |
|
146 |
$checks[] = $record; |
|
147 |
} |
|
160 |
$results = security_review_get_stored_results(); |
|
148 | 161 |
// Print results. |
149 |
if (!empty($checks)) { |
|
150 |
foreach ($checks as $check) { |
|
151 |
_security_review_drush_print_result($checklist[$check['namespace']][$check['reviewcheck']], $short_titles, $show_results); |
|
162 |
if (!empty($results)) { |
|
163 |
foreach ($results as $result) { |
|
164 |
if (isset($checklist[$result['namespace']][$result['reviewcheck']])) { |
|
165 |
$check = array_merge($result, $checklist[$result['namespace']][$result['reviewcheck']]); |
|
166 |
_security_review_drush_print_result($check, $short_titles, $show_results); |
|
167 |
} |
|
152 | 168 |
} |
153 | 169 |
} |
154 | 170 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules