Giter Club home page Giter Club logo

tr-05-serverless-gigamon-threatinsight's Introduction

Gitter Chat

NOTE! This code has been upgraded and the current release no longer supports installation in AWS

If you wish to deploy in AWS, use this previous release.

Gigamon ThreatINSIGHT (Cisco Hosted)

A Cisco SecureX Concrete Relay implementation using Gigamon ThreatINSIGHT as a third-party Cyber Threat Intelligence service provider.

The Relay itself is just a simple application written in Python that can be easily packaged and deployed. This relay is now Cisco Hosted and no longer requires AWS Lambda.

The code is provided here purely for educational purposes.

Rationale

  • We need an application that will translate API requests from SecureX Threat Response to the third-party integration, and vice versa.
  • We need an application that can be completely self contained within a virtualized container using Docker.

Testing (Optional)

Open the code folder in your terminal.

cd code

If you want to test the application you will require Docker and several dependencies from the requirements.txt file:

pip install --no-cache-dir --upgrade pipenv && pipenv install --dev

You can perform two kinds of testing:

  • Run static code analysis checking for any semantic discrepancies and PEP 8 compliance:

    flake8 .

  • Run the suite of unit tests and measure the code coverage: coverage run --source api/ -m pytest --verbose tests/unit/ && coverage report

NOTE. If you need input data for testing purposes you can use data from the observables.json file.

Building the Docker Container

In order to build the application, we need to use a Dockerfile.

  1. Open a terminal. Build the container image using the docker build command.
docker build -t tr-05-gigamon-threatinsight .
  1. Once the container is built, and an image is successfully created, start your container using the docker run command and specify the name of the image we have just created. By default, the container will listen for HTTP requests using port 9090. 
docker run -dp 9090:9090 --name tr-05-gigamon-threatinsight tr-05-gigamon-threatinsight
  1. Watch the container logs to ensure it starts correctly. 
docker logs tr-05-gigamon-threatinsight
  1. Once the container has started correctly, open your web browser to http://localhost:9090. You should see a response from the container. 
curl http://localhost:9090

SecureX Threat Response Module

Now, the only thing left to do is to follow one of these URLs to navigate to SecureX Threat Response page in your region and create the Gigamon ThreatINSIGHT module using your Lambda's URL and Gigamon ThreatINSIGHT API key:

You will also be prompted to enter CTR_ENTITIES_LIMIT variable that:

  • Restricts the maximum number of CTIM entities of each type returned in a single response per each requested observable.
  • Applies to the following CTIM entities:
    • Indicator,
    • Sighting.
  • Must be a positive integer. Defaults to 100 (if unset or incorrect). Has the upper bound of 1000 to avoid getting overwhelmed with too much data, so any greater values are still acceptable but also limited at the same time.

And be prompted to choice option GTI_ALLOW_TEST_ACCOUNTS:

  • Allows fake data from the test accounts (Demo and Training) to be returned along with real data (if enabled).

Implementation Details

This application was developed and tested under Python version 3.9.

Implemented Relay Endpoints

  • POST /health

    • Verifies the Authorization Bearer JWT and decodes it to restore the original credentials.
    • Authenticates to the underlying external service to check that the provided credentials are valid and the service is available at the moment.
  • POST /observe/observables

    • Accepts a list of observables and filters out unsupported ones.
    • Verifies the Authorization Bearer JWT and decodes it to restore the original credentials.
    • Makes a series of requests to the underlying external service to query for some cyber threat intelligence data on each supported observable.
    • Maps the fetched data into appropriate CTIM entities.
    • Returns a list per each of the following CTIM entities (if any extracted):
      • Indicator,
      • Sighting,
      • Relationship.
  • POST /refer/observables

    • Accepts a list of observables and filters out unsupported ones.
    • Builds a search link per each supported observable to pivot back to the underlying external service and look up the observable there.
    • Returns a list of those links.
  • POST /version

    • Returns the current version of the application.

Supported Types of Observables

  • ip
  • domain
  • md5
  • sha1
  • sha256

CTIM Mapping Specifics

Each Sighting for a supported observable is based on a matching network event that occurred in your environment and was recorded by GTI sensors. There are quite a few different event types. Each event type contains both a set of common fields (included in all event types) and event fields (unique to the event type). Thus, each particular Sighting may have different types of embedded CTIM relations depending on the actual type of the original event the Sighting is based on.

Besides inspecting your network traffic and extracting key protocol metadata into events, GTI also provides an alerting mechanism of rules and detections, notifying you when events matching specific criteria appear in your environment. Thus, if an event was detected by a rule, then the corresponding Sighting for the given event will also contain additional information about the given matching rule spread across several CTIM fields.

Since each GTI rule is effectively an Indicator in terms of CTIM, each event detected by a rule will also result in a Relationship between the event's Sighting and the matching rule's Indicator.

tr-05-serverless-gigamon-threatinsight's People

Contributors

anastasiiarozlyvan avatar ceilingduster avatar gdavoian avatar maxmhonc avatar mdougal avatar mistergreen22 avatar mmysk avatar mstoro avatar opavlyshyn avatar oshtaier avatar oshynk avatar tarasmaliuchenko avatar yevhenlysen avatar ytsek avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tr-05-serverless-gigamon-threatinsight's Issues

Multi-Threaded requests increase latency

While Event API is designed to handle concurrent requests, too many requests can affect latency. The current best practice is to make requests serially or make requests laziy. This reduces the likelihood that multiple requests trigger resource contingency for the backend systems.

Consider using "daily" queries for scouting in Event API

In some cases, Secure X seems to only be interested in the last 100 events for an entity. However, Event API will attempt to search the entire requested time range for events (defaults to 7 days). In cases where the events for the target entity appear in all 7 then the backend system must merge/reduce/filter those results. However, if the entity doesn't have events for a given day, any requests targeting that day can return extremely quickly.

The only benefit for querying an entire range is if you need to know the total event count for that query. Otherwise, querying each day sequentially should be considerably faster and less resource intensive on our end.

Switch from Entity queries to IQL filters

Currently, all requests to Event API submit queries in a pure entity form. For example 8.8.8.8 or google.com. These queries are very broad and compute a number of aggregations that don't appear to be useful for this integration. The recommendation to is switch to queries of the form field = value. Some examples include:

  1. ip = 8.8.8.8 <--- searches all IP fields
  2. src.ip = 8.8.8.8 or dst.ip = 8.8.8.8 <--- only look for events sent by or sent to a particular IP.
  3. domain = 'google.com <---- find events that involve google in any way
  4. `sha256 = '5e9a7996fe94d7be10595d7133748760bf8348198b71b7a50fd8affaa980ac61'
  5. md5 = '04c3fc4a88588ee47d33d066920ac410'
  6. `sha1 = 'c49d3bb4c93b31e2ce67fa23e93464adf902e9d9'

Some quick testing indicates that this should improve latency by ~50% in most cases.

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.