mozilla-services/ip-reputation-js-client

Name: ip-reputation-js-client

Owner: Mozilla Services

Description: A node JS client to the tigerblood IP reputation service

Created: 2016-11-04 15:39:04.0

Updated: 2017-10-15 12:32:51.0

Pushed: 2017-09-27 15:42:00.0

Homepage: null

Size: 94

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Tigerblood (IP Reputation Service) node.js client library

Client library to send IP reputations to the tigerblood service.

Usage:

Create a client:

t IPReputationClient = require('ip-reputation-service-client-js')

t client = new IPReputationClient({
serviceUrl: 'http://<tigerblood service host without trailing slash>',
id: '<a hawk ID>',
key: '<a hawk key>',
timeout: <number in ms>

Get the reputation for an IP:

nt.get('127.0.0.1').then(function (response) {
if (response && response.statusCode === 404) {
    console.log('No reputation found for 127.0.0.1');
} else {
    console.log('127.0.0.1 has reputation: ', response.body.Reputation);
}

Set the reputation for an IP:

nt.add('127.0.0.1', 20).then(function (response) {
console.log('Added reputation of 20 for 127.0.0.1');

Update the reputation for an IP:

nt.update('127.0.0.1', 79).then(function (response) {
console.log('Set reputation for 127.0.0.1 to 79.');

Remove an IP:

nt.remove('127.0.0.1').then(function (response) {
console.log('Removed reputation for 127.0.0.1.');

Send a violation for an IP:

nt.sendViolation('127.0.0.1', 'exceeded-password-reset-failure-rate-limit').then(function (response) {
console.log('Upserted reputation for 127.0.0.1.');

Development
  1. Create the following config.yml in project root:
entials:
ot: toor
  1. run tigerblood with a new database (docker run --name postgres -p 127.0.0.1:5432:5432 -d postgres-ip4r)
  2. install this library with npm install
  3. run db setup script: scripts/setup-test-db.sh
  4. run tigerblood from the project root: CGO_ENABLED=0 go build --ldflags '-extldflags "-static"' ./cmd/tigerblood/ && TIGERBLOOD_DSN="user=tigerblood dbname=tigerblood sslmode=disable" ./tigerblood
  5. run npm test to test the client against the tigerblood server
  6. stop the tigerblood server
  7. run db cleanup script: scripts/cleanup-test-db.sh

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.