refactor(enrichers): deduplicate shared logic into base classes and consolidate utils#2
Open
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
…onsolidate utils - Consolidate triplicated utility functions (13+ functions) from flowsint-api/app/utils.py and flowsint-enrichers/utils.py into flowsint-core/utils.py as single source of truth - Add get_root_domain() to flowsint-core/utils.py (was only in enrichers) - Create DehashedBase, HudsonRockBase, AsnmapBase in _shared/ module - Refactor 4 DeHashed enrichers (domain/email/ip/social) to use DehashedBase - Refactor 3 HudsonRock enrichers (email/phone/social) to use HudsonRockBase - Refactor 3 ASN enrichers (domain/ip/organization) to use AsnmapBase - Delete duplicate utils.py files from flowsint-api and flowsint-enrichers - Clean up unused imports in domain/to_root_domain.py Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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.
Summary
Eliminates ~1,850 lines of duplicated code across enrichers and utility modules by extracting shared logic into base classes and consolidating triplicated utility functions.
Utility consolidation
Three copies of 13+ identical functions (
is_valid_email,is_valid_domain,is_valid_ip,flatten,unflatten, etc.) existed inflowsint-core/utils.py,flowsint-enrichers/utils.py, andflowsint-api/app/utils.py. Since bothflowsint-apiandflowsint-enrichersdepend onflowsint-core, the core copy is now the single source of truth. The other two files are deleted.get_root_domain()(previously only in enrichers) was added to core.Enricher base classes (
_shared/)Created three base classes in
flowsint-enrichers/_shared/:DehashedBase— 4 enrichers (domain/email/ip/social → Individual):Base handles API call (
/search?query={field}:{value}),Individualconstruction, error handling, and Neo4jBREACH_FOUND_INrelationships.HudsonRockBase— 3 enrichers (email/phone/social → Device):Base handles cavalier API call,
Deviceconstruction with_parse_ip_addresses()for string/list/null IP handling, and Neo4j relationships.AsnmapBase— 3 enrichers (domain/ip/organization → ASN):Base handles
AsnmapToolinvocation,PDCP_API_KEYvault/env resolution, ASN number parsing, and Neo4j relationships.Link to Devin session: https://app.devin.ai/sessions/bae2d12602f34bbabfd124c29af15fa7
Requested by: @netty-linux