Overview
The AlienVault Search module provides functions to fetch threat intelligence data from AlienVault Open Threat Exchange (OTX). It implements NIST SP 800-53 Rev. 5 controls for threat intelligence monitoring and risk assessment.NIST SP 800-53 Rev. 5 Controls Implemented
- SI-4 (Information System Monitoring): Continuous threat intelligence monitoring
- RA-3 (Risk Assessment): Threat intelligence integration for risk analysis
- PM-16 (Threat Awareness Program): External threat intelligence consumption
- SC-7 (Boundary Protection): Secure external threat intelligence API communication
- AU-3 (Content of Audit Records): Threat intelligence query logging
Classes
AlienVaultAPIError
Functions
fetch_otx_data()
The API key for accessing the OTX API
The technology of interest for threat intelligence filtering
The industry of interest (used in search query)
The number of days to look back from today (default is ~8 years)
The maximum number of threat intelligence pulses to return
Filter results by specific adversary name (case-insensitive partial match)
Filter results by specific malware family (case-insensitive exact match)
Filter by TLP (Traffic Light Protocol) level (case-insensitive)
A formatted string containing threat intelligence pulse information including:
- Industry
- Pulse name
- Description
- Modified date
- TLP level
- Adversary
- Malware families
- Total pulses found
Error Handling
Raises:AlienVaultAPIError: For various API-related errors including:- No response from OTX API
- Timeout while searching pulses
- Rate limit exceeded (HTTP 429)
- Other HTTP errors
- Unexpected errors during processing
- Uses retry logic with exponential backoff (3 attempts by default)
- Logs all errors through the error handler
- Returns None on failure rather than raising exceptions
- Returns “No threat intelligence data found” if no matching pulses exist
Filtering Logic
Pulses are filtered by:- Modified date: Must be within specified
daysparameter - Public status: Only public pulses (public=1)
- Adversary: Case-insensitive partial match if specified
- Malware family: Case-insensitive exact match if specified
- TLP level: Case-insensitive exact match if specified
max_results.
Example Usage
retry_with_backoff()
The function to retry (should be a callable with no arguments)
Maximum number of retry attempts
Initial delay in seconds between retry attempts
The result of the function call if successful, or None if all retries fail
Error Handling
- Catches
RequestExceptionandTimeoutexceptions - Logs warnings for each retry attempt
- Implements exponential backoff (delay doubles after each attempt)
- Calls error handler on final failure
- Returns None after exhausting all retries
Example Usage
Implementation Notes
Date Filtering
The module uses ISO 8601 format for date filtering:days parameter.
Logging
All functions implement comprehensive logging:- API key masking for security (only first 8 characters shown)
- Debug logs for search queries and date ranges
- Info logs for pulse counts (found and filtered)
- Warning logs for processing errors
- Error handling through centralized error handler
Security
- API keys are masked in all log output
- Never logs sensitive credentials
- Implements rate limit handling
- Uses secure retry logic with exponential backoff
- Only returns public pulses
Traffic Light Protocol (TLP)
The module supports TLP filtering with standard levels:- white: Information can be shared publicly
- green: Community sharing
- amber: Limited distribution
- red: No distribution beyond recipients
Pulse Structure
Each pulse returned contains:- name: Title of the threat intelligence pulse
- description: Detailed information about the threat
- modified: Last modification timestamp
- TLP: Traffic Light Protocol classification
- adversary: Attributed threat actor
- malware_families: List of associated malware families
- public: Visibility status (always 1 for returned results)