Threat Intelligence & SIEM Pipeline Agents
Problem Statement
Threat intelligence arrives in fragmented formats: raw text blogs, PDF threat advisories, unstructured CSVs, and REST API feeds. SOC analysts spend substantial time converting these feeds into standardized STIX 2.1 (Structured Threat Information Expression) objects for ingest into SIEM/TIP systems.
Goal
Construct an AI agent that extracts threat indicators (IPs, hashes, domain names, MITRE techniques) from unstructured threat text reports and builds valid STIX 2.1 JSON bundle objects.
Outcome Measurement
- Ingest Velocity: Threat intel report parsing speed increased by 95%.
- Schema Validity: 100% compliance with STIX 2.1 specifications.
How the Code was Built
Parses unstructured threat reports into structured Pydantic representations of STIX Indicator and ThreatActor objects.
Executable Code
import jsonfrom pydantic import BaseModel, Fieldfrom langchain_openai import ChatOpenAIclass STIXIndicator(BaseModel): indicator_type: str = Field(description="ipv4-addr, domain-name, file-hash, or url") pattern: str = Field(description="STIX pattern syntax, e.g. [ipv4-addr:value = '1.2.3.4']") valid_from: str = Field(description="ISO timestamp") description: strclass STIXBundle(BaseModel): bundle_type: str = "bundle" threat_actor_name: str indicators: list[STIXIndicator]def convert_intel_to_stix(raw_report: str) -> STIXBundle: llm = ChatOpenAI(model="gpt-4o", temperature=0) structured_llm = llm.with_structured_output(STIXBundle) prompt = f"Extract threat indicators and construct a STIX 2.1 JSON bundle from this report:\n{raw_report}" return structured_llm.invoke(prompt)if __name__ == "__main__": report = "APT29 deployed backdoor malware connecting to malicious domain updates-service-check.com and IP 198.51.100.12 starting 2026-03-01." stix_output = convert_intel_to_stix(report) print(json.dumps(stix_output.model_dump(), indent=2))






Leave a Reply