Skip describeTypes.json fetch for fully explicit --type queries - #41
Open
elhoim wants to merge 1 commit into
Open
Skip describeTypes.json fetch for fully explicit --type queries#41elhoim wants to merge 1 commit into
elhoim wants to merge 1 commit into
Conversation
Previously, every invocation fetched MISP's describeTypes.json from raw.githubusercontent.com, even for a fully explicit query such as '--type domain --value circl.lu' that names no type to guess or validate. A network failure there returned exit 1 before any module was queried, which is confusing in air-gapped environments since the README only lists the local misp-modules service as a requirement. Skip that fetch (and the subsequent valid-types filter) when --type is given and no type listing/guessing output is requested. When the fetch is still needed (guessing, --list-supported-types, --verbose-types), cache the response in the existing local cache file/TTL so repeated invocations don't hit GitHub every time. Documented the dependency, its caching, and the --type skip in the README.
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.
Finding 13 (Medium) —
bin/cli.py:850Problem
describeTypes.json is fetched from raw.githubusercontent.com on EVERY query, including a fully explicit --type domain --value circl.lu, and failure returns 1 before any module is queried. README lists only the local misp-modules service as a requirement, so air-gapped use fails confusingly.
Fix
Finding 13 (github-dependency-per-query, medium): bin/cli.py unconditionally fetched MISP's describeTypes.json from raw.githubusercontent.com on every invocation, even for a fully explicit
--type domain --value circl.luquery that names no type to guess or validate — a network failure there returned exit 1 before any module was queried, confusing in air-gapped setups since the README lists only the local misp-modules service as a requirement. Fix: skip that fetch (and the resulting valid-types filter) whenever --type is explicit and no type-listing/guessing output is requested; when the fetch is still needed (guessing, --list-supported-types, --verbose-types), route it through a new get_describe_types() helper that reuses the CLI's existing local cache file/TTL so repeated runs within the TTL don't hit GitHub again. Documented the dependency, its caching, and the --type skip behavior in README.md.Verification
Reproduced against the unmodified code at
9b8c605, then re-checked after the change.Before
After
python bin/cli.py --helpexits 0 and the module still imports cleanly. Verification was performed offline against the pure functions — no runningmisp-modulesinstance is required.Branched from
9b8c605. This PR addresses only this finding; the other findings from the same review are in separate PRs, so they will need rebasing against each other as they merge.🤖 Generated with Claude Code
https://claude.ai/code/session_01DYX4TKA5inzByJ4qGWKjqh