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

Migrate API entries from .wazuh index to wazuh.yml #1811

Merged
merged 111 commits into from
Oct 9, 2019
Merged
Show file tree
Hide file tree
Changes from 110 commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
71a096f
Removed "Pattern" and "First use" sections from Settings
Sep 5, 2019
f7f5a23
Simplified API entries table in Settings
Sep 5, 2019
5002caf
Started "API is down" guide
Sep 5, 2019
834843e
Started "Add API" guide
Sep 5, 2019
5263d41
Loading new components for Settings
Sep 5, 2019
2bf9f49
Adapt Settings views for using new components
Sep 5, 2019
b1802f5
Migrate hosts and remove .wazuh index
adri9valle Sep 6, 2019
aa0931a
Prevent duplicate hosts
adri9valle Sep 6, 2019
294490e
Improve regex
adri9valle Sep 6, 2019
dcee4c1
Cleaning settings.js controller (in progress)
Sep 6, 2019
5ba1417
Prevent try to add again if .wazuh was not deleted
adri9valle Sep 9, 2019
fd81183
Add function to check if is busy
adri9valle Sep 9, 2019
20d5597
Migrate the cluster_info and extensions to the wazuh-registry
adri9valle Sep 9, 2019
d173808
Replace wazuh-version by wazuh-registry
adri9valle Sep 9, 2019
e84aeaf
Merge branch 'issue-1771-1' into migrate-index-yml
adri9valle Sep 9, 2019
8bc7e1c
Add endpoint to get the host from wazuh-hosts.yml
adri9valle Sep 9, 2019
1cfbce8
Get the APIs from the wazuh-hosts.yml
adri9valle Sep 10, 2019
e39b337
Updates the cluster info in the registry when checking connection
adri9valle Sep 10, 2019
fcf3adb
Remove console.error
adri9valle Sep 11, 2019
c6baca0
Check api connection from wazuh-host data
adri9valle Sep 11, 2019
ae3cb3f
Try to connect to another API in case the default fails
adri9valle Sep 11, 2019
43ae995
Adapt settings-wizard and api-count
adri9valle Sep 12, 2019
5b08adb
Adapt wazuh-api.js controller for using wazuh-hosts.yml
adri9valle Sep 12, 2019
f1d8334
Prevent undefined results
adri9valle Sep 12, 2019
5ac837b
Clean initialize
adri9valle Sep 13, 2019
bff51ee
Remove wazuh-api-elastic routes and controllers
adri9valle Sep 13, 2019
f66e53d
Remove addApiProps
adri9valle Sep 13, 2019
4c10cb5
Change config.yml by wazuh.yml
adri9valle Sep 13, 2019
c83cd31
Replace config.yml in the kibana plugin helper
adri9valle Sep 13, 2019
58da979
Delete wazuh-api-elastic tests
adri9valle Sep 13, 2019
58998f6
Check for orphan registry entries
adri9valle Sep 13, 2019
1f67eb8
Check manager connection before setting as default
adri9valle Sep 13, 2019
8e450df
Prevent error toaster when there is any api entry
adri9valle Sep 13, 2019
eb1713d
Prevent errors when any api is reachable
adri9valle Sep 13, 2019
6b5ca07
Check for new apis and their connection
adri9valle Sep 13, 2019
ad0d4bc
Prevent error when update registry of undefined
adri9valle Sep 16, 2019
984692a
Prevent error when no cluster_info
adri9valle Sep 16, 2019
8fdf31b
Remove console.log
adri9valle Sep 16, 2019
0b75bb3
Change state by props
adri9valle Sep 16, 2019
76fc40a
Fix settings-wizard
adri9valle Sep 16, 2019
b9525f3
Fix when joinning hosts and registry
adri9valle Sep 16, 2019
500a16a
Check for new API entries
adri9valle Sep 16, 2019
f878a7c
Close add api component
adri9valle Sep 17, 2019
9002bd8
Remove await
adri9valle Sep 17, 2019
22af7b9
Improve checks for new apis
adri9valle Sep 17, 2019
b769ce1
Test if API is down in wazuh-api
adri9valle Sep 17, 2019
9eefcba
Check down APIs
adri9valle Sep 17, 2019
6289407
Api is down component finish
adri9valle Sep 17, 2019
8a7428b
Transform hosts in the backend
adri9valle Sep 18, 2019
b1ee3e7
Fix key
adri9valle Sep 18, 2019
88d0f4a
Adapt removeOrphanentries
adri9valle Sep 18, 2019
f792e85
Adapt settings-wizard
adri9valle Sep 18, 2019
ebb519f
Improve api-is-down component
adri9valle Sep 18, 2019
67af21d
Change the way to display the helpers components
adri9valle Sep 18, 2019
3274500
Check APIs status when get them
adri9valle Sep 18, 2019
2b8c083
Remove console.log
adri9valle Sep 18, 2019
91306e5
Check manager sets the status to the API entry
adri9valle Sep 18, 2019
b2b1907
Merge branch '3.11-7.3' into migrate-index-yml
adri9valle Sep 18, 2019
53b0057
Prevent create wazuh-registry.json without hosts
adri9valle Sep 18, 2019
0d39f5c
FIx extensions
adri9valle Sep 18, 2019
2be2f32
Add panel
adri9valle Sep 18, 2019
cff1ea8
Change style for wazuh hosts
adri9valle Sep 18, 2019
0522b54
Show add api component from the table
adri9valle Sep 19, 2019
8261918
Refresh API entries
adri9valle Sep 19, 2019
69cb240
Update wazuh-hosts
adri9valle Sep 19, 2019
f322c57
Api is down table loading effect
adri9valle Sep 19, 2019
2f080a9
Show API is down when accessing to settings if any API is up
adri9valle Sep 19, 2019
0debcd1
Update cluster info in the settings wizard
adri9valle Sep 19, 2019
dea965a
Change color
adri9valle Sep 19, 2019
121f45a
Remove wazuh-hosts.yml
adri9valle Sep 19, 2019
83fa28d
Remove hosts from configuration
adri9valle Sep 19, 2019
b518db7
Fix \n in the migration
adri9valle Sep 20, 2019
ecd1035
Fix api-count
adri9valle Sep 20, 2019
8618247
Fix typo
adri9valle Sep 20, 2019
77ea7eb
Fix API wizard
pablotr9 Sep 25, 2019
8817e28
Fix example in getting started guide
juankaromo Sep 25, 2019
fb0d6a1
Fix typos
adri9valle Sep 30, 2019
41f9ff8
Refresh hosts in api-is-down component
adri9valle Sep 30, 2019
aee0bb8
Set default in props
adri9valle Sep 30, 2019
392186b
Fix API count
adri9valle Sep 30, 2019
3901f7e
Iterates the api entries to set one as default
adri9valle Sep 30, 2019
301d02a
Fix component unmount
adri9valle Sep 30, 2019
e0a53d3
Fix flick
adri9valle Sep 30, 2019
a3ea820
Fix when refresh and all entries and the yml is corrupt
adri9valle Sep 30, 2019
7906def
Improve handler error when getting error in the yml parser
adri9valle Oct 1, 2019
a788465
Adapt monitoring
adri9valle Oct 1, 2019
9f7fd5b
Allow unsigned certs
adri9valle Oct 2, 2019
651bbef
Fix when there is not stored api - health check
adri9valle Oct 4, 2019
7e6a0ea
Fix when any api entry could be select
adri9valle Oct 4, 2019
3fd9dae
Warning when set an API as default
adri9valle Oct 4, 2019
eba8ced
Send to settings when achieve connect with an API when trying set as …
adri9valle Oct 4, 2019
96d901e
Try to set others API entries
adri9valle Oct 4, 2019
e97c0f5
Preven duplicate hosts: in wazuh.yml
adri9valle Oct 4, 2019
97fa302
Improve when stored api is not reachable handler
adri9valle Oct 7, 2019
f41a87e
Fix typo
adri9valle Oct 7, 2019
0bb127e
Added ID and the capability to search in the table
adri9valle Oct 8, 2019
77c18a1
Fix input style
adri9valle Oct 8, 2019
0e76d80
Fix typo
adri9valle Oct 8, 2019
93c14ca
Do pararell requests
adri9valle Oct 8, 2019
d3fe262
Resolving conflicts
adri9valle Oct 8, 2019
a6b9361
Fix when checking entry
adri9valle Oct 8, 2019
2b7c142
Add cheking spinner while checking api connection
adri9valle Oct 8, 2019
eed7a5e
Spinner while checking in api-is-down component
adri9valle Oct 8, 2019
42859ed
Use for instead of forEach
adri9valle Oct 8, 2019
8e203a4
Change spinner by message while refreshing entries
adri9valle Oct 8, 2019
aed1ccd
Merge branch '3.11-7.3' into migrate-index-yml
adri9valle Oct 8, 2019
3509c6a
Add a spinner by each entry while checking it
adri9valle Oct 9, 2019
2203b98
Show the reason why wazuh is down
adri9valle Oct 9, 2019
d2e9bae
Improve message from error 3099
adri9valle Oct 9, 2019
875d757
Add capability to copy to the clipboard the error
adri9valle Oct 9, 2019
0e0995e
Merge branch '3.11-7.3' into migrate-index-yml
adri9valle Oct 9, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .kibana-plugin-helpers.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"package.json",
"LICENSE",
"tsconfig.json",
"config.yml",
"wazuh.yml",
"index.js",
"init.js",
"server/**/*",
Expand Down
4 changes: 2 additions & 2 deletions init.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
// Imports all server modules
import { Initialize } from './server/initialize';
import { WazuhElasticRouter } from './server/routes/wazuh-elastic';
import { WazuhApiElasticRoutes } from './server/routes/wazuh-api-elastic';
import { Monitoring } from './server/monitoring';
import { WazuhApiRoutes } from './server/routes/wazuh-api';
import { WazuhHostsRoutes } from './server/routes/wazuh-hosts'
import { WazuhReportingRoutes } from './server/routes/wazuh-reporting';
import { WazuhUtilsRoutes } from './server/routes/wazuh-utils';
import { IndexPatternCronJob } from './server/index-pattern-cron-job';
Expand All @@ -37,11 +37,11 @@ export function initApp(server) {
);
Initialize(server);
WazuhElasticRouter(server);
WazuhApiElasticRoutes(server);
monitoringInstance.run();
indexPatternCronJobInstance.run();
Queue.launchCronJob();
WazuhApiRoutes(server);
WazuhHostsRoutes(server);
WazuhReportingRoutes(server);
WazuhUtilsRoutes(server);
})
Expand Down
12 changes: 4 additions & 8 deletions public/components/eui-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ import {
EuiButtonEmpty,
EuiHealth,
EuiCallOut,
EuiSwitch
EuiSwitch,
EuiSpacer
} from '@elastic/eui';

import { BasicTable } from '../directives/wz-table-eui/components/table';
import { Tabs } from '../directives/wz-tabs-eui/components/tabs';
import { Logtest } from '../directives/wz-logtest/components/logtest';
import { ToolsWelcomeCards } from '../controllers/dev-tools/components/tools-welcome-cards';
import { TestConfiguration } from '../controllers/dev-tools/components/test-configuration';

const app = uiModules.get('app/wazuh', ['react']);

Expand All @@ -46,7 +44,5 @@ app
.value('EuiCallOut', EuiCallOut)
.value('BasicTable', BasicTable)
.value('Tabs', Tabs)
.value('Logtest', Logtest)
.value('ToolsWelcomeCards', ToolsWelcomeCards)
.value('TestConfiguration', TestConfiguration)
.value('EuiSwitch', EuiSwitch);
.value('EuiSwitch', EuiSwitch)
.value('EuiSpacer',EuiSpacer);
15 changes: 9 additions & 6 deletions public/controllers/misc/health-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,9 @@ export class HealthCheck {
*/
async checkApiConnection() {
try {
if (this.checks.api) {
const data = await this.testAPI.checkStored(
JSON.parse(this.appState.getCurrentAPI()).id
);
const currentApi = JSON.parse(this.appState.getCurrentAPI() || '{}');
if (this.checks.api && currentApi && currentApi.id) {
const data = await this.testAPI.checkStored(currentApi.id);

if (((data || {}).data || {}).idChanged) {
const apiRaw = JSON.parse(this.appState.getCurrentAPI());
Expand Down Expand Up @@ -204,7 +203,11 @@ export class HealthCheck {
this.$scope.$applyAsync();
return;
} catch (error) {
this.handleError(error);
if (error && error.data && error.data.code && error.data.code === 3002) {
return error;
} else {
this.handleError(error);
}
}
}

Expand All @@ -214,7 +217,7 @@ export class HealthCheck {
async load() {
try {
const configuration = this.wazuhConfig.getConfig();

this.appState.setPatternSelector(configuration['ip.selector']);

this.checks.pattern = configuration['checks.pattern'];
Expand Down
227 changes: 162 additions & 65 deletions public/controllers/settings/components/add-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,88 +15,185 @@ import PropTypes from 'prop-types';
import {
EuiFlexGroup,
EuiFlexItem,
EuiFormRow,
EuiFieldText,
EuiFieldPassword,
EuiFieldNumber,
EuiCodeBlock,
EuiText,
EuiSpacer,
EuiCode,
EuiButton,
EuiPanel
EuiButtonEmpty,
EuiSteps,
EuiCallOut
} from '@elastic/eui';

export class AddApi extends Component {
constructor(props) {
super(props);

this.state = {
user: '',
password: '',
url: '',
port: 55000
status: 'incomplete',
fetchingData: false,
blockClose: false
};
}

onChangeEdit(e, field) {
this.setState({
[field]: e.target.value
});

componentDidMount() {
this.setState({enableClose: this.props.enableClose});
this.checkErrorsAtInit();
}

/**
* Checks if the component was initialized with some error in order to show it
*/
checkErrorsAtInit() {
if (this.props.errorsAtInit) {
const error = this.props.errorsAtInit;
this.setState({
status: error.type || 'danger',
blockClose: true,
message: (error.data || error).message || 'Wazuh API not reachable, please review your configuration',
fetchingData: false
});
}
}

/**
* Check the APIs connections
*/
async checkConnection() {
//TODO handle this
try {
this.setState({
status: 'incomplete',
fetchingData: true,
blockClose: false,
});

await this.props.checkForNewApis();

this.setState({
status: 'complete',
fetchingData: false,
closedEnabled: true
});
} catch (error) {
const close = (error.data && error.data.code && error.data.code === 2001) ? false : (error.closedEnabled || false);
this.setState({
status: error.type || 'danger',
closedEnabled: close,
blockClose: !close,
enableClose: false,
message: (error.data || error).message || 'Wazuh API not reachable, please review your configuration',
fetchingData: false
});
}
}

render() {
return (
<EuiPanel>
<EuiFlexGroup>
<EuiFlexItem>
<EuiFormRow label="Username">
<EuiFieldText
onChange={e => this.onChangeEdit(e, 'user')}
placeholder="foo"
/>
</EuiFormRow>
</EuiFlexItem>
<EuiFlexItem>
<EuiFormRow label="Password">
<EuiFieldPassword
onChange={e => this.onChangeEdit(e, 'password')}
placeholder="bar"
/>
</EuiFormRow>
</EuiFlexItem>
<EuiFlexItem>
<EuiFormRow label="Host">
<EuiFieldText
onChange={e => this.onChangeEdit(e, 'url')}
placeholder="http://localhost"
/>
</EuiFormRow>
</EuiFlexItem>
<EuiFlexItem>
<EuiFormRow label="Port">
<EuiFieldNumber
max={99999}
onChange={e => this.onChangeEdit(e, 'port')}
placeholder={55000}
/>
</EuiFormRow>
</EuiFlexItem>
const apiExample = `hosts:
- <id>:
url: <api_url>
port: <api_port>
user: <api_user>
password: <api_password>`;

const checkConnectionChildren = (
<div>
{(this.state.status === 'warning' || this.state.status === 'danger') && (
<EuiCallOut
color={this.state.status}
iconType="help"
title={this.state.message}
/>
)}
{(this.state.status === 'warning' || this.state.status === 'danger') && <EuiSpacer />}
<EuiText>
Check that the Kibana server can reach the configured Wazuh API(s).
</EuiText>
<EuiSpacer />
<EuiButton
onClick={async () => await this.checkConnection()}
isLoading={this.state.fetchingData}
>
Check connection
</EuiButton>
{((this.state.closedEnabled || this.state.enableClose) && !this.state.blockClose) && (
<EuiButtonEmpty
onClick={() => this.props.closeAddApi()}
>
Close
</EuiButtonEmpty>
)}
</div>
);

<EuiFlexItem grow={false}>
<EuiFormRow label="Actions">
<EuiButton
aria-label="Save"
iconType="save"
color="primary"
onClick={() => this.props.saveSettings({ ...this.state })}
>
Save
</EuiButton>
</EuiFormRow>
</EuiFlexItem>
</EuiFlexGroup>
</EuiPanel>
const editConfigChildren = (
<div>
<EuiText>
Modify <EuiCode>kibana/plugins/wazuh/wazuh.yml</EuiCode> to set the
connection information.
</EuiText>
<EuiSpacer />
<EuiCodeBlock language="yaml">{apiExample}</EuiCodeBlock>
<EuiSpacer />
<EuiText>
Where <EuiCode>{'<id>'}</EuiCode> is an arbitrary ID,{' '}
<EuiCode>{'<api_url>'}</EuiCode> is the URL of the Wazuh API,{' '}
<EuiCode>{'<api_port>'}</EuiCode> is the port,{' '}
<EuiCode>{'<api_user>'}</EuiCode> and{' '}
<EuiCode>{'<api_password>'}</EuiCode> are the credentials to
authenticate.
</EuiText>
</div>
);

const steps = [
{
title: 'Edit the configuration',
children: editConfigChildren
},
{
title: 'Test the configuration',
children: checkConnectionChildren,
status: this.state.status
}
];

const view = (
<EuiFlexGroup>
<EuiFlexItem />
<EuiFlexItem>
<EuiFlexGroup>
<EuiFlexItem grow={false}>
<EuiText>
<h2>Getting started</h2>
</EuiText>
</EuiFlexItem>
<EuiFlexItem />
<EuiFlexItem grow={false}>
{(this.state.enableClose && !this.state.blockClose) && (
<EuiButtonEmpty
size="s"
onClick={() => this.props.closeAddApi()}
iconType="cross"
>
close
</EuiButtonEmpty>
)}
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer />
<EuiSteps firstStepNumber={1} steps={steps} />
</EuiFlexItem>
<EuiFlexItem />
</EuiFlexGroup>
);

return view;
}
}

AddApi.propTypes = {
saveSettings: PropTypes.func
checkForNewApis: PropTypes.func,
closeAddApi: PropTypes.func,
enableClose: PropTypes.bool
};
Loading