Repository navigation
Conversation
The credential check joins its two operands with `and`, so it only fires when the request has no `config` key at all *and* the config lacks an apikey or url. When `config` is absent the second operand evaluates `request["config"]` and the module dies with a KeyError, which MISP shows as an opaque module failure rather than the intended "EUPI authentication is missing" error. When `config` is present but incomplete the guard short-circuits to False and PyEUPI is constructed straight away, so a missing apikey or url raises a KeyError on the very next line instead of reporting the misconfiguration. Using `or` makes either condition sufficient to return the authentication error. 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
Member
|
EUPI always requires an API key. Claude is confused. |
Contributor
Author
|
Sorry... (#/。\#) |
Member
|
For the warning-lists it was easy. Now for misp-modules it's a complete different story. Testing is needed with the service and so on. So it won't easy. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The defect
The two halves of this guard were joined with
and, but they check mutually exclusive situations (config absent vs. config present-but-incomplete), so they can never both be true at once:request["config"]is absent entirely,not request.get("config")isTrue, but Python still evaluates the right-hand side to resolve theand, andrequest["config"]raisesKeyErrorbecause the key doesn't exist.configis present but missingapikeyand/orurl,not request.get("config")isFalse, so the wholeandshort-circuits toFalseand the guard is skipped — execution falls through toPyEUPI(request["config"]["apikey"], ...)a few lines down, which raisesKeyErrorthere instead.Either way the intended "friendly error" branch is unreachable, and the module raises an uncaught
KeyErrorinstead.Impact
Any MISP user who enables the
eupiexpansion module without a complete config (missingconfigblock, or anapikey/urlleft blank) gets an unhandled exception/HTTP 500 out of the module instead of the clear message"EUPI authentication is missing". This makes misconfiguration confusing to diagnose from the MISP UI.The fix
Changed the operator from
andtoor, so the guard fires — and returns the intended error — wheneverconfigis missing at all, or present but incomplete (missingapikeyorurl). The innerapikey and urlcheck is left intact since both values are dereferenced unconditionally on the next line.No behaviour change beyond making the existing, already-written error message reachable; no new default or contract change.
Verification
flake8onmisp_modules/modules/expansion/eupi.py: clean.161 passed, 4 skipped, 5 subtests passed in 115.25s (0:01:55).Found during a review of the repository; other findings are being submitted as separate PRs.
🤖 Generated with Claude Code