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

catch the schema mismatch error and produce an error raw file #3995

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 4 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
20 changes: 17 additions & 3 deletions boefjes/boefjes/job_handler.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import os
import traceback
from collections.abc import Callable
Expand Down Expand Up @@ -131,22 +132,35 @@ def handle(self, boefje_meta: BoefjeMeta) -> None:

boefje_meta.arguments["input"] = ooi.serialize()

boefje_results: list[tuple[set, bytes | str]] = []

boefje_meta.runnable_hash = plugin.runnable_hash
boefje_meta.environment = get_environment_settings(boefje_meta, plugin.boefje_schema)

logger.info("Starting boefje %s[%s]", boefje_meta.boefje.id, str(boefje_meta.id))

boefje_meta.started_at = datetime.now(timezone.utc)
ammar92 marked this conversation as resolved.
Show resolved Hide resolved

boefje_results: list[tuple[set, bytes | str]] = []

try:
boefje_meta.environment = get_environment_settings(boefje_meta, plugin.boefje_schema)

boefje_results = self.job_runner.run(boefje_meta, boefje_meta.environment)

except SettingsNotConformingToSchema:
logger.exception(
"Error running boefje due to settings/schema mismatch %s[%s]",
boefje_meta.boefje.id,
str(boefje_meta.id),
)
boefje_results = [({"error/boefje"}, json.dumps(plugin.boefje_schema))]

raise

except:
logger.exception("Error running boefje %s[%s]", boefje_meta.boefje.id, str(boefje_meta.id))
boefje_results = [({"error/boefje"}, traceback.format_exc())]

raise

finally:
boefje_meta.ended_at = datetime.now(timezone.utc)
logger.info("Saving to Bytes for boefje %s[%s]", boefje_meta.boefje.id, str(boefje_meta.id))
Expand Down
Loading