mirror of
https://github.com/valitydev/wazuh-kibana-app.git
synced 2024-11-06 01:45:18 +00:00
Migrating to import/export paradigm (in progress 2)
This commit is contained in:
parent
9bcfd8f445
commit
c9fdd38baa
2
init.js
2
init.js
@ -9,6 +9,6 @@ export default (server, options) => {
|
||||
initialize(server, options);
|
||||
wazuhElastic(server, options);
|
||||
wazuhApiElastic(server, options);
|
||||
monitoring(server, options);
|
||||
monitoring(server, false);
|
||||
wazuhApi(server, options);
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Require CSS
|
||||
require('plugins/wazuh/less/loader');
|
||||
import 'plugins/wazuh/less/loader';
|
||||
|
||||
// Set up Wazuh app
|
||||
const app = require('ui/modules').get('app/wazuh', ['ngCookies', 'ngMaterial']);
|
||||
@ -13,78 +13,78 @@ app.config(['$httpProvider', function ($httpProvider) {
|
||||
}]);
|
||||
|
||||
// Font Awesome, Kibana UI framework and others
|
||||
require('plugins/wazuh/utils/fontawesome/css/font-awesome.min.css');
|
||||
require('plugins/wazuh/utils/when-scrolled/when-scrolled.js');
|
||||
require('../../../ui_framework/dist/ui_framework.css');
|
||||
import 'plugins/wazuh/utils/fontawesome/css/font-awesome.min.css';
|
||||
import 'plugins/wazuh/utils/when-scrolled/when-scrolled.js';
|
||||
import '../../../ui_framework/dist/ui_framework.css';
|
||||
|
||||
// Material
|
||||
require('plugins/wazuh/../node_modules/angular-material/angular-material.css');
|
||||
require('plugins/wazuh/../node_modules/angular-aria/angular-aria.js');
|
||||
require('plugins/wazuh/../node_modules/angular-animate/angular-animate.js');
|
||||
require('plugins/wazuh/../node_modules/angular-material/angular-material.js');
|
||||
import 'plugins/wazuh/../node_modules/angular-material/angular-material.css';
|
||||
import 'plugins/wazuh/../node_modules/angular-aria/angular-aria.js';
|
||||
import 'plugins/wazuh/../node_modules/angular-animate/angular-animate.js';
|
||||
import 'plugins/wazuh/../node_modules/angular-material/angular-material.js';
|
||||
|
||||
// Cookies
|
||||
require('plugins/wazuh/../node_modules/angular-cookies/angular-cookies.min.js');
|
||||
import 'plugins/wazuh/../node_modules/angular-cookies/angular-cookies.min.js';
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Require Kibana integrations
|
||||
require('ui/autoload/all');
|
||||
require('ui/chrome');
|
||||
require('plugins/wazuh/kibana-integrations/kibana-visualization.js');
|
||||
require('plugins/wazuh/kibana-integrations/kibana-filter-bar.js');
|
||||
require('plugins/wazuh/kibana-integrations/kibana-discover.js');
|
||||
require('plugins/wazuh/kibana-integrations/saved-visualizations.js');
|
||||
import 'ui/autoload/all';
|
||||
import 'ui/chrome';
|
||||
import 'plugins/wazuh/kibana-integrations/kibana-visualization.js';
|
||||
import 'plugins/wazuh/kibana-integrations/kibana-filter-bar.js';
|
||||
import 'plugins/wazuh/kibana-integrations/kibana-discover.js';
|
||||
import 'plugins/wazuh/kibana-integrations/saved-visualizations.js';
|
||||
|
||||
// Require services
|
||||
require('plugins/wazuh/services/error-handler.js');
|
||||
require('plugins/wazuh/services/theming.js');
|
||||
require('plugins/wazuh/services/api-request.js');
|
||||
require('plugins/wazuh/services/generic-request.js');
|
||||
require('plugins/wazuh/services/data-handler.js');
|
||||
require('plugins/wazuh/services/app-state.js');
|
||||
require('plugins/wazuh/services/api-tester.js');
|
||||
require('plugins/wazuh/services/pattern-handler.js');
|
||||
import 'plugins/wazuh/services/error-handler.js';
|
||||
import 'plugins/wazuh/services/theming.js';
|
||||
import 'plugins/wazuh/services/api-request.js';
|
||||
import 'plugins/wazuh/services/generic-request.js';
|
||||
import 'plugins/wazuh/services/data-handler.js';
|
||||
import 'plugins/wazuh/services/app-state.js';
|
||||
import 'plugins/wazuh/services/api-tester.js';
|
||||
import 'plugins/wazuh/services/pattern-handler.js';
|
||||
|
||||
// Set up routes and views
|
||||
require('plugins/wazuh/services/routes.js');
|
||||
import 'plugins/wazuh/services/routes.js';
|
||||
|
||||
// Require controllers
|
||||
|
||||
// Factories
|
||||
require('plugins/wazuh/factories/data-handler-composer.js');
|
||||
import 'plugins/wazuh/factories/data-handler-composer.js';
|
||||
|
||||
// Wazuh Directives
|
||||
require('plugins/wazuh/directives/wz-dynamic/wz-dynamic.js');
|
||||
require('plugins/wazuh/directives/wz-enter/wz-enter.js');
|
||||
require('plugins/wazuh/directives/wz-menu/wz-menu.js');
|
||||
require('plugins/wazuh/directives/wz-menu/wz-menu.less');
|
||||
require('plugins/wazuh/directives/wz-search-bar/wz-search-bar.js');
|
||||
require('plugins/wazuh/directives/wz-table-header/wz-table-header.js');
|
||||
require('plugins/wazuh/directives/wz-table-header/wz-table-header.less');
|
||||
require('plugins/wazuh/directives/wz-table/wz-table.js');
|
||||
require('plugins/wazuh/directives/wz-table/wz-table.less');
|
||||
import 'plugins/wazuh/directives/wz-dynamic/wz-dynamic.js';
|
||||
import 'plugins/wazuh/directives/wz-enter/wz-enter.js';
|
||||
import 'plugins/wazuh/directives/wz-menu/wz-menu.js';
|
||||
import 'plugins/wazuh/directives/wz-menu/wz-menu.less';
|
||||
import 'plugins/wazuh/directives/wz-search-bar/wz-search-bar.js';
|
||||
import 'plugins/wazuh/directives/wz-table-header/wz-table-header.js';
|
||||
import 'plugins/wazuh/directives/wz-table-header/wz-table-header.less';
|
||||
import 'plugins/wazuh/directives/wz-table/wz-table.js';
|
||||
import 'plugins/wazuh/directives/wz-table/wz-table.less';
|
||||
|
||||
// Blank Screen
|
||||
require('plugins/wazuh/controllers/blank-screen-controller.js');
|
||||
import 'plugins/wazuh/controllers/blank-screen-controller.js';
|
||||
|
||||
// Login
|
||||
require('plugins/wazuh/controllers/login.js');
|
||||
import 'plugins/wazuh/controllers/login.js';
|
||||
|
||||
// Overview
|
||||
require('plugins/wazuh/controllers/overview.js');
|
||||
import 'plugins/wazuh/controllers/overview.js';
|
||||
|
||||
// Manager
|
||||
require('plugins/wazuh/controllers/manager.js');
|
||||
require('plugins/wazuh/controllers/ruleset.js');
|
||||
require('plugins/wazuh/controllers/osseclog.js');
|
||||
require('plugins/wazuh/controllers/groups.js');
|
||||
import 'plugins/wazuh/controllers/manager.js';
|
||||
import 'plugins/wazuh/controllers/ruleset.js';
|
||||
import 'plugins/wazuh/controllers/osseclog.js';
|
||||
import 'plugins/wazuh/controllers/groups.js';
|
||||
|
||||
// Agents
|
||||
require('plugins/wazuh/controllers/agents.js');
|
||||
require('plugins/wazuh/controllers/agents-preview.js');
|
||||
import 'plugins/wazuh/controllers/agents.js';
|
||||
import 'plugins/wazuh/controllers/agents-preview.js';
|
||||
|
||||
// Settings
|
||||
require('plugins/wazuh/controllers/settings.js');
|
||||
import 'plugins/wazuh/controllers/settings.js';
|
||||
|
||||
// Health check
|
||||
require('plugins/wazuh/controllers/health-check.js');
|
||||
import 'plugins/wazuh/controllers/health-check.js';
|
||||
|
@ -1,4 +1,6 @@
|
||||
let app = require('ui/modules').get('app/wazuh', []);
|
||||
import * as modules from 'ui/modules'
|
||||
|
||||
const app = modules.get('app/wazuh', []);
|
||||
|
||||
app.controller('agentsPreviewController', function ($scope, $rootScope, $routeParams, genericReq, apiReq, appState, Agents, $location, errorHandler) {
|
||||
$scope.loading = true;
|
||||
|
@ -1,5 +1,7 @@
|
||||
const app = require('ui/modules').get('app/wazuh', []);
|
||||
const beautifier = require('plugins/wazuh/utils/json-beautifier');
|
||||
import beautifier from 'plugins/wazuh/utils/json-beautifier';
|
||||
import * as modules from 'ui/modules'
|
||||
|
||||
const app = modules.get('app/wazuh', []);
|
||||
|
||||
app.controller('agentsController',
|
||||
function ($scope, $location, $q, $rootScope, appState, genericReq, apiReq, AgentsAutoComplete, errorHandler) {
|
||||
|
@ -1,4 +1,6 @@
|
||||
const app = require('ui/modules').get('app/wazuh', []);
|
||||
import * as modules from 'ui/modules'
|
||||
|
||||
const app = modules.get('app/wazuh', []);
|
||||
|
||||
// Logs controller
|
||||
app.controller('blankScreenController', function ($scope, $rootScope, errorHandler,$location) {
|
||||
|
@ -1,5 +1,7 @@
|
||||
let app = require('ui/modules').get('app/wazuh', []);
|
||||
const beautifier = require('plugins/wazuh/utils/json-beautifier');
|
||||
import beautifier from 'plugins/wazuh/utils/json-beautifier';
|
||||
import * as modules from 'ui/modules'
|
||||
|
||||
const app = modules.get('app/wazuh', []);
|
||||
|
||||
// Groups preview controller
|
||||
app.controller('groupsPreviewController',
|
||||
|
@ -1,4 +1,6 @@
|
||||
const app = require('ui/modules').get('app/wazuh', []);
|
||||
import * as modules from 'ui/modules'
|
||||
|
||||
const app = modules.get('app/wazuh', []);
|
||||
|
||||
app.controller('healthCheck', function ($scope, $rootScope, $timeout, $location, Notifier, courier, genericReq, apiReq, appState, testAPI,errorHandler) {
|
||||
const checks = {
|
||||
|
@ -1,4 +1,6 @@
|
||||
const app = require('ui/modules').get('app/wazuh', []);
|
||||
import * as modules from 'ui/modules'
|
||||
|
||||
const app = modules.get('app/wazuh', []);
|
||||
|
||||
app.controller('loginController', function ($scope, $rootScope, $location, appState, genericReq, $window) {
|
||||
$scope.submit = password => {
|
||||
|
@ -1,5 +1,6 @@
|
||||
// Require config
|
||||
let app = require('ui/modules').get('app/wazuh', []);
|
||||
import * as modules from 'ui/modules'
|
||||
|
||||
const app = modules.get('app/wazuh', []);
|
||||
|
||||
app.controller('managerController', function ($scope, $rootScope, $routeParams, $location, apiReq, errorHandler) {
|
||||
$scope.submenuNavItem = 'status';
|
||||
@ -95,7 +96,8 @@ app.controller('managerStatusController', function ($scope,$rootScope, errorHand
|
||||
|
||||
});
|
||||
|
||||
const beautifier = require('plugins/wazuh/utils/json-beautifier');
|
||||
import beautifier from 'plugins/wazuh/utils/json-beautifier';
|
||||
|
||||
app.controller('managerConfigurationController', function ($scope,$rootScope, errorHandler, apiReq) {
|
||||
//Initialization
|
||||
$scope.load = true;
|
||||
|
@ -1,4 +1,6 @@
|
||||
const app = require('ui/modules').get('app/wazuh', []);
|
||||
import * as modules from 'ui/modules'
|
||||
|
||||
const app = modules.get('app/wazuh', []);
|
||||
|
||||
// Logs controller
|
||||
app.controller('managerLogController', function ($scope, $rootScope, Logs, apiReq,errorHandler) {
|
||||
|
@ -1,5 +1,7 @@
|
||||
const app = require('ui/modules').get('app/wazuh', []);
|
||||
import $ from 'jquery';
|
||||
import $ from 'jquery';
|
||||
import * as modules from 'ui/modules'
|
||||
|
||||
const app = modules.get('app/wazuh', []);
|
||||
|
||||
app.controller('overviewController', function ($scope, $location, $rootScope, appState, genericReq, errorHandler) {
|
||||
$rootScope.rawVisualizations = null;
|
||||
|
@ -1,4 +1,6 @@
|
||||
let app = require('ui/modules').get('app/wazuh', []);
|
||||
import * as modules from 'ui/modules'
|
||||
|
||||
const app = modules.get('app/wazuh', []);
|
||||
|
||||
app.controller('rulesController', function ($scope, $rootScope, Rules,RulesAutoComplete, errorHandler, genericReq, appState) {
|
||||
// Timestamp for visualizations at controller's startup
|
||||
|
@ -1,9 +1,8 @@
|
||||
// Require utils
|
||||
let base64 = require('plugins/wazuh/utils/base64.js');
|
||||
import chrome from 'ui/chrome';
|
||||
import base64 from 'plugins/wazuh/utils/base64.js';
|
||||
import chrome from 'ui/chrome';
|
||||
import * as modules from 'ui/modules'
|
||||
|
||||
// Require App
|
||||
const app = require('ui/modules').get('app/wazuh', []);
|
||||
const app = modules.get('app/wazuh', []);
|
||||
|
||||
app.controller('settingsController', function ($scope, $rootScope, $http, $routeParams, $route, $location, testAPI, appState, genericReq, courier, errorHandler) {
|
||||
$rootScope.page = "settings";
|
||||
|
@ -1,4 +1,7 @@
|
||||
const app = require('ui/modules').get('app/wazuh', []);
|
||||
import * as modules from 'ui/modules'
|
||||
|
||||
const app = modules.get('app/wazuh', []);
|
||||
|
||||
app.directive('wzDynamic', function($compile) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
|
@ -1,4 +1,7 @@
|
||||
const app = require('ui/modules').get('app/wazuh', []);
|
||||
import * as modules from 'ui/modules'
|
||||
|
||||
const app = modules.get('app/wazuh', []);
|
||||
|
||||
app.directive('wzEnter', function () {
|
||||
return function (scope, element, attrs) {
|
||||
element.bind("keydown keypress", function (event) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
import menuTemplate from './wz-menu.html'
|
||||
import * as modules from 'ui/modules'
|
||||
|
||||
const app = require('ui/modules').get('app/wazuh', []);
|
||||
const app = modules.get('app/wazuh', []);;
|
||||
|
||||
app.directive('wzMenu',function(){
|
||||
return {
|
||||
|
@ -1,6 +1,7 @@
|
||||
import searchBarTemplate from './wz-search-bar.html'
|
||||
import * as modules from 'ui/modules'
|
||||
|
||||
const app = require('ui/modules').get('app/wazuh', []);
|
||||
const app = modules.get('app/wazuh', []);
|
||||
|
||||
app.directive('wzSearchBar',function(){
|
||||
return {
|
||||
|
@ -1,6 +1,7 @@
|
||||
import tableTemplate from './wz-table.html'
|
||||
import * as modules from 'ui/modules'
|
||||
|
||||
const app = require('ui/modules').get('app/wazuh', []);
|
||||
const app = modules.get('app/wazuh', []);
|
||||
|
||||
const colors = [
|
||||
'#3F6833', '#967302', '#2F575E', '#99440A', '#58140C', '#052B51', '#511749', '#3F2B5B', //6
|
||||
|
@ -1,4 +1,6 @@
|
||||
const app = require('ui/modules').get('app/wazuh', []);
|
||||
import * as modules from 'ui/modules'
|
||||
|
||||
const app = modules.get('app/wazuh', []);
|
||||
|
||||
/**
|
||||
* Main function to build a data handler factory.
|
||||
|
@ -1,6 +1,8 @@
|
||||
import chrome from 'ui/chrome';
|
||||
import chrome from 'ui/chrome';
|
||||
import * as modules from 'ui/modules'
|
||||
|
||||
const app = modules.get('app/wazuh', []);
|
||||
|
||||
const app = require('ui/modules').get('app/wazuh', []);
|
||||
app.service('apiReq', function ($q, $http, genericReq, appState, $location, $rootScope) {
|
||||
return {
|
||||
request: (method, path, body) => {
|
||||
|
@ -1,5 +1,7 @@
|
||||
import chrome from 'ui/chrome';
|
||||
const app = require('ui/modules').get('app/wazuh', []);
|
||||
import chrome from 'ui/chrome';
|
||||
import * as modules from 'ui/modules'
|
||||
|
||||
const app = modules.get('app/wazuh', []);
|
||||
|
||||
app.service('testAPI', function ($http, $location, $rootScope, appState, genericReq) {
|
||||
return {
|
||||
|
@ -1,4 +1,7 @@
|
||||
require('ui/modules').get('app/wazuh', []).service('appState', function ($cookies, $window) {
|
||||
import * as modules from 'ui/modules'
|
||||
|
||||
modules.get('app/wazuh', [])
|
||||
.service('appState', function ($cookies, $window) {
|
||||
return {
|
||||
getExtensions: () => {
|
||||
const data = {
|
||||
|
@ -1,4 +1,6 @@
|
||||
let app = require('ui/modules').get('app/wazuh', []);
|
||||
import * as modules from 'ui/modules'
|
||||
|
||||
const app = modules.get('app/wazuh', []);
|
||||
|
||||
app.factory('DataHandler', function ($q, apiReq,errorHandler) {
|
||||
class DataHandler {
|
||||
|
@ -1,4 +1,6 @@
|
||||
const app = require('ui/modules').get('app/wazuh', []);
|
||||
import * as modules from 'ui/modules'
|
||||
|
||||
const app = modules.get('app/wazuh', []);
|
||||
|
||||
app.service('errorHandler', function ( Notifier, appState, $location) {
|
||||
const notify = new Notifier();
|
||||
|
@ -1,7 +1,9 @@
|
||||
const prepError = require('plugins/wazuh/services/prep-error');
|
||||
import chrome from 'ui/chrome';
|
||||
import prepError from 'plugins/wazuh/services/prep-error';
|
||||
import chrome from 'ui/chrome';
|
||||
import * as modules from 'ui/modules'
|
||||
|
||||
require('ui/modules').get('app/wazuh', []).service('genericReq', function ($q, $http, $location, $rootScope, appState,errorHandler) {
|
||||
modules.get('app/wazuh', [])
|
||||
.service('genericReq', function ($q, $http, $location, $rootScope, appState,errorHandler) {
|
||||
|
||||
const _request = (method, url, payload = null) => {
|
||||
let defered = $q.defer();
|
||||
|
@ -1,4 +1,6 @@
|
||||
require('ui/modules').get('app/wazuh', [])
|
||||
import * as modules from 'ui/modules'
|
||||
|
||||
modules.get('app/wazuh', [])
|
||||
.service('patternHandler', function ($rootScope, $location, genericReq, appState, errorHandler) {
|
||||
return {
|
||||
getPatternList: async () => {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Require routes
|
||||
let routes = require('ui/routes');
|
||||
import routes from 'ui/routes';
|
||||
|
||||
// Kibana dependencies to load index-patterns and saved searches
|
||||
import { StateProvider } from 'ui/state_management/state';
|
||||
|
@ -1,4 +1,6 @@
|
||||
require('ui/modules').get('app/wazuh', [])
|
||||
import * as modules from 'ui/modules'
|
||||
|
||||
modules.get('app/wazuh', [])
|
||||
.config(function ($mdThemingProvider) {
|
||||
|
||||
let kibanaWhiteBlack = {
|
||||
|
@ -1,92 +1,89 @@
|
||||
module.exports = {
|
||||
encode: function (text){
|
||||
export default {
|
||||
encode: text => {
|
||||
|
||||
if (/([^\u0000-\u00ff])/.test(text)){
|
||||
throw new Error("Can't base64 encode non-ASCII characters.");
|
||||
}
|
||||
if (/([^\u0000-\u00ff])/.test(text)){
|
||||
throw new Error("Can't base64 encode non-ASCII characters.");
|
||||
}
|
||||
|
||||
var digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",
|
||||
i = 0,
|
||||
cur, prev, byteNum,
|
||||
result=[];
|
||||
const digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
||||
|
||||
let i = 0, cur, prev, byteNum, result=[];
|
||||
|
||||
while(i < text.length){
|
||||
while(i < text.length){
|
||||
|
||||
cur = text.charCodeAt(i);
|
||||
byteNum = i % 3;
|
||||
cur = text.charCodeAt(i);
|
||||
byteNum = i % 3;
|
||||
|
||||
switch(byteNum){
|
||||
case 0: //first byte
|
||||
result.push(digits.charAt(cur >> 2));
|
||||
break;
|
||||
switch(byteNum){
|
||||
case 0: //first byte
|
||||
result.push(digits.charAt(cur >> 2));
|
||||
break;
|
||||
|
||||
case 1: //second byte
|
||||
result.push(digits.charAt((prev & 3) << 4 | (cur >> 4)));
|
||||
break;
|
||||
case 1: //second byte
|
||||
result.push(digits.charAt((prev & 3) << 4 | (cur >> 4)));
|
||||
break;
|
||||
|
||||
case 2: //third byte
|
||||
result.push(digits.charAt((prev & 0x0f) << 2 | (cur >> 6)));
|
||||
result.push(digits.charAt(cur & 0x3f));
|
||||
break;
|
||||
}
|
||||
|
||||
prev = cur;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (byteNum == 0){
|
||||
result.push(digits.charAt((prev & 3) << 4));
|
||||
result.push("==");
|
||||
} else if (byteNum == 1){
|
||||
result.push(digits.charAt((prev & 0x0f) << 2));
|
||||
result.push("=");
|
||||
}
|
||||
|
||||
return result.join("");
|
||||
},
|
||||
decode: function (text){
|
||||
|
||||
text = text.replace(/\s/g,"");
|
||||
|
||||
if(!(/^[a-z0-9\-_\s]+\={0,2}$/i.test(text)) || text.length % 4 > 0){
|
||||
throw new Error("Not a base64-encoded string.");
|
||||
}
|
||||
|
||||
//local variables
|
||||
var digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
|
||||
cur, prev, digitNum,
|
||||
i=0,
|
||||
result = [];
|
||||
|
||||
text = text.replace(/=/g, "");
|
||||
|
||||
while(i < text.length){
|
||||
|
||||
cur = digits.indexOf(text.charAt(i));
|
||||
digitNum = i % 4;
|
||||
|
||||
switch(digitNum){
|
||||
|
||||
//case 0: first digit - do nothing, not enough info to work with
|
||||
|
||||
case 1: //second digit
|
||||
result.push(String.fromCharCode(prev << 2 | cur >> 4));
|
||||
break;
|
||||
|
||||
case 2: //third digit
|
||||
result.push(String.fromCharCode((prev & 0x0f) << 4 | cur >> 2));
|
||||
break;
|
||||
|
||||
case 3: //fourth digit
|
||||
result.push(String.fromCharCode((prev & 3) << 6 | cur));
|
||||
break;
|
||||
}
|
||||
|
||||
prev = cur;
|
||||
i++;
|
||||
case 2: //third byte
|
||||
result.push(digits.charAt((prev & 0x0f) << 2 | (cur >> 6)));
|
||||
result.push(digits.charAt(cur & 0x3f));
|
||||
break;
|
||||
}
|
||||
|
||||
return result.join("");
|
||||
prev = cur;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (byteNum == 0){
|
||||
result.push(digits.charAt((prev & 3) << 4));
|
||||
result.push("==");
|
||||
} else if (byteNum == 1){
|
||||
result.push(digits.charAt((prev & 0x0f) << 2));
|
||||
result.push("=");
|
||||
}
|
||||
|
||||
return result.join("");
|
||||
},
|
||||
decode: text => {
|
||||
|
||||
text = text.replace(/\s/g,"");
|
||||
|
||||
if(!(/^[a-z0-9\-_\s]+\={0,2}$/i.test(text)) || text.length % 4 > 0){
|
||||
throw new Error("Not a base64-encoded string.");
|
||||
}
|
||||
|
||||
//local variables
|
||||
const digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
let cur, prev, digitNum, i=0, result = [];
|
||||
|
||||
text = text.replace(/=/g, "");
|
||||
|
||||
while(i < text.length){
|
||||
|
||||
cur = digits.indexOf(text.charAt(i));
|
||||
digitNum = i % 4;
|
||||
|
||||
switch(digitNum){
|
||||
|
||||
//case 0: first digit - do nothing, not enough info to work with
|
||||
|
||||
case 1: //second digit
|
||||
result.push(String.fromCharCode(prev << 2 | cur >> 4));
|
||||
break;
|
||||
|
||||
case 2: //third digit
|
||||
result.push(String.fromCharCode((prev & 0x0f) << 4 | cur >> 2));
|
||||
break;
|
||||
|
||||
case 3: //fourth digit
|
||||
result.push(String.fromCharCode((prev & 3) << 6 | cur));
|
||||
break;
|
||||
}
|
||||
|
||||
prev = cur;
|
||||
i++;
|
||||
}
|
||||
|
||||
return result.join("");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -17,4 +17,4 @@ const prettyPrint = obj => {
|
||||
.replace(jsonLine, replacer);
|
||||
};
|
||||
|
||||
module.exports = { replacer, prettyPrint };
|
||||
export default { replacer, prettyPrint };
|
||||
|
@ -1,4 +1,5 @@
|
||||
var app = require('ui/modules').get('app/wazuh', []);
|
||||
import * as modules from 'ui/modules';
|
||||
const app = modules.get('app/wazuh', []);
|
||||
|
||||
app.directive('whenScrolled', function() {
|
||||
return function(scope, elm, attr) {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { ElasticWrapper } from '../lib/elastic-wrapper';
|
||||
|
||||
const userRegEx = new RegExp(/^.{3,100}$/);
|
||||
const passRegEx = new RegExp(/^.{3,100}$/);
|
||||
const urlRegEx = new RegExp(/^https?:\/\/[a-zA-Z0-9]{1,300}$/);
|
||||
|
@ -1,21 +1,15 @@
|
||||
|
||||
// Require some libraries
|
||||
const needle = require('needle');
|
||||
|
||||
// External references
|
||||
const fetchAgentsExternal = require('../monitoring');
|
||||
import { ElasticWrapper } from '../lib/elastic-wrapper';
|
||||
const getPath = require('../../util/get-path');
|
||||
|
||||
// Colors for console logging
|
||||
const colors = require('ansicolors');
|
||||
const blueWazuh = colors.blue('wazuh');
|
||||
|
||||
const fs = require('fs');
|
||||
const yml = require('js-yaml');
|
||||
const path = require('path');
|
||||
|
||||
import needle from 'needle';
|
||||
import fs from 'fs';
|
||||
import yml from 'js-yaml';
|
||||
import path from 'path';
|
||||
import colors from 'ansicolors';
|
||||
import pciRequirementsFile from '../integration-files/pci-requirements';
|
||||
import { ElasticWrapper } from '../lib/elastic-wrapper';
|
||||
import getPath from '../../util/get-path';
|
||||
|
||||
const blueWazuh = colors.blue('wazuh');
|
||||
|
||||
let packageInfo;
|
||||
|
||||
@ -30,6 +24,7 @@ try {
|
||||
export class WazuhApi {
|
||||
constructor(server){
|
||||
this.wzWrapper = new ElasticWrapper(server);
|
||||
this.fetchAgentsExternal = require('../monitoring')(server,{disableCron:true})
|
||||
}
|
||||
|
||||
async checkStoredAPI (req, reply) {
|
||||
@ -420,14 +415,23 @@ export class WazuhApi {
|
||||
};
|
||||
|
||||
// Fetch agent status and insert it directly on demand
|
||||
fetchAgents (req, reply) {
|
||||
if(!protectedRoute(req)) return reply(this.genericErrorBuilder(401,7,'Session expired.')).code(401);
|
||||
fetchAgentsExternal();
|
||||
return reply({
|
||||
'statusCode': 200,
|
||||
'error': '0',
|
||||
'data': ''
|
||||
});
|
||||
async fetchAgents (req, reply) {
|
||||
try{
|
||||
if(!protectedRoute(req)) return reply(this.genericErrorBuilder(401,7,'Session expired.')).code(401);
|
||||
const output = await this.fetchAgentsExternal();
|
||||
return reply({
|
||||
'statusCode': 200,
|
||||
'error': '0',
|
||||
'data': '',
|
||||
output
|
||||
});
|
||||
} catch(error){
|
||||
return reply({
|
||||
statusCode: 200,
|
||||
error : '1',
|
||||
data : error.message || error
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
postErrorLog (req, reply) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { ElasticWrapper } from '../lib/elastic-wrapper';
|
||||
const fs = require('fs');
|
||||
const yml = require('js-yaml');
|
||||
const path = require('path');
|
||||
import fs from 'fs';
|
||||
import yml from 'js-yaml';
|
||||
import path from 'path';
|
||||
|
||||
export class WazuhElastic {
|
||||
constructor(server){
|
||||
|
@ -1,16 +1,16 @@
|
||||
const needle = require('needle');
|
||||
const colors = require('ansicolors');
|
||||
const blueWazuh = colors.blue('wazuh');
|
||||
const fs = require('fs');
|
||||
const yml = require('js-yaml');
|
||||
const path = require('path');
|
||||
import log from './logger';
|
||||
|
||||
const KIBANA_TEMPLATE = './integration-files/kibana-template';
|
||||
import knownFields from './integration-files/known-fields';
|
||||
import needle from 'needle';
|
||||
import colors from 'ansicolors';
|
||||
import fs from 'fs';
|
||||
import yml from'js-yaml';
|
||||
import path from'path';
|
||||
import log from './logger';
|
||||
import knownFields from './integration-files/known-fields';
|
||||
import { ElasticWrapper } from './lib/elastic-wrapper';
|
||||
|
||||
export default (server, options) => {
|
||||
const blueWazuh = colors.blue('wazuh');
|
||||
const KIBANA_TEMPLATE = './integration-files/kibana-template';
|
||||
|
||||
// Elastic JS Client
|
||||
const wzWrapper = new ElasticWrapper(server);
|
||||
log('[initialize]', `Kibana index: ${wzWrapper.WZ_KIBANA_INDEX}`, 'info');
|
||||
|
@ -1,7 +1,9 @@
|
||||
const winston = require('winston');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
let allowed = false;
|
||||
import winston from 'winston';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
let allowed = false;
|
||||
|
||||
/**
|
||||
* Checks if ../../wazuh-logs exists. If it doesn't exist, it will be created.
|
||||
*/
|
||||
|
@ -1,14 +1,15 @@
|
||||
const cron = require('node-cron');
|
||||
const needle = require('needle');
|
||||
const getPath = require('../util/get-path');
|
||||
const colors = require('ansicolors');
|
||||
const blueWazuh = colors.blue('wazuh');
|
||||
import log from './logger';
|
||||
import cron from 'node-cron';
|
||||
import needle from 'needle';
|
||||
import getPath from'../util/get-path';
|
||||
import colors from 'ansicolors';
|
||||
import log from './logger';
|
||||
import { ElasticWrapper } from './lib/elastic-wrapper';
|
||||
const index_pattern = "wazuh-monitoring-3.x-*";
|
||||
const index_prefix = "wazuh-monitoring-3.x-";
|
||||
|
||||
export default (server, options) => {
|
||||
const blueWazuh = colors.blue('wazuh');
|
||||
const index_pattern = "wazuh-monitoring-3.x-*";
|
||||
const index_prefix = "wazuh-monitoring-3.x-";
|
||||
|
||||
// Elastic JS Client
|
||||
const wzWrapper = new ElasticWrapper(server);
|
||||
|
||||
@ -130,6 +131,7 @@ export default (server, options) => {
|
||||
}
|
||||
await checkAndSaveStatus(apiEntry);
|
||||
}
|
||||
return { result: 'ok' }
|
||||
} catch(error){
|
||||
log('[monitoring][loadCredentials]',error.message || error);
|
||||
server.log([blueWazuh, 'monitoring', 'error'], error.message || error);
|
||||
@ -161,7 +163,7 @@ export default (server, options) => {
|
||||
};
|
||||
|
||||
// fetchAgents on demand
|
||||
const fetchAgents = async () => {
|
||||
const fetchAgentsExternal = async () => {
|
||||
try {
|
||||
const data = await getConfig();
|
||||
return loadCredentials(data);
|
||||
@ -351,7 +353,7 @@ export default (server, options) => {
|
||||
};
|
||||
|
||||
// Check Kibana index and if it is prepared, start the initialization of Wazuh App.
|
||||
checkKibanaStatus();
|
||||
if(!options) checkKibanaStatus();
|
||||
|
||||
const cronTask = async () => {
|
||||
try {
|
||||
@ -364,9 +366,8 @@ export default (server, options) => {
|
||||
server.log([blueWazuh, 'monitoring [cronTask]', 'error'], error.message || error)
|
||||
}
|
||||
}
|
||||
cronTask()
|
||||
if(!options) cronTask()
|
||||
// Cron tab for getting agent status.
|
||||
cron.schedule('0 */10 * * * *', cronTask, true);
|
||||
|
||||
module.exports = fetchAgents;
|
||||
if(!options) cron.schedule('0 */10 * * * *', cronTask, true);
|
||||
return fetchAgentsExternal;
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { WazuhApi} from '../controllers/wazuh-api';
|
||||
import { WazuhApi } from '../controllers/wazuh-api';
|
||||
|
||||
export default (server, options) => {
|
||||
const ctrl = new WazuhApi(server);
|
||||
|
Loading…
Reference in New Issue
Block a user