Skip to content

Add local Manalyze enrichment for PE attachments and malware samples - #1013

Open
adulau wants to merge 1 commit into
mainfrom
codex/manalyze-enrichment
Open

adulau wants to merge 1 commit into
mainfrom
codex/manalyze-enrichment

Conversation

@adulau

@adulau adulau commented Oct 26, 2026

Copy link
Copy Markdown
Member

Closes #203.

Adds a local Manalyze expansion module for attachment and malware-sample attributes. It runs static PE analysis with an explicit set of offline plugins, returns file hashes, preserves each plugin's independent verdict in malware-analysis objects, and attaches the complete JSON report through an annotation object. Existing MISP object templates cover the results, so no template change is needed.

Supports MISP ZIP samples with the infected password and verifies the extracted MD5. Provides configurable executable, timeout and sample size limits, temporary-file cleanup, and errors for invalid inputs or analyzer failures. Includes installation/configuration documentation and a README entry. Reports over 20 MiB are rejected after analysis; operating-system resource quotas remain the deployment's responsibility.

Validation:

  • 50 Manalyze unit tests pass, covering discovery, object/template validation, ZIP extraction and hash verification, size limits, malformed results, timeouts and cleanup.
  • 90 tests pass across tests/test_manalyze.py and tests/test_bingraph.py.
  • Flake8, Black formatting, isort, and git diff --check pass for the changed code.
  • Native smoke tests pass for both attachment and malware-sample requests using the official v1.0.0 Linux release asset (its executable identifies as Manalyze 0.9) and upstream test/testfiles/manatest.exe.

Samples remain local; the module does not upload to Manalyzer.org or select the VirusTotal plugin.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T10:57:03.639470Z cd98902 PR opened
🔒 Security Review 🔄 Running since 2026-10-26T10:54:30.283096Z cd98902 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cd989023ec

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +137 to +138
for kind in ("md5", "sha1", "sha256"):
file_object.add_attribute(kind, value=hashlib.new(kind, content).hexdigest(), to_ids=False)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Allow non-security hashes on FIPS hosts

On hosts enforcing FIPS restrictions, hashlib.new("md5", content) raises ValueError, so every otherwise successful attachment analysis is discarded and returned as a generic error; malware-sample requests fail earlier for the same reason at the direct hashlib.md5 call. These hashes identify the file rather than protect security, so pass usedforsecurity=False as the existing binGraph module does.

Useful? React with 👍 / 👎.

Comment on lines +181 to +184
if not isinstance(attribute, dict) or not all(
isinstance(attribute.get(k), str) and attribute[k] for k in ("type", "value", "uuid")
):
raise ModuleError("An attribute containing type, value and uuid is required.")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject malformed UUIDs before invoking Manalyze

When a direct module request supplies any nonempty string as attribute.uuid, this validation accepts it, runs the potentially expensive analyzer, and emits ObjectReference entries targeting that invalid identifier. The resulting payload is not valid misp_standard data and cannot reliably be merged into MISP; validate the value as a UUID before analysis and return an input error otherwise.

Useful? React with 👍 / 👎.

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.

Manalyze module

1 participant