Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
neography-calamitates
Advanced tools
Neography is a thin Ruby wrapper to the Neo4j Rest API, for more information:
If you want to utilize the full power of Neo4j, you will want to use JRuby and the excellent Neo4j.rb gem at https://github.com/andreasronge/neo4j by Andreas Ronge
Add neography
to your Gemfile:
gem 'neography'
And run Bundler:
$ bundle
Or install neography
manually:
$ gem install 'neography'
And require the gem in your Ruby code:
require 'rubygems'
require 'neography'
Read the wiki for information about dependencies.
Rake tasks are available for downloading, installing and running Neo4j.
Configure Neography as follows:
# these are the default values:
Neography.configure do |config|
config.protocol = "http://"
config.server = "localhost"
config.port = 7474
config.directory = "" # prefix this path with '/'
config.cypher_path = "/cypher"
config.gremlin_path = "/ext/GremlinPlugin/graphdb/execute_script"
config.log_file = "neography.log"
config.log_enabled = false
config.max_threads = 20
config.authentication = nil # 'basic' or 'digest'
config.username = nil
config.password = nil
config.parser = MultiJsonParser
end
Then initialize a Rest
instance:
@neo = Neography::Rest.new
For overriding these default and other initialization methods, see the configuration and initialization page in the Wiki.
Neography supports the creation and retrieval of nodes and relationships through the Neo4j REST interface. It supports indexes, Gremlin scripts, Cypher queries and batch operations.
Some of this functionality is shown here, but all of it is explained in the following Wiki pages:
2.0 Only features:
1.8+ features:
Some example usage:
# Node creation:
node1 = @neo.create_node("age" => 31, "name" => "Max")
node2 = @neo.create_node("age" => 33, "name" => "Roel")
# Node properties:
@neo.set_node_properties(node1, {"weight" => 200})
# Relationships between nodes:
@neo.create_relationship("coding_buddies", node1, node2)
# Get node relationships:
@neo.get_node_relationships(node2, "in", "coding_buddies")
# Use indexes:
@neo.add_node_to_index("people", "name", "max", node1)
@neo.get_node_index("people", "name", "max")
# Cypher queries:
@neo.execute_query("start n=node(0) return n")
# Batches:
@neo.batch [:create_node, {"name" => "Max"}],
[:create_node, {"name" => "Marc"}]
This is just a small sample of the full API, see the Wiki documentation for the full API.
Neography raises REST API errors as Ruby errors, see the wiki page about errors. (Note: older versions of Neography did not raise any errors!)
Trying to mimic the Neo4j.rb API.
Now we are returning full objects. The properties of the node or relationship can be accessed directly (node.name
).
The Neo4j ID is available by using node.neo_id
.
Some of this functionality is shown here, but all of it is explained in the following Wiki pages:
# create two nodes:
n1 = Neography::Node.create("age" => 31, "name" => "Max")
n2 = Neography::Node.create("age" => 33, "name" => "Roel")
n1.exist? # => true
# get and change some properties:
n1[:age] # => 31
n1.name # => "Max"
n1[:age] = 32 # change property
n1.weight = 190 # new property
n1.age = nil # remove property
# add a relationship between nodes:
new_rel = Neography::Relationship.create(:coding_buddies, n1, n2)
# remove a relationship:
new_rel.del
# add a relationship on nodes:
n1.outgoing(:coding_buddies) << n2
# more advanced relationship traversal:
n1.outgoing(:friends) # Get nodes related by outgoing friends relationship
n1.outgoing(:friends).depth(2).include_start_node # Get n1 and nodes related by friends and friends of friends
n1.rel?(:outgoing, :friends) # Has outgoing friends relationship
n1.rels(:friends,:work).outgoing # Get outgoing friends and work relationships
n1.all_paths_to(n2).incoming(:friends).depth(4) # Gets all paths of a specified type
n1.shortest_path_to(n2).incoming(:friends).depth(4).nodes # Gets just nodes in path
This is just a small sample of the full API, see the Wiki documentation for the full API.
Some example code.
Some tips about testing.
Complement to Neography are the:
An alternative to Neography is Architect4r by Maximilian Schulz
Please create a new issue if you run into any bugs.
Contribute patches via pull requests.
If you are just starting out, or need help send me an e-mail at maxdemarzi@gmail.com.
Check you my blog at http://maxdemarzi.com where I have more Neography examples.
FAQs
Unknown package
We found that neography-calamitates demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.