def test_service(sample): config = helper.get_service_attributes().config cls = emlparser.emlparser.EmlParser(config=config) cls.start() task = Task(create_service_task(sample=sample)) service_request = ServiceRequest(task) cls.execute(service_request) # Get the result of execute() from the test method test_result = task.get_service_result() assert "0766" in test_result["temp_submission_data"]["email_body"]
def __init__(self, config: Optional[Dict] = None) -> None: # Load the service attributes from the service manifest self.service_attributes = helper.get_service_attributes() # Start with default service parameters and override with anything provided self.config = self.service_attributes.config if config: self.config.update(config) # Initialize logging for the service log.init_logging(f'{self.service_attributes.name}', log_level=logging.INFO) self.log = logging.getLogger(f'assemblyline.service.{self.service_attributes.name.lower()}') self._task = None self._working_directory = None
def __init__(self, config: Optional[Dict] = None) -> None: # Load the service attributes from the service manifest self.service_attributes = helper.get_service_attributes() # Start with default service parameters and override with anything provided self.config = self.service_attributes.config if config: self.config.update(config) self.name = self.service_attributes.name.lower() # Initialize logging for the service log.init_logging(f'{self.service_attributes.name}', log_level=LOG_LEVEL) self.log = logging.getLogger(f'assemblyline.service.{self.name}') # Replace warning/error methods with our own patched version self._log_warning = self.log.warning self._log_error = self.log.error self.log.warning = self._warning self.log.error = self._error self._task = None self._working_directory = None # Initialize interface for interacting with system safelist self._api_interface = None self.dependencies = self._get_dependencies_info() self.ontologies: Dict = None # Updater-related self.rules_directory: str = None self.rules_list: list = [] self.update_time: int = None self.rules_hash: str = None
import json import logging from typing import List, Union, Optional, Dict, Any from assemblyline.common import forge from assemblyline.common import log as al_log from assemblyline.common.attack_map import attack_map, software_map, group_map, revoke_map from assemblyline.common.dict_utils import unflatten from assemblyline.common.str_utils import StringTable, safe_str from assemblyline_v4_service.common.helper import get_service_attributes, get_heuristics al_log.init_logging('service.result') log = logging.getLogger('assemblyline.service.result') Classification = forge.get_classification() SERVICE_ATTRIBUTES = get_service_attributes() BODY_FORMAT = StringTable( 'BODY_FORMAT', [ ('TEXT', 0), ('MEMORY_DUMP', 1), ('GRAPH_DATA', 2), ('URL', 3), ('JSON', 4), ('KEY_VALUE', 5), ('PROCESS_TREE', 6), ('TABLE', 7), ('IMAGE', 8), ('MULTI', 9), (