Skip to content
This repository was archived by the owner on Nov 2, 2024. It is now read-only.

Commit 8107bf1

Browse files
carellamartinaMichalsus
authored andcommitted
adjusted investigation filters (intelowlproject#2440)
* adjusted investigation filters * fixed 'playbook to execute' column * fix
1 parent 43c8bb1 commit 8107bf1

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed

api_app/investigations_manager/filters.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,45 @@
44

55

66
class InvestigationFilter(filters.FilterSet):
7+
name = filters.CharFilter(lookup_expr="icontains")
8+
9+
owner = filters.CharFilter(method="filter_for_owner")
10+
id = filters.CharFilter(method="filter_for_id")
11+
tlp = filters.CharFilter(method="filter_for_tlp")
12+
tags = filters.CharFilter(method="filter_for_tags")
13+
14+
@staticmethod
15+
def filter_for_owner(queryset, value, owner, *args, **kwargs):
16+
return queryset.filter(owner__username__icontains=owner)
17+
18+
@staticmethod
19+
def filter_for_id(queryset, value, _id, *args, **kwargs):
20+
try:
21+
int_id = int(_id)
22+
except ValueError:
23+
# this is to manage bad data as input
24+
return queryset
25+
else:
26+
return queryset.filter(id=int_id)
27+
28+
@staticmethod
29+
def filter_for_tlp(queryset, value, tlp, *args, **kwargs):
30+
id_list = [
31+
investigation.id
32+
for investigation in Investigation.objects.all()
33+
if investigation.tlp == tlp
34+
]
35+
return queryset.filter(id__in=id_list)
36+
37+
@staticmethod
38+
def filter_for_tags(queryset, value, tags, *args, **kwargs):
39+
id_list = [
40+
investigation.id
41+
for investigation in Investigation.objects.all()
42+
if tags in investigation.tags
43+
]
44+
return queryset.filter(id__in=id_list)
45+
746
class Meta:
847
model = Investigation
948
fields = {

frontend/src/components/investigations/table/investigationTableColumns.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ export const investigationTableColumns = [
9999
(tag) =>
100100
tag !== null && (
101101
<JobTag
102-
key={`jobtable-tags-${tag?.label}`}
103-
tag={tag}
102+
key={`jobtable-tags-${tag}`}
103+
tag={{ label: tag, color: "#1655D3" }}
104104
className="ms-2"
105105
/>
106106
),

frontend/src/components/plugins/types/pluginTableColumns.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,9 @@ export const pivotTableColumns = [
303303
{
304304
Header: "Playbook to execute",
305305
id: "playbook",
306-
accessor: "playbook_to_execute",
306+
accessor: "playbooks_choice",
307307
Cell: ({ value }) => (
308-
<TableCell isCopyToClipboard isTruncate value={value} />
308+
<TableCellList value={value} ulKey={value} size={20} />
309309
),
310310
Filter: SelectColumnFilter,
311311
maxWidth: 145,

0 commit comments

Comments
 (0)