forked from initiativa/wazuh
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.php
More file actions
152 lines (130 loc) · 4.41 KB
/
Copy pathsetup.php
File metadata and controls
152 lines (130 loc) · 4.41 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?php
/**
* -------------------------------------------------------------------------
* Wazuh plugin for GLPI
* -------------------------------------------------------------------------
*
* LICENSE
*
* This file is part of Wazuh GLPI Plugin.
*
* Wazuh is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Wazuh is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Wazuh. If not, see <http://www.gnu.org/licenses/>.
* -------------------------------------------------------------------------
* @copyright Copyright (C) 2022 by initiativa s.r.l. - http://www.initiativa.it
* @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
* @link https://github.com/initiativa/Wazug
* -------------------------------------------------------------------------
*/
if (!defined('PLUGIN_WAZUH_DIR')) {
define('PLUGIN_WAZUH_DIR', __DIR__);
}
require_once (PLUGIN_WAZUH_DIR . "/src/PluginConfig.php");
use GlpiPlugin\Wazuh\PluginConfig;
use GlpiPlugin\Wazuh\PluginLogger;
use GlpiPlugin\Wazuh\ComputerTab;
use Glpi\Plugin\Hooks;
define('PLUGIN_WAZUH_VERSION', PluginConfig::loadVersionNumber());
// Minimal GLPI version, inclusive
define("PLUGIN_WAZUH_MIN_GLPI_VERSION", "11.0.4");
// Maximum GLPI version, exclusive
define("PLUGIN_WAZUH_MAX_GLPI_VERSION", "12.0.1");
/**
* Init hooks of the plugin.
* REQUIRED
*
* @return void
*/
function plugin_init_wazuh() {
global $PLUGIN_HOOKS;
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
if (Plugin::isPluginActive(PluginConfig::APP_CODE)) {
if (Session::haveRight('config', UPDATE)) {
$PLUGIN_HOOKS[Hooks::CONFIG_PAGE][PluginConfig::APP_CODE] = 'front/connection.php';
$PLUGIN_HOOKS['use_massive_action'][PluginConfig::APP_CODE] = true;
}
if (Session::getLoginUserID()) {
plugin_wazuh_registerClasses();
}
$PLUGIN_HOOKS['menu_toadd'][PluginConfig::APP_CODE] = [
'admin' => [\GlpiPlugin\Wazuh\WazuhAgent::class],
'config' => [\GlpiPlugin\Wazuh\Connection::class],
];
$PLUGIN_HOOKS[Hooks::ADD_CSS][PluginConfig::APP_CODE] = ['css/wazuh.css'];
$PLUGIN_HOOKS[Hooks::ADD_JAVASCRIPT][PluginConfig::APP_CODE] = ['js/wazuh.js'];
}
}
function plugin_wazuh_registerClasses() {
Plugin::registerClass(\GlpiPlugin\Wazuh\ComputerTab::class, [
'addtabon' => ['Computer']
]);
Plugin::registerClass(\GlpiPlugin\Wazuh\ComputerAlertsTab::class, [
'addtabon' => ['Computer']
]);
Plugin::registerClass(\GlpiPlugin\Wazuh\NetworkEqTab::class, [
'addtabon' => ['NetworkEquipment']
]);
Plugin::registerClass(\GlpiPlugin\Wazuh\NetworkEqAlertsTab::class, [
'addtabon' => ['NetworkEquipment']
]);
Plugin::registerClass(\GlpiPlugin\Wazuh\WazuhAgent::class);
Plugin::registerClass(\GlpiPlugin\Wazuh\Connection::class);
}
/**
* Get the name and the version of the plugin
* REQUIRED
*
* @return array
*/
function plugin_version_wazuh() {
return [
'name' => PluginConfig::APP_NAME,
'version' => PluginConfig::loadVersionNumber(),
'author' => '<a href="http://www.initiativa.it">Initiativa</a>',
'license' => 'GPL v3+',
'homepage' => 'https://github.com/initiativa/Wazuh',
'requirements' => [
'glpi' => [
'min' => PLUGIN_WAZUH_MIN_GLPI_VERSION,
'max' => PLUGIN_WAZUH_MAX_GLPI_VERSION,
]
]
];
}
/**
* Check pre-requisites before install
* OPTIONNAL, but recommanded
*
* @return boolean
*/
function plugin_wazuh_check_prerequisites() {
return true;
}
/**
* Check configuration process
*
* @param boolean $verbose Whether to display message on failure. Defaults to false
*
* @return boolean
*/
function plugin_wazuh_check_config($verbose = false) {
if (true) {
return true;
}
if ($verbose) {
echo __('Installed / not configured', PluginConfig::APP_CODE);
}
return false;
}