Skip to main content

psengine is a simple, yet elegant, library for rapid development of integrations with Recorded Future.

Project description

PSEngine is a simple, yet elegant, library for rapid development of integrations with Recorded Future.

>>> from psengine.enrich import LookupMgr
>>> lookup_mgr = LookupMgr(rf_token='token')
>>> domain = lookup_mgr.lookup('cpejcogzznpudbsmaxxm.com', 'domain')
>>> domain
'EnrichedDomain: cpejcogzznpudbsmaxxm.com, Risk Score: 20, Last Seen: 2024-07-22 02:50:59PM'
>>> domain.entity
'cpejcogzznpudbsmaxxm.com'
>>> domain.content.risk
EntityRisk(criticality_label='Unusual', risk_string='4/52', score=20, rules=4...)
>>> domain.content.risk.score
20
>>>
domain.content.risk.risk_summary
'4 of 52 Risk Rules currently observed.'

PSEngine allows you to interact with the Recorded Future API extremely easily. There’s no need to manually build the URLs and query parameters - but nowadays, just use the modules dedicated to individual API endpoints!

PSEngine is a Python package solely built and maintained by the Cyber Security Engineering team powering a number of high profile integrations, such as: Elasticsearch, QRadar, Anomali, Jira, TheHive, etc..

Installation

PSEngine is a Python package that can be installed using pip. To install PSengine, run the following command:

$ pip install psengine

PSEngine officially supports Python >= 3.9, < 3.14

Supported Features & Best–Practices

PSEngine is ready for the demands of building robust and reliable integrations.

  • Collective Insights

  • Analyst Notes

  • Classic & Playbook Alerts

  • Risklists

  • On demand IOC enrichment

  • List management

  • Detection Rules

  • Built in logging

  • Easy configuration management

  • Proxy support

Quick Start

Excited, to get started?

The section below will give you the basic building blocks to start building integrations with PSEngine.

But first ensure that:

  • PSEngine is installed

  • PSEngine is up-to-date

Let’s get started with some core concepts and practices.

Config Management

The key requirement when building integrations with PSEngine is initializing Config as early as possible in your program, before initializing any PSEngine managers. This way rf_token app_id and platform_id you set will be used by every manager initialized after the Config.

>>> from psengine.config import Config, get_config
# Name & version of the integration itself
>>> APP_ID = 'example-app/1.0.0'
# Name & version of the tool this integrates with (Optional)
>>> PLATFORM_ID = 'PSE/1.0.0'
>>> Config.init(rf_token='your_token', app_id=APP_ID, platform_id=PLATFORM_ID)
>>> config = get_config()
>>> config.app_id
'example-app/1.0.0'

The above will result in API calls made by the managers having the following headers set:

  • ‘X-RFToken’ Header will contain the Recorded Future API Token

  • ‘User-Agent’ Header will contain APP ID and Platform ID (if supplied) which is a Recorded Future requirement, which might look like this:

    example-app/1.0.0 (macOS-14.1-arm64-arm-64bit) psengine-py/2.0.1 PSE/1.0.0

Authorization

In the example above we saw a token passed to the Config by the caller, but you can also omit the token during initialization and let Config retrieve it from the environment variable RF_TOKEN. Just ensure that the environment variable is set before running your program:

export RF_TOKEN=your_token

Alternatively, if you want to set an rf_token separately for a single manager, you may pass it in the constructor:

>>> note_mgr = AnalystNoteMgr(rf_token='your_token')

Logging

PSEngine also provides the capability for logging to console and files. If your program needs to show log output on the terminal and keep a .log file, just import and use psengine’s logger:

>>> from psengine.logger import RFLogger
>>> LOG = RFLogger().get_logger()
>>> LOG.info('Hello, world!')

On the other hand, if your program’s log statements already have handlers setup, just log the normal way:

>>> import logging
>>> LOG = logging.getLogger(__name__)
>>> LOG.info('Hello, world!')

In the second example, nothing is printed to terminal or file unless a handler is setup by another program running your code.

Proxies

If your environment requires a proxy to access the internet, you can set the proxy in the Config:

>>> Config.init(
        app_id=APP_ID,
        platform_id=PLATFORM_ID,
        http_proxy='http://proxy:8080',
        https_proxy='http://proxy:8080',
        client_ssl_verify=False,
    )

Examples

Please refer to examples for usage example of each module.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

psengine-2.0.6.tar.gz (108.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

psengine-2.0.6-py3-none-any.whl (190.6 kB view details)

Uploaded Python 3

File details

Details for the file psengine-2.0.6.tar.gz.

File metadata

  • Download URL: psengine-2.0.6.tar.gz
  • Upload date:
  • Size: 108.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for psengine-2.0.6.tar.gz
Algorithm Hash digest
SHA256 5da912c4156f7424f202eb576cb534811f8738dae2e6f97202b9c36da1fdbf81
MD5 f7fbb259ef1ba5a7ecb562d3e3f755ac
BLAKE2b-256 ebd186fbde359870fe7ad7d10d03173e75fb3f3b17218079aa01fcd2422d3c10

See more details on using hashes here.

Provenance

The following attestation bundles were made for psengine-2.0.6.tar.gz:

Publisher: workflow.yml on RecordedFuture-ProfessionalServices/psengine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file psengine-2.0.6-py3-none-any.whl.

File metadata

  • Download URL: psengine-2.0.6-py3-none-any.whl
  • Upload date:
  • Size: 190.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for psengine-2.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 0606253d20df5cb0b651f312f96dd8d9ae7c1ed8e438a72749fccf9e668f7494
MD5 ef851710e9d6ecbe6ff8b8021d0b5b95
BLAKE2b-256 785e8b5d3a82051b6415dff6545eca0af4f9f1fe6c8ef3083088083388e22040

See more details on using hashes here.

Provenance

The following attestation bundles were made for psengine-2.0.6-py3-none-any.whl:

Publisher: workflow.yml on RecordedFuture-ProfessionalServices/psengine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page