Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renamed all server routes #932

Merged
merged 1 commit into from
Oct 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions init.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { WazuhApiElasticRoutes } from './server/routes/wazuh-api-elastic';
import { Monitoring } from './server/monitoring';
import { WazuhApiRoutes } from './server/routes/wazuh-api';
import { WazuhReportingRoutes } from './server/routes/wazuh-reporting';
import { WazuhUtilsRoutes } from './server/routes/wazuh-utils';

export function initApp(server) {
Initialize(server);
Expand All @@ -25,4 +26,5 @@ export function initApp(server) {
Monitoring(server, false);
WazuhApiRoutes(server);
WazuhReportingRoutes(server);
WazuhUtilsRoutes(server);
}
6 changes: 3 additions & 3 deletions public/controllers/agent/agents-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ class AgentsPreviewController {
const data = await Promise.all([
this.genericReq.request(
'GET',
'/api/wazuh-api/agents-unique/' + api,
'/api/agents-unique/' + api,
{}
),
this.genericReq.request(
'GET',
`/api/wazuh-elastic/top/${firstUrlParam}/${secondUrlParam}/agent.name/${pattern}`
`/elastic/top/${firstUrlParam}/${secondUrlParam}/agent.name/${pattern}`
)
]);
const [agentsUnique, agentsTop] = data;
Expand All @@ -158,7 +158,7 @@ class AgentsPreviewController {
this.$scope.mostActiveAgent.name = agentsTop.data.data;
const info = await this.genericReq.request(
'GET',
`/api/wazuh-elastic/top/${firstUrlParam}/${secondUrlParam}/agent.id/${pattern}`
`/elastic/top/${firstUrlParam}/${secondUrlParam}/agent.id/${pattern}`
);
if (info.data.data === '' && this.$scope.mostActiveAgent.name !== '') {
this.$scope.mostActiveAgent.id = '000';
Expand Down
2 changes: 1 addition & 1 deletion public/controllers/management/monitoring.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ app.controller('clusterController', function(

const visData = await genericReq.request(
'POST',
`/api/wazuh-elastic/create-vis/cluster-monitoring/${appState.getCurrentPattern()}`,
`/elastic/visualizations/cluster-monitoring/${appState.getCurrentPattern()}`,
{ nodes }
);

Expand Down
6 changes: 3 additions & 3 deletions public/controllers/misc/health-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class HealthCheck {
const i = this.$scope.results.map(item => item.id).indexOf(2);
const patternData = await this.genericReq.request(
'GET',
`/api/wazuh-elastic/pattern/${patternTitle}`
`/elastic/index-patterns/${patternTitle}`
);
if (!patternData.data.status) {
this.$scope.errors.push('The selected index-pattern is not present.');
Expand All @@ -89,7 +89,7 @@ class HealthCheck {
const i = this.$scope.results.map(item => item.id).indexOf(3);
const templateData = await this.genericReq.request(
'GET',
`/api/wazuh-elastic/template/${patternTitle}`
`/elastic/template/${patternTitle}`
);
if (!templateData.data.status) {
this.$scope.errors.push(
Expand Down Expand Up @@ -136,7 +136,7 @@ class HealthCheck {
const apiVersion = versionData.data.data;
const setupData = await this.genericReq.request(
'GET',
'/api/wazuh-elastic/setup'
'/elastic/setup'
);
if (!setupData.data.data['app-version'] || !apiVersion) {
this.errorHandler.handle(
Expand Down
4 changes: 2 additions & 2 deletions public/controllers/misc/reporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ReportingController {
this.$scope.loading = true;
await this.genericReq.request(
'DELETE',
'/api/wazuh-reporting/report/' + name,
'/reports/' + name,
{}
);
await this.load();
Expand Down Expand Up @@ -110,7 +110,7 @@ class ReportingController {
this.$scope.loading = true;
const data = await this.genericReq.request(
'GET',
'/api/wazuh-reporting/reports',
'/reports',
{}
);
this.items = data.data.list;
Expand Down
20 changes: 10 additions & 10 deletions public/controllers/settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ app.controller('settingsController', function(
}
await genericReq.request(
'DELETE',
`/api/wazuh-api/apiEntries/${$scope.apiEntries[index]._id}`
`/elastic/apis/${$scope.apiEntries[index]._id}`
);
$scope.showEditForm[$scope.apiEntries[index]._id] = false;
$scope.apiEntries.splice(index, 1);
Expand Down Expand Up @@ -166,7 +166,7 @@ app.controller('settingsController', function(
// Get settings function
const getSettings = async () => {
try {
const patternList = await genericReq.request('GET', '/get-list', {});
const patternList = await genericReq.request('GET', '/elastic/index-patterns', {});
$scope.indexPatterns = patternList.data.data;

if (!patternList.data.data.length) {
Expand All @@ -175,7 +175,7 @@ app.controller('settingsController', function(
$location.path('/blank-screen');
return;
}
const data = await genericReq.request('GET', '/api/wazuh-api/apiEntries');
const data = await genericReq.request('GET', '/elastic/apis');
for (const entry of data.data) $scope.showEditForm[entry._id] = false;

$scope.apiEntries = data.data.length > 0 ? data.data : [];
Expand Down Expand Up @@ -297,7 +297,7 @@ app.controller('settingsController', function(
// Insert new API entry
const data = await genericReq.request(
'PUT',
'/api/wazuh-api/settings',
'/elastic/api',
tmpData
);
appState.setExtensions(data.data.response._id, tmpData.extensions);
Expand Down Expand Up @@ -350,7 +350,7 @@ app.controller('settingsController', function(
}

try {
await genericReq.request('GET', '/api/wazuh-api/fetchAgents');
await genericReq.request('GET', '/api/monitoring');
} catch (error) {
if (error && error.status && error.status === -1) {
errorHandler.handle(
Expand Down Expand Up @@ -412,7 +412,7 @@ app.controller('settingsController', function(
tmpData.cluster_info = data.data;
await genericReq.request(
'PUT',
'/api/wazuh-api/update-settings',
'/elastic/api-settings',
tmpData
);
$scope.apiEntries[index]._source.cluster_info = tmpData.cluster_info;
Expand Down Expand Up @@ -461,7 +461,7 @@ app.controller('settingsController', function(
const data = await testAPI.check(tmpData);
tmpData.cluster_info = data.data;

const tmpUrl = `/api/wazuh-api/updateApiHostname/${
const tmpUrl = `/elastic/api-hostname/${
$scope.apiEntries[index]._id
}`;
await genericReq.request('PUT', tmpUrl, {
Expand Down Expand Up @@ -501,7 +501,7 @@ app.controller('settingsController', function(
$scope.changeIndexPattern = async newIndexPattern => {
try {
appState.setCurrentPattern(newIndexPattern);
await genericReq.request('GET', `/refresh-fields/${newIndexPattern}`, {});
await genericReq.request('GET', `/elastic/known-fields/${newIndexPattern}`, {});
$scope.$emit('updatePattern', {});
errorHandler.info(
'Successfully changed the default index-pattern',
Expand All @@ -528,7 +528,7 @@ app.controller('settingsController', function(
const getAppLogs = async () => {
try {
$scope.loadingLogs = true;
const logs = await genericReq.request('GET', '/api/wazuh-api/logs', {});
const logs = await genericReq.request('GET', '/utils/logs', {});
$scope.logs = logs.data.lastLogs.map(item => JSON.parse(item));
$scope.loadingLogs = false;
if (!$scope.$$phase) $scope.$digest();
Expand All @@ -545,7 +545,7 @@ app.controller('settingsController', function(

const getAppInfo = async () => {
try {
const data = await genericReq.request('GET', '/api/wazuh-elastic/setup');
const data = await genericReq.request('GET', '/elastic/setup');
$scope.appInfo = {};
$scope.appInfo['app-version'] = data.data.data['app-version'];
$scope.appInfo['installationDate'] = data.data.data['installationDate'];
Expand Down
4 changes: 2 additions & 2 deletions public/directives/wz-menu/wz-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class WzMenu {
let filtered = false;
// If there is no current pattern, fetch it
if (!appState.getCurrentPattern()) {
const currentPattern = await genericReq.request('GET', '/get-list');
const currentPattern = await genericReq.request('GET', '/elastic/index-patterns');
if (!currentPattern.data.data.length) {
wzMisc.setBlankScr('Sorry but no valid index patterns were found');
$location.search('tab', null);
Expand All @@ -72,7 +72,7 @@ class WzMenu {
appState.setCurrentPattern(currentPattern.data.data[0].id);
} else {
// If there is current pattern, check if there is some pattern
const patternList = await genericReq.request('GET', '/get-list');
const patternList = await genericReq.request('GET', '/elastic/index-patterns');

if (!patternList.data.data.length) {
wzMisc.setBlankScr('Sorry but no valid index patterns were found');
Expand Down
2 changes: 1 addition & 1 deletion public/services/api-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class ApiRequest {

const data = await this.genericReq.request(
'POST',
'/api/wazuh-api/request',
'/api/request',
requestData
);

Expand Down
4 changes: 2 additions & 2 deletions public/services/api-tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class ApiTester {
/** End of checks for outdated cookies */
} else {
const result = await this.$http.post(
chrome.addBasePath('/api/wazuh-api/checkStoredAPI'),
chrome.addBasePath('/api/check-stored-api'),
data,
headers
);
Expand Down Expand Up @@ -74,7 +74,7 @@ export class ApiTester {
timeout: timeout || 8000
};

const url = chrome.addBasePath('/api/wazuh-api/checkAPI');
const url = chrome.addBasePath('/api/check-api');
const response = await this.$http.post(url, data, headers);

if (response.error) {
Expand Down
4 changes: 2 additions & 2 deletions public/services/common-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class CommonData {
const gdprTabs = [];
const data = await this.genericReq.request(
'GET',
'/api/wazuh-api/gdpr/all'
'/api/gdpr/all'
);
if (!data.data) return [];
for (const key in data.data) {
Expand All @@ -162,7 +162,7 @@ export class CommonData {
const pciTabs = [];
const data = await this.genericReq.request(
'GET',
'/api/wazuh-api/pci/all'
'/api/pci/all'
);
if (!data.data) return [];
for (const key in data.data) {
Expand Down
4 changes: 2 additions & 2 deletions public/services/csv-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class CSVRequest {
}

/**
* It fetchs data from /api/wazuh-api/csv route using the below parameters.
* It fetchs data from /api/csv route using the below parameters.
* @param {string} path Wazuh API route
* @param {number|string} id Elasticsearch document ID
* @param {*} filters Array of Wazuh API filters. Optional
Expand All @@ -28,7 +28,7 @@ export class CSVRequest {
try {
const output = await this.genericReq.request(
'POST',
'/api/wazuh-api/csv',
'/api/csv',
{ path, id, filters }
);
return output.data;
Expand Down
4 changes: 2 additions & 2 deletions public/services/pattern-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class PatternHandler {

async getPatternList() {
try {
const patternList = await this.genericReq.request('GET', '/get-list', {});
const patternList = await this.genericReq.request('GET', '/elastic/index-patterns', {});

if (!patternList.data.data.length) {
this.wzMisc.setBlankScr('Sorry but no valid index patterns were found');
Expand Down Expand Up @@ -49,7 +49,7 @@ export class PatternHandler {
this.appState.setCurrentPattern(selectedPattern);
await this.genericReq.request(
'GET',
`/refresh-fields/${selectedPattern}`,
`/elastic/known-fields/${selectedPattern}`,
{}
);
return this.appState.getCurrentPattern();
Expand Down
2 changes: 1 addition & 1 deletion public/services/reporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class ReportingService {

await this.genericReq.request(
'POST',
'/api/wazuh-reporting/report',
'/reports',
data
);

Expand Down
2 changes: 1 addition & 1 deletion public/services/resolves/check-ram.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
export async function totalRAM(genericReq, errorHandler) {
try {
const data = await genericReq.request('GET', '/api/wazuh-api/ram');
const data = await genericReq.request('GET', '/utils/memory');
const totalRAM = data.data.ram;
if (totalRAM < 3072 && totalRAM > 2048) {
errorHandler.handle(
Expand Down
2 changes: 1 addition & 1 deletion public/services/resolves/check-timestamp.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function checkTimestamp(appState, genericReq, $location, wzMisc) {
try {
const data = await genericReq.request(
'GET',
'/api/wazuh-elastic/timestamp'
'/elastic/timestamp'
);
const current = appState.getCreatedAt();
if (data && data.data) {
Expand Down
2 changes: 1 addition & 1 deletion public/services/resolves/get-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function getWzConfig($q, genericReq, errorHandler, wazuhConfig) {
try {
const config = await genericReq.request(
'GET',
'/api/wazuh-api/configuration',
'/utils/configuration',
{}
);

Expand Down
2 changes: 1 addition & 1 deletion public/services/resolves/get-ip.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function getIp(

const { savedObjects } = savedObjectsData;

const data = await genericReq.request('GET', '/get-list');
const data = await genericReq.request('GET', '/elastic/index-patterns');

let currentPattern = '';

Expand Down
2 changes: 1 addition & 1 deletion public/services/resolves/settings-wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export function settingsWizard(
// There's no cookie for current API
if (!appState.getCurrentAPI()) {
genericReq
.request('GET', '/api/wazuh-api/apiEntries')
.request('GET', '/elastic/apis')
.then(data => {
if (data.data.length > 0) {
const apiEntries = data.data;
Expand Down
4 changes: 2 additions & 2 deletions public/services/vis-factory-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class VisFactoryService {
try {
const data = await this.genericReq.request(
'GET',
`/api/wazuh-elastic/create-vis/overview-${tab}/${this.appState.getCurrentPattern()}`
`/elastic/visualizations/overview-${tab}/${this.appState.getCurrentPattern()}`
);
this.rawVisualizations.assignItems(data.data.raw);
this.commonData.assignFilters(filterHandler, tab, localChange);
Expand All @@ -64,7 +64,7 @@ export class VisFactoryService {
try {
const data = await this.genericReq.request(
'GET',
`/api/wazuh-elastic/create-vis/agents-${tab}/${this.appState.getCurrentPattern()}`
`/elastic/visualizations/agents-${tab}/${this.appState.getCurrentPattern()}`
);
this.rawVisualizations.assignItems(data.data.raw);
this.commonData.assignFilters(filterHandler, tab, localChange, id);
Expand Down
2 changes: 1 addition & 1 deletion public/templates/management/reporting.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<td>{{item.size / 1024 | number: 2}}KB</td>
<td>{{item.date.split('T')[0]}} {{item.date.split('T')[1].split('.')[0]}}</td>
<td>
<a ng-href="/api/wazuh-reporting/report/{{item.name}}" flex class="wz-text-right" target="_blank">
<a ng-href="/reports/{{item.name}}" flex class="wz-text-right" target="_blank">
<i class="fa fa-fw fa-download"></i>
</a>
<a flex class="wz-text-right cursor-pointer" ng-click="deleteReport(item.name)">
Expand Down
4 changes: 3 additions & 1 deletion server/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import { WazuhElasticCtrl } from './wazuh-elastic';
import { WazuhApiElasticCtrl } from './wazuh-api-elastic';
import { WazuhApiCtrl } from './wazuh-api';
import { WazuhReportingCtrl } from './wazuh-reporting';
import { WazuhUtilsCtrl } from './wazuh-utils';

export {
WazuhElasticCtrl,
WazuhApiElasticCtrl,
WazuhApiCtrl,
WazuhReportingCtrl
WazuhReportingCtrl,
WazuhUtilsCtrl
};