Giter Club home page Giter Club logo

stixtoneolib's Introduction

A Scala library to load STIX-2 objects to a Neo4j graph database

This library stixtoneolib provides for loading STIX-2 objects and relations into a Neo4j graph database.

The OASIS open standard Structured Threat Information Expression STIX-2 is a language for expressing cyber threat and observable information.

Neo4j "is a highly scalable native graph database that leverages data relationships as first-class entities, helping enterprises build intelligent applications to meet today’s evolving data challenges." In essence, a graph database and processing engine that is used here for storing Stix objects and their relationships.

stixtoneolib provides a set of classes and methods to convert STIX-2 domain objects (SDO) and relationships (SRO) to Neo4j nodes and relations using the Java Neo4j API. The library adds the converted STIX-2 objects and bundles to an existing Neo4j graph database or creates a new one. The library includes methods for processing text files containing STIX-2 bundles in JSON format and zip files.

Installation and packaging

stixtoneolib is a library for use in Scala applications to convert and load STIX-2 objects into a Neo4j graph database. To use the latest release add the following dependency to your build.sbt:

libraryDependencies += "com.github.workingDog" %% "stixtoneolib" % "0.5"

The current source code version is 0.6-SNAPSHOT using scala 2.13.0.

To compile and package stixtoneolib from source use SBT. To compile and generate a jar file from source:

sbt package

This will produce stixtoneolib-0.6-SNAPSHOT.jar in the ./target/scala-2.13 directory. See the build.sbt file for the required dependencies.

To publish the library to your local (Ivy) repository, simply type:

sbt publishLocal

Then put this in your Scala application build.sbt file:

libraryDependencies += "com.github.workingDog" %% "stixtoneolib" % "0.6-SNAPSHOT" 

Usage

The main class for loading STIX-2 objects into a Neo4j database is Neo4jLoader. This class constructor requires a Neo4j database directory name, which is used to connect to an existing database or create a new database. In addition a Logger can be passed-in implicitly to log the loading progress, defaults to no Logger if absent. Neo4jLoader has two main methods:

loadIntoNeo4j(bundle)  to load a bundle of STIX-2 objects into a Neo4j database
loadIntoNeo4j(stix)    to load a STIX-2 object into a Neo4j database

Neo4jLoader delegates the creation of Neo4j nodes and relations to NodesMaker and RelationsMaker classes respectively. Typically, nodes are created first followed by the relations.

In addition the Neo4jFileLoader helper class has four methods for processing files of STIX-2 bundles:

loadBundleFile(infile)        to load a file containing a bundle of STIX-2 objects
loadBundleZipFile(infile)     to load a zip file containing files each having a bundle of STIX-2 objects

loadLargeTextFile(infile)     to load one line at a time a file containing a STIX-2 object on one line
loadLargeZipTextFile(infile)  to load one line at a time a zip file containing files each having a STIX-2 object on one line

An example use of stixtoneolib is StixToNeoDB which loads files of STIX-2 data into a Neo4j database.

Dependencies and requirements

Depends on the ScalaStix and the Neo4j Community 3.5.5 jar file.

See also the build.sbt file.

Neo4j Community Edition should be installed to process the results.

References

  1. Neo4j

  2. Java Neo4j API

  3. ScalaStix

  4. STIX-2

Status

work in progress.

stixtoneolib's People

Contributors

workingdog avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.