Options
All
  • Public
  • Public/Protected
  • All
Menu

Production Development Unit Tests Contributor Covenant License: MIT

ipblock-microservice

A "cloud native" service in AWS that will check if an IP address exists in a Firehol blocklist

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

  1. You will need an AWS account. You can create an AWS account and use the free tier.
  2. You will need nodejs version 12 or higher.

Installing

  1. Fork this repository on github
  2. clone your copy to you local machine
    git clone [email protected]:<YOURUSERNAME>/ipblock-microservice.git
  3. Move to your directory, open in vscode or your favorite editor and install the dependencies
    cd ipblock-microservice && code . && npm install
  4. Install serverless globally; read the serverless documentation
    npm install -g serverless
  5. Add your AWS credentials
    serverless config credentials --provider aws --key <YOUR KEY> --secret <YOUR SECRET>

Deployment

Deploying can be done with

serverless deploy

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Built With

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Index

Functions

Const evaluateRequest

  • evaluateRequest(request: APIGatewayEvent): { ip: string; origin: object }
  • Evaluate incoming request for querystring AND|OR origin

    throws

    {InValidArgumentException} Invalid IP Address

    Parameters

    • request: APIGatewayEvent

      Inbound request

    Returns { ip: string; origin: object }

    IP and origin

    • ip: string
    • origin: object
      • country: string
      • ip: string
      • userAgent: string

Const getFireholLists

  • getFireholLists(): Promise<[]>
  • Return a array of Files ending in .ipset from the git repository master branch

    Returns Promise<[]>

    An array of file:File

Const ipcheck

  • ipcheck(event: APIGatewayProxyEvent, _context: Context): Promise<{ body: string; statusCode: number }>
  • Primary function for comparing input/request IP to a list of blocked IPSets from Firehol

    Parameters

    • event: APIGatewayProxyEvent
    • _context: Context

    Returns Promise<{ body: string; statusCode: number }>

    JSON object with success or error data

Const readIPset

  • Strips out comment lines and converts the IP address lines to an array of IP addresses

    Parameters

    • file: FireHolFile

      File object from which to grab the path

    Returns Promise<[]>

    A sanitized list of IP Addresses

Const validateIp

  • validateIp(ip: any): boolean
  • Validate IP Address as either ipV4 or ipV6

    Parameters

    • ip: any

      v4 or v6 IP address

    Returns boolean

    Valid IP address?

Legend

  • Property

Generated using TypeDoc