Skip to content

feat: [fortisandbox] add hash ratings and sample submissions - #1066

Merged
adulau merged 2 commits into
mainfrom
codex/enrich-fortisandbox
Oct 30, 2026
Merged

adulau merged 2 commits into
mainfrom
codex/enrich-fortisandbox

Conversation

@adulau

@adulau adulau commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Analysts can query FortiSandbox ratings by hash using authenticated JSON-RPC. Supplied samples are hashed before lookup; explicit submit_samples configuration permits submission when the rating is unknown. The module returns provider results or a submission receipt, closes sessions after operations and performs no background polling.

Includes a usage guide and focused adapter tests.

Validation: 19 passed, 1 warning in 0.73s with pytest -q tests/test_fortisandbox.py; flake8 passed for the module. The combined enrichment regression check passed 389 tests.

Authenticated provider API validation remains pending. Tests use sanitized fixtures; no provider credentials are included.

Review updates: Encode submission filenames, handle rating arrays, accept current MISP sample archives with digest verification, and classify reports using the appliance provider relation. Remove MD5 from advertised inputs because the single-file rating endpoint supports SHA-1 and SHA-256.

Updated validation: 22 passed, 1 warning in 0.64s; module lint passed. Combined regression validation passed 409 tests.

Companion provider suggestions: MISP/misp-objects#552. The adapters use the existing sandbox-report relations.

@adulau
adulau marked this pull request as ready for review October 29, 2026 22:10
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 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-29T22:12:59.749535Z aac05f9 Draft marked ready
🔒 Security Review ✅ Completed 2026-10-29T22:15:02.925590Z aac05f9 Draft marked ready
ℹ️ 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: aac05f919b

ℹ️ 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".

"/alert/ondemand/submit-file",
session,
type="file",
filename=sample[0],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Base64-encode filenames before submitting samples

When submit_samples reaches this branch, the FortiSandbox JSON API requires both file and filename to be base64-encoded; sending the plain attribute filename causes the appliance to return FILENAME_NOT_ENCODED, so compliant appliances reject every sample submission. The filename should be encoded just like the file contents. See the FortiSandbox JSON API Reference.

Useful? React with 👍 / 👎.

if isinstance(payload, list):
payload = payload[0] if payload else {}
rating = payload.get("rating") if isinstance(payload, dict) else None
if rating is not None and str(rating).lower() not in ("unknown", ""):

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 Normalize rating arrays before deciding to submit

FortiSandbox returns rating as an array, including for a single file (for example, ["Unknown"]). Converting that array to a string produces "['unknown']", which is not equal to "unknown", so an unknown sample is incorrectly emitted as a completed sandbox report and the submit_samples branch is skipped. Inspect the array elements rather than stringifying the container. See the documented rating response.

Useful? React with 👍 / 👎.

Comment on lines +129 to +130
entries = [entry for entry in archive.infolist() if not entry.is_dir()]
if len(entries) != 1 or entries[0].file_size > limit:

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 Ignore MISP filename metadata when unpacking samples

Current MISP malware-sample archives normally contain the binary plus a <md5>.filename.txt metadata member, as handled in bingraph.py:79-86. Counting every non-directory member therefore rejects standard MISP samples with the “must contain one file” error before lookup or submission; exclude the metadata member and require one remaining payload.

Useful? React with 👍 / 👎.

if kind in ("attachment", "malware-sample"):
sample = _binary(attribute, config)
kind, value = ("sha256", sample[2])
_, report = _rpc(base, "get", "/scan/result/filerating", session, checksum=value, ctype=kind)

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 Route MD5 lookups through an endpoint that supports MD5

For an advertised md5 input, this sends ctype="md5" to /scan/result/filerating, but that endpoint's documented contract accepts only sha1 and sha256; affected appliances return INVALID_PARAM instead of an enrichment. FortiSandbox documents MD5 support on the separate multi-file verdict endpoint, so MD5 should use a compatible endpoint or be removed from the declared inputs. See the FortiSandbox filerating contract.

Useful? React with 👍 / 👎.

@adulau
adulau merged commit 0b16be5 into main Oct 30, 2026
7 checks passed
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