Skip to content

Commit

Permalink
[backend] improvements (#6348)
Browse files Browse the repository at this point in the history
  • Loading branch information
Archidoit committed Mar 14, 2024
1 parent d4242b7 commit 97e94f9
Show file tree
Hide file tree
Showing 5 changed files with 673 additions and 690 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { constructHandleAddFilter, constructHandleRemoveFilter, emptyFilterGroup
import ContentKnowledgeTimeLineBar from '../../common/containers/ContainertKnowledgeTimeLineBar';
import ContainerContent, { containerContentQuery } from '../../common/containers/ContainerContent';
import investigationAddFromContainer from '../../../../utils/InvestigationUtils';
import { UserContext } from '../../../../utils/hooks/useAuth';

const styles = () => ({
container: {
Expand Down Expand Up @@ -253,189 +252,181 @@ class ReportKnowledgeComponent extends Component {
orderMode: 'desc',
};
return (
<UserContext.Consumer>
{({ schema }) => {
const { filterKeysSchema } = schema;
return (
<div
className={classes.container}
id={location.pathname.includes('matrix') ? 'parent' : 'container'}
>
{mode !== 'graph' && (
<ContainerHeader
container={report}
PopoverComponent={<ReportPopover />}
link={`/dashboard/analyses/reports/${report.id}/knowledge`}
modes={['graph', 'content', 'timeline', 'correlation', 'matrix']}
currentMode={mode}
knowledge={true}
enableSuggestions={true}
investigationAddFromContainer={investigationAddFromContainer}
/>
)}
<Route
exact
path="/dashboard/analyses/reports/:reportId/knowledge/graph"
render={() => (
<QueryRenderer
query={reportKnowledgeGraphQuery}
variables={{ id: report.id }}
render={({ props }) => {
if (props && props.report) {
return (
<ReportKnowledgeGraph report={props.report} mode={mode} />
);
}
return (
<Loader
variant={LoaderVariant.inElement}
withTopMargin={true}
/>
);
}}
<div
className={classes.container}
id={location.pathname.includes('matrix') ? 'parent' : 'container'}
>
{mode !== 'graph' && (
<ContainerHeader
container={report}
PopoverComponent={<ReportPopover />}
link={`/dashboard/analyses/reports/${report.id}/knowledge`}
modes={['graph', 'content', 'timeline', 'correlation', 'matrix']}
currentMode={mode}
knowledge={true}
enableSuggestions={true}
investigationAddFromContainer={investigationAddFromContainer}
/>
)}
<Route
exact
path="/dashboard/analyses/reports/:reportId/knowledge/graph"
render={() => (
<QueryRenderer
query={reportKnowledgeGraphQuery}
variables={{ id: report.id }}
render={({ props }) => {
if (props && props.report) {
return (
<ReportKnowledgeGraph report={props.report} mode={mode} />
);
}
return (
<Loader
variant={LoaderVariant.inElement}
withTopMargin={true}
/>
)}
/>
<Route
exact
path="/dashboard/analyses/reports/:reportId/knowledge/content"
render={() => (
<QueryRenderer
query={containerContentQuery}
variables={{ id: report.id }}
render={({ props }) => {
if (props && props.container) {
return <ContainerContent containerData={props.container} />;
}
return (
<Loader
variant={LoaderVariant.inElement}
withTopMargin={true}
/>
);
}}
);
}}
/>
)}
/>
<Route
exact
path="/dashboard/analyses/reports/:reportId/knowledge/content"
render={() => (
<QueryRenderer
query={containerContentQuery}
variables={{ id: report.id }}
render={({ props }) => {
if (props && props.container) {
return <ContainerContent containerData={props.container} />;
}
return (
<Loader
variant={LoaderVariant.inElement}
withTopMargin={true}
/>
);
}}
/>
)}
/>
<Route
exact
path="/dashboard/analyses/reports/:reportId/knowledge/timeline"
render={() => (
<>
<ContentKnowledgeTimeLineBar
handleTimeLineSearch={this.handleTimeLineSearch.bind(this)}
timeLineSearchTerm={timeLineSearchTerm}
timeLineDisplayRelationships={timeLineDisplayRelationships}
handleToggleTimeLineDisplayRelationships={this.handleToggleTimeLineDisplayRelationships.bind(
this,
)}
timeLineFunctionalDate={timeLineFunctionalDate}
handleToggleTimeLineFunctionalDate={this.handleToggleTimeLineFunctionalDate.bind(
this,
)}
timeLineFilters={timeLineFilters}
handleAddTimeLineFilter={this.handleAddTimeLineFilter.bind(
this,
)}
handleRemoveTimeLineFilter={this.handleRemoveTimeLineFilter.bind(
this,
)}
handleSwitchFilterLocalMode={this.handleSwitchFilterLocalMode.bind(this)}
handleSwitchFilterGlobalMode={this.handleSwitchFilterGlobalMode.bind(this)}
/>
<Route
exact
path="/dashboard/analyses/reports/:reportId/knowledge/timeline"
render={() => (
<>
<ContentKnowledgeTimeLineBar
handleTimeLineSearch={this.handleTimeLineSearch.bind(this)}
timeLineSearchTerm={timeLineSearchTerm}
timeLineDisplayRelationships={timeLineDisplayRelationships}
handleToggleTimeLineDisplayRelationships={this.handleToggleTimeLineDisplayRelationships.bind(
this,
)}
timeLineFunctionalDate={timeLineFunctionalDate}
handleToggleTimeLineFunctionalDate={this.handleToggleTimeLineFunctionalDate.bind(
<QueryRenderer
query={reportKnowledgeTimeLineQuery}
variables={{ id: report.id, ...timeLinePaginationOptions }}
render={({ props }) => {
if (props && props.report) {
return (
<ReportKnowledgeTimeLine
report={props.report}
dateAttribute={orderBy}
displayRelationships={timeLineDisplayRelationships}
/>
);
}
return (
<Loader
variant={LoaderVariant.inElement}
withTopMargin={true}
/>
);
}}
/>
</>
)}
/>
<Route
exact
path="/dashboard/analyses/reports/:reportId/knowledge/correlation"
render={() => (
<QueryRenderer
query={reportKnowledgeCorrelationQuery}
variables={{ id: report.id }}
render={({ props }) => {
if (props && props.report) {
return <ReportKnowledgeCorrelation report={props.report} />;
}
return (
<Loader
variant={LoaderVariant.inElement}
withTopMargin={true}
/>
);
}}
/>
)}
/>
<Route
exact
path="/dashboard/analyses/reports/:reportId/knowledge/matrix"
render={() => (
<QueryRenderer
query={reportKnowledgeAttackPatternsGraphQuery}
variables={{ id: report.id }}
render={({ props }) => {
if (props && props.report) {
const attackPatterns = R.pipe(
R.map((n) => n.node),
R.filter((n) => n.entity_type === 'Attack-Pattern'),
)(props.report.objects.edges);
return (
<AttackPatternsMatrix
entity={report}
attackPatterns={attackPatterns}
searchTerm=""
currentKillChain={currentKillChain}
currentModeOnlyActive={currentModeOnlyActive}
currentColorsReversed={currentColorsReversed}
handleChangeKillChain={this.handleChangeKillChain.bind(
this,
)}
timeLineFilters={timeLineFilters}
handleAddTimeLineFilter={this.handleAddTimeLineFilter.bind(
handleToggleColorsReversed={this.handleToggleColorsReversed.bind(
this,
filterKeysSchema,
)}
handleRemoveTimeLineFilter={this.handleRemoveTimeLineFilter.bind(
handleToggleModeOnlyActive={this.handleToggleModeOnlyActive.bind(
this,
)}
handleSwitchFilterLocalMode={this.handleSwitchFilterLocalMode.bind(this)}
handleSwitchFilterGlobalMode={this.handleSwitchFilterGlobalMode.bind(this)}
/>
<QueryRenderer
query={reportKnowledgeTimeLineQuery}
variables={{ id: report.id, ...timeLinePaginationOptions }}
render={({ props }) => {
if (props && props.report) {
return (
<ReportKnowledgeTimeLine
report={props.report}
dateAttribute={orderBy}
displayRelationships={timeLineDisplayRelationships}
/>
);
}
return (
<Loader
variant={LoaderVariant.inElement}
withTopMargin={true}
/>
);
}}
/>
</>
)}
/>
<Route
exact
path="/dashboard/analyses/reports/:reportId/knowledge/correlation"
render={() => (
<QueryRenderer
query={reportKnowledgeCorrelationQuery}
variables={{ id: report.id }}
render={({ props }) => {
if (props && props.report) {
return <ReportKnowledgeCorrelation report={props.report} />;
}
return (
<Loader
variant={LoaderVariant.inElement}
withTopMargin={true}
/>
);
}}
/>
)}
/>
<Route
exact
path="/dashboard/analyses/reports/:reportId/knowledge/matrix"
render={() => (
<QueryRenderer
query={reportKnowledgeAttackPatternsGraphQuery}
variables={{ id: report.id }}
render={({ props }) => {
if (props && props.report) {
const attackPatterns = R.pipe(
R.map((n) => n.node),
R.filter((n) => n.entity_type === 'Attack-Pattern'),
)(props.report.objects.edges);
return (
<AttackPatternsMatrix
entity={report}
attackPatterns={attackPatterns}
searchTerm=""
currentKillChain={currentKillChain}
currentModeOnlyActive={currentModeOnlyActive}
currentColorsReversed={currentColorsReversed}
handleChangeKillChain={this.handleChangeKillChain.bind(
this,
)}
handleToggleColorsReversed={this.handleToggleColorsReversed.bind(
this,
)}
handleToggleModeOnlyActive={this.handleToggleModeOnlyActive.bind(
this,
)}
/>
);
}
return (
<Loader
variant={LoaderVariant.inElement}
withTopMargin={true}
/>
);
}}
);
}
return (
<Loader
variant={LoaderVariant.inElement}
withTopMargin={true}
/>
)}
/>
</div>
);
}}
</UserContext.Consumer>
);
}}
/>
)}
/>
</div>
);
}
}
Expand Down

0 comments on commit 97e94f9

Please sign in to comment.