mirror of
https://github.com/reconurge/flowsint.git
synced 2026-07-11 09:42:15 -05:00
[PR #185] feat(types): detect MD5/SHA1/SHA256 file hashes on import #2875
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/reconurge/flowsint/pull/185
Author: @rachit367
Created: 6/9/2026
Status: 🔄 Open
Base:
main← Head:feat/detect-file-hashes📝 Commits (1)
2e12e42feat(types): detect MD5/SHA1/SHA256 file hashes on import📊 Changes
4 files changed (+120 additions, -7 deletions)
View changed files
📝
flowsint-core/tests/import/test_entity_detection.py(+15 -1)📝
flowsint-types/src/flowsint_types/file.py(+35 -5)📝
flowsint-types/src/flowsint_types/username.py(+6 -1)➕
flowsint-types/tests/test_file.py(+64 -0)📄 Description
What
Makes TXT import recognize MD5 / SHA1 / SHA256 hashes and map them to the
Filetype, so analysts can pivot from a hash to related domains/URLs/IPs (VirusTotal, MalwareBazaar, sandboxes) — as requested in #45.Closes #45
The bug
File.detect()always returnedFalse, andUsername.detect()matches any 3–80 char alphanumeric string (^[a-zA-Z0-9_-]{3,80}$). A hash is alphanumeric and 32/40/64 chars long, so on import a hash was silently detected as a Username, not a File:(Verified against the live registry: all three hash types resolved to
Username.)The fix
File.detect()now recognizes 32/40/64-char hex strings (MD5/SHA1/SHA256).File.from_string()stores the value in the matchinghash_md5/hash_sha1/hash_sha256field (normalized to lowercase) while keeping it as thefilenameso the node still has a label. TheFiletype already had these hash fields — no schema change needed.Username.detect()now explicitly rejects hash-shaped strings.Fileis already registered beforeUsername(indices 14 vs 29), soFilewins detection on its own — but this guard removes the implicit dependency on registration order, so a future import reorder can't regress it.Non-hash filenames are intentionally still not auto-detected (too ambiguous), so existing TXT-import behavior for ordinary values is unchanged.
Testing
New tests: detection of each hash type (case-insensitive, whitespace-trimmed), rejection of non-hashes (wrong length, non-hex, filenames, usernames),
from_stringhash-field population + lowercase normalization, the Username regression, and end-to-enddetect_type()→File. No DB/Docker needed.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.