Giter Site home page Giter Site logo

nightfallai / nightfall-java-sdk Goto Github PK

View Code? Open in Web Editor NEW
9.0 4.0 3.0 128 KB

Java Data Loss Prevention (DLP) SDK - Nightfall Developer Platform

Home Page: https://docs.nightfall.ai

License: MIT License

Makefile 0.17% Java 99.83%
dlp data-security java data-privacy api data-protection data-loss-prevention nightfall secrets-detection

nightfall-java-sdk's Introduction

Nightfall Java SDK

Embed Nightfall scanning and detection functionality into Java applications

Features

This SDK provides Java bindings for the Nightfall API. It allows you to add functionality to your applications to scan plain text and files in order to detect different categories of information. You can leverage any of the detectors in Nightfall's pre-built library, or you may programmatically define your own custom detectors.

Additionally, this library provides convenience features such as encapsulating the steps to chunk and upload files.

To obtain an API Key, login to the Nightfall dashboard and click the section titled "Manage API Keys".

See our developer documentation for more details about integrating with the Nightfall API.

Dependencies

The Nightfall Java SDK requires Java 8 or later.

For a full list of external dependencies please consult pom.xml.

Installation

Maven

Add the following to your project's pom.xml:

<dependency>
    <groupId>ai.nightfall</groupId>
    <artifactId>scan-api</artifactId>
    <version>1.0.0</version>
</dependency>

Gradle

Add the following to your project's dependencies:

implementation group: 'ai.nightfall', name: 'scan-api', version: '1.0.0'

Building Locally

Alternatively, if you would like to build the project yourself:

  1. Clone this git repository
  2. Run mvn package from the top-level directory.
  3. The build directory should contain two artifacts: api-$VERSION.jar and api-$VERSION-shaded.jar. The former contains only the compiled source files of this project, whereas the latter includes the compiled dependencies.
  4. Take whichever jar you prefer from the build/ directory and add it to your project's classpath.

Usage

Scanning Plain Text

Nightfall provides pre-built detector types, covering data types ranging from PII to PHI to credentials. The following snippet shows an example of how to scan using pre-built detectors.

Sample Code

To run the the TextScannerExample class,

first compile:

make jar

and then set your API key as an environment variable and run the sample program (changing version number in the jar if necessary):

export NIGHTFALL_API_KEY="NF-XXXXXX" # replace with your API key
java -cp build/scan-api-1.2.3-beta-1.jar ai.nightfall.examples.FileScannerExample /path/to/file

Scanning Files

Scanning common file types like PDF's or office documents typically requires cumbersome text extraction methods like OCR.

Rather than implementing this functionality yourself, the Nightfall API allows you to upload the original files, and then we'll handle the heavy lifting.

The file upload process is implemented as a series of requests to upload the file in chunks. The library provides a single method that wraps the steps required to upload your file. Please refer to the API Reference for more details.

The file is uploaded synchronously, but as files can be arbitrarily large, the scan itself is conducted asynchronously. The results from the scan are delivered by webhook; for more information about setting up a webhook server, refer to the webhook server docs.

Sample Code

To run the the FileScannerExample class, first start a webhook server to which results will be delivered. ngrok is a good way to expose a locally running webhook service on a publically-reachable URL:

# ngrok creates a public webhook URL that tunnels to your local machine. Change the port if you're not listening on port 8075.
ngrok http 8075
# copy the HTTPS URL ngrok displays, for example https://myurl.ngrok.io
# supposing you're running a Python webhook server
python webhook.py

Compile the SDK and example code:

make jar

then set your API key as an environment variable and run the sample program (changing version number in the jar if necessary):

export NIGHTFALL_API_KEY="NF-XXXXXX" # replace with your API key
NGROK_URL="myurl" # replace with the URL from running ngrok above
java -cp build/scan-api-1.2.3-beta-1.jar ai.nightfall.examples.FileScannerExample "$NGROK_URL" /path/to/file

Contributing

Contributions are welcome! Open a pull request to fix a bug, or open an issue to discuss a new feature or change. Please adhere to the linting criteria defined in checkstyle.xml, and be sure to add unit tests for any new functionality you add.

Refer to CONTRIBUTING.md for the full details.

License

This code is licensed under the terms of the MIT License. See here for more information.

Java is licensed by Oracle. See here for more information.

nightfall-java-sdk's People

Contributors

bradleymcallister97 avatar dependabot[bot] avatar evanfuller avatar galennightfall avatar martinmr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  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.