Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add ability to view scans.

  • Loading branch information...
commit 40f509a59ad1b76f47a85d239d58171824979868 1 parent bdb6414
@lattera lattera authored
View
33 sites/all/modules/wayfair/vulnscan/helpers.inc
@@ -251,3 +251,36 @@ function get_all_sites_assoc() {
return $sites;
}
+
+/* Functions for retrieving scans */
+
+function list_scans($user) {
+ $scans = array();
+ $base = variable_get('vulnscan_scan_output_location', '');
+
+ if (strlen($base) == 0)
+ return $scans;
+
+ if (is_dir($base . '/' . $user->uid) == false)
+ return $scans;
+
+ $basedir = dir($base . '/' . $user->uid);
+ while (($server = $basedir->read()) !== FALSE) {
+ if ($server[0] == '.')
+ continue;
+
+ $scans[$server] = array();
+
+ $serverdir = dir($base . '/' . $user->uid . '/' . $server);
+ while (($scan = $serverdir->read()) !== FALSE) {
+ if ($scan[0] == '.')
+ continue;
+
+ $scans[$server][$scan] = $base . '/' . $user->uid . '/' . $server . '/' . $scan;
+ }
+ $serverdir->close();
+ }
+ $basedir->close();
+
+ return $scans;
+}
View
31 sites/all/modules/wayfair/vulnscan/view.inc
@@ -0,0 +1,31 @@
+<?php
+
+require_once('helpers.inc');
+
+function vulnscan_list_scans_form($form, &$form_state) {
+ global $user;
+ $scans = list_scans($user);
+
+ $markup = '<ul>';
+ foreach ($scans as $server => $server_scans) {
+ $markup .= '<li>' . t($server) . '';
+ $markup .= '<ul>';
+
+ foreach ($server_scans as $scan => $location) {
+ $markup .= '<li><a href="' . $location . '">"' . t($scan) . '</a></li>';
+ }
+
+ $markup .= '</ul></li>';
+ }
+
+ $markup .= '</li></ul>';
+
+ $form['vulnscan_scans'] = array(
+ '#type' => 'markup',
+ '#prefix' => '<div>',
+ '#markup' => $markup,
+ '#suffix' => '</div>',
+ );
+
+ return $form;
+}
View
10 sites/all/modules/wayfair/vulnscan/vulnscan.module
@@ -95,5 +95,15 @@ function vulnscan_menu() {
'type' => MENU_NORMAL_ITEM,
);
+ $items['vulnscan/list'] = array(
+ 'title' => 'List Scans',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('vulnscan_list_scans_form'),
+ 'file' => 'view.inc',
+ 'access callback' => 'user_access',
+ 'access arguments' => array('view own scans'),
+ 'type' => MENU_NORMAL_ITEM,
+ );
+
return $items;
}
Please sign in to comment.
Something went wrong with that request. Please try again.