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

Remove the ability to store the PDF reports into the filesystem #6495

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 0 additions & 10 deletions plugins/main/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,6 @@ export const WAZUH_DATA_CONFIG_REGISTRY_PATH = path.join(
'wazuh-registry.json',
);

// Wazuh data path - downloads
export const WAZUH_DATA_DOWNLOADS_DIRECTORY_PATH = path.join(
WAZUH_DATA_ABSOLUTE_PATH,
'downloads',
);
export const WAZUH_DATA_DOWNLOADS_REPORTS_DIRECTORY_PATH = path.join(
WAZUH_DATA_DOWNLOADS_DIRECTORY_PATH,
'reports',
);

// Queue
export const WAZUH_QUEUE_CRON_FREQ = '*/15 * * * * *'; // Every 15 seconds

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { useEffect } from 'react';
import { useDispatch } from 'react-redux';
import { updateReportingCommunicateSearchContext } from '../../../redux/actions/reportingActions';

/**
* WORKAROUND: this hook stores the search context to be used by the Generate report button of
* module dashboards
* @param context
*/
export function useReportingCommunicateSearchContext(context) {
const dispatch = useDispatch();
useEffect(() => {
dispatch(updateReportingCommunicateSearchContext(context));
return () => dispatch(updateReportingCommunicateSearchContext(null));
}, [JSON.stringify(context)]);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,48 +16,66 @@ import { getUiSettings } from '../../../../kibana-services';
import { ReportingService } from '../../../../react-services';
import $ from 'jquery';
import { WzButton } from '../../../common/buttons';
import { connect } from 'react-redux';

const mapStateToProps = state => ({
dataSourceSearchContext: state.reportingReducers.dataSourceSearchContext,
});

export const ButtonModuleGenerateReport = ({agent, moduleID, disabledReport}) => {
const action = useAsyncAction(async () => {
const reportingService = new ReportingService();
const isDarkModeTheme = getUiSettings().get('theme:darkMode');
if (isDarkModeTheme) {
export const ButtonModuleGenerateReport = connect(mapStateToProps)(
({ agent, moduleID, dataSourceSearchContext }) => {
const disabledReport = ![
!dataSourceSearchContext?.isLoading,
!dataSourceSearchContext?.isSearching,
dataSourceSearchContext?.totalResults,
dataSourceSearchContext?.indexPattern,
].every(value => Boolean(value));
const totalResults = dataSourceSearchContext?.totalResults;
const action = useAsyncAction(async () => {
const reportingService = new ReportingService();
const isDarkModeTheme = getUiSettings().get('theme:darkMode');
if (isDarkModeTheme) {
//Patch to fix white text in dark-mode pdf reports
const defaultTextColor = '#DFE5EF';

//Patch to fix white text in dark-mode pdf reports
const defaultTextColor = '#DFE5EF';
//Patch to fix dark backgrounds in visualizations dark-mode pdf reports
const $labels = $('.euiButtonEmpty__text, .echLegendItem');
const $vizBackground = $('.echChartBackground');
const defaultVizBackground = $vizBackground.css('background-color');

//Patch to fix dark backgrounds in visualizations dark-mode pdf reports
const $labels = $('.euiButtonEmpty__text, .echLegendItem');
const $vizBackground = $('.echChartBackground');
const defaultVizBackground = $vizBackground.css('background-color');

try {
$labels.css('color', 'black');
$vizBackground.css('background-color', 'transparent');
await reportingService.startVis2Png(moduleID, agent?.id || false)
$vizBackground.css('background-color', defaultVizBackground);
$labels.css('color', defaultTextColor);
} catch (e) {
$labels.css('color', defaultTextColor);
$vizBackground.css('background-color', defaultVizBackground);
try {
$labels.css('color', 'black');
$vizBackground.css('background-color', 'transparent');
await reportingService.startVis2Png(moduleID, agent?.id || false);
$vizBackground.css('background-color', defaultVizBackground);
$labels.css('color', defaultTextColor);
} catch (e) {
$labels.css('color', defaultTextColor);
$vizBackground.css('background-color', defaultVizBackground);
}
} else {
await reportingService.startVis2Png(moduleID, agent?.id || false);
}
} else {
await reportingService.startVis2Png(moduleID, agent?.id || false)
}
}, [agent]);

return (
<WzButton
buttonType='empty'
iconType='document'
isLoading={action.running}
onClick={action.run}
isDisabled={disabledReport}
tooltip={disabledReport ? {position: 'top', content: 'No results match for this search criteria.'} : undefined}
>
Generate report
</WzButton>
)
}
}, [agent]);

return (
<WzButton
buttonType='empty'
iconType='document'
isLoading={action.running}
onClick={action.run}
isDisabled={disabledReport}
tooltip={
disabledReport && totalResults === 0
? {
position: 'top',
content: 'No results match for this search criteria.',
}
: undefined
}
>
Generate report
</WzButton>
);
},
);
25 changes: 17 additions & 8 deletions plugins/main/public/components/common/modules/main-agent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ import { AppState } from '../../../react-services/app-state';
import { ReportingService } from '../../../react-services/reporting';
import { WAZUH_MODULES } from '../../../../common/wazuh-modules';
import { AgentInfo } from '../../common/welcome/agents-info';
import { getAngularModule, getCore } from '../../../kibana-services';
import {
getAngularModule,
getCore,
getDataPlugin,
} from '../../../kibana-services';
import { compose } from 'redux';
import { withGlobalBreadcrumb } from '../hocs';
import { endpointSummary } from '../../../utils/applications';
Expand All @@ -46,7 +50,7 @@ export class MainModuleAgent extends Component {
constructor(props) {
super(props);
this.reportingService = new ReportingService();
this.filterHandler = new FilterHandler(AppState.getCurrentPattern());
this.filterHandler = new FilterHandler(AppState.getCurrentPattern()); //
this.state = {
selectView: false,
loadingReport: false,
Expand All @@ -70,14 +74,19 @@ export class MainModuleAgent extends Component {
{}
).id || false;
if (this.props.section === 'syscollector' && agent) {
syscollectorFilters.push(this.filterHandler.managerQuery(agent, true));
syscollectorFilters.push(this.filterHandler.managerQuery(agent, true)); // This could be adding a filter with a wrong index name when the selected index has different title and id. Currently the index property is not used in the report of the Inventory data.
syscollectorFilters.push(this.filterHandler.agentQuery(agent));
}
await this.reportingService.startVis2Png(
this.props.section,
agent,
syscollectorFilters.length ? syscollectorFilters : null,
);
await this.reportingService.startVis2Png(this.props.section, agent, {
filters: syscollectorFilters,
time: {
from: 'now-1d/d',
to: 'now',
},
indexPattern: await getDataPlugin().indexPatterns.get(
AppState.getCurrentPattern(),
),
});
this.setState({ loadingReport: false });
}

Expand Down
11 changes: 0 additions & 11 deletions plugins/main/public/controllers/agent/agents.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export class AgentsController {
* @param {Object} $rootScope
* @param {Object} errorHandler
* @param {Object} commonData
* @param {Object} reportingService
* @param {Object} visFactoryService
* @param {Object} csvReq
*/
Expand All @@ -51,7 +50,6 @@ export class AgentsController {
$rootScope,
errorHandler,
commonData,
reportingService,
visFactoryService,
csvReq,
) {
Expand All @@ -63,7 +61,6 @@ export class AgentsController {
this.$scope.visualizations = visualizations;
this.shareAgent = new ShareAgent();
this.commonData = commonData;
this.reportingService = reportingService;
this.visFactoryService = visFactoryService;
this.csvReq = csvReq;
this.wazuhConfig = new WazuhConfig();
Expand Down Expand Up @@ -192,14 +189,6 @@ export class AgentsController {
this.$location.path('/manager/groups');
};

this.$scope.exportConfiguration = enabledComponents => {
this.reportingService.startConfigReport(
this.$scope.agent,
'agentConfig',
enabledComponents,
);
};

//Load
try {
this.$scope.getAgent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import WzDecoders from './decoders/main-decoders';
import WzGroups from './groups/groups-main';
import WzStatus from './status/status-main';
import WzLogs from './mg-logs/logs';
import WzReporting from './reporting/reporting-main';
import WzConfiguration from './configuration/configuration-main';
import WzStatistics from './statistics/statistics-main';
import {
Expand All @@ -41,7 +40,6 @@ class WzManagementMain extends Component {
<Fragment>
{(section === 'groups' && <WzGroups {...this.props} />) ||
(section === 'status' && <WzStatus />) ||
(section === 'reporting' && <WzReporting />) ||
(section === 'statistics' && <WzStatistics />) ||
(section === 'logs' && <WzLogs />) ||
(section === 'configuration' && (
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading