GithubHelp home page GithubHelp logo

mozilla-github-standards / 013a7e748479dda04d12bef8a1752deab4f2f80462d76a99e63c46e7bc568a6b Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mozilla-services/ip-reputation-js-client

0.0 0.0 0.0 322 KB

A node JS client to the iprepd IP reputation service

License: Mozilla Public License 2.0

JavaScript 92.90% Shell 7.10%

013a7e748479dda04d12bef8a1752deab4f2f80462d76a99e63c46e7bc568a6b's Introduction

iprepd (IP Reputation Service) node.js client library

Client library to send IP reputations to the iprepd service.

npm version Coverage Status Build Status

Usage:

Create a client:

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

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

Get the reputation for an IP:

client.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:

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

Remove an IP:

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

Send a violation for an IP:

client.sendViolation('127.0.0.1', 'exceeded-password-reset-failure-rate-limit').then(function (response) {
    console.log('Applied violation to 127.0.0.1.');
});

Development

Tests run against the iprepd service with docker-compose from the ip-reputation-js-client repo root:

  1. Install docker and docker-compose
  2. Run docker-compose build then docker-compose run --rm test (note: this may fail on the first run, but should work on subsequent runs due to the web and test containers not waiting long enough for the cache and web servers to start)
  3. Open coverage/lcov-report/index.html to see the coverage report

013a7e748479dda04d12bef8a1752deab4f2f80462d76a99e63c46e7bc568a6b's People

Contributors

g-k avatar mozilla-github-standards avatar pdehaan avatar vladikoff 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.