scanmalware: report a rejected value as rejected, and look up a URL as that URL - #806
Open
jonaslejon wants to merge 1 commit into
Open
scanmalware: report a rejected value as rejected, and look up a URL as that URL#806jonaslejon wants to merge 1 commit into
jonaslejon wants to merge 1 commit into
Conversation
Three changes, all prompted by review feedback on this PR and by the API changes that followed it. The API now answers 422 for a value that is not a hostname. The module was turning that into "No ScanMalware results for this attribute", which tells the analyst we looked and found nothing when we never asked a valid question. A single-label MISP hostname attribute reaches this in ordinary use, so the rejection and its reason are now surfaced. A URL attribute is now looked up as that URL. Previously the module took the newest scan of the same host, so enriching https://github.io/ reported the verdict for http://cobig99.github.io/microsoft365-en-us-excel/ as if it were a judgment on the attribute. Falling back to a host-level scan is still useful, but it is now labelled as being about a different URL. Scans matched via a redirect now carry the API's matched_on field, so a scan of another site that redirects to the queried host is explicable rather than looking like noise.
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.
Follow-up to #803, which merged this morning. Three fixes, one of them a correctness
bug I found while chasing @adulau's review comment.
A URL attribute is now looked up as that URL. The merged module takes the newest
scan of the same host, so enriching
https://github.io/reports the verdict forhttp://cobig99.github.io/microsoft365-en-us-excel/as though it judged the attribute.Measured against the live API just now:
https://github.io/http://cobig99.github.io/microsoft365-en-us-excel/https://github.io/Host-level fallback is still there, because it is often what you want, but it now says
so: "has no scan of X; nearest scan on the same host: Y".
This was only fixable now. The API's
url:filter used to terminate a field value atthe first
:, sourl:https://…silently matched every scan; querying the host was theworkaround. That was reported and fixed server-side on 2026-08-27.
A rejected value is reported as rejected. Following @adulau's note, the API now
returns
422for a value that is not a hostname. The module turned that into "NoScanMalware results for this attribute", which says we looked and found nothing when no
valid question was asked. A single-label MISP
hostnameattribute reaches this inordinary use:
Scans matched via a redirect carry the API's new
matched_onfield, so a scan ofanother site that redirects to the queried host is explicable instead of looking like
noise.
Proof: 15 tests pass (
pytest tests/test_scanmalware.py),flake8clean with theproject config. The three new tests were each run against a deliberately broken build
first: removing the 422 branch, querying the host instead of the URL, dropping the
distinct fallback label, and dropping
matched_oneach fail the test that covers themand nothing else. All three paths were also exercised against the live API, not only
mocks.