Skip to content

Commit

Permalink
Merge pull request #3524 from wazuh/feat/3507-configuration-viewer-of…
Browse files Browse the repository at this point in the history
…fice365

Module Office 365 configuration viewer
  • Loading branch information
mpRegalado authored Aug 10, 2021
2 parents d95c9ac + bff96ea commit ad424d3
Show file tree
Hide file tree
Showing 16 changed files with 3,026 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- Added sample data for office365 events [#3424](https://github.com/wazuh/wazuh-kibana-app/pull/3424)
- Created a separate component to check for sample data [#3475](https://github.com/wazuh/wazuh-kibana-app/pull/3475)
- Added a new hook for getting value suggestions [#3506](https://github.com/wazuh/wazuh-kibana-app/pull/3506)
- Added configuration viewer for Module Office365 on Management > Configuration [3524](https://github.com/wazuh/wazuh-kibana-app/pull/3524)
- Added base Module Panel view with Office365 setup [#3518](https://github.com/wazuh/wazuh-kibana-app/pull/3518)
- Adding Pagination and filter to drilldown tables at Office pannel [#3544](https://github.com/wazuh/wazuh-kibana-app/issues/3544).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,13 @@ export default [
name: 'Google Cloud Pub/Sub',
description: 'Configuration options of the Google Cloud Pub/Sub module',
goto: 'gcp-pubsub'
},
{
name: 'Office 365',
description:
'Configuration options of the Office 365 module',
goto: 'office365',
when: 'manager'
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import { WzRequest } from '../../../../../react-services/wz-request';
import { UI_LOGGER_LEVELS } from '../../../../../../common/constants';
import { UI_ERROR_SEVERITIES } from '../../../../../react-services/error-orchestrator/types';
import { getErrorOrchestrator } from '../../../../../react-services/common-services';
import { WzConfigurationOffice365 } from './office365/office365';

class WzConfigurationSwitch extends Component {
constructor(props) {
Expand Down Expand Up @@ -156,7 +157,7 @@ class WzConfigurationSwitch extends Component {
this.setState({ loadingOverview: true });
const masterNodeInfo = await WzRequest.apiReq('GET', '/agents', { params: { q: 'id=000'}});
this.setState({
masterNodeInfo: masterNodeInfo.data.affected_items[0]
masterNodeInfo: masterNodeInfo.data.data.affected_items[0]
});
this.setState({ loadingOverview: false });
}catch(error){
Expand Down Expand Up @@ -426,6 +427,14 @@ class WzConfigurationSwitch extends Component {
updateConfigurationSection={this.updateConfigurationSection}
/>
</WzViewSelectorSwitch>
<WzViewSelectorSwitch view="office365">
<WzConfigurationOffice365
clusterNodeSelected={this.props.clusterNodeSelected}
agent={agent}
updateBadge={this.updateBadge}
updateConfigurationSection={this.updateConfigurationSection}
/>
</WzViewSelectorSwitch>
</WzViewSelector>
)}
</EuiPanel>
Expand All @@ -448,8 +457,8 @@ const mapDispatchToProps = dispatch => ({
});

export default compose(
withUserAuthorizationPrompt((props) => [props.agent.id === '000' ?
{action: 'manager:read', resource: '*:*:*'} :
withUserAuthorizationPrompt((props) => [props.agent.id === '000' ?
{action: 'manager:read', resource: '*:*:*'} :
[
{action: 'agent:read', resource: `agent:id:${props.agent.id}`},
...(props.agent.group || []).map(group => ({ action: 'agent:read', resource: `agent:group:${group}` }))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`WzConfigurationOffice365 component renders correctly to match the snapshot 1`] = `
<ContextProvider
value={
Object {
"store": Object {
"clearActions": [Function],
"dispatch": [Function],
"getActions": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
},
"subscription": Subscription {
"handleChangeWrapper": [Function],
"listeners": Object {
"notify": [Function],
},
"onStateChange": [Function],
"parentSub": undefined,
"store": Object {
"clearActions": [Function],
"dispatch": [Function],
"getActions": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
},
"unsubscribe": null,
},
}
}
>
<Connect(WithLoading(Component))
agent={
Object {
"id": "000",
}
}
currentConfig="master-test-node"
updateBadge={[Function]}
updateConfigurationSection={[Function]}
/>
</ContextProvider>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Wazuh app - React Test component SubscriptionTab
* Copyright (C) 2015-2021 Wazuh, Inc.
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* Find more information about this on the LICENSE file.
*/

import React from 'react';
import { SubscriptionTab } from './SubscriptionTab';
import { mount } from 'enzyme';

jest.mock(
'../../../../../../../../../../../../kibana/node_modules/@elastic/eui/lib/services/accessibility/html_id_generator',
() => ({
htmlIdGenerator: () => () => 'htmlId',
})
);

describe('SubscriptionTab component', () => {
it('renders correctly to match the snapshot', () => {
const wodleConfiguration = {
office365: {
enabled: 'yes',
only_future_events: 'yes',
interval: 600,
curl_max_size: 1024,
api_auth: [
{
tenant_id: 'your_tenant_id_test',
client_id: 'your_client_id_test',
client_secret: 'your_secret_test',
},
],
subscriptions: [
'Audit.AzureActiveDirectory',
'Audit.Exchange',
'Audit.SharePoint',
'Audit.General',
'DLP.All',
],
},
};
const agent = { id: '000' };

const wrapper = mount(
<SubscriptionTab wodleConfiguration={wodleConfiguration} agent={agent} />
);

expect(wrapper).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Wazuh app - React component SubscriptionTab
* Copyright (C) 2015-2021 Wazuh, Inc.
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* Find more information about this on the LICENSE file.
*/

import React from 'react';
import { EuiBasicTable } from '@elastic/eui';
import WzConfigurationSettingsTabSelector from '../../../util-components/configuration-settings-tab-selector';
import { HELP_LINKS, OFFICE_365 } from '../../constants';

export type SubscriptionTabProps = {
agent: { id: string };
wodleConfiguration: any;
};

export const SubscriptionTab = ({ agent, wodleConfiguration }: SubscriptionTabProps) => {
const columns = [{ field: 'subscription', name: 'Name' }];

return (
<WzConfigurationSettingsTabSelector
title="Subscriptions list"
currentConfig={wodleConfiguration}
minusHeight={agent.id === '000' ? 370 : 320}
helpLinks={HELP_LINKS}
>
<EuiBasicTable
columns={columns}
items={wodleConfiguration[OFFICE_365].subscriptions.map((item) => ({ subscription: item }))}
/>
</WzConfigurationSettingsTabSelector>
);
};
Loading

0 comments on commit ad424d3

Please sign in to comment.