Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
113 lines (98 sloc) 3.4 KB
<?php
/**
* @file
* Wayfair Vulnerability Scanner module
*/
require_once('helpers.inc');
/**
* Implements hook_permission().
*/
function vulnscan_permission() {
$groups = get_all_server_groups_assoc();
$perms = array(
'administer vulnscan' => array(
'title' => t('Administer Wayfair Vulnerability Scanner'),
),
'scan all servers' => array(
'title' => t('Scan all servers'),
'description' => t('Scan all servers'),
),
'run scan' => array(
'title' => t('Run scan'),
'description' => t('Run a new scan'),
),
'view own scans' => array(
'title' => t('View own scans'),
),
'view others scans' => array(
'title' => t('View other\'s scans'),
),
);
/* The "run scan" permission is for the "Run Scan" link to show. The permission below is for actually running the scan. */
foreach ($groups as $key => $value) {
$perms['scan ' . $value] = array(
'title' => t('Run scan for Server Group @group', array('@group' => $value)),
);
}
return $perms;
}
/**
* Implements hook_menu().
*/
function vulnscan_menu() {
/* Admin settings */
$items['admin/config/vulnscan'] = array(
'title' => 'Wayfair Vulnerability Scanner',
'description' => 'Wayfair Vulnerability Scanner options.',
'position' => 'right',
'weight' => -5,
'page callback' => 'system_admin_menu_block_page',
'access arguments' => array('administer vulnscan'),
'file' => 'system.admin.inc',
'file path' => drupal_get_path('module', 'system'),
);
$items['admin/config/vulnscan/settings'] = array(
'title' => 'Wayfair Vulnerability Scanner settings.',
'description' => 'Change Wayfair Vulnerability Scanner settings.',
'page callback' => 'drupal_get_form',
'page arguments' => array('vulnscan_admin_settings'),
'access arguments' => array('administer vulnscan'),
'type' => MENU_NORMAL_ITEM,
'file' => 'vulnscan.admin.inc',
);
$items['admin/config/vulnscan/servergroups'] = array(
'title' => 'Server Group settings.',
'description' => 'Add/Modify/Delete Server Groups',
'page callback' => 'drupal_get_form',
'page arguments' => array('vulnscan_admin_settings_servergroup'),
'access arguments' => array('administer vulnscan'),
'type' => MENU_NORMAL_ITEM,
'file' => 'vulnscan.admin.inc',
);
/* Actions */
$items['vulnscan/scan'] = array(
'title' => 'Run Scan',
'page callback' => 'drupal_get_form',
'page arguments' => array('vulnscan_scan_form'),
'file' => 'scan.inc',
'access callback' => 'user_access',
'access arguments' => array('run scan'),
'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_view_perms',
'access arguments' => array(array('view own scans', 'view others scans')),
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
function user_view_perms($perms=array()) {
foreach ($perms as $perm)
if (user_access($perm))
return TRUE;
return FALSE;
}