Skip to content

[high] fix: [vmray_submit] default unset optional flags to false - #831

Open
elhoim wants to merge 1 commit into
MISP:mainfrom
elhoim:fix/021-vmray-submit-strtobool-none
Open

elhoim wants to merge 1 commit into
MISP:mainfrom
elhoim:fix/021-vmray-submit-strtobool-none

Conversation

@elhoim

@elhoim elhoim commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

BLUF — vmray_submit crashes on every submission when an optional flag is left unset in its config.

  • Problem — expansion/vmray_submit.py reads the optional shareable, do_not_reanalyze and do_not_include_vmrayjobids keys with a bare .get() and passes the result to strtobool, which raises AttributeError on None; only ValueError is caught, so the exception escapes handler().
  • Fix — each of the three reads now falls back to "false" with or "false".
  • Effect — an instance that configured vmray_submit but left one of those flags unset now takes the documented default (not shared, reanalyze, include job IDs) instead of crashing; configs that already set the keys are unchanged.

The optional VMRay settings are read straight from config and handed to strtobool with no default:

shareable = request["config"].get("shareable")
do_not_reanalyze = request["config"].get("do_not_reanalyze")
do_not_include_vmrayjobids = request["config"].get("do_not_include_vmrayjobids")

try:
    shareable = bool(strtobool(shareable))
    reanalyze = not bool(strtobool(do_not_reanalyze))
    include_vmrayjobids = not bool(strtobool(do_not_include_vmrayjobids))
except ValueError:
    misperrors["error"] = "Error while processing settings. Please double-check your values."
    return misperrors

If any of these three optional config keys is left unset, .get() returns None, and strtobool(None) raises AttributeError (it calls .lower() on its argument internally). Only ValueError is caught, so the AttributeError propagates out of handler() uncaught.

Impact: any MISP instance that has configured vmray_submit but left one or more of shareable, do_not_reanalyze, or do_not_include_vmrayjobids unset will have the module crash on every submission attempt instead of falling back to its documented default behaviour (not shared, reanalyze, include job IDs) — a working-looking module that is actually unusable until an analyst notices and sets every optional flag explicitly.

Fix: each of the three reads now falls back to the string "false" with or "false", which covers both a missing key and an explicit None/empty value, so an unset flag takes its documented default instead of crashing strtobool.

No behaviour change for instances that already set these keys; instances that left them unset now get the documented default instead of a crash.

Verification

  • flake8 on misp_modules/modules/expansion/vmray_submit.py: clean, no output.
  • Full test suite against a live server on port 6721: 161 passed, 4 skipped, 5 subtests passed in 113.51s (0:01:53) — matches the expected baseline.

Found during a review of the repository; other findings are being submitted as separate PRs.

🤖 Generated with Claude Code

The module reads the optional shareable, do_not_reanalyze and
do_not_include_vmrayjobids settings straight out of the request config and
hands them to strtobool. When an analyst configures only apikey and url and
leaves those flags blank, MISP sends them as None, and strtobool(None) raises
AttributeError while only ValueError is caught, so the submission crashes with
an unhandled exception instead of running with the documented defaults.

Falling back to "false" when the value is absent or empty keeps the flag
semantics unchanged: samples are not shared, samples are reanalyzed and VMRay
job IDs are included.

Verified with flake8 on the changed file and the full test suite against a
local modules server: 161 passed, 4 skipped, 5 subtests passed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018dfYpyaSZd1nxSRLr8suj8
@elhoim elhoim changed the title fix: [vmray_submit] default unset optional flags to false [high] fix: [vmray_submit] default unset optional flags to false Sep 3, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant