Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Neo4j Library #778

Closed
TheTechromancer opened this issue Oct 13, 2023 · 9 comments
Closed

Update Neo4j Library #778

TheTechromancer opened this issue Oct 13, 2023 · 9 comments
Assignees
Labels
enhancement New feature or request high-priority

Comments

@TheTechromancer
Copy link
Collaborator

Since py2neo has been deprecated, we need to transition our Neo4j output module to use the official Neo4j python library instead.

In the meantime, a temporary fix for py2neo has been issued here: #773.

@TheTechromancer TheTechromancer added the enhancement New feature or request label Oct 13, 2023
@TheTechromancer TheTechromancer self-assigned this Oct 13, 2023
@TheTechromancer TheTechromancer added bug Something isn't working high-priority and removed bug Something isn't working labels Feb 16, 2024
@stryker2k2 stryker2k2 self-assigned this Feb 22, 2024
@stryker2k2
Copy link
Collaborator

Doing research on using neomodel instead of py2neo, as suggested by the developers of Neo4j in their Py2neo Is End-of-Life Blog

@stryker2k2
Copy link
Collaborator

We will be using the native neo4j library utilizing the neo4j Driver instead of neomodel or py2neo.

I have pushed a branch that successfully creates a Node and a Relationship for each event using the Neo4j Driver.

At this moment, I am having issues with some Relationships being successfully established but not visibly linked when looking at the Neo4j output. The debug output shows the same... the relationship query is a success but 0 relationships are established sometimes.

Image

@stryker2k2
Copy link
Collaborator

We successfully moved away from py2neo and we are using the Official Neo4j "driver".

I was able to easily get the Nodes to populate... but I had some difficulty getting the relationships to connect to Source Nodes that had not yet been created.

I have queued those Relationships that did not have an existing Source Node for later parsing. Once the Source Node becomes available, that relationship is now established.

I have pushed this update_neo4j branch and I will polish it up before making a Merge Request (Pull Request).

TODO: Run against a big target with all the modules activated. Troubleshoot as needed.

Image

@stryker2k2
Copy link
Collaborator

Tinkering around with the idea of sending a "MATCH (n) DETACH DELETE (n)" command before every new BBOT Scan.

@stryker2k2
Copy link
Collaborator

Tinkering around with the idea of sending a "MATCH (n) DETACH DELETE (n)" command before every new BBOT Scan.

I have implemented this functionality which now removes all previous Neo4j data. As of right now, it ALWAYS clears the previous Neo4j data... it DOES NOT ASK or accept command prompt args.

Image

@stryker2k2
Copy link
Collaborator

It works. But, something isn't quite working as intended. It's not broke... just... not what I expected to see.

Image

@stryker2k2
Copy link
Collaborator

I re-ran the dev branch with -om neo4j (py2neo). The output looks a lot similar to my update_neo4j branch now. All that is left to do is to make relationships between CODE_REPOSITORY have a relationship with the ORG_STUB that SPECULATE emitted.

Image

@stryker2k2
Copy link
Collaborator

It just keeps getting better and better! I fixed an error that was occuring when ASN was being parsed where the quotations would confuse Neo4j and it would throw an error.

Furthermore, I have made a single (post-init) driver.session for our output module to utiliize for all events and we now properly clean up after ourselves.

Image

@TheTechromancer
Copy link
Collaborator Author

Implemented in #1205.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request high-priority
Projects
None yet
Development

No branches or pull requests

2 participants