Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging master into the SubmissionProfile #1874

Merged
merged 6 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion assemblyline/common/log.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions assemblyline/odm/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=''),
Expand Down Expand Up @@ -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": {},
Expand Down
1 change: 1 addition & 0 deletions assemblyline/odm/models/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
1 change: 1 addition & 0 deletions assemblyline/odm/models/service_delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down