-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvulnscan.module
112 lines (98 loc) · 3.4 KB
/
vulnscan.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?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;
}