Permalink
Browse files

Refactor code. Add ability to scan individual servers.

  • Loading branch information...
1 parent 33489a8 commit 880b68e984cb0b222e3dcd9580259d862e3cd8ce @lattera lattera committed Jan 16, 2012
Showing with 26 additions and 14 deletions.
  1. +21 −12 sites/all/modules/wayfair/vulnscan/helpers.inc
  2. +5 −2 sites/all/modules/wayfair/vulnscan/scan.inc
@@ -202,22 +202,31 @@ function prep_scanner($scanner, $server, $site) {
return $ret;
}
-function run_scan_on_server_groups($site, $groups=array()) {
+function run_scan_on_server($site, $server) {
$scanners = scanners();
- foreach ($groups as $group) {
- foreach (get_all_servers_in_server_group_assoc($group) as $server) {
- foreach ($scanners as $scanner) {
- $prepped = prep_scanner($scanner, $server, $site);
- if ($prepped === False)
- return false;
-
- exec(t($prepped . ' > /dev/null 2>&1 &'));
- }
- }
+ foreach ($scanners as $scanner) {
+ $prepped = prep_scanner($scanner, $server, $site);
+ if ($prepped === FALSE)
+ return FALSE;
+
+ exec($prepped . ' > /dev/null 2>&1 &');
}
- return true;
+ return TRUE;
+}
+
+function run_scan_on_server_group($site, $group) {
+ foreach (get_all_servers_in_server_group_assoc($group) as $server)
+ if (run_scan_on_server($site, $server) == FALSE)
+ return FALSE;
+
+ return TRUE;
+}
+
+function run_scan_on_server_groups($site, $groups=array()) {
+ foreach ($groups as $group)
+ run_scan_on_server_group($site, $group);
}
/* Functions for sites to scan */
@@ -68,9 +68,10 @@ function vulnscan_scan_form_submit($form, &$form_state) {
drupal_set_message(t('Invalid group: @group', array('@group' => $group)), 'error');
continue;
}
- }
- run_scan_on_server_groups($site, array_filter($form_state['values']['groups']));
+ if (run_scan_on_server_group($site, $group) == false)
+ return;
+ }
}
if (isset($form_state['values']['servers'])) {
@@ -79,6 +80,8 @@ function vulnscan_scan_form_submit($form, &$form_state) {
drupal_set_message(t('Invalid server: @server', array('@server' => $server)), 'error');
continue;
}
+
+ run_scan_on_server($site, $server);
}
}
}

0 comments on commit 880b68e

Please sign in to comment.