← All case studies

// analysis

Building a Fault Tolerant Automation Pipeline for External Data Feeds

PythonAPI IntegrationResilience Engineering

Overview

An automated orchestration pipeline was built to ingest third party threat intelligence feeds, such as malicious IP blocklists, on an hourly schedule to update internal network perimeter firewalls. The pipeline needed to run reliably in the background, keeping firewall rules synchronised with active external threats while operating without human intervention.

The Problem

Integrating with external vendor APIs introduces unpredictable failure modes: transient network drops, rate limiting, and partial payload transfers. In a firewall management context, an incomplete or corrupted file transfer is serious. If a truncated blocklist containing only a fraction of the active IPs overwrote the existing configuration, most active security rules would disappear instantly. The system needed a way to handle third party instability without ever applying an incomplete dataset to production firewalls.

Investigation

Reviewing past vendor integration issues and existing ingestion scripts surfaced three notable vulnerabilities. Hardcoded API keys and static environment variables posed a security risk and made credential rotation difficult. Unhandled rate limiting caused retry loops to repeatedly hit the vendor API at the same time, worsening the underlying outage. Ingestion logic also assumed that a successful response guaranteed a complete payload, ignoring cases where a connection drop mid stream resulted in truncated data.

pipeline_flow.txt
HAPPY PATH

Threat Feed
    |
    v
Download
    |
    v
Integrity Check (SHA-256)
    |
    v
Volume Validation (vs active set)
    |
    v
Atomic Deploy
    |
    v
Firewall Rules Updated


FAILURE PATH

Integrity Check FAILED  or  Volume dropped >30%
    |
    v
Abort + Alert
    |
    v
Existing Firewall Rules Preserved

The Solution

The solution combined credential isolation, exponential backoff for transport resilience, and two stage payload validation prior to firewall deployment.

The deployment stage validated both payload integrity and rule-set stability before allowing any production update, the snippet below is that gate.

validate_and_apply_rules.pyimport hashlib

def validate_and_apply_rules(raw_payload: bytes, expected_hash: str, active_rule_count: int):
    # Stage 1: Verify Payload Integrity via SHA-256 Digest
    computed_hash = hashlib.sha256(raw_payload).hexdigest()
    if computed_hash.lower() != expected_hash.lower():
        raise ValueError("Payload integrity error: SHA-256 mismatch.")

    # Stage 2: Parse items and check volume stability threshold
    parsed_rules = [line.strip() for line in raw_payload.decode('utf-8').splitlines() if line]

    # Abort if incoming list unexpectedly drops significantly compared to active set
    if len(parsed_rules) < (active_rule_count * 0.70):
        raise RuntimeError(
            f"Safety check triggered: Incoming rule count ({len(parsed_rules)}) "
            f"dropped significantly compared to active rules ({active_rule_count}). Aborting."
        )

    # Atomic deployment to active firewall engine
    return apply_firewall_rules(parsed_rules)

Engineering Trade-offs

The core principle

Never allow bad state to replace good state.

The key decision was choosing to fail safe by preserving existing state rather than forcing an update through. If a download failed integrity checks or dropped unexpectedly in volume, the pipeline aborted the job, raised an alert, and left existing firewall rules intact. Preserving a slightly stale blocklist for an extra hour was vastly preferable to clearing valid security rules because of a corrupted feed.

Challenges

Defining the right threshold for volume anomaly detection was the trickiest balance. External threat blocklists naturally fluctuate in size as IPs are added or removed. Setting the safety margin too tight triggered false alarms during normal vendor list cleanups, while setting it too wide risked letting a truncated payload pass through. A threshold around thirty percent, paired with cryptographic hash checks, provided a solid safety margin.

Outcome

Reflection

When building automated pipelines that push changes to production infrastructure, the focus cannot just be on the happy path of fetching data. Designing checks that prove data integrity before applying state changes is what keeps automation safe.