Skip to content

Commit

Permalink
Merge pull request #2 from CybercentreCanada/submission_classificatio…
Browse files Browse the repository at this point in the history
…n_propagation

ResultSample service now generates sections and files with RESTRICTED…
  • Loading branch information
cccs-sgaron authored May 5, 2020
2 parents 583d238 + b557ec7 commit bcf3f90
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions assemblyline_result_sample_service/result_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import random
import tempfile

from assemblyline.common import forge
from assemblyline.common.dict_utils import flatten
from assemblyline.common.hexdump import hexdump
from assemblyline_v4_service.common.base import ServiceBase
Expand All @@ -13,6 +14,8 @@
# DO NOT LIST BODY FORMATS LIKE THIS. This is again for the data randomizer.
FORMAT_LIST = [BODY_FORMAT.TEXT, BODY_FORMAT.MEMORY_DUMP]

cl_engine = forge.get_classification()


class ResultSample(ServiceBase):
def __init__(self, config=None):
Expand Down Expand Up @@ -110,8 +113,9 @@ def execute(self, request):
'values': [random.random() * cmap_max for _ in range(50)]
}
}
# The classification of a section can be set to any valid classification for your system
section_color_map = ResultSection("Example of colormap result section", body_format=BODY_FORMAT.GRAPH_DATA,
body=json.dumps(color_map_data))
body=json.dumps(color_map_data), classification=cl_engine.RESTRICTED)
result.add_section(section_color_map)

# ==================================================================
Expand Down Expand Up @@ -214,7 +218,8 @@ def execute(self, request):
fd, temp_path = tempfile.mkstemp(dir=self.working_directory)
with os.fdopen(fd, "wb") as myfile:
myfile.write(data.encode())
request.add_extracted(temp_path, "file.txt", "Extracted by some magic!")
request.add_extracted(temp_path, "file.txt", "Extracted by some magic!",
classification=cl_engine.RESTRICTED)

# This file will generate empty results on the next run
fd, temp_path = tempfile.mkstemp(dir=self.working_directory)
Expand Down

0 comments on commit bcf3f90

Please sign in to comment.