diff --git a/assemblyline/common/log.py b/assemblyline/common/log.py index f90bdb91d..7e08febb2 100644 --- a/assemblyline/common/log.py +++ b/assemblyline/common/log.py @@ -1,7 +1,9 @@ import logging import logging.config import logging.handlers + from traceback import format_exception +from typing import Optional import json import os @@ -10,6 +12,10 @@ from assemblyline.common.logformat import AL_LOG_FORMAT, AL_SYSLOG_FORMAT, AL_JSON_FORMAT from assemblyline.odm.models.config import Config +# Check to see if a log level override is set in the environment. +# This is useful for debugging purposes. +LOG_LEVEL_OVERRIDE = os.environ.get("LOG_LEVEL") + log_level_map = { "DEBUG": logging.DEBUG, "INFO": logging.INFO, @@ -59,9 +65,13 @@ def formatException(self, exc_info): return ''.join(format_exception(*exc_info)) -def init_logging(name: str, config: Config = None, log_level: int = None): +def init_logging(name: str, config: Config = None, log_level: Optional[str] = None): logger = logging.getLogger('assemblyline') + # If the environment has a log level override, use it. + if not log_level and LOG_LEVEL_OVERRIDE: + log_level = LOG_LEVEL_OVERRIDE + # Test if we've initialized the log handler already. if len(logger.handlers) != 0: return diff --git a/assemblyline/odm/models/config.py b/assemblyline/odm/models/config.py index bb85845b0..b77fbc090 100644 --- a/assemblyline/odm/models/config.py +++ b/assemblyline/odm/models/config.py @@ -1205,6 +1205,7 @@ class ServiceRegistry(odm.Model): @odm.model(index=False, store=False, description="Services Configuration") class Services(odm.Model): categories: List[str] = odm.List(odm.Keyword(), description="List of categories a service can be assigned to") + default_auto_update: bool = odm.Boolean(default=False, description="Should services be auto-updated?") default_timeout: int = odm.Integer(description="Default service timeout time in seconds") stages: List[str] = odm.List(odm.Keyword(), description="List of execution stages a service can be assigned to") image_variables: Dict[str, str] = odm.Mapping(odm.Keyword(default=''), @@ -1242,6 +1243,7 @@ class Services(odm.Model): DEFAULT_SERVICES = { "categories": SERVICE_CATEGORIES, + "default_auto_update": False, "default_timeout": 60, "stages": SERVICE_STAGES, "image_variables": {}, diff --git a/assemblyline/odm/models/service.py b/assemblyline/odm/models/service.py index 8c32470cf..cf28e542c 100644 --- a/assemblyline/odm/models/service.py +++ b/assemblyline/odm/models/service.py @@ -123,6 +123,7 @@ class Service(odm.Model): # Regexes applied to assemblyline style file type string accepts = odm.Keyword(store=True, default=DEFAULT_SERVICE_ACCEPTS, description="Regex to accept files as identified by Assemblyline") + auto_update: bool | None = odm.Optional(odm.Boolean(), description="Should the service be auto-updated?") rejects = odm.Optional(odm.Keyword(store=True, default=DEFAULT_SERVICE_REJECTS), description="Regex to reject files as identified by Assemblyline") diff --git a/assemblyline/odm/models/service_delta.py b/assemblyline/odm/models/service_delta.py index 3cf69ccb3..571a868df 100644 --- a/assemblyline/odm/models/service_delta.py +++ b/assemblyline/odm/models/service_delta.py @@ -95,6 +95,7 @@ class SubmissionParamsDelta(odm.Model): @ odm.model(index=True, store=False, description="Service Delta relative to Initial Service Configuration") class ServiceDelta(odm.Model): accepts = odm.Optional(odm.Keyword(), store=True, description=REF_SERVICE) + auto_update: bool | None = odm.Optional(odm.Boolean(), description=REF_SERVICE) rejects = odm.Optional(odm.Keyword(), store=True, description=REF_SERVICE) category = odm.Optional(odm.Keyword(), store=True, copyto="__text__", description=REF_SERVICE) classification = odm.Optional(odm.ClassificationString(), description=REF_SERVICE)