Skip to content

Create Security policies plugin #7237

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

Draft
wants to merge 33 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
fb7ef7f
Plugin created
yenienserrano Jan 14, 2025
3236353
Add navigation
yenienserrano Jan 14, 2025
1d43c48
Fix lint
yenienserrano Jan 14, 2025
39cd36b
Add integrations view
yenienserrano Jan 15, 2025
fca31c2
Merge branch 'master' into enhancement/409-create-security-policies-p…
yenienserrano Jan 15, 2025
7cf84e6
Add navigation integration
yenienserrano Jan 15, 2025
70c36c1
Add integration view
yenienserrano Jan 16, 2025
1143229
Add tty:true on osd service dev.yml
yenienserrano Jan 17, 2025
7ec4a22
Add no-results.tsx
yenienserrano Jan 17, 2025
2c59f77
Add category new menu
yenienserrano Jan 17, 2025
b718539
Refactors
yenienserrano Jan 17, 2025
c78abd9
Add rules views
yenienserrano Jan 17, 2025
51a3764
Add table and refactoring for use in decoders and kvdb
yenienserrano Jan 20, 2025
b5f0ace
Add decoders and kvdb views
yenienserrano Jan 20, 2025
f97305e
Refactor route
yenienserrano Jan 21, 2025
efbab28
Optional render menu
yenienserrano Jan 21, 2025
c419cb7
Add header details
yenienserrano Jan 21, 2025
91b829a
Add header details and start rendering inputs
yenienserrano Jan 21, 2025
9dce3c1
Fix lint
yenienserrano Jan 21, 2025
20afcdd
Add step title
yenienserrano Jan 22, 2025
0866438
Add render string and object inputs
yenienserrano Jan 22, 2025
643a3e3
Update mock data rule
yenienserrano Jan 24, 2025
61fba37
Update inputs renders
yenienserrano Jan 24, 2025
a60ec29
Merge branch 'master' into enhancement/409-create-security-policies-p…
yenienserrano Jan 27, 2025
c9f7e55
Update inputs details rule view
yenienserrano Jan 27, 2025
3926f30
Add details view to decoders and kvdb
yenienserrano Jan 27, 2025
f2c7d8d
Merge branch 'master' into enhancement/409-create-security-policies-p…
yenienserrano Jan 27, 2025
19b0f5f
Changes and add create template
yenienserrano Jan 28, 2025
d7dcdd2
Fix lint
yenienserrano Jan 28, 2025
a034679
Update inputs form
yenienserrano Jan 29, 2025
19bfc00
Update form
yenienserrano Feb 3, 2025
c30e711
Update forms and start codeEditor
yenienserrano Feb 4, 2025
d843582
Change xml to yaml
yenienserrano Feb 5, 2025
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: 2 additions & 0 deletions docker/osd-dev/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,13 @@ services:
- ${OSD_PORT}:5601
environment:
- 'LOGS=/proc/1/fd/1'
tty: true
volumes:
- osd_cache:/home/node/.cache
- '${SRC}/main:/home/node/kbn/plugins/main'
- '${SRC}/wazuh-core:/home/node/kbn/plugins/wazuh-core'
- '${SRC}/wazuh-check-updates:/home/node/kbn/plugins/wazuh-check-updates'
- '${SRC}/wazuh-security-policies:/home/node/kbn/plugins/wazuh-security-policies'
- '${SRC}/wazuh-engine:/home/node/kbn/plugins/wazuh-engine'
- '${SRC}/wazuh-fleet:/home/node/kbn/plugins/wazuh-fleet'
- wd_certs:/home/node/kbn/certs/
Expand Down
7 changes: 7 additions & 0 deletions plugins/wazuh-security-policies/.i18nrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"prefix": "wazuhSecurityPolicies",
"paths": {
"wazuhSecurityPolicies": "."
},
"translations": ["translations/ja-JP.json"]
}
22 changes: 22 additions & 0 deletions plugins/wazuh-security-policies/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# wazuhSecurityPolicies

A OpenSearch Dashboards plugin

---

## Development

See the [OpenSearch Dashboards contributing
guide](https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/CONTRIBUTING.md) for instructions
setting up your development environment.

## Scripts
<dl>
<dt><code>yarn osd bootstrap</code></dt>
<dd>Execute this to install node_modules and setup the dependencies in your plugin and in OpenSearch Dashboards
</dd>

<dt><code>yarn plugin-helpers build</code></dt>
<dd>Execute this to create a distributable version of this plugin that can be installed in OpenSearch Dashboards
</dd>
</dl>
2 changes: 2 additions & 0 deletions plugins/wazuh-security-policies/common/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const PLUGIN_ID = 'wazuhSecurityPolicies';
export const PLUGIN_NAME = 'Ruleset';
9 changes: 9 additions & 0 deletions plugins/wazuh-security-policies/opensearch_dashboards.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"id": "wazuhSecurityPolicies",
"version": "1.0.0",
"opensearchDashboardsVersion": "opensearchDashboards",
"server": true,
"ui": true,
"requiredPlugins": ["navigation", "opensearchDashboardsUtils"],
"optionalPlugins": []
}
17 changes: 17 additions & 0 deletions plugins/wazuh-security-policies/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "wazuhSecurityPolicies",
"version": "0.0.0",
"private": true,
"scripts": {
"build": "yarn plugin-helpers build",
"plugin-helpers": "../../scripts/use_node ../../scripts/plugin_helpers",
"osd": "../../scripts/use_node ../../scripts/osd"
},
"dependencies": {
"@types/js-yaml": "^4.0.9",
"js-yaml": "^4.1.0"
},
"devDependencies": {
"@types/react": "^19.0.8"
}
}
23 changes: 23 additions & 0 deletions plugins/wazuh-security-policies/public/application.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { AppMountParameters, CoreStart } from '../../../src/core/public';
import { AppPluginStartDependencies } from './types';
import { WazuhSecurityPoliciesApp } from './components/app';

export const renderApp = (
{ notifications, http }: CoreStart,
{ navigation }: AppPluginStartDependencies,
{ appBasePath, element }: AppMountParameters,
) => {
ReactDOM.render(
<WazuhSecurityPoliciesApp
basename={appBasePath}
notifications={notifications}
http={http}
navigation={navigation}
/>,
element,
);

return () => ReactDOM.unmountComponentAtNode(element);
};
111 changes: 111 additions & 0 deletions plugins/wazuh-security-policies/public/components/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import React, { useState, useEffect } from 'react';
import { I18nProvider } from '@osd/i18n/react';
import {
EuiPage,
EuiPageBody,
EuiSideNav,
EuiPageSideBar,
EuiPanel,
} from '@elastic/eui';
import { Router, Route, Switch, Redirect, useParams } from 'react-router-dom';
import { getCore, getHistory } from '../plugin-services';
import { views } from './common/views';
import '../components/common/common.scss';

export const WazuhSecurityPoliciesApp = () => {
const history = getHistory();
const [currentTab, setCurrentTab] = useState('');
const [renderMenu, setRenderMenu] = useState(true);
const [isSideNavOpenOnMobile, setIsSideNavOpenOnMobile] = useState(false);

const toggleOpenOnMobile = () => {
setIsSideNavOpenOnMobile(!isSideNavOpenOnMobile);
};

useEffect(() => {
setCurrentTab(history.location.pathname);
}, [history.location.pathname]);

const sideNav = [
{
name: 'Ruleset',
id: 'wazuhRuleset',
items: views
.filter(view => view.renderOnMenu)
.map(item => ({
id: item.id,
name: item.name,
onClick: () => {
history.push(`${item.path}`);
setCurrentTab(item.id);
},
isSelected:
item.id === currentTab ||
history.location.pathname === `/${item.id}`,
})),
},
];

// Render the application DOM.
// Note that `navigation.ui.TopNavMenu` is a stateful component exported on the `navigation` plugin's start contract.
return (
<Router history={history}>
<I18nProvider>
<>
<EuiPage paddingSize='m'>
{renderMenu && (
<EuiPageSideBar>
<EuiSideNav
mobileTitle='Ruleset'
toggleOpenOnMobile={() => toggleOpenOnMobile()}
isOpenOnMobile={isSideNavOpenOnMobile}
aria-label='Ruleset'
items={sideNav}
/>
</EuiPageSideBar>
)}

<EuiPageBody component='main'>
<EuiPanel
paddingSize='none'
color='transparent'
hasShadow={false}
hasBorder={false}
>
<Switch>
{views.map(view => [
<Route
key={view.id}
path={`${view.path}`}
exact
component={() => {
const { id } = useParams() || null;

if (id) {
getCore().chrome.setBreadcrumbs(
view.breadcrumb(decodeURIComponent(id)),
);
} else {
getCore().chrome.setBreadcrumbs(view.breadcrumb());
}

if (view.renderMenu) {
setRenderMenu(true);
} else {
setRenderMenu(false);
}

return view.render();
}}
/>,
])}
<Redirect to={`${views[0].path}`} />
</Switch>
</EuiPanel>
</EuiPageBody>
</EuiPage>
</>
</I18nProvider>
</Router>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.wz-mtb-10 {
margin-top: 10px;
margin-bottom: 10px;
}

.wz-mr-10 {
margin-right: '10px';
}

.wz-capitalize {
text-transform: capitalize;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import { EuiLink } from '@elastic/eui';

export const LastUpdateContentManagerText = (lastUpdate: {
lastUpdateDate: string;
status: string;
}) => (
<>
Last update of the content manager was {lastUpdate.lastUpdateDate} (
{lastUpdate.status}).{' '}
<EuiLink href='link-documentation' target='_blank'>
Learn more
</EuiLink>
</>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React, { useState } from 'react';
import { EuiButtonIcon, EuiPopover } from '@elastic/eui';

interface PopoverIconButtonProps {
children?: React.ReactNode;
styles?: React.CSSProperties;
color?: string;
icon?: string;
}

export const PopoverIconButton = (props: PopoverIconButtonProps) => {
const { children, styles, color = 'text', icon = 'boxesVertical' } = props;
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
const onButtonClick = () => setIsPopoverOpen(isPopoverOpen => !isPopoverOpen);
const closePopover = () => setIsPopoverOpen(false);

return (
<EuiPopover
style={styles}
ownFocus={false}
button={
<EuiButtonIcon
color={color}
onClick={onButtonClick}
iconType={icon}
aria-label='Options'
/>
}
isOpen={isPopoverOpen}
closePopover={closePopover}
>
{children}
</EuiPopover>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.multiple-panels-step:not(:last-child) {
margin-bottom: 10px;
}
Loading
Loading