Skip to content

Commit

Permalink
Merge pull request #83 from CybercentreCanada/feature/auto_collapse
Browse files Browse the repository at this point in the history
Feature/auto collapse
  • Loading branch information
cccs-sgaron authored Aug 3, 2021
2 parents c6e2fac + d8cf0d2 commit 9b579cb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 9 additions & 1 deletion assemblyline_result_sample_service/result_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,20 @@ def execute(self, request):
# Zeroize on safe tags
# When this feature is turned on, the section will get its score set to zero if all its tags
# were safelisted by the safelisting engine
zero_section = ResultSection('Exemple of zeroize-able section', zeroize_on_tag_safe=True)
zero_section = ResultSection('Example of zeroize-able section', zeroize_on_tag_safe=True)
zero_section.set_heuristic(2)
zero_section.add_line("This section will have a zero score if all tags are safelisted.")
zero_section.add_tag('network.static.ip', '127.0.0.1')
result.add_section(zero_section)

# ==================================================================
# Auto-collapse
# When this feature is turned on, the section will be collapsed when first displayed
collapse_section = ResultSection('Example of auto-collapse section', auto_collapse=True)
collapse_section.set_heuristic(2)
collapse_section.add_line("This section was collapsed when first loaded in the UI")
result.add_section(collapse_section)

# ==================================================================
# Wrap-up:
# Save your result object back into the request
Expand Down
5 changes: 4 additions & 1 deletion assemblyline_v4_service/common/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def __init__(
tags: Optional[Dict[str, List[str]]] = None,
parent: Optional[Union[ResultSection, Result]] = None,
zeroize_on_tag_safe: bool = False,
auto_collapse: bool = False,
):
self._finalized: bool = False
self.parent = parent
Expand All @@ -181,6 +182,7 @@ def __init__(
self.tags = tags or {}
self.heuristic = None
self.zeroize_on_tag_safe = zeroize_on_tag_safe
self.auto_collapse = auto_collapse

if isinstance(title_text, list):
title_text = ''.join(title_text)
Expand Down Expand Up @@ -302,7 +304,8 @@ def _append_section(self, section: ResultSection) -> None:
heuristic=get_heuristic_primitives(section.heuristic),
tags=unflatten(section.tags),
title_text=section.title_text,
zeroize_on_tag_safe=section.zeroize_on_tag_safe
zeroize_on_tag_safe=section.zeroize_on_tag_safe,
auto_collapse=section.auto_collapse
))

def _flatten_sections(self, section: ResultSection, root: bool = True) -> None:
Expand Down

0 comments on commit 9b579cb

Please sign in to comment.