Overview
SafeNetworking is a threat intelligence platform built on Flask that enriches Palo Alto Networks firewall logs with malware intelligence from AutoFocus. The system operates as a multi-threaded application that continuously processes threat events from Elasticsearch, enriches them with AutoFocus data, and stores the results back to Elasticsearch for visualization in Kibana.System Components
Core Application Stack
Flask Application
Python web framework serving the UI and managing background processing threads
Elasticsearch
Document store for threat events, domain cache, IoT data, and tag metadata
Logstash
Ingests syslog from PAN firewalls and forwards events to Elasticsearch
Kibana
Visualization and dashboard interface for enriched threat intelligence
External Integration
AutoFocus API - Palo Alto Networks threat intelligence service providing:- Domain reputation and malware sample data
- Tag classification (malware families, actors, campaigns)
- Rate-limited API with daily and per-minute point quotas
Architecture Diagram
Data Flow
Event Ingestion Pipeline
Logstash Processing
Logstash parses syslog, extracts fields, tags event type (DNS, URL, IoT), and forwards to Elasticsearch
Background Processing Model
SafeNetworking runs continuous background threads initialized insfn:102-161:
DNS Processing Thread
- Query Elasticsearch for unprocessed DNS events (
SFN.processed=0) - Retrieve up to
DNS_EVENT_QUERY_SIZE(default: 1000) events - Classify events as primary (cached domain) or secondary (needs lookup)
- Process in parallel using multiprocessing pool (
DNS_POOL_COUNTworkers, max 16) - Update events with enrichment data and set
SFN.processed=1
project/dns/runner.py:75-128
IoT Processing Thread
- Calculate time delta since last update to IoT database
- Query external IoT Honeypot API for new malicious IPs
- Normalize family names and tag classifications
- Update
sfn-iot-detailsindex with new threat intelligence
project/iot/runner.py:136-171
AutoFocus Points Monitoring Thread
- Daily points: Total daily API call budget
- Minute points: Per-minute rate limit (max 16 concurrent calls)
- Automatically throttles processing when quotas approach limits
project/dns/dnsutils.py:15-57
Multi-Processing Architecture
SafeNetworking uses Python’smultiprocessing.dummy.Pool for parallelization:
project/dns/runner.py:92-97
Configuration Management
Configuration is managed through a layered approach:- Default Settings: Defined in
project/__init__.py:36-191 - Instance Overrides:
.panrcfile in base directory (project/__init__.py:194) - Runtime Flags: Dynamic adjustments (e.g.,
AF_POINTS_MODE)
Key Configuration Parameters
| Parameter | Default | Description |
|---|---|---|
DNS_POOL_TIME | 5 | Seconds between DNS processing cycles |
DNS_POOL_COUNT | 16 | Number of parallel DNS workers |
DNS_EVENT_QUERY_SIZE | 1000 | Events to process per cycle |
IOT_POOL_TIME | 600 | Seconds between IoT updates |
AF_POOL_TIME | 600 | Seconds between AF point checks |
AF_POINTS_LOW | 5000 | Threshold to slow processing |
AF_POINT_NOEXEC | 500 | Threshold to halt processing |
DNS_DOMAIN_INFO_MAX_AGE | 30 days | Domain cache TTL |
DOMAIN_TAG_INFO_MAX_AGE | 120 days | Tag cache TTL |
Scalability Considerations
Performance Tuning
Parallel Processing: AdjustDNS_POOL_COUNT based on:
- Available AutoFocus API points
- Elasticsearch cluster capacity
- System resources (CPU, memory)
- Domain cache: 30 days (configurable)
- Tag cache: 120 days (configurable)
- Cache reduces API costs and improves response time
- Normal mode: Multi-threaded processing at full speed
- Low points mode (
< AF_POINTS_LOW): Single-threaded processing - No-exec mode (
< AF_POINT_NOEXEC): Processing halts until quota resets
project/dns/dnsutils.py:59-105
High Availability
For production deployments:Next Steps
Data Model
Explore Elasticsearch document schemas and field definitions
Event Processing
Learn about enrichment workflows and confidence scoring
